less annoying alert dialog.. no more confirmation box, but still safe from accidental...
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 30 Sep 2006 03:36:08 +0000 (03:36 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 30 Sep 2006 03:36:08 +0000 (03:36 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6279 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 1ad5c5c..3ec9770 100644 (file)
@@ -300,9 +300,60 @@ util.error.prototype = {
                }
        },
 
-
        'yns_alert' : function (s,title,b1,b2,b3,c) {
 
+               /* The original purpose of yns_alert was to prevent errors from being scanned through accidentally with a barcode scanner.  
+               However, this can be done in a less annoying manner by rolling our own dialog and not having any of the options in focus */
+
+               /*
+                       s       = Message to display
+                       title   = Text in Title Bar
+                       b1      = Text for button 1
+                       b2      = Text for button 2
+                       b3      = Text for button 3
+                       c       = Text for confirmation checkbox.  null for no confirm
+               */
+
+               dump('yns_alert:\n\ts = ' + s + '\n\ttitle = ' + title + '\n\tb1 = ' + b1 + '\n\tb2 = ' + b2 + '\n\tb3 = ' + b3 + '\n\tc = ' + c + '\n');
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
+
+               this.sound.bad();
+
+
+               //FIXME - need to escape these values before embedding them into xml.. but window.escape was weird..
+
+               var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">' + 
+                       '<groupbox style="overflow: auto"><caption label="' + (title) + '"/><description>' + (s)
+                       + '</description></groupbox><groupbox><caption label="Options"/><hbox>';
+               var b1_key = b1 ? b1[0] : '';
+               var b2_key = b2 ? b2[0] : '';
+               var b3_key = b3 ? b3[0] : ''; /* FIXME - need to check for collisions */
+               if (b1) xml += '<button id="b1" accesskey="' + b1_key + '" label="' + (b1) + '" name="fancy_submit" value="b1"/>'
+               if (b2) xml += '<button id="b2" accesskey="' + b2_key + '" label="' + (b2) + '" name="fancy_submit" value="b2"/>'
+               if (b3) xml += '<button id="b3" accesskey="' + b3_key + '" label="' + (b3) + '" name="fancy_submit" value="b3"/>'
+               xml += '</hbox></groupbox></vbox>';
+               window.open(
+                       urls.XUL_FANCY_PROMPT
+                       + '?xml=' + window.escape(xml)
+                       + '&title=' + window.escape(title),
+                       'fancy_prompt', 'chrome,resizable,modal,width=700,height=500'
+               );
+               JSAN.use('OpenILS.data');
+               var data = new OpenILS.data(); data.init({'via':'stash'});
+               if (data.fancy_prompt_data != '') {
+                       switch(data.fancy_prompt_data.fancy_submit) {
+                               case 'b1' : return 0; break;
+                               case 'b2' : return 1; break;
+                               case 'b3' : return 2; break;
+                       }
+               } else {
+                       return this.yns_alert(s,title,b1,b2,b3,c);
+               }
+       },
+
+
+       'yns_alert_original' : function (s,title,b1,b2,b3,c) {
+
                /*
                        s       = Message to display
                        title   = Text in Title Bar