Merge branch 'master' into kcls_dcl53
[evergreen-equinox.git] / Open-ILS / xul / staff_client / chrome / content / OpenILS / global_util.js
index 364d573..8250cae 100644 (file)
 
     function update_modal_xulG(v) {
         try {
+            if (typeof xulG != "undefined" && xulG.not_modal) {
+                xulG = v;
+                xulG.not_modal = true;
+                return;
+            }
+
             JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
             var key = location.pathname + location.search + location.hash;
             if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
             }
             if (typeof _params.no_xulG == 'undefined') {
                 if (typeof _params.modal_xulG != 'undefined') {
-                    JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
-                    var key = location.pathname + location.search + location.hash;
-                    //dump('xul_param, considering modal key = ' + key + '\n');
-                    if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
-                        xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
+                    if (typeof xulG != 'undefined' && xulG.not_modal) {
+                        // for interfaces that used to be modal but aren't now, do nothing
+                    } else {
+                        JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
+                        var key = location.pathname + location.search + location.hash;
+                        //dump('xul_param, considering modal key = ' + key + '\n');
+                        if (typeof data.modal_xulG_stack != 'undefined' && typeof data.modal_xulG_stack[key] != 'undefined') {
+                            xulG = data.modal_xulG_stack[key][ data.modal_xulG_stack[key].length - 1 ];
+                        }
                     }
                 }
                 if (typeof xulG == 'object' && typeof xulG[ param_name ] != 'undefined') {
         return url;
     }
 
+    function widget_prompt(node,args) {
+        // args is an object that may contain the following keys: title, desc, ok_label, ok_accesskey, cancel_label, cancel_accesskey, access, method
+        // access may contain 'property' or 'attribute' or 'method' for retrieving the value from the node
+        // if 'method', then the method key will reference a function that returns the value
+        try {
+            if (!node) { return false; }
+            if (!args) { args = {}; }
+            args[ 'widget' ] = node;
+
+            var url = location.protocol == 'chrome'
+                ? 'chrome://open_ils_staff_client/content/util/widget_prompt.xul'
+                : '/xul/server/util/widget_prompt.xul';
+
+            JSAN.use('util.window'); var win = new util.window();
+            var my_xulG = win.open(
+                url,
+                args.title || 'widget_prompt',
+                'chrome,modal',
+                args
+            );
+
+            if (my_xulG.status == 'incomplete') {
+                return false;
+            } else {
+                return my_xulG.value;
+            }
+        } catch(E) {
+            alert('Error in global_utils.js, widget_prompt(): ' + E);
+        }
+    }