From 6b4c7649a2e1ec1f9038578a0ae82feaa595caf4 Mon Sep 17 00:00:00 2001 From: Robert Gaggl Date: Fri, 2 Jan 2004 10:45:25 +0000 Subject: [PATCH] modified checkbox rendering: use createCheckBoxParam() instead of createInputParam(), checkboxes now preserve their status even if the user is redirected back to the form --- code/Layout/macros.js | 6 +++--- code/Site/macros.js | 33 +++++++++++++++------------------ code/User/macros.js | 6 +++--- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/code/Layout/macros.js b/code/Layout/macros.js index 69163378..ac0d7da9 100644 --- a/code/Layout/macros.js +++ b/code/Layout/macros.js @@ -245,9 +245,9 @@ function description_macro(param) { */ function shareable_macro(param) { if (param.as == "editor" && !this.site) { - var inputParam = this.createInputParam("shareable", param); - if ((req.data.save && req.data.shareable) || (!req.data.save && this.shareable)) - inputParam.checked = "checked"; + var inputParam = this.createCheckBoxParam("shareable", param); + if (req.data.save && !req.data.shareable) + delete inputParam.checked; Html.checkBox(inputParam); } else if (this.shareable) res.write(param.yes ? param.yes : "yes"); diff --git a/code/Site/macros.js b/code/Site/macros.js index b8c75abe..ede0d547 100644 --- a/code/Site/macros.js +++ b/code/Site/macros.js @@ -68,9 +68,9 @@ function lastupdate_macro(param) { */ function online_macro(param) { if (param.as == "editor") { - var inputParam = this.createInputParam("online", param); - if ((req.data.save && req.data.online) || (!req.data.save && this.online)) - inputParam.checked = "checked"; + var inputParam = this.createCheckBoxParam("online", param); + if (req.data.save && !req.data.online) + delete inputParam.checked; Html.checkBox(inputParam); } else if (this.online) res.write(param.yes ? param.yes : "yes"); @@ -84,10 +84,9 @@ function online_macro(param) { */ function hasdiscussions_macro(param) { if (param.as == "editor") { - var inputParam = this.preferences.createInputParam("discussions", param); - if ((req.data.save && req.data.discussions) || - (!req.data.save && this.preferences.getProperty("discussions"))) - inputParam.checked = "checked"; + var inputParam = this.createCheckBoxParam("discussions", param); + if (req.data.save && !req.data.discussions) + delete inputParam.checked; Html.checkBox(inputParam); } else res.write(this.preferences.getProperty("discussions") ? "yes" : "no"); @@ -100,10 +99,9 @@ function hasdiscussions_macro(param) { */ function usermaycontrib_macro(param) { if (param.as == "editor") { - var inputParam = this.preferences.createInputParam("usercontrib", param); - if ((req.data.save && req.data.usercontrib) || - (!req.data.save && this.preferences.getProperty("usercontrib"))) - inputParam.checked = "checked"; + var inputParam = this.createCheckBoxParam("usercontrib", param); + if (req.data.save && !req.data.usercontrib) + delete inputParam.checked; Html.checkBox(inputParam); } else res.write(this.preferences.getProperty("usercontrib") ? "yes" : "no"); @@ -126,10 +124,9 @@ function showdays_macro(param) { */ function showarchive_macro(param) { if (param.as == "editor") { - var inputParam = this.preferences.createInputParam("archive", param); - if ((req.data.save && req.data.archive) || - (!req.data.save && this.preferences.getProperty("archive"))) - inputParam.checked = "checked"; + var inputParam = this.createCheckBoxParam("archive", param); + if (req.data.save && !req.data.archive) + delete inputParam.checked; Html.checkBox(inputParam); } else res.write(this.preferences.getProperty("archive") ? "yes" : "no"); @@ -141,9 +138,9 @@ function showarchive_macro(param) { */ function enableping_macro(param) { if (param.as == "editor") { - var inputParam = this.createInputParam("enableping", param); - if ((req.data.save && req.data.enableping) || (!req.data.save && this.enableping)) - inputParam.checked = "checked"; + var inputParam = this.createCheckBoxParam("enableping", param); + if (req.data.save && !req.data.enableping) + delete inputParam.checked; Html.checkBox(inputParam); } else res.write(this.enableping ? "yes" : "no"); diff --git a/code/User/macros.js b/code/User/macros.js index 25493d06..23129f19 100644 --- a/code/User/macros.js +++ b/code/User/macros.js @@ -49,9 +49,9 @@ function email_macro(param) { function publishemail_macro(param) { if (param.as == "editor") { - var inputParam = this.createInputParam("publishemail", param); - if ((req.data.save && req.data.publishemail) || (!req.data.save && this.publishemail)) - inputParam.checked = "checked"; + var inputParam = this.createCheckBoxParam("publishemail", param); + if (req.data.save && !req.data.publishemail) + delete inputParam.checked; Html.checkBox(inputParam); } else res.write(this.publishemail ? "yes" : "no");