toward patron display
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 1 Dec 2005 17:50:23 +0000 (17:50 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 1 Dec 2005 17:50:23 +0000 (17:50 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2145 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/OpenILS/util_overlay.xul
Open-ILS/xul/staff_client/server/main/menu.js
Open-ILS/xul/staff_client/server/main/menu_frame.xul
Open-ILS/xul/staff_client/server/patron/patron_barcode_entry.xul
Open-ILS/xul/staff_client/server/patron/patron_display.xul

index 33ac900..e8300a1 100644 (file)
@@ -11,7 +11,7 @@
                <script type="text/javascript" src="/opac/common/js/JSON.js" />
                <script type="text/javascript" src="/opac/common/js/fmall.js" />
                <script type="text/javascript" src="/opac/common/js/fmgen.js" />
-               <script type="text/javascript" src="/opac/common/js/RemoteRequest.js" />
+               <script type="text/javascript" src="/xul/server/OpenILS/RemoteRequest.js" />
                <script type="text/javascript" src="/opac/common/js/OrgTree.js" />
                <script type="text/javascript" src="/opac/common/js/org_utils.js" />   
        </scripts>
index 7db459e..e10715e 100644 (file)
@@ -11,48 +11,71 @@ main.menu = function () {
 
 main.menu.prototype = {
 
-       'init' : function() {
+       'init' : function( params ) {
+
+               var session = params['session'];
 
                var obj = this;
+               obj.view = {};
 
-               obj.tabbox = obj.w.document.getElementById('main_tabbox');
-               obj.tabs = obj.tabbox.firstChild;
-               obj.panels = obj.tabbox.lastChild;
+               obj.view.tabbox = obj.w.document.getElementById('main_tabbox');
+               obj.view.tabs = obj.view.tabbox.firstChild;
+               obj.view.panels = obj.view.tabbox.lastChild;
 
                var cmd_map = {
-                       'cmd_close_window' : function() { obj.w.close(); },
-                       'cmd_new_window' : function() {
-                               obj.window.open('/xul/server/main/menu_frame.xul','test' + 
-                                       obj.window.appshell_name_increment++ ,'chrome'); 
-                       },
-                       'cmd_new_tab' : function() { obj.new_tab(true); },
-                       'cmd_close_tab' : function() { obj.close_tab(); },
-                       'cmd_broken' : function() { alert('Not Yet Implemented'); },
-                       'cmd_circ_checkout' : function() { 
-                               obj.set_tab('/xul/server/patron/patron_barcode_entry.xul');
-                       }
+                       'cmd_close_window' : [ 
+                               ['command','keypress'], 
+                               function() { obj.w.close(); } 
+                       ],
+                       'cmd_new_window' : [
+                               ['command','keypress'],
+                               function() {
+                                       obj.window.open('/xul/server/main/menu_frame.xul','test' + 
+                                               obj.window.appshell_name_increment++ ,'chrome'); 
+                               }
+                       ],
+                       'cmd_new_tab' : [
+                               ['command','keypress'],
+                               function() { obj.new_tab(true); }
+                       ],
+                       'cmd_close_tab' : [
+                               ['command','keypress'],
+                               function() { obj.close_tab(); }
+                       ],
+                       'cmd_broken' : [
+                               ['command','keypress'],
+                               function() { alert('Not Yet Implemented'); }
+                       ],
+                       'cmd_circ_checkout' : [
+                               ['command','keypress'],
+                               function() { 
+                                       obj.set_tab('/xul/server/patron/patron_barcode_entry.xul?session='+obj.w.escape(session));
+                               }
+                       ]
                };
 
                for (var i in cmd_map) {
                        var cmd = this.w.document.getElementById(i);
                        if (cmd) {
-                               cmd.addEventListener('command',cmd_map[i],false);
-                               cmd.addEventListener('keypress',cmd_map[i],false);
+                               for (var j in cmd_map[i][0]) {
+                                       cmd.addEventListener(cmd_map[i][0][j],cmd_map[i][1],false);
+                               }
                        }
+                       obj.view[i] = cmd;
                }
 
                obj.new_tab(true);
        },
 
        'close_tab' : function () {
-               var idx = this.tabs.selectedIndex;
+               var idx = this.view.tabs.selectedIndex;
                if (idx == 0) {
                        try {
-                               this.tabs.advanceSelectedTab(+1);
+                               this.view.tabs.advanceSelectedTab(+1);
                        } catch(E) {
                                this.error.sdump('D_TAB','failed tabs.advanceSelectedTab(+1):'+js2JSON(E) + '\n');
                                try {
-                                       this.tabs.advanceSelectedTab(-1);
+                                       this.view.tabs.advanceSelectedTab(-1);
                                } catch(E) {
                                        this.error.sdump('D_TAB','failed again tabs.advanceSelectedTab(-1):'+
                                                js2JSON(E) + '\n');
@@ -60,11 +83,11 @@ main.menu.prototype = {
                        }
                } else {
                        try {
-                               this.tabs.advanceSelectedTab(-1);
+                               this.view.tabs.advanceSelectedTab(-1);
                        } catch(E) {
                                this.error.sdump('D_TAB','failed tabs.advanceSelectedTab(-1):'+js2JSON(E) + '\n');
                                try {
-                                       this.tabs.advanceSelectedTab(+1);
+                                       this.view.tabs.advanceSelectedTab(+1);
                                } catch(E) {
                                        this.error.sdump('D_TAB','failed again tabs.advanceSelectedTab(+1):'+
                                                js2JSON(E) + '\n');
@@ -73,15 +96,15 @@ main.menu.prototype = {
 
                }
                
-               this.error.sdump('D_TAB','\tnew tabbox.selectedIndex = ' + this.tabbox.selectedIndex + '\n');
+               this.error.sdump('D_TAB','\tnew tabbox.selectedIndex = ' + this.view.tabbox.selectedIndex + '\n');
 
-               this.tabs.childNodes[ idx ].hidden = true;
+               this.view.tabs.childNodes[ idx ].hidden = true;
                this.error.sdump('D_TAB','tabs.childNodes[ ' + idx + ' ].hidden = true;\n');
 
                // Make sure we keep at least one tab open.
                var tab_flag = true;
-               for (var i = 0; i < this.tabs.childNodes.length; i++) {
-                       var tab = this.tabs.childNodes[i];
+               for (var i = 0; i < this.view.tabs.childNodes.length; i++) {
+                       var tab = this.view.tabs.childNodes[i];
                        if (!tab.hidden)
                                tab_flag = false;
                }
@@ -90,23 +113,23 @@ main.menu.prototype = {
 
        'find_free_tab' : function() {
                var last_not_hidden = -1;
-               for (var i = 0; i<this.tabs.childNodes.length; i++) {
-                       var tab = this.tabs.childNodes[i];
+               for (var i = 0; i<this.view.tabs.childNodes.length; i++) {
+                       var tab = this.view.tabs.childNodes[i];
                        if (!tab.hidden)
                                last_not_hidden = i;
                }
-               if (last_not_hidden == this.tabs.childNodes.length - 1)
+               if (last_not_hidden == this.view.tabs.childNodes.length - 1)
                        last_not_hidden = -1;
                // If the one next to last_not_hidden is hidden, we want it.
                // Basically, we fill in tabs after existing tabs for as 
                // long as possible.
                var idx = last_not_hidden + 1;
-               var candidate = this.tabs.childNodes[ idx ];
+               var candidate = this.view.tabs.childNodes[ idx ];
                if (candidate.hidden)
                        return idx;
                // Alright, find the first hidden then
-               for (var i = 0; i<this.tabs.childNodes.length; i++) {
-                       var tab = this.tabs.childNodes[i];
+               for (var i = 0; i<this.view.tabs.childNodes.length; i++) {
+                       var tab = this.view.tabs.childNodes[i];
                        if (tab.hidden)
                                return i;
                }
@@ -116,11 +139,11 @@ main.menu.prototype = {
        'new_tab' : function(focus) {
                var tc = this.find_free_tab();
                if (tc == -1) { return null; } // 9 tabs max
-               var tab = this.tabs.childNodes[ tc ];
+               var tab = this.view.tabs.childNodes[ tc ];
                //tab.setAttribute('label','Tab ' + (tc + 1) );
                tab.hidden = false;
                try {
-                       if (focus) this.tabs.selectedIndex = tc;
+                       if (focus) this.view.tabs.selectedIndex = tc;
                        this.set_tab('data:text/html,<h1>Hello World</h1>',tc);
                } catch(E) {
                        this.error.sdump('D_ERROR',E);
@@ -128,9 +151,9 @@ main.menu.prototype = {
        },
 
        'set_tab' : function(url,idx) {
-               if (!idx) idx = this.tabs.selectedIndex;
-               var tab = this.tabs.childNodes[ idx ];
-               var panel = this.panels.childNodes[ idx ];
+               if (!idx) idx = this.view.tabs.selectedIndex;
+               var tab = this.view.tabs.childNodes[ idx ];
+               var panel = this.view.panels.childNodes[ idx ];
                while ( panel.lastChild ) panel.removeChild( panel.lastChild );
                var frame = this.w.document.createElement('iframe');
                frame.setAttribute('flex','1');
index d04e204..0560589 100644 (file)
                                JSAN.use('util.error'); g.error = new util.error();
                                g.error.sdump('D_TRACE','my_init() for menu_frame.xul');
 
+                               g.cgi = new CGI();
+
                                JSAN.use('main.menu'); g.menu = new main.menu();
-                               g.menu.init();
+                               g.menu.init( { 'session' : g.cgi.param('session') } );
        
                        } catch(E) {
                                var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
index 94fd4d6..836e4c0 100644 (file)
 <!-- LOCALIZATION -->
 <!DOCTYPE window SYSTEM "menu_frame.dtd">
 
+<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
+<!-- OVERLAYS -->
+<?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
+
 <window id="patron_barcode_entry_win" 
        onload="my_init()"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
@@ -20,6 +24,7 @@
         <script type="text/javascript">var myPackageDir = 'evergreen'; var IAMXUL = true; var g = {};</script>
         <scripts id="openils_util_scripts"/>
 
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
        <script>
        <![CDATA[
                function my_init() {
@@ -38,7 +43,7 @@
                                        'keypress',
                                        function(ev) {
                                                if (ev.keyCode == 13 || ev.keyCode == 77) {
-                                                       spawn(g.cgi.params('session'));
+                                                       spawn(g.cgi.param('session'));
                                                }
                                        },
                                        false
                }
 
                function spawn(session) {
+                       alert('session = ' + session);
                        var tb = document.getElementById('barcode_tb');
                        var barcode = tb.value;
 
-                       location.href = '/xul/server/patron/patron_display.xul?session=' + session + '&barcode=' + barcode;
+                       location.href = '/xul/server/patron/patron_display.xul?session=' 
+                               + window.escape(session) + '&barcode=' + window.escape(barcode);
                }
 
        ]]>
index d7c5376..5b175e7 100644 (file)
@@ -24,6 +24,7 @@
         <script type="text/javascript">var myPackageDir = 'evergreen'; var IAMXUL = true; var g = {};</script>
         <scripts id="openils_util_scripts"/>
 
+       <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
        <script>
        <![CDATA[
                function my_init() {
@@ -38,7 +39,7 @@
                                g.cgi = new CGI();
 
                                JSAN.use('patron.display'); g.patron = new patron.display();
-                               g.patron.init( { 'barcode' : g.cgi.param('barcode', 'session' : g.cgi.param('session') } );
+                               g.patron.init( { 'barcode' : g.cgi.param('barcode', 'session' : g.cgi.param('session') } );
        
                        } catch(E) {
                                var err_msg = "!! This software has encountered an error.  Please tell your friendly " +
@@ -53,7 +54,7 @@
 
        <vbox flex="1" class="my_overflow">
                <groupbox orient="vertical" flex="1">
-                       <caption id="my_patron_name" />
+                       <caption id="my_patron_caption" />
                </groupbox>
        </vbox>