X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=js%2FeditPage.js;h=4e5d25512cb518b79d199b14cb59515cf229e16a;hb=354a3b69406608a2570060bdbdbc65e83260c8ff;hp=fb887352f85a5b80bac5092b146ea6ed68ad03bd;hpb=89c3c6ff37517012b5a799014c5a6d05d3e2e902;p=Rakka.git diff --git a/js/editPage.js b/js/editPage.js index fb88735..4e5d255 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -25,19 +25,20 @@ : $page.attr("redirect") != null ? "redirect" : "unknown" ; + var isLocked = $page.attr("isLocked") == "yes"; var source = $page.attr("redirect") != null ? $page.attr("redirect") : $page.find("textData").text() ; var summary = $page.find("summary").text(); - displayPageEditor(pageName, oldRevision, defaultType, source, summary); + displayPageEditor(pageName, oldRevision, defaultType, isLocked, source, summary); }, error : function (req) { Rakka.hideWaitingMessage(); if (req.status == 404) { - displayPageEditor(pageName, null, "rakka", null, ""); + displayPageEditor(pageName, null, "rakka", false, null, ""); } else { $area.text("Error: " + req.status + " " + req.statusText); @@ -47,10 +48,10 @@ }; Rakka.newPage = function () { - displayPageEditor("", null, "rakka", null, ""); + displayPageEditor("", null, "rakka", false, null, ""); }; - var displayPageEditor = function (pageName, oldRevision, defaultType, source, summary) { + var displayPageEditor = function (pageName, oldRevision, defaultType, isLocked, source, summary) { var $area = Rakka.switchScreen(); $previewHeader = $( $.H1({}, "Preview") ); @@ -72,6 +73,20 @@ $(fldPageName).change(makeDirty); + var chkIsLocked + = $.INPUT({type : "checkbox", + checked : (isLocked ? "checked" : "")}); + + $(chkIsLocked).change(makeDirty); + + var trIsLocked + = $.TR({}, + $.TH({}, "Page lock"), + $.TD({}, + $.LABEL({}, + chkIsLocked, + "Disallow anonymous users to edit or delete this page"))); + var btnTypeRakka = $.INPUT({type : "radio", name : "type", @@ -161,6 +176,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, "text/x-rakka", fldSummary.value, fldRakkaSource.value); @@ -170,6 +186,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, "text/css", fldSummary.value, fldCSSSource.value); @@ -179,6 +196,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, fldSummary.value, fldUploadFile.value); } @@ -187,6 +205,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, fldRedirect.value); } }); @@ -253,6 +272,7 @@ $.TH({}, "Page name"), $.TD({}, fldPageName) ), + trIsLocked, $.TR({}, $.TH({}, "Page type"), $.TD({}, @@ -300,6 +320,10 @@ $area.append(pageEditor); + if (!Rakka.isLoggedIn() || Rakka.isGlobalLocked) { + $(trIsLocked).hide(); + } + isDirty = false; }; @@ -365,7 +389,7 @@ Rakka.scrollToTopLeft(); }; - var submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, summary, text) { + var submitTextPage = function (pageName, oldRevision, givenPageName, isLocked, mimeType, summary, text) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -385,6 +409,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", mimeType); if (summary != null) { @@ -409,6 +434,9 @@ contentType: "text/xml", data : doc, processData: false, + beforeSend : function (req) { + Rakka.setAuthorization(req); + }, success : function () { window.location.replace(url); }, @@ -421,7 +449,7 @@ }); }; - var submitBinaryPage = function (pageName, oldRevision, givenPageName, summary, path) { + var submitBinaryPage = function (pageName, oldRevision, givenPageName, isLocked, summary, path) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -441,6 +469,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", ""); if (summary != null) { @@ -468,6 +497,9 @@ contentType: "text/xml", data : doc, processData: false, + beforeSend : function (req) { + Rakka.setAuthorization(req); + }, success : function () { window.location.replace(url); }, @@ -480,7 +512,7 @@ }); }; - var submitRedirection = function (pageName, oldRevision, givenPageName, destination) { + var submitRedirection = function (pageName, oldRevision, givenPageName, isLocked, destination) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -500,6 +532,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("redirect", destination); Rakka.displayWaitingMessage("Submitting... please wait."); @@ -511,6 +544,9 @@ contentType: "text/xml", data : doc, processData: false, + beforeSend : function (req) { + Rakka.setAuthorization(req); + }, success : function () { window.location.replace(url); }, @@ -528,6 +564,9 @@ $.ajax({ type : "DELETE", url : url, + beforeSend : function (req) { + Rakka.setAuthorization(req); + }, success : function () { window.location.replace(url); },