fccd68cb87a36e63e29b3b3c57f089aafcb9bb69
[Evergreen.git] / Evergreen / staff_client / chrome / content / evergreen / opac / opac.js
1 sdump('D_OPAC','Loading opac.js\n');
2
3 //var OPAC_URL = "http://gapines.org:8080/opac/?top_target=advanced_search";
4 var OPAC_URL = "http://gapines.org/opac/?top_target=advanced_search";
5 //var OPAC_URL = "http://google.com/";
6
7 /* init the opac */
8 function opac_init(p) {
9         sdump('D_OPAC',"Initing OPAC\n");
10
11         var box = p.w.document.getElementById('opac_vbox');
12         p.opac_iframe = box.appendChild(document.createElement("browser"));
13
14         p.opac_iframe.setAttribute("type", "content-primary");
15         p.opac_iframe.setAttribute("id", "opac_opac_iframe");
16         p.opac_iframe.setAttribute("flex", "1");
17         p.opac_iframe.setAttribute("src", OPAC_URL) 
18
19         opac_build_callbacks(p);
20
21         p.opac_iframe.contentWindow.IAMXUL = true;
22         p.opac_iframe.contentWindow.xulEvtRecordResultDisplayed 
23                 = p.xulEvtRecordResultDisplayed;
24
25         p.opac_iframe.contentWindow.xulEvtMRResultDisplayed 
26                 = p.xulEvtMRResultDisplayed;
27
28         p.opac_iframe.contentWindow.xulEvtRecordDetailDisplayed 
29                 = p.xulEvtRecordDetailDisplayed;
30
31         p.opac_iframe.contentWindow.xulEvtViewMARC = p.xulEvtViewMARC;
32
33         /* shove BIG G in so global variables may be accessed */
34         p.opac_iframe.contentWindow.G = mw.G;
35
36 }
37
38
39 function opac_build_navigation(p) {
40         p.webForward = function webForward() {
41                 try {
42                         if(p.opac_iframe.webNavigation.canGoForward)
43                                 p.opac_iframe.webNavigation.goForward();
44                 } catch(E) {
45                         sdump('D_OPAC','goForward error: ' + js2JSON(E) + '\n');
46                 }
47         }
48
49         p.webBack = function webBack() {
50                 try {
51                         if(p.opac_iframe.webNavigation.canGoBack)
52                                 p.opac_iframe.webNavigation.goBack();
53                 } catch(E) {
54                         sdump('D_OPAC','goBack error: ' + js2JSON(E) + '\n');
55                 }
56         }
57 }
58
59 /* -------------------------------------------------------------------------- 
60         XUL Callbacks
61         -------------------------------------------------------------------------- */
62
63 function opac_build_callbacks(p) {
64         p.xulEvtRecordResultDisplayed = function(ui_obj, record) {
65                 ui_obj.addItem("Edit MARC", function() { 
66                                 spawn_marc_editor( 
67                                         p.w.app_shell, 'new_tab', 'main_tabbox', { 
68                                                 'find_this_id' : record.doc_id() 
69                                         } 
70                                 ).find_this_id = record.doc_id();
71                         }
72                 );
73
74                 ui_obj.addItem("Open Copy Browser", function() { 
75                                 spawn_copy_browser(
76                                         p.w.app_shell, 'new_tab', 'main_tabbox', {
77                                                 'find_this_id' : record.doc_id()
78                                         }
79                                 ).find_this_id = record.doc_id();
80                         }
81                 );
82
83         }
84
85         p.xulEvtMRResultDisplayed = function(ui_obj, record) {
86                 sdump('D_OPAC',"xulEvtMRRsultsDisplayed()\n");
87         }
88
89
90         p.xulEvtRecordDetailDisplayed = function(ui_obj, record) {
91                 ui_obj.addItem("Edit MARC", function() { 
92                                 spawn_marc_editor( 
93                                         p.w.app_shell, 'new_tab', 'main_tabbox', { 
94                                                 'find_this_id' : record.doc_id() 
95                                         } 
96                                 ).find_this_id = record.doc_id();
97                         }
98                 );
99
100                 ui_obj.addItem("Open Copy Browser", function() { 
101                                 spawn_copy_browser(
102                                         p.w.app_shell, 'new_tab', 'main_tabbox', {
103                                                 'find_this_id' : record.doc_id()
104                                         }
105                                 ).find_this_id = record.doc_id();
106                         }
107                 );
108         }
109
110         p.xulEvtViewMARC = function( node, record ) {
111                 node.onclick = p.buildViewMARCWindow(record);
112         }
113
114
115
116 p.buildViewMARCWindow = function(record) {
117
118    debug("Setting up view marc with record " + record.doc_id());
119
120    var func = function() { marc_view(p.w.app_shell,record.doc_id()); }
121    return func;
122 }
123
124
125 }