Rakka.$previewHeader = null;
Rakka.$previewArea = null;
+Rakka.isDirty = null;
+
Rakka.editPage = function (pageName) {
var $area = Rakka.switchScreen();
Rakka.$previewArea.hide();
$area.append($.H1({}, pageName == "" ? "Create page" : "Edit page"));
+
+ var makeDirty = function () {
+ Rakka.isDirty = true;
+ };
var fldPageName
= $.INPUT({type : "text", value: pageName});
+ $(fldPageName).change(makeDirty);
+
var btnTypeRakka
= $.INPUT({type : "radio",
name : "type",
checked: (defaultType == "rakka" ? "checked" : "")});
+ $(btnTypeRakka).change(makeDirty);
+
var btnTypeCSS
= $.INPUT({type : "radio",
name : "type",
checked: (defaultType == "css" ? "checked" : "")});
+ $(btnTypeCSS).change(makeDirty);
+
var btnTypeBinary
= $.INPUT({type : "radio",
name : "type",
checked: (defaultType == "binary" ? "checked" : "")});
+ $(btnTypeBinary).change(makeDirty);
+
var btnTypeRedirect
= $.INPUT({type : "radio",
name : "type",
checked: (defaultType == "redirect" ? "checked" : "")});
+ $(btnTypeRedirect).change(makeDirty);
+
var fldSummary
= $.TEXTAREA({className: "summary"}, summary);
+ $(fldSummary).change(makeDirty);
+
var trSummary
= $.TR({},
$.TH({}, "Summary"),
= $.TEXTAREA({className: "source"},
(defaultType == "rakka" && source != null ? source : ""));
+ $(fldRakkaSource).change(makeDirty);
+
var fldCSSSource
= $.TEXTAREA({className: "source"},
(defaultType == "css" && source != null ? source : ""));
+ $(fldCSSSource).change(makeDirty);
+
var fldUploadFile
= $.INPUT({type: "file"});
+ $(fldUploadFile).change(makeDirty);
+
var fldRedirect
= $.INPUT({type: "text", value: (defaultType == "redirect" ? source : "")});
+ $(fldRedirect).change(makeDirty);
+
var trContent
= $.TR({},
$.TH({}),
}
});
+ var btnCancel
+ = $.INPUT({type: "button", value: "Cancel editing"});
+
+ $(btnCancel).click(function () {
+ if (Rakka.isDirty) {
+ if (window.confirm("Do you really want to discard changes?")) {
+ Rakka.restoreScreen();
+ }
+ }
+ else {
+ Rakka.restoreScreen();
+ }
+ });
+
var updateTRContent = function () {
if (btnTypeRakka.checked) {
$(trSummary).show();
trContent,
$.TR({},
$.TH({}),
- $.TD({}, btnPreview, btnSubmit, btnDelete)
+ $.TD({}, btnPreview, btnSubmit, btnDelete, btnCancel)
)
)
);
}
$area.append(pageEditor);
+
+ Rakka.isDirty = false;
};
Rakka.previewRakkaPage = function (pageName, source) {
Rakka.$previewArea.append(child.cloneNode(true));
}
} while (child = child.nextSibling);
+
+ Rakka.scrollToTopLeft();
};
Rakka.submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, summary, text) {