padding: 0.2em 0 0 0;
}
+table.pageEditor {
+ width: 100%;
+}
+.pageEditor td, .pageEditor th {
+ padding: 3px;
+}
+.pageEditor th {
+ width: 6em;
+}
+.pageEditor ul {
+ list-style-type: none;
+ margin: 0;
+}
+.pageEditor li {
+ margin: 0;
+ padding: 3px;
+}
+.pageEditor input[type="radio"] {
+ margin-right: 10px;
+}
+.pageEditor input[type="text"],
+.pageEditor input[type="file"],
+.pageEditor textarea {
+ width: 97%;
+ padding: 3px;
+}
+.pageEditor textarea {
+ height: 30em;
+}
+.pageEditor input[type="button"] {
+ margin: 0 2px;
+}
+
/* color and text *************************************************************/
* {
font-family: sans-serif;
border-style: dashed;
}
+th, td {
+ border-color: #dddddd;
+ border-width: 1px;
+ border-style: solid;
+}
+th {
+ background-color: #eeeeee;
+ font-weight: bold;
+}
+td {
+ background-color: #fafafa;
+}
+
.title {
background-color: #fafafa;
background-color: #e0e0e0;
}
+.pageEditor input[type="text"],
+.pageEditor input[type="file"],
+.pageEditor textarea {
+ border-color: #dddddd #fafafa #fafafa #dddddd;
+ border-width: 2px;
+ border-style: solid;
+
+ background-color: white;
+}
+
/* float **********************************************************************/
h1, h2, h3, h4, h5, h6 {
clear: both;
success: function (pageXml) {
var $page = $(pageXml).find("page");
var oldRevision = $page.attr("revision");
- var defaultAction = $page.attr("isBinary") == "yes" ? "uploadFile"
- : $page.attr("type") == "text/x-rakka" ? "editAsWiki"
- : $page.attr("type") == "text/css" ? "editAsCSS"
+ var defaultType = $page.attr("isBinary") == "yes" ? "binary"
+ : $page.attr("type") == "text/x-rakka" ? "rakka"
+ : $page.attr("type") == "text/css" ? "css"
: "unknown"
;
var source = $page.find("source").text();
- Rakka.displayPageEditor($body, pageName, oldRevision, defaultAction, source);
+ Rakka.displayPageEditor($body, pageName, oldRevision, defaultType, source);
},
error : function (req) {
if (req.status == 404) {
- Rakka.displayPageEditor($body, pageName, null, "editAsWiki");
+ Rakka.displayPageEditor($body, pageName, null, "rakka", null);
}
else {
$body.text("Error: " + req.status + " " + req.statusText);
});
};
-Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultAction, source) {
+Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultType, source) {
$place.empty();
+ $place.append($.H1({}, "Edit page"));
+
var fldPageName
= $.INPUT({type : "text", value: pageName});
- var btnEditAsWiki
+ var btnTypeRakka
= $.INPUT({type : "radio",
- name : "action",
- checked: (defaultAction == "editAsWiki" ? "checked" : "")});
+ name : "type",
+ checked: (defaultType == "rakka" ? "checked" : "")});
- var btnEditAsCSS
+ var btnTypeCSS
= $.INPUT({type : "radio",
- name : "action",
- checked: (defaultAction == "editAsCSS" ? "checked" : "")});
+ name : "type",
+ checked: (defaultType == "css" ? "checked" : "")});
- var btnUploadFile
+ var btnTypeBinary
= $.INPUT({type : "radio",
- name : "action",
- checked: (defaultAction == "uploadFile" ? "checked" : "")});
+ name : "type",
+ checked: (defaultType == "binary" ? "checked" : "")});
+
+
+ var fldRakkaSource
+ = $.TEXTAREA({}, (defaultType == "rakka" && source != null ? source : ""));
+
+ var fldCSSSource
+ = $.TEXTAREA({}, (defaultType == "css" && source != null ? source : ""));
+
+ var fldUploadFile
+ = $.INPUT({type: "file"});
+
+ var trContent
+ = $.TR({},
+ $.TH({}),
+ $.TD({})
+ );
+
+ var btnPreview
+ = $.INPUT({type: "button", value: "Preview page"});
+
+ var btnSubmit
+ = $.INPUT({type: "button", value: "Submit page"});
var btnDelete
- = $.INPUT({type : "radio",
- name : "action",
- checked: ""});
+ = $.INPUT({type: "button", value: "Delete this page"});
+
+ var updateTRContent = function () {
+ if (btnTypeRakka.checked) {
+ $(trContent).find("th").text("Wiki source");
+ $(trContent).find("td").empty().append(fldRakkaSource);
+ $(trContent).show();
+ }
+ else if (btnTypeCSS.checked) {
+ $(trContent).find("th").text("CSS source");
+ $(trContent).find("td").empty().append(fldCSSSource);
+ $(trContent).show();
+ }
+ else if (btnTypeBinary.checked) {
+ $(trContent).find("th").text("File");
+ $(trContent).find("td").empty().append(fldUploadFile);
+ $(trContent).show();
+ }
+ else {
+ $(trContent).hide();
+ }
+ };
+ $(btnTypeRakka ).change(updateTRContent);
+ $(btnTypeCSS ).change(updateTRContent);
+ $(btnTypeBinary).change(updateTRContent);
+ updateTRContent();
var pageEditor
= $.TABLE({className: "pageEditor"},
$.TBODY({},
$.TR({},
- $.TH({}, "Name of the page"),
+ $.TH({}, "Page name"),
$.TD({}, fldPageName)
),
$.TR({},
- $.TH({}, "Action"),
+ $.TH({}, "Page type"),
$.TD({},
$.UL({},
$.LI({},
$.LABEL({},
- btnEditAsWiki,
- "Edit as a Wiki page"
+ btnTypeRakka,
+ "Wiki page"
)
),
$.LI({},
$.LABEL({},
- btnEditAsCSS,
- "Edit as a style sheet"
+ btnTypeCSS,
+ "Style sheet"
)
),
$.LI({},
$.LABEL({},
- btnUploadFile,
- "Upload a file"
+ btnTypeBinary,
+ "Binary file"
)
- ),
- (oldRevision != "" && oldRevision != 0
- ? $.LI({},
- $.LABEL({},
- btnDelete,
- "Delete this page"
- )
- )
- : [])
+ )
)
)
+ ),
+ trContent,
+ $.TR({},
+ $.TH({}),
+ $.TD({}, btnPreview, btnSubmit, btnDelete)
)
)
);
+ if (oldRevision == null || oldRevision == 0) {
+ // 削除不可
+ $(btnDelete).hide();
+ }
+
$place.append(pageEditor);
};