]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/cat/volume_copy_editor.js
e15c3951fc14be8cf121a336308d7092085f9785
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / cat / volume_copy_editor.js
1 var error;
2 var g = {};
3
4 function my_init() {
5     try {
6         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
7         if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
8         JSAN.errorLevel = "die"; // none, warn, or die
9         JSAN.addRepository('/xul/server/');
10         JSAN.use('util.error'); error = new util.error();
11         error.sdump('D_TRACE','my_init() for main_test.xul');
12
13         /*if (typeof window.xulG == 'object' && typeof window.xulG.set_tab_name == 'function') {
14             try { window.xulG.set_tab_name('Test'); } catch(E) { alert(E); }
15         }*/
16
17         // Both interfaces look for this
18         xulG.unified_interface = true;
19
20         // Item Attribute Editor looks for these
21         xulG.not_modal = true;
22         xulG.edit = true;
23
24         // Spawn the volume/copy creator
25         JSAN.use('util.browser');
26         var volume_pane = new util.browser();
27         volume_pane.init(
28             {
29                 'url' : urls.XUL_VOLUME_COPY_CREATOR_ORIGINAL,
30                 'push_xulG' : true,
31                 'alt_print' : false,
32                 'browser_id' : 'volume_pane',
33                 'passthru_content_params' : xulG
34             }
35         );
36
37         setup_templates();
38
39         // Spawn the item attribute editor
40         var item_pane = new util.browser();
41         item_pane.init(
42             {
43                 'url' : urls.XUL_COPY_EDITOR,
44                 'push_xulG' : true,
45                 'alt_print' : false,
46                 'browser_id' : 'item_pane',
47                 'passthru_content_params' : xulG,
48                 'on_url_load' : g.clone_template_bar // from setup_templates()
49             }
50         );
51
52     } catch(E) {
53         alert('Error in volume_copy_editor.js, my_init(): ' + E);
54     }
55 }
56
57 function setup_templates() {
58     try {
59         JSAN.use('util.widgets'); JSAN.use('util.functional');
60
61         // Once the item attribute editor is loaded, clone and import its template menu to this window with this callback
62         g.clone_template_bar = function() {
63             var item_editor_template_bar = get_contentWindow( $('item_pane') ).document.getElementById('template_bar');
64             $('template_bar_holder').appendChild(
65                 document.importNode(
66                     item_editor_template_bar,
67                     true // children
68                 )
69             );
70             item_editor_template_bar.hidden = true;
71             g.apply_template = function() {
72                 xulG.update_item_editor_template_selection( $('template_menu').value );
73                 xulG.item_editor_apply_template();
74             };
75             g.delete_template = function() {
76                 xulG.update_item_editor_template_selection( $('template_menu').value );
77                 xulG.item_editor_delete_template();
78             };
79             g.save_template = function() { xulG.item_editor_save_template(); };
80             g.import_templates = function() { xulG.item_editor_import_templates(); };
81             g.export_templates = function() { xulG.item_editor_apply_templates(); };
82             g.reset = function() { xulG.item_editor_reset(); };
83
84             // just do this once; not sure if on_url_load could fire multiple times
85             g.clone_template_bar = function() {};
86         }
87
88         // callback for populating the list of templates
89         xulG.update_unified_template_list = function(list) {
90             try {
91                 util.widgets.remove_children('template_placeholder');
92                 g.template_menu = util.widgets.make_menulist( list );
93                 g.template_menu.setAttribute('id','template_menu');
94                 $('template_placeholder').appendChild(g.template_menu);
95                 g.template_menu.addEventListener(
96                     'command',
97                     function() {
98                         xulG.update_item_editor_template_selection( g.template_menu.value );
99                     },
100                     false
101                 );
102             } catch(E) {
103                 alert('Error in volume_copy_editor.js, xulG.update_unified_template_list(): ' + E);
104             }
105         };
106
107     } catch(E) {
108         alert('Error in volume_copy_editor.js, setup_templates(): ' + E);
109     }
110 }
111