[open-ils-commits] r14017 - trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Sep 13 23:18:14 EDT 2009


Author: phasefx
Date: 2009-09-13 23:18:12 -0400 (Sun, 13 Sep 2009)
New Revision: 14017

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
Log:
fire a command event on checkboxes if persist_helper makes them checked.  This handles checkboxes like Stack Subfields and Fast Item Add in the marc editor

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js	2009-09-13 15:31:41 UTC (rev 14016)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js	2009-09-14 03:18:12 UTC (rev 14017)
@@ -51,24 +51,29 @@
                     dump('persist_helper: retrieving key = ' + key + ' value = ' + value + ' for ' + nodes[i].nodeName + '\n');
                     if (value) nodes[i].setAttribute( attribute_list[j], value );
                 }
-                if (nodes[i].nodeName == 'checkbox' && attribute_list.indexOf('checked') > -1) nodes[i].addEventListener(
-                    'command',
-                    function(bk) {
-                        return function(ev) {
-                            try {
-                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                                var key = bk + 'checked';
-                                var value = ev.target.checked;
-                                ev.target.setAttribute( 'checked', value );
-                                prefs.setCharPref( key, value );
-                                dump('persist_helper: setting key = ' +  key + ' value = ' + value + ' for checkbox\n');
-                            } catch(E) {
-                                alert('Error in persist_helper(), checkbox command event listener: ' + E);
-                            }
-                        };
-                    }(base_key), 
-                    false
-                );
+                if (nodes[i].nodeName == 'checkbox' && attribute_list.indexOf('checked') > -1) {
+                    var evt = document.createEvent("Events");
+                    evt.initEvent( 'command', true, true );
+                    nodes[i].dispatchEvent(evt);
+                    nodes[i].addEventListener(
+                        'command',
+                        function(bk) {
+                            return function(ev) {
+                                try {
+                                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                                    var key = bk + 'checked';
+                                    var value = ev.target.checked;
+                                    ev.target.setAttribute( 'checked', value );
+                                    prefs.setCharPref( key, value );
+                                    dump('persist_helper: setting key = ' +  key + ' value = ' + value + ' for checkbox\n');
+                                } catch(E) {
+                                    alert('Error in persist_helper(), checkbox command event listener: ' + E);
+                                }
+                            };
+                        }(base_key), 
+                        false
+                    );
+                }
                 // TODO: Need to add event listeners for window resizing, splitter repositioning, grippy state, etc.
             }
         } catch(E) {



More information about the open-ils-commits mailing list