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