modal xulG infrastructure for util.window
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 13 May 2007 08:27:00 +0000 (08:27 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 13 May 2007 08:27:00 +0000 (08:27 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@7289 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/util/window.js

index e21e1a1..c7a73bf 100644 (file)
@@ -71,13 +71,40 @@ util.window.prototype = {
                return w;
        },
 
-       'open' : function(url,title,features) {
+       'open' : function(url,title,features,my_xulG) {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+               var key;
                if (!title) title = 'anon' + this.window_name_increment();
                if (!features) features = 'chrome';
-               this.error.sdump('D_WIN',
-                       'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n');
+               this.error.sdump('D_WIN', 'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n');
+               var data;
+               if (features.match(/modal/) && my_xulG) {
+                       JSAN.use('OpenILS.data'); data = new OpenILS.data(); data.init({'via':'stash'});
+                       if (typeof data.modal_xulG_stack == 'undefined') data.modal_xulG_stack = {}; 
+                       /* FIXME - not a perfect key.. could imagine two top-level windows both opening modal windows */
+                       key = url; 
+                       if (typeof xulG == 'object') if (typeof xulG.url_prefix == 'function') {
+                               key = key.replace( xulG.url_prefix('/'), '/' ); 
+                       }
+                       if (typeof data.modal_xulG_stack[key] == 'undefined') data.modal_xulG_stack[key] = [];
+                       data.modal_xulG_stack[key].push( my_xulG );
+                       data.stash('modal_xulG_stack');
+                       this.error.sdump('D_WIN','modal key = ' + key);
+               }
                var w = this.SafeWindowOpen(url,title,features);
+               if (features.match(/modal/) && my_xulG) { 
+                       var x = data.modal_xulG_stack[key].pop();
+                       data.stash('modal_xulG_stack');
+                       return x;
+               } else {
+                       if (my_xulG) {
+                               if (w.contentWindow) {
+                                       w.contentWindow.xulG = my_xulG;
+                               } else {
+                                       w.xulG = my_xulG;
+                               }
+                       }
+               }
                /*
                setTimeout( 
                        function() {