From fb86cb6941e466fd43ce45338024c79d0fdb33a2 Mon Sep 17 00:00:00 2001 From: pho Date: Sat, 16 Feb 2008 13:17:34 +0900 Subject: [PATCH] implemented page language select box darcs-hash:20080216041734-62b54-faf24f351f00b12c2aa5ab410600116e9e657ff4.gz --- defaultPages/StyleSheet/Default.xml | 4 ++ js/editPage.js | 61 +++++++++++++++++++++++++---- js/systemConfig.js | 7 ++++ 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/defaultPages/StyleSheet/Default.xml b/defaultPages/StyleSheet/Default.xml index cdcc83a..790b74c 100644 --- a/defaultPages/StyleSheet/Default.xml +++ b/defaultPages/StyleSheet/Default.xml @@ -65,6 +65,10 @@ td, th { padding: 3px; } +option { + padding: 3px 3px 1px 3px; +} + .title { padding: 5px 20px; } diff --git a/js/editPage.js b/js/editPage.js index 5948d6d..c512fcc 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -26,6 +26,7 @@ : $page.attr("redirect") != null ? "redirect" : "unknown" ; + var lang = $page.attr("lang"); var isLocked = $page.attr("isLocked") == "yes"; var source = $page.attr("redirect") != null ? $page.attr("redirect") @@ -33,17 +34,17 @@ ; var summary = $page.find("summary").text(); - displayPageEditor(pageName, oldRevision, defaultType, isLocked, source, summary); + displayPageEditor(pageName, oldRevision, defaultType, lang, isLocked, source, summary); } else { - displayPageEditor(pageName, null, "rakka", false, null, ""); + displayPageEditor(pageName, null, "rakka", null, false, null, ""); } }, error : function (req) { Rakka.hideWaitingMessage(); if (req.status == 404) { - displayPageEditor(pageName, null, "rakka", false, null, ""); + displayPageEditor(pageName, null, "rakka", null, false, null, ""); } else { $area.text("Error: " + req.status + " " + req.statusText); @@ -53,10 +54,10 @@ }; Rakka.newPage = function () { - displayPageEditor("", null, "rakka", false, null, ""); + displayPageEditor("", null, "rakka", null, false, null, ""); }; - var displayPageEditor = function (pageName, oldRevision, defaultType, isLocked, source, summary) { + var displayPageEditor = function (pageName, oldRevision, defaultType, lang, isLocked, source, summary) { var $area = Rakka.switchScreen(); $previewHeader = $( $.H1({}, "Preview") ); @@ -120,6 +121,34 @@ $(btnTypeRedirect).change(makeDirty); + var selPageLang + = $.SELECT({}, + $.OPTION({value: ""}, "(unspecified)"), + (function () { + var options = []; + + $.each(Rakka.getSystemConfig().languages, function (tag, name) { + options.push( + $.OPTION({value: tag}, name)); + }); + + return options; + })()); + + $(selPageLang).change(makeDirty); + + if (lang == null || lang == "") { + $(selPageLang).val($("html").attr("xml:lang")); + } + else { + $(selPageLang).val(lang); + } + + var trPageLang + = $.TR({}, + $.TH({}, "Page language"), + $.TD({}, selPageLang)); + var fldSummary = $.TEXTAREA({className: "summary"}, summary); @@ -183,6 +212,7 @@ fldPageName.value, chkIsLocked.checked, "text/x-rakka", + $(selPageLang).val(), fldSummary.value, fldRakkaSource.value); } @@ -193,6 +223,7 @@ fldPageName.value, chkIsLocked.checked, "text/css", + $(selPageLang).val(), fldSummary.value, fldCSSSource.value); } @@ -202,6 +233,7 @@ oldRevision, fldPageName.value, chkIsLocked.checked, + $(selPageLang).val(), fldSummary.value, fldUploadFile.value); } @@ -240,24 +272,28 @@ var updateTRContent = function () { if (btnTypeRakka.checked) { + $(trPageLang).show(); $(trSummary).show(); $(trContent).find("th").text("Wiki source"); $(trContent).find("td").empty().append(fldRakkaSource); $(btnPreview).show(); } else if (btnTypeCSS.checked) { + $(trPageLang).show(); $(trSummary).show(); $(trContent).find("th").text("CSS source"); $(trContent).find("td").empty().append(fldCSSSource); $(btnPreview).hide(); } else if (btnTypeBinary.checked) { + $(trPageLang).show(); $(trSummary).show(); $(trContent).find("th").text("File"); $(trContent).find("td").empty().append(fldUploadFile); $(btnPreview).show(); } else if (btnTypeRedirect.checked) { + $(trPageLang).hide(); $(trSummary).hide(); $(trContent).find("th").text("Destination Page"); $(trContent).find("td").empty().append(fldRedirect); @@ -309,6 +345,7 @@ ) ) ), + trPageLang, trSummary, trContent, $.TR({}, @@ -394,7 +431,7 @@ Rakka.scrollToTopLeft(); }; - var submitTextPage = function (pageName, oldRevision, givenPageName, isLocked, mimeType, summary, text) { + var submitTextPage = function (pageName, oldRevision, givenPageName, isLocked, mimeType, lang, summary, text) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -417,7 +454,11 @@ page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", mimeType); - if (summary != null) { + if (lang != null && lang != "") { + page.setAttribute("lang", lang); + } + + if (summary != null && summary != "") { var s = doc.createElement("summary"); s.appendChild( doc.createTextNode(summary)); @@ -454,7 +495,7 @@ }); }; - var submitBinaryPage = function (pageName, oldRevision, givenPageName, isLocked, summary, path) { + var submitBinaryPage = function (pageName, oldRevision, givenPageName, isLocked, lang, summary, path) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -477,6 +518,10 @@ page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", ""); + if (lang != null && lang != "") { + page.setAttribute("lang", lang); + } + if (summary != null) { var s = doc.createElement("summary"); s.appendChild( diff --git a/js/systemConfig.js b/js/systemConfig.js index cb46670..9dd7f9c 100644 --- a/js/systemConfig.js +++ b/js/systemConfig.js @@ -30,8 +30,15 @@ globalLock : boolDecoder }; + var cachedConf = null; + Rakka.getSystemConfig = function () { + if (cachedConf != null) { + return cachedConf; + } + var conf = {}; + cachedConf = conf; $.ajax({ type : "GET", -- 2.40.0