From df16f1eb8b399dd6d91814c5da45a37830877041 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 14 Sep 2009 03:18:12 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@14017 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/OpenILS/global_util.js | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js index 56d7e597c6..0ab8fef44b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js @@ -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) { -- 2.43.2