Author: eallen
Date: 2009-04-15 16:12:50 -0400 (Wed, 15 Apr 2009)
New Revision: 3296
Modified:
mgmt/trunk/cumin/resources/app.js
Log:
Added functions to save and restore checkbox states for auto-updated tables.
Modified: mgmt/trunk/cumin/resources/app.js
===================================================================
--- mgmt/trunk/cumin/resources/app.js 2009-04-15 20:12:14 UTC (rev 3295)
+++ mgmt/trunk/cumin/resources/app.js 2009-04-15 20:12:50 UTC (rev 3296)
@@ -45,6 +45,54 @@
img.setattr("src", src);
}
+ this.clickTableCheckbox = function (check, name) {
+ var val = check.value;
+ var hash = wooly.session.hash();
+ if (!(name in hash)) {
+ hash[name] = "";
+ }
+ var vals = $A(hash[name].split('|'));
+ if ((vals.length == 1) && (vals[0] == ""))
+ vals.empty();
+ var valIndex = vals.indexOf(val);
+ if (check.checked) {
+ if (valIndex > -1)
+ vals[valIndex] = val;
+ else
+ vals.push(val);
+ }
+ else
+ vals = vals.erase(val);
+ if (vals.length == 0)
+ delete hash[name];
+ else
+ hash[name] = vals.join('|');
+ wooly.session.setHash(hash);
+ }
+
+ this.restoreTableCheckboxes = function () {
+ var hash = wooly.session.hash();
+ for (var key in hash) {
+ if (!(hash[key] instanceof Function)) {
+ var checks = document.forms[0].elements[key];
+ if (checks) {
+ var vals = $A(hash[key].split('|'));
+ if (typeof checks.length == "undefined") {
+ if (vals.contains(checks.value)) {
+ checks.checked = true;
+ }
+ } else {
+ for (var i=0; i < checks.length; i++) {
+ if (vals.contains(checks[i].value)) {
+ checks[i].checked = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
}
}())