modified checkbox rendering: use createCheckBoxParam() instead of createInputParam(), checkboxes now preserve their status even if the user is redirected back to the form

This commit is contained in:
Robert Gaggl 2004-01-02 10:45:25 +00:00
parent 3ee00ed75d
commit 6b4c7649a2
3 changed files with 21 additions and 24 deletions

View file

@ -245,9 +245,9 @@ function description_macro(param) {
*/ */
function shareable_macro(param) { function shareable_macro(param) {
if (param.as == "editor" && !this.site) { if (param.as == "editor" && !this.site) {
var inputParam = this.createInputParam("shareable", param); var inputParam = this.createCheckBoxParam("shareable", param);
if ((req.data.save && req.data.shareable) || (!req.data.save && this.shareable)) if (req.data.save && !req.data.shareable)
inputParam.checked = "checked"; delete inputParam.checked;
Html.checkBox(inputParam); Html.checkBox(inputParam);
} else if (this.shareable) } else if (this.shareable)
res.write(param.yes ? param.yes : "yes"); res.write(param.yes ? param.yes : "yes");

View file

@ -68,9 +68,9 @@ function lastupdate_macro(param) {
*/ */
function online_macro(param) { function online_macro(param) {
if (param.as == "editor") { if (param.as == "editor") {
var inputParam = this.createInputParam("online", param); var inputParam = this.createCheckBoxParam("online", param);
if ((req.data.save && req.data.online) || (!req.data.save && this.online)) if (req.data.save && !req.data.online)
inputParam.checked = "checked"; delete inputParam.checked;
Html.checkBox(inputParam); Html.checkBox(inputParam);
} else if (this.online) } else if (this.online)
res.write(param.yes ? param.yes : "yes"); res.write(param.yes ? param.yes : "yes");
@ -84,10 +84,9 @@ function online_macro(param) {
*/ */
function hasdiscussions_macro(param) { function hasdiscussions_macro(param) {
if (param.as == "editor") { if (param.as == "editor") {
var inputParam = this.preferences.createInputParam("discussions", param); var inputParam = this.createCheckBoxParam("discussions", param);
if ((req.data.save && req.data.discussions) || if (req.data.save && !req.data.discussions)
(!req.data.save && this.preferences.getProperty("discussions"))) delete inputParam.checked;
inputParam.checked = "checked";
Html.checkBox(inputParam); Html.checkBox(inputParam);
} else } else
res.write(this.preferences.getProperty("discussions") ? "yes" : "no"); res.write(this.preferences.getProperty("discussions") ? "yes" : "no");
@ -100,10 +99,9 @@ function hasdiscussions_macro(param) {
*/ */
function usermaycontrib_macro(param) { function usermaycontrib_macro(param) {
if (param.as == "editor") { if (param.as == "editor") {
var inputParam = this.preferences.createInputParam("usercontrib", param); var inputParam = this.createCheckBoxParam("usercontrib", param);
if ((req.data.save && req.data.usercontrib) || if (req.data.save && !req.data.usercontrib)
(!req.data.save && this.preferences.getProperty("usercontrib"))) delete inputParam.checked;
inputParam.checked = "checked";
Html.checkBox(inputParam); Html.checkBox(inputParam);
} else } else
res.write(this.preferences.getProperty("usercontrib") ? "yes" : "no"); res.write(this.preferences.getProperty("usercontrib") ? "yes" : "no");
@ -126,10 +124,9 @@ function showdays_macro(param) {
*/ */
function showarchive_macro(param) { function showarchive_macro(param) {
if (param.as == "editor") { if (param.as == "editor") {
var inputParam = this.preferences.createInputParam("archive", param); var inputParam = this.createCheckBoxParam("archive", param);
if ((req.data.save && req.data.archive) || if (req.data.save && !req.data.archive)
(!req.data.save && this.preferences.getProperty("archive"))) delete inputParam.checked;
inputParam.checked = "checked";
Html.checkBox(inputParam); Html.checkBox(inputParam);
} else } else
res.write(this.preferences.getProperty("archive") ? "yes" : "no"); res.write(this.preferences.getProperty("archive") ? "yes" : "no");
@ -141,9 +138,9 @@ function showarchive_macro(param) {
*/ */
function enableping_macro(param) { function enableping_macro(param) {
if (param.as == "editor") { if (param.as == "editor") {
var inputParam = this.createInputParam("enableping", param); var inputParam = this.createCheckBoxParam("enableping", param);
if ((req.data.save && req.data.enableping) || (!req.data.save && this.enableping)) if (req.data.save && !req.data.enableping)
inputParam.checked = "checked"; delete inputParam.checked;
Html.checkBox(inputParam); Html.checkBox(inputParam);
} else } else
res.write(this.enableping ? "yes" : "no"); res.write(this.enableping ? "yes" : "no");

View file

@ -49,9 +49,9 @@ function email_macro(param) {
function publishemail_macro(param) { function publishemail_macro(param) {
if (param.as == "editor") { if (param.as == "editor") {
var inputParam = this.createInputParam("publishemail", param); var inputParam = this.createCheckBoxParam("publishemail", param);
if ((req.data.save && req.data.publishemail) || (!req.data.save && this.publishemail)) if (req.data.save && !req.data.publishemail)
inputParam.checked = "checked"; delete inputParam.checked;
Html.checkBox(inputParam); Html.checkBox(inputParam);
} else } else
res.write(this.publishemail ? "yes" : "no"); res.write(this.publishemail ? "yes" : "no");