From e62814ee2acebd4fb6ab5a1cb4d0d9070121b1e8 Mon Sep 17 00:00:00 2001
From: phasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Tue, 23 Mar 2010 16:35:01 +0000
Subject: [PATCH] progressmeter as a "throbber" for page loads, etc. in staff
 client browser

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15938 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 .../xul/staff_client/chrome/content/util/browser.js   | 19 +++++++++++++++++++
 .../xul/staff_client/chrome/content/util/browser.xul  |  1 +
 .../xul/staff_client/chrome/content/util/rbrowser.xul |  1 +
 3 files changed, 21 insertions(+)

diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.js b/Open-ILS/xul/staff_client/chrome/content/util/browser.js
index 5ffe5ac88b..6cd7a3bb24 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/browser.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.js
@@ -231,6 +231,24 @@ util.browser.prototype = {
                         var s = obj.url + '\n' + obj.get_content().location.href + '\n';
                         const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
                         const nsIChannel = Components.interfaces.nsIChannel;
+                        ////// handle the throbber
+                        var throbber = document.getElementById('throbber');
+                        if (throbber) {
+                            var busy = false;
+                            if (!(stateFlags & nsIWebProgressListener.STATE_RESTORING)) {
+                                busy = true;
+                                throbber.setAttribute('mode','undetermined'); 
+                            }
+                            if (stateFlags & nsIWebProgressListener.STATE_STOP) {
+                                busy = false;
+                                setTimeout(
+                                    function() {
+                                        if (!busy) { throbber.setAttribute('mode','determined'); }
+                                    }, 2000
+                                );
+                            }
+                        }
+                        //////
                         if (stateFlags == 65540 || stateFlags == 65537 || stateFlags == 65552) { return; }
                         s += ('onStateChange: stateFlags = ' + stateFlags + ' status = ' + status + '\n');
                         if (stateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
@@ -279,6 +297,7 @@ util.browser.prototype = {
                             s += ('\tSTATE_STOP\n');
                         }
                         //obj.error.sdump('D_BROWSER',s);    
+                        if (throbber) { throbber.setAttribute('tooltiptext',s); }
                     } catch(E) {
                         obj.error.sdump('D_ERROR','util.browser.progresslistener.onstatechange: ' + (E));
                     }
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul
index d9279927b1..a58845d242 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/browser.xul
+++ b/Open-ILS/xul/staff_client/chrome/content/util/browser.xul
@@ -111,6 +111,7 @@
             <button id="reload" command="cmd_reload" disabled="false" hidden="false"/>
             <button id="forward" command="cmd_forward" disabled="true" hidden="true"/>
             <spacer flex="1"/>
+            <progressmeter id="throbber" mode="determined" flex="1"/>
             <label id="debug" value="Debug" disabled="true" command="cmd_debug" onclick="this.doCommand();" />
             <button id="browser_print" label="Print Page" command="cmd_print" hidden="true"/>
         </hbox>
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul b/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul
index 8ba1a7055b..10325cb469 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul
+++ b/Open-ILS/xul/staff_client/chrome/content/util/rbrowser.xul
@@ -112,6 +112,7 @@
             <button id="reload" command="cmd_reload" disabled="false" hidden="false"/>
             <button id="forward" command="cmd_forward" disabled="true" hidden="true"/>
             <spacer flex="1"/>
+            <progressmeter id="throbber" mode="determined" flex="1"/>
             <label id="debug" value="Debug" disabled="true" command="cmd_debug" onclick="this.doCommand();" />
             <button id="browser_print" label="Print Page" oldcommand="cmd_print" hidden="true"
                 oncommand="netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); if (g.browser.alt_print) { JSAN.use('util.print'); var p = new util.print(); p.NSPrint(g.browser.get_content(),false,{}); } else { g.browser.get_content().print(); }"
-- 
2.11.0