]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/chrome/content/util/widget_prompt.js
Rip modal_xulG_stack out, replace with openDialog
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / util / widget_prompt.js
1 var xulG = {};
2 var widget;
3
4 function my_init() {
5     try {
6         if (typeof JSAN == 'undefined') { throw( "The JSAN library object is missing."); }
7         JSAN.errorLevel = "die"; // none, warn, or die
8         JSAN.addRepository('/xul/server/');
9         JSAN.use('util.error'); g.error = new util.error();
10         g.error.sdump('D_TRACE','my_init() for widget_prompt.xul');
11
12         widget = xul_param('widget');
13         if (widget) {
14             $('widget_prompt_main').appendChild(widget);
15         }
16
17         var ok_label = xul_param('ok_label') || offlineStrings.getString('common.ok.label');
18         $('ok_btn').setAttribute('label',ok_label);
19
20         var ok_accesskey = xul_param('ok_accesskey') || offlineStrings.getString('common.ok.accesskey');
21         $('ok_btn').setAttribute('accesskey',ok_accesskey);
22
23         var cancel_label = xul_param('cancel_label') || offlineStrings.getString('common.cancel.label');
24         $('cancel_btn').setAttribute('label',cancel_label);
25
26         var cancel_accesskey = xul_param('cancel_accesskey') || offlineStrings.getString('common.cancel.accesskey');
27         $('cancel_btn').setAttribute('accesskey',cancel_accesskey);
28
29         var desc = xul_param('desc');
30         if (desc) {
31             $('desc').appendChild( document.createTextNode( desc ) );
32         }
33
34         $('ok_btn').addEventListener('command',widget_save,false);
35         $('cancel_btn').addEventListener('command',function(ev) { window.close(); },false);
36
37         if (xul_param('title')) {
38             try { window.title = xul_param('title'); } catch(E) {}
39             try { document.title = xul_param('title'); } catch(E) {}
40         }
41
42         xulG[ 'status' ] = 'incomplete';
43
44         try { widget.focus(); } catch(E) {}
45
46     } catch(E) {
47         alert('Error in widget_prompt.js, my_init(): ' + E);
48     }
49 }
50
51 function widget_save(ev) {
52     try {
53         if (widget) {
54             switch( xul_param('access') ) {
55                 case 'method' :
56                     xulG[ 'value' ] = xulG[ 'method' ]();
57                 break;
58                 case 'attribute':
59                     xulG[ 'value' ] = widget.getAttribute('value');
60                 break;
61                 case 'property':
62                 default:
63                     xulG[ 'value'  ] = widget.value;
64                 break;
65             }
66         }
67         xulG[ 'status' ] = 'complete';
68
69         window.close();
70     } catch(E) {
71         alert('Error in widget_prompt.js, widget_save(): ' + E);
72     }
73 }
74