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 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
45 /* load translatable strings for cataloging interfaces */
46 catStrings = document.getElementById('catStrings');
48 if (typeof JSAN == 'undefined') {
49 throw( $('commonStrings').getString('common.jsan.missing') );
51 JSAN.errorLevel = "die"; // none, warn, or die
52 JSAN.addRepository('/xul/server/');
53 JSAN.use('util.error'); g.error = new util.error();
54 g.error.sdump('D_TRACE','my_init() for example_template.xul');
56 if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
57 try { window.xulG.set_tab_name(catStrings.getString('staff.cat.marc_new.tab_name')); } catch(E) { alert(E); }
60 JSAN.use('util.network'); g.network = new util.network();
61 JSAN.use('util.widgets');
62 JSAN.use('util.functional');
63 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
65 var templates = g.network.simple_request('MARC_XML_TEMPLATE_LIST',[]);
66 if (typeof templates.ilsevent != 'undefined') throw(templates);
67 var ml = util.widgets.make_menulist(
68 util.functional.map_list(
71 return [ el /* The menu entry label */, el /* The menu entry value */ ];
75 $('menu_placeholder').appendChild(ml);
77 $('load').addEventListener(
84 template_name = $('menu_placeholder').firstChild.value;
85 var marc = g.network.simple_request(
86 'MARC_XML_TEMPLATE_RETRIEVE',
89 if (typeof marc.ilsevent != 'undefined') throw(marc);
91 var url = urls.XUL_MARC_EDIT;
93 'record' : { 'marc' : marc },
94 'marc_control_number_identifier': g.data.hash.aous['cat.marc_control_number_identifier'] || 'Set cat.marc_control_number_identifier in Library Settings',
95 'fast_add_item' : function(doc_id,cn_label,cp_barcode) {
97 JSAN.use('cat.util'); return cat.util.fast_item_add(doc_id,cn_label,cp_barcode);
103 'label' : catStrings.getString('staff.cat.marc_new.create_record.label'),
104 'func' : function(new_marcxml) {
106 var robj = g.network.simple_request(
107 'MARC_XML_RECORD_IMPORT',
108 [ ses(), new_marcxml, catStrings.getString('staff.cat.marc_new.system_local.label'), 1 ]
110 if (typeof robj.ilsevent != 'undefined') throw(robj);
112 /* Replace tab with OPAC-view of record */
114 var opac_url = xulG.url_prefix( urls.opac_rdetail ) + '?r=' + robj.id();
115 var content_params = {
117 'authtime' : ses('authtime'),
118 'opac_url' : opac_url
122 'on_complete' : function() {
125 xulG.url_prefix(urls.XUL_OPAC_WRAPPER),
126 {'tab_name': catStrings.getString('staff.cat.marc_new.retrieving.label')},
136 g.error.standard_unexpected_error_alert(
137 catStrings.getString('staff.cat.marc_new.creating_record.error'), E
142 'lock_tab' : xulG.lock_tab,
143 'unlock_tab' : xulG.unlock_tab
145 var marc_editor = document.createElement('iframe');
146 $('marc_editor_box').appendChild(marc_editor);
147 marc_editor.setAttribute('flex','1');
148 marc_editor.setAttribute('src',url);
149 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
150 get_contentWindow(marc_editor).xulG = params;
152 /* hide template widgets */
153 $('actions').hidden = true;
155 window.xulG.set_tab_name(template_name);
158 g.error.standard_unexpected_error_alert(
159 catStrings.getFormattedString('staff.cat.marc_new.loading_template.error', [template_name]), E
168 g.error.standard_unexpected_error_alert('cat/marc_new.xul',E);
175 <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
176 <messagecatalog id="circStrings" src="/xul/server/locale/<!--#echo var='locale'-->/circ.properties" />
178 <vbox id="marc_editor_box" flex="1">
180 <hbox id="menu_placeholder" />
181 <button id="load" label="&staff.cat.marc_new.load.label;" accesskey="&staff.cat.marc_new.load.accesskey;"/>