]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/patron/summary.xul
patch from Lebbeous Fogle-Weekley to make address clipboard copying come from a strin...
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / patron / summary.xul
1 <?xml version="1.0"?>
2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Patron Display -->
4
5 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
6 <!-- STYLESHEETS -->
7 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
8 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
9 <?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
10 <?xml-stylesheet href="/xul/server/skin/patron_summary.css" type="text/css"?>
11
12 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
13 <!-- LOCALIZATION -->
14 <!DOCTYPE window PUBLIC "" ""[
15     <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
16 ]>
17
18 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
19 <!-- OVERLAYS -->
20 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
21
22 <window id="patron_summary_win" 
23     onload="try { my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }" onunload="try { observer.unregister(); } catch(E) { alert(E); }"
24     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
25
26     <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
27     <!-- BEHAVIOR -->
28         <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
29         <scripts id="openils_util_scripts"/>
30
31     <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
32     <script>
33     <![CDATA[
34         function $(id) { return document.getElementById(id); }
35         
36         var observer;
37         function myObserver() { this.register(); }
38         myObserver.prototype = {
39             register: function() {
40                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
41                 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
42                 observerService.addObserver(this, "xul-overlay-merged", false);
43             },
44             unregister: function() {
45                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
46                 var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
47                 observerService.removeObserver(this, "xul-overlay-merged");
48             },
49             observe: function(subject,topic,data) {
50                 dump('observe: <'+subject+','+topic+','+data+'>\n');
51                 // setTimeout is needed here for xulrunner 1.8
52                 setTimeout( function() { try { post_overlay(); } catch(E) { alert(E); } }, 0 );
53             }
54         }
55                 
56         function my_init() {
57             try {
58                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
59                 if (typeof JSAN == 'undefined') { throw( $("commonStrings").getString('common.jsan.missing') ); }
60                 JSAN.errorLevel = "die"; // none, warn, or die
61                 JSAN.addRepository('/xul/server/');
62                 JSAN.use('util.error'); g.error = new util.error();
63                 g.error.sdump('D_TRACE','my_init() for patron_summary.xul');
64                 
65                 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
66                 
67                 var horizontal_interface = String( g.data.hash.aous['ui.circ.patron_summary.horizontal'] ) == 'true';
68                 var url = horizontal_interface ? '/xul/server/patron/summary_overlay_horiz.xul' : '/xul/server/patron/summary_overlay.xul';
69                 
70                 observer = new myObserver();
71                 document.loadOverlay(location.protocol + '//' + location.hostname + url,observer)
72             } catch(E) {
73                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:my_init()', E]);
74                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
75                 alert(err_msg);
76             }
77         }
78
79         function copy_address(a) {
80             var p = g.summary.patron;
81             var s = $("patronStrings").getFormattedString(
82                 'staff.patron.mailable_address_format',
83                 [p.first_given_name(), p.second_given_name(), p.family_name(),
84                     a.street1(), a.street2(), a.city(), a.county(),
85                     a.state(), a.post_code(), a.country()]
86             );
87             // Without the following call to replace(), you get
88             // literal instances of '\n' in the string.
89             copy_to_clipboard(s.replace(/(\\n)+/g, "\n"));
90         }
91
92         function copy_mailing_address() {
93             var a = g.summary.patron.mailing_address();
94             if (!a) return;
95             copy_address(a);
96         }
97
98         function copy_billing_address() {
99             var a = g.summary.patron.billing_address();
100             if (!a) return;
101             copy_address(a);
102         }
103     
104         function post_overlay() {
105             try {
106                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
107
108                 var patron_id = xul_param('id'); 
109                 var patron_bc = xul_param('barcode'); 
110
111                 JSAN.use('patron.summary'); g.summary = new patron.summary();
112                 g.summary.init( { 
113                     'barcode' : patron_bc,
114                     'id' : patron_id,
115                     'show_name' : xul_param('show_name'),
116                 } );
117
118                 window.refresh = function () { g.summary.retrieve(); }
119                 font_helper();
120             } catch(E) {
121                 var err_msg = $("commonStrings").getFormattedString('common.exception', ['patron/summary.xul:post_overlay()', E]);
122                 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
123                 alert(err_msg);
124             }
125         }
126     ]]>
127     </script>
128     
129     <messagecatalog id="patronStrings" src="/xul/server/locale/<!--#echo var='locale'-->/patron.properties"/>
130
131     <commandset id="patron_summary_cmds">
132     </commandset>
133
134     <box id="patron_summary_main" />
135
136 </window>
137