X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=js%2FeditPage.js;h=e4483a1e3520104e5372401ae8f6f12a13dfd489;hb=a039dfc12ba7b8b703e9f0ee7deaaffbfbdd0b8f;hp=406b7e3561603a5b083cf35e6870ad8f48b7bed2;hpb=cddd833c65cdd8092588bd3bdfe2b9153848302f;p=Rakka.git diff --git a/js/editPage.js b/js/editPage.js index 406b7e3..e4483a1 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -18,11 +18,12 @@ var $page = $(pageXml).find("page"); var oldRevision = $page.attr("revision"); var defaultType - = $page.attr("isBinary") == "yes" ? "binary" - : $page.attr("type") == "text/x-rakka" ? "rakka" - : $page.attr("type") == "text/css" ? "css" - : $page.attr("redirect") != null ? "redirect" - : "unknown" + = $page.attr("isBinary") == "yes" ? "binary" + : $page.attr("type") == "text/x-rakka" ? "rakka" + : $page.attr("type") == "text/css" ? "css" + : $page.attr("type") == "text/javascript" ? "js" + : $page.attr("redirect") != null ? "redirect" + : "unknown" ; var lang = $page.attr("lang"); var isLocked = $page.attr("isLocked") == "yes"; @@ -113,6 +114,12 @@ $(btnTypeCSS).change(makeDirty); + var btnTypeJS + = $.INPUT({type : "radio", + name : "type", + checked: (defaultType == "js" ? "checked" : "")}); + $(btnTypeJS).change(makeDirty); + var btnTypeBinary = $.INPUT({type : "radio", name : "type", @@ -215,10 +222,24 @@ $(fldCSSSource).change(makeDirty); - var fldUploadFile - = $.INPUT({type: "file"}); + var fldJSSource + = $.TEXTAREA({className: "source"}, + (defaultType == "js" && source != null ? source : "")); + + $(fldJSSource).change(makeDirty); - $(fldUploadFile).change(makeDirty); + var fldUploadFile + = $.INPUT({type: "text", disabled: true}); + var btnSelectFile + = $.INPUT({type: "button", value: "Select File"}); + + $(btnSelectFile).click(function () { + var path = Rakka.selectFile("Select a binary file to upload", "open"); + if (path != null) { + fldUploadFile.value = path; + makeDirty(); + } + }); var fldRedirect = $.INPUT({type: "text", value: (defaultType == "redirect" ? source : "")}); @@ -275,6 +296,18 @@ fldSummary.value, fldCSSSource.value); } + else if (btnTypeJS.checked) { + submitTextPage( + pageName, + oldRevision, + fldPageName.value, + chkIsLocked.checked, + "text/javascript", + $(selPageLang).val(), + otherLangs, + fldSummary.value, + fldJSSource.value); + } else if (btnTypeBinary.checked) { if (fldUploadFile.value != "") { submitBinaryPage( @@ -338,12 +371,20 @@ $(trContent).find("td").empty().append(fldCSSSource); $(btnPreview).hide(); } + else if (btnTypeJS.checked) { + $(trPageLang).show(); + $(trOtherLangs).show(); + $(trSummary).show(); + $(trContent).find("th").text("JavaScript source"); + $(trContent).find("td").empty().append(fldJSSource); + $(btnPreview).hide(); + } else if (btnTypeBinary.checked) { $(trPageLang).show(); $(trOtherLangs).show(); $(trSummary).show(); $(trContent).find("th").text("File"); - $(trContent).find("td").empty().append(fldUploadFile); + $(trContent).find("td").empty().append(fldUploadFile).append(btnSelectFile); $(btnPreview).show(); } else if (btnTypeRedirect.checked) { @@ -357,6 +398,7 @@ }; $(btnTypeRakka ).change(updateTRContent); $(btnTypeCSS ).change(updateTRContent); + $(btnTypeJS ).change(updateTRContent); $(btnTypeBinary ).change(updateTRContent); $(btnTypeRedirect).change(updateTRContent); updateTRContent(); @@ -385,6 +427,12 @@ "Style sheet" ) ), + $.LI({}, + $.LABEL({}, + btnTypeJS, + "JavaScript" + ) + ), $.LI({}, $.LABEL({}, btnTypeBinary, @@ -444,6 +492,7 @@ $(fldPageName) .add(btnTypeRakka) .add(btnTypeCSS) + .add(btnTypeJS) .add(btnTypeBinary) .add(btnTypeRedirect) .add($(trOtherLangs).find("input"))