move network, window, and controller from main to util
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 13 Dec 2005 00:52:54 +0000 (00:52 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 13 Dec 2005 00:52:54 +0000 (00:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2353 dcc99617-32d9-48b4-a31d-7c20da2025e4

17 files changed:
Open-ILS/xul/staff_client/chrome/content/evergreen/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/evergreen/auth/controller.js
Open-ILS/xul/staff_client/chrome/content/evergreen/auth/session.js
Open-ILS/xul/staff_client/chrome/content/evergreen/main/controller.js [deleted file]
Open-ILS/xul/staff_client/chrome/content/evergreen/main/main.js
Open-ILS/xul/staff_client/chrome/content/evergreen/main/network.js [deleted file]
Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js [deleted file]
Open-ILS/xul/staff_client/chrome/content/evergreen/util/controller.js [new file with mode: 0644]
Open-ILS/xul/staff_client/chrome/content/evergreen/util/fm_view.xul
Open-ILS/xul/staff_client/chrome/content/evergreen/util/network.js [new file with mode: 0644]
Open-ILS/xul/staff_client/chrome/content/evergreen/util/window.js [new file with mode: 0644]
Open-ILS/xul/staff_client/server/cat/opac.js
Open-ILS/xul/staff_client/server/circ/checkout.js
Open-ILS/xul/staff_client/server/main/menu.js
Open-ILS/xul/staff_client/server/patron/display.js
Open-ILS/xul/staff_client/server/patron/search_form.js
Open-ILS/xul/staff_client/server/patron/summary.js

index f0ce596..ce5b400 100644 (file)
@@ -4,7 +4,7 @@ if (typeof OpenILS == 'undefined') OpenILS = {};
 OpenILS.data = function () {
 
        JSAN.use('util.error'); this.error = new util.error();
-       JSAN.use('main.network'); this.network = new main.network();
+       JSAN.use('util.network'); this.network = new util.network();
 
        return this;
 }
index 22a8a61..b47c4c2 100644 (file)
@@ -16,7 +16,7 @@ auth.controller.prototype = {
                var w = obj.w;
 
                // MVC
-               JSAN.use('main.controller'); obj.controller = new main.controller();
+               JSAN.use('util.controller'); obj.controller = new util.controller();
                obj.controller.init(
                        {
                                'control_map' : {
index 6a3f24d..196dea2 100644 (file)
@@ -4,7 +4,7 @@ if (typeof auth == 'undefined') auth = {};
 auth.session = function (view) {
 
        JSAN.use('util.error'); this.error = new util.error();
-       JSAN.use('main.network'); this.network = new main.network();
+       JSAN.use('util.network'); this.network = new util.network();
        this.view = view;
 
        return this;
diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/controller.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/controller.js
deleted file mode 100644 (file)
index 2b9d05a..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-dump('entering main/controller.js\n');
-
-if (typeof main == 'undefined') main = {};
-main.controller = function () {
-
-       JSAN.use('util.error'); this.error = new util.error();
-
-       return this;
-};
-
-main.controller.prototype = {
-
-       'init' : function (params) {
-
-               if (typeof params.control_map == 'undefined') throw('main.controller.init: No control_map');
-
-               this.control_map = params.control_map;
-               this.render_list = [];
-               this.view = {};
-               
-               for (var i in this.control_map) {
-                       var cmd = document.getElementById(i);
-                       if (cmd) {
-                               for (var j in this.control_map[i][0]) {
-                                       if (this.control_map[i][1]) {
-                                               var ev_type = this.control_map[i][0][j];
-                                               switch(ev_type) {
-                                                       case 'render':
-                                                               this.render_list.push( [i, this.control_map[i][1](cmd)] ); 
-                                                       break;
-                                                       default: cmd.addEventListener(ev_type,this.control_map[i][1],false);
-                                               }
-                                       }
-                               }
-                       }
-                       this.view[i] = cmd;
-               }
-       },
-
-       'render' : function(id) {
-               for (var i in this.render_list) {
-                       try {
-                               if (id) {
-                                       if (id == this.render_list[i][0]) this.render_list[i][1]();
-                               } else {
-                                       this.render_list[i][1]();
-                               }
-                       } catch(E) {
-                               var error = 'Problem in circ.checkout.render with\n' 
-                                       + this.render_list[i] + '\n\n' + js2JSON(E);
-                               this.error.sdump('D_ERROR',error);
-                       }
-               }
-       }
-}
-dump('exiting main/controller.js\n');
index 7fc8455..d0fab3d 100644 (file)
@@ -31,8 +31,8 @@ function main_init() {
                G.error = new util.error();
                G.error.sdump('D_ERROR','Testing');
 
-               JSAN.use('main.window');
-               G.window = new main.window();
+               JSAN.use('util.window');
+               G.window = new util.window();
 
                JSAN.use('auth.controller');
                G.auth = new auth.controller( { 'window' : mw } );
diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/network.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/network.js
deleted file mode 100644 (file)
index 3573802..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-dump('entering main/network.js\n');
-
-if (typeof main == 'undefined') main = {};
-main.network = function () {
-
-       JSAN.use('util.error'); this.error = new util.error();
-       // Place a test here for network connectivity
-       // this.offline = true;
-
-       return this;
-};
-
-main.network.prototype = {
-
-       // Flag for whether the staff client should act as if it were offline or not
-       'offline' : false,
-
-       'request' : function (app,name,params,f) {
-
-               try {
-
-                       this.error.sdump('D_SES','=-=-=-=-= user_request("'+app+'","'+name+'",'+js2JSON(params)+')\n');
-                       var request = new RemoteRequest( app, name );
-                       for(var index in params) {
-                               request.addParam(params[index]);
-                       }
-       
-                       if (f)  {
-                               request.setCompleteCallback(f);
-                               request.send(false);
-                               this.error.sdump('D_SES_RESULT','=-=-= result asynced\n');
-                               return null;
-                       } else {
-                               request.send(true);
-                               var result = request.getResultObject();
-                               this.error.sdump('D_SES_RESULT','=-=-= result = ' + js2JSON(result) + '\n');
-                               return result;
-                       }
-
-               } catch(E) {
-                       if (instanceOf(E,perm_ex)) {
-                               alert('permission exception: ' + js2JSON(E));
-                       }
-                       throw(E);
-               }
-       }
-}
-
-/*
-function sample_callback(request) {
-       var result = request.getResultObject();
-}
-*/
-
-dump('exiting main/network.js\n');
diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/main/window.js
deleted file mode 100644 (file)
index 83f34c7..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-dump('entering main/window.js\n');
-
-if (typeof main == 'undefined') main = {};
-main.window = function () {
-       JSAN.use('util.error'); this.error = new util.error(); this.win = window;
-       return this;
-};
-
-main.window.prototype = {
-       
-       // list of open window references, used for debugging in shell
-       'win_list' : [],        
-
-       // list of Top Level menu interface window references
-       'appshell_list' : [],   
-
-       // list of documents for debugging.  BROKEN
-       'doc_list' : [],        
-
-       // Windows need unique names.  This number helps.
-       'window_name_increment' : 0, 
-
-       // This number gets put into the title bar for Top Level menu interface windows
-       'appshell_name_increment' : 0,
-
-       // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
-       // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
-       // Modified by Jason for Evergreen
-       'SafeWindowOpen' : function (url,title,features) {
-               var w;
-
-               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-               netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead");
-               netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
-               netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
-               netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
-
-               const CI = Components.interfaces;
-               const PB = Components.classes["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefBranch);
-
-               var blocked = false;
-               try {
-                       // pref 'dom.disable_open_during_load' is the main popup blocker preference
-                       blocked = PB.getBoolPref("dom.disable_open_during_load");
-                       if(blocked) PB.setBoolPref("dom.disable_open_during_load",false);
-                       w = this.win.open(url,title,features);
-               } catch(E) {
-                       this.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
-                       throw(E);
-               }
-               if(blocked) PB.setBoolPref("dom.disable_open_during_load",true);
-
-               return w;
-       },
-
-       'open' : function(url,title,features) {
-               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-               this.error.sdump('D_WIN',
-                       'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n');
-               var w = this.SafeWindowOpen(url,title,features);
-               /*
-               setTimeout( 
-                       function() { 
-                               try { w.title = title; } catch(E) { dump('**'+E+'\n'); }
-                               try { w.document.title = title; } catch(E) { dump('**'+E+'\n'); }
-                       }, 0 
-               );
-               */
-               return w;
-       }
-}
-
-dump('exiting main/window.js\n');
diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/controller.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/controller.js
new file mode 100644 (file)
index 0000000..f944451
--- /dev/null
@@ -0,0 +1,56 @@
+dump('entering util/controller.js\n');
+
+if (typeof util == 'undefined') util = {};
+util.controller = function () {
+
+       JSAN.use('util.error'); this.error = new util.error();
+
+       return this;
+};
+
+util.controller.prototype = {
+
+       'init' : function (params) {
+
+               if (typeof params.control_map == 'undefined') throw('util.controller.init: No control_map');
+
+               this.control_map = params.control_map;
+               this.render_list = [];
+               this.view = {};
+               
+               for (var i in this.control_map) {
+                       var cmd = document.getElementById(i);
+                       if (cmd) {
+                               for (var j in this.control_map[i][0]) {
+                                       if (this.control_map[i][1]) {
+                                               var ev_type = this.control_map[i][0][j];
+                                               switch(ev_type) {
+                                                       case 'render':
+                                                               this.render_list.push( [i, this.control_map[i][1](cmd)] ); 
+                                                       break;
+                                                       default: cmd.addEventListener(ev_type,this.control_map[i][1],false);
+                                               }
+                                       }
+                               }
+                       }
+                       this.view[i] = cmd;
+               }
+       },
+
+       'render' : function(id) {
+               for (var i in this.render_list) {
+                       try {
+                               if (id) {
+                                       if (id == this.render_list[i][0]) this.render_list[i][1]();
+                               } else {
+                                       this.render_list[i][1]();
+                               }
+                       } catch(E) {
+                               var error = 'Problem in circ.checkout.render with\n' 
+                                       + this.render_list[i] + '\n\n' + js2JSON(E);
+                               this.error.sdump('D_ERROR',error);
+                       }
+               }
+       }
+}
+dump('exiting util/controller.js\n');
index 52b753c..ff1dd72 100644 (file)
@@ -58,8 +58,8 @@
                                JSAN.errorLevel = "die"; // none, warn, or die
                                JSAN.addRepository('/xul/server/');
                                JSAN.use('util.error'); g.error = new util.error();
-                               JSAN.use('main.network'); g.network = new main.network();
-                               JSAN.use('main.window'); g.window = new main.window();
+                               JSAN.use('util.network'); g.network = new util.network();
+                               JSAN.use('util.window'); g.window = new util.window();
                                JSAN.use('util.functional');
                                g.error.sdump('D_TRACE','my_init() for fm_view.xul');
 
diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/network.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/network.js
new file mode 100644 (file)
index 0000000..024a36e
--- /dev/null
@@ -0,0 +1,55 @@
+dump('entering util/network.js\n');
+
+if (typeof util == 'undefined') util = {};
+util.network = function () {
+
+       JSAN.use('util.error'); this.error = new util.error();
+       // Place a test here for network connectivity
+       // this.offline = true;
+
+       return this;
+};
+
+util.network.prototype = {
+
+       // Flag for whether the staff client should act as if it were offline or not
+       'offline' : false,
+
+       'request' : function (app,name,params,f) {
+
+               try {
+
+                       this.error.sdump('D_SES','=-=-=-=-= user_request("'+app+'","'+name+'",'+js2JSON(params)+')\n');
+                       var request = new RemoteRequest( app, name );
+                       for(var index in params) {
+                               request.addParam(params[index]);
+                       }
+       
+                       if (f)  {
+                               request.setCompleteCallback(f);
+                               request.send(false);
+                               this.error.sdump('D_SES_RESULT','=-=-= result asynced\n');
+                               return null;
+                       } else {
+                               request.send(true);
+                               var result = request.getResultObject();
+                               this.error.sdump('D_SES_RESULT','=-=-= result = ' + js2JSON(result) + '\n');
+                               return result;
+                       }
+
+               } catch(E) {
+                       if (instanceOf(E,perm_ex)) {
+                               alert('permission exception: ' + js2JSON(E));
+                       }
+                       throw(E);
+               }
+       }
+}
+
+/*
+function sample_callback(request) {
+       var result = request.getResultObject();
+}
+*/
+
+dump('exiting util/network.js\n');
diff --git a/Open-ILS/xul/staff_client/chrome/content/evergreen/util/window.js b/Open-ILS/xul/staff_client/chrome/content/evergreen/util/window.js
new file mode 100644 (file)
index 0000000..e6ddb21
--- /dev/null
@@ -0,0 +1,73 @@
+dump('entering util/window.js\n');
+
+if (typeof util == 'undefined') util = {};
+util.window = function () {
+       JSAN.use('util.error'); this.error = new util.error(); this.win = window;
+       return this;
+};
+
+util.window.prototype = {
+       
+       // list of open window references, used for debugging in shell
+       'win_list' : [],        
+
+       // list of Top Level menu interface window references
+       'appshell_list' : [],   
+
+       // list of documents for debugging.  BROKEN
+       'doc_list' : [],        
+
+       // Windows need unique names.  This number helps.
+       'window_name_increment' : 0, 
+
+       // This number gets put into the title bar for Top Level menu interface windows
+       'appshell_name_increment' : 0,
+
+       // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004
+       // Message-ID: <ckjh7a$18q1@ripley.netscape.com>
+       // Modified by Jason for Evergreen
+       'SafeWindowOpen' : function (url,title,features) {
+               var w;
+
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesRead");
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalPreferencesWrite");
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
+
+               const CI = Components.interfaces;
+               const PB = Components.classes["@mozilla.org/preferences-service;1"].getService(CI.nsIPrefBranch);
+
+               var blocked = false;
+               try {
+                       // pref 'dom.disable_open_during_load' is the main popup blocker preference
+                       blocked = PB.getBoolPref("dom.disable_open_during_load");
+                       if(blocked) PB.setBoolPref("dom.disable_open_during_load",false);
+                       w = this.win.open(url,title,features);
+               } catch(E) {
+                       this.error.sdump('D_ERROR','window.SafeWindowOpen: ' + E + '\n');
+                       throw(E);
+               }
+               if(blocked) PB.setBoolPref("dom.disable_open_during_load",true);
+
+               return w;
+       },
+
+       'open' : function(url,title,features) {
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+               this.error.sdump('D_WIN',
+                       'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n');
+               var w = this.SafeWindowOpen(url,title,features);
+               /*
+               setTimeout( 
+                       function() { 
+                               try { w.title = title; } catch(E) { dump('**'+E+'\n'); }
+                               try { w.document.title = title; } catch(E) { dump('**'+E+'\n'); }
+                       }, 0 
+               );
+               */
+               return w;
+       }
+}
+
+dump('exiting util/window.js\n');
index b0f7c5f..502c7aa 100644 (file)
@@ -22,7 +22,7 @@ cat.opac.prototype = {
                        obj.session = params['session'];
                        obj.url = params['url'];
 
-                       JSAN.use('main.controller'); obj.controller = new main.controller();
+                       JSAN.use('util.controller'); obj.controller = new util.controller();
                        obj.controller.init(
                                {
                                        control_map : {
index 4cb4205..34656a1 100644 (file)
@@ -4,7 +4,7 @@ if (typeof patron == 'undefined') patron = {};
 circ.checkout = function (params) {
 
        JSAN.use('util.error'); this.error = new util.error();
-       JSAN.use('main.network'); this.network = new main.network();
+       JSAN.use('util.network'); this.network = new util.network();
 
        JSAN.use('OpenILS.data'); this.OpenILS = {};
        this.OpenILS.data = new OpenILS.data(); this.OpenILS.data.init({'via':'stash'});
@@ -123,7 +123,7 @@ circ.checkout.prototype = {
                        }
                );
                
-               JSAN.use('main.controller'); obj.controller = new main.controller();
+               JSAN.use('util.controller'); obj.controller = new util.controller();
                obj.controller.init(
                        {
                                'control_map' : {
index 1e6717f..a3f36b6 100644 (file)
@@ -4,7 +4,7 @@ if (typeof main == 'undefined') main = {};
 main.menu = function () {
 
        JSAN.use('util.error'); this.error = new util.error();
-       JSAN.use('main.window'); this.window = new main.window();
+       JSAN.use('util.window'); this.window = new util.window();
 
        this.w = window;
 }
index 749c2fd..b6ac5e4 100644 (file)
@@ -4,8 +4,8 @@ if (typeof patron == 'undefined') patron = {};
 patron.display = function (params) {
 
        JSAN.use('util.error'); this.error = new util.error();
-       JSAN.use('main.window'); this.window = new main.window();
-       JSAN.use('main.network'); this.network = new main.network();
+       JSAN.use('util.window'); this.window = new util.window();
+       JSAN.use('util.network'); this.network = new util.network();
        this.w = window;
 }
 
@@ -43,7 +43,7 @@ patron.display.prototype = {
                        dump('obj.right_deck.node.childNodes.length = ' + obj.right_deck.node.childNodes.length + '\n');
                }
 
-               JSAN.use('main.controller'); obj.controller = new main.controller();
+               JSAN.use('util.controller'); obj.controller = new util.controller();
                obj.controller.init(
                        {
                                control_map : {
index 6a671ed..5ba97d1 100644 (file)
@@ -4,7 +4,7 @@ if (typeof patron == 'undefined') patron = {};
 patron.search_form = function (params) {
 
        JSAN.use('util.error'); this.error = new util.error();
-       JSAN.use('main.network'); this.network = new main.network();
+       JSAN.use('util.network'); this.network = new util.network();
        this.w = window;
 }
 
@@ -19,7 +19,7 @@ patron.search_form.prototype = {
                JSAN.use('OpenILS.data'); this.OpenILS = {}; 
                obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
 
-               JSAN.use('main.controller'); obj.controller = new main.controller();
+               JSAN.use('util.controller'); obj.controller = new util.controller();
                obj.controller.init(
                        {
                                control_map : {
index badfffd..ae2baf1 100644 (file)
@@ -4,8 +4,8 @@ if (typeof patron == 'undefined') patron = {};
 patron.summary = function (params) {
 
        JSAN.use('util.error'); this.error = new util.error();
-       JSAN.use('main.window'); this.window = new main.window();
-       JSAN.use('main.network'); this.network = new main.network();
+       JSAN.use('util.window'); this.window = new util.window();
+       JSAN.use('util.network'); this.network = new util.network();
        this.w = window;
 }
 
@@ -21,7 +21,7 @@ patron.summary.prototype = {
                JSAN.use('OpenILS.data'); this.OpenILS = {}; 
                obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'});
 
-               JSAN.use('main.controller'); obj.controller = new main.controller();
+               JSAN.use('util.controller'); obj.controller = new util.controller();
                obj.controller.init(
                        {
                                control_map : {