From: Jason Etheridge Date: Mon, 21 Mar 2011 07:09:21 +0000 (-0400) Subject: move the javascript out of the xul file X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=654ec8c0a4a85447d73012fd8f07ed247a03d9c2;p=evergreen%2Fequinox.git move the javascript out of the xul file --- diff --git a/Open-ILS/xul/staff_client/server/cat/volume_editor.js b/Open-ILS/xul/staff_client/server/cat/volume_editor.js new file mode 100644 index 0000000000..37ec1c8327 --- /dev/null +++ b/Open-ILS/xul/staff_client/server/cat/volume_editor.js @@ -0,0 +1,65 @@ +var xulG = {}; + +function my_init() { + try { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); } + JSAN.errorLevel = "die"; // none, warn, or die + JSAN.addRepository('/xul/server/'); + JSAN.use('util.error'); g.error = new util.error(); + g.error.sdump('D_TRACE','my_init() for cat/volume_editor.xul'); + + JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'}); + + JSAN.use('util.functional'); + + g.volumes = xul_param('volumes',{'stash_name':'volumes_temp','clear_xpcom':true,'modal_xulG':true}); //JSON2js( g.data.volumes_temp ); + //g.data.volumes_temp = ''; g.data.stash('volumes_temp'); + + var rows = document.getElementById('rows'); + + var first_tb; + + for (var i = 0; i < g.volumes.length; i++) { + var row = document.createElement('row'); rows.appendChild(row); + var lib_label = document.createElement('label'); row.appendChild(lib_label); + var tb = document.createElement('textbox'); row.appendChild(tb); + if (!first_tb) { first_tb = tb; } + + var lib_id = g.volumes[i].owning_lib(); + var last_lib_seen; + + if (last_lib_seen != lib_id ) { + lib_label.setAttribute('value',g.data.hash.aou[ lib_id ].shortname() ); + last_lib_seen = lib_id; + } + + tb.setAttribute('value',g.volumes[i].label()); + tb.setAttribute('onchange','try { var v = g.volumes['+i+']; v.ischanged("1"); v.label( this.value ); } catch(E) { alert(E); }'); + } + + first_tb.select(); first_tb.focus(); + + } catch(E) { + var err_msg = $("commonStrings").getFormattedString('common.exception', ['cat/volume_editor.xul', E]); + try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); dump(js2JSON(E)); } + alert(err_msg); + } +} + +g.stash_and_close = function() { + try { + //g.data.volumes_temp = js2JSON( g.volumes ); + //g.error.sdump('D_CAT','in modal window, g.data.volumes_temp = \n' + g.data.volumes_temp + '\n'); + //g.data.stash('volumes_temp'); + xulG.volumes = g.volumes; + xulG.update_these_volumes = 1; + xulG.auto_merge = document.getElementById('auto_merge').checked; + update_modal_xulG(xulG); + window.close(); + } catch(E) { + alert('FIXME: volume editor -> ' + E); + } +} + + diff --git a/Open-ILS/xul/staff_client/server/cat/volume_editor.xul b/Open-ILS/xul/staff_client/server/cat/volume_editor.xul index b8f57783e7..4ea3423397 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_editor.xul +++ b/Open-ILS/xul/staff_client/server/cat/volume_editor.xul @@ -30,76 +30,8 @@ -