]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
implemented page language select box
authorpho <pho@cielonegro.org>
Sat, 16 Feb 2008 04:17:34 +0000 (13:17 +0900)
committerpho <pho@cielonegro.org>
Sat, 16 Feb 2008 04:17:34 +0000 (13:17 +0900)
darcs-hash:20080216041734-62b54-faf24f351f00b12c2aa5ab410600116e9e657ff4.gz

defaultPages/StyleSheet/Default.xml
js/editPage.js
js/systemConfig.js

index cdcc83a2916fb38e818f01dd763d9a7ab6c4b10c..790b74ce88e4c28762cf5ffe1eb5ccd8df051c37 100644 (file)
@@ -65,6 +65,10 @@ td, th {
     padding: 3px;
 }
 
+option {
+    padding: 3px 3px 1px 3px;
+}
+
 .title {
     padding: 5px 20px;
 }
index 5948d6dc94bfb30fa62c6003ac8e1fcc767fc22e..c512fcc0d78c1556310b584fb7022933232c3d26 100644 (file)
@@ -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")
                         ;
                     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);
     };
 
     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") );
 
         $(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);
 
                     fldPageName.value,
                     chkIsLocked.checked,
                     "text/x-rakka",
+                    $(selPageLang).val(),
                     fldSummary.value,
                     fldRakkaSource.value);
             }
                     fldPageName.value,
                     chkIsLocked.checked,
                     "text/css",
+                    $(selPageLang).val(),
                     fldSummary.value,
                     fldCSSSource.value);
             }
                     oldRevision,
                     fldPageName.value,
                     chkIsLocked.checked,
+                    $(selPageLang).val(),
                     fldSummary.value,
                     fldUploadFile.value);
             }
 
         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);
                                             )
                                        )
                                   ),
+                              trPageLang,
                               trSummary,
                               trContent,
                               $.TR({},
         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);
 
         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));
         });
     };
 
-    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);
 
         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(
index cb46670fd6fddccca272cac08bc60314fee020c5..9dd7f9c280507c1da619c1693d4de43b66905f88 100644 (file)
         globalLock : boolDecoder
     };
 
+    var cachedConf = null;
+
     Rakka.getSystemConfig = function () {
+        if (cachedConf != null) {
+            return cachedConf;
+        }
+        
         var conf = {};
+        cachedConf = conf;
         
         $.ajax({
             type   : "GET",