2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Example Template for remote xul -->
8 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
10 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
11 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
13 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
15 <!DOCTYPE window PUBLIC "" ""[
16 <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
19 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
21 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
23 <window id="example_template_win"
24 onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
25 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
27 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
29 <script type="text/javascript">
30 var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};
32 <scripts id="openils_util_scripts"/>
34 <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
39 function $(id) { return document.getElementById(id); }
43 /* load translatable strings for cataloging interfaces */
44 catStrings = document.getElementById('catStrings');
46 if (typeof JSAN == 'undefined') {
47 throw( $('commonStrings').getString('common.jsan.missing') );
49 JSAN.errorLevel = "die"; // none, warn, or die
50 JSAN.addRepository('/xul/server/');
51 JSAN.use('util.error'); g.error = new util.error();
52 g.error.sdump('D_TRACE','my_init() for example_template.xul');
54 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
55 try { window.xulG.set_tab_name(catStrings.getString('staff.cat.marc_new.tab_name')); } catch(E) { alert(E); }
58 JSAN.use('util.network'); g.network = new util.network();
59 JSAN.use('util.widgets');
60 JSAN.use('util.functional');
61 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
63 var templates = g.network.simple_request('MARC_XML_TEMPLATE_LIST',[]);
64 if (typeof templates.ilsevent != 'undefined') throw(templates);
66 g.prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces['nsIPrefBranch']);
67 var default_template_key = 'oils.marc_new.default_template.' + window.location.hostname;
68 if(g.data.last_marc_template) default_template = g.data.last_marc_template;
69 if(!default_template) {
70 var has_key = g.prefs.prefHasUserValue(default_template_key);
71 if(has_key) default_template = g.prefs.getCharPref(default_template_key);
73 var ml = util.widgets.make_menulist(
74 util.functional.map_list(
77 return [ el /* The menu entry label */, el /* The menu entry value */ ];
81 $('menu_placeholder').appendChild(ml);
83 $('load').addEventListener(
90 template_name = $('menu_placeholder').firstChild.value;
91 var marc = g.network.simple_request(
92 'MARC_XML_TEMPLATE_RETRIEVE',
95 if (typeof marc.ilsevent != 'undefined') throw(marc);
97 g.data.stash_retrieve();
98 g.data.last_marc_template = template_name;
99 g.data.stash('last_marc_template');
101 var url = urls.XUL_MARC_EDIT;
103 'record' : { 'marc' : marc },
104 'marc_control_number_identifier': g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
105 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
107 JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
113 'label' : catStrings.getString('staff.cat.marc_new.create_record.label'),
114 'func' : function(new_marcxml) {
116 var robj = g.network.simple_request(
117 'MARC_XML_RECORD_IMPORT',
118 [ ses(), new_marcxml, catStrings.getString('staff.cat.marc_new.system_local.label'), 1 ]
120 if (typeof robj.ilsevent != 'undefined') throw(robj);
122 /* Replace tab with OPAC-view of record */
124 var opac_url = xulG.url_prefix('opac_rdetail') + robj.id();
125 var content_params = {
127 'authtime' : ses('authtime'),
128 'opac_url' : opac_url
132 'on_complete' : function() {
135 xulG.url_prefix('XUL_OPAC_WRAPPER'),
136 {'tab_name': catStrings.getString('staff.cat.marc_new.retrieving.label')},
146 g.error.standard_unexpected_error_alert(
147 catStrings.getString('staff.cat.marc_new.creating_record.error'), E
152 'lock_tab' : xulG.lock_tab,
153 'unlock_tab' : xulG.unlock_tab
155 var marc_editor = document.createElement('iframe');
156 $('marc_editor_box').appendChild(marc_editor);
157 marc_editor.setAttribute('flex','1');
158 marc_editor.setAttribute('src',url);
159 get_contentWindow(marc_editor).xulG = params;
161 /* hide template widgets */
162 $('actions').hidden = true;
164 window.xulG.set_tab_name(template_name);
167 g.error.standard_unexpected_error_alert(
168 catStrings.getFormattedString('staff.cat.marc_new.loading_template.error', [template_name]), E
176 $('set_default').addEventListener(
181 template_name = $('menu_placeholder').firstChild.value;
182 g.prefs.setCharPref(default_template_key, template_name);
183 alert(catStrings.getFormattedString('staff.cat.marc_new.set_default.success', [template_name]));
185 g.error.standard_unexpected_error_alert(
186 catStrings.getFormattedString('staff.cat.marc_new.set_default.error', [template_name]), E
194 g.error.standard_unexpected_error_alert('cat/marc_new.xul',E);
201 <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
202 <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
204 <vbox id="marc_editor_box" flex="1">
206 <hbox id="menu_placeholder" />
207 <button id="load" label="&staff.cat.marc_new.load.label;" accesskey="&staff.cat.marc_new.load.accesskey;"/>
208 <button id="set_default" label="&staff.cat.marc_new.set_default.label;" accesskey="&staff.cat.marc_new.set_default.accesskey;"/>