1 /* Top level page object. All pages descend from this class */
5 Page.prototype.init = function() {
6 debug("Falling back to Page.init()");
10 Page.prototype.instance = function() {
12 "instance() must be overridden by all Page subclasses");
16 /* XXX move me to the status bar */
17 Page.prototype.updateSelectedLocation = function(org) {
19 if( typeof org == 'object' ) node = org;
20 else node = getOrgById(org);
21 globalSelectedLocation = node;
22 globalSearchDepth = findOrgType(node.ou_type()).depth();
26 Page.prototype.updateCurrentLocation = function(org) {
27 if( typeof org == 'object' ) node = org;
28 else node = getOrgById(orgid);
29 globalLocation = node;
34 /* tells the user where he is searching */
35 Page.prototype.setLocDisplay = function(name) {
37 debug("Setting loc display on the status bar");
38 this.searchingCell = getById("now_searching_cell");
40 if( this.searchingCell == null ) return;
44 if( globalSelectedLocation )
45 orgunit = globalSelectedLocation;
46 else { orgunit = globalLocation; }
48 this.searchingCell.innerHTML =
49 "Now Searching <span class='breadcrumb_label'>" + orgunit.name() + "</span>";
57 var arr = orgNodeTrail(orgunit);
59 this.searchingCell.innerHTML = "";
60 var names = new Array()
62 names.push(arr[i].name());
64 this.searchingCell.innerHTML =
65 "<span class='breadcrumb_label'>" +
66 names.join("</span> / <span class='breadcrumb_label'>") +
73 Page.prototype.resetRange = function() {
75 this.searchRange = getById("search_range_select");
77 while( this.searchRange.options.length ) {
78 this.searchRange.options[0] = null;
81 var orgunit = globalSelectedLocation;
83 orgunit = globalLocation;
85 debug("Reseting search range with search location " + orgunit);
86 debug("Resetting search range with search depth " + globalSearchDepth );
88 var selectedOption = null;
90 if(this.searchRange) {
92 for( var index in globalOrgTypes ) {
93 var otype = globalOrgTypes[index];
95 if( otype.depth() > findOrgType(orgunit.ou_type()).depth() )
98 var select = new Option(otype.opac_label(), otype.depth());
99 this.searchRange.options[this.searchRange.options.length] = select;
101 if( otype.depth() == globalSearchDepth ) {
102 selectedOption = index;
107 this.searchRange.selectedIndex = selectedOption;
108 var opt = this.searchRange.options[selectedOption];
109 if(opt) opt.selected = true;
111 if(this.searchRange.options.length == 1 )
112 hideMe(this.searchRange.parentNode);
114 this.searchRange.parentNode.style.visibility = "visible";
115 this.searchRange.parentNode.style.display = "inline";
118 if( instanceOf(this, AbstractRecordResultPage) ) {
120 /* submit the search when the search range is selected */
123 debug("Setting onclick for selector");
126 this.searchRange.onchange = function() {
128 var location = globalSelectedLocation;
129 if(location == null) location = globalLocation.id();
130 else location = location.id();
131 globalSearchDepth = obj.searchRange.options[obj.searchRange.selectedIndex].value;
134 "target", "mr_result",
135 "mr_search_type", lastSearchType,
136 "mr_search_query", lastSearchString,
137 "mr_search_location", location,
138 "mr_search_depth", globalSearchDepth,
149 Page.prototype.setPageTrail = function() {
150 debug("Falling back to Page.setPageTrail");
154 Page.prototype.buildTrailLink = function(type, active) {
156 var obj = locationStack[type];
157 if(obj == null) return;
159 var div = createAppElement("div");
162 add_css_class(div,"page_trail_word");
163 var a = createAppElement("a");
164 a.setAttribute("href", obj.location);
165 a.appendChild(createAppTextNode(obj.title));
170 add_css_class(div,"page_trail_word_inactive");
171 div.appendChild(createAppTextNode(obj.title));
177 Page.prototype.buildDivider = function() {
178 var div = createAppElement("div");
179 div.className = "page_trail_divider";
180 var text = createAppTextNode(" / ");
181 div.appendChild(text);
185 /* if 'full' add target=_top to break out of the page */
186 Page.prototype.buildNavBox = function(full) {
187 Page.navBox = new Box();
188 Page.navBox.init("Navigation", false, false);
189 var table = elem("table");
190 add_css_class(table, "main_nav_table");
199 {id:"location_nav_link", href:"javascript:void(0);"},
200 null, "Change Search Location");
202 loc.onclick = function(evt) {
203 globalPage.locationTree.toggle(getById("location_nav_link"));
208 if(globalPort == "443") globalPort = "80";
209 var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath;
211 arr.push(elem("a", {href: prefix + '?target=advanced_search'}, null, "Advanced Search"));
214 var mylink = elem("a", {href: "?target=my_opac"}, null, "My OPAC");
217 /* if user is not logged in, popup the login dialog when they
218 select the myopac link */
219 if(!UserSession.instance().verifySession()) {
220 mylink.setAttribute("href","javascript:void(0);");
221 var func = function(){url_redirect(["target","my_opac"])};
222 var diag = new LoginDialog(func);
223 mylink.onclick = function(){diag.display(mylink);}
227 if(loc) arr.push(this.buildDeepLink());
229 if(UserSession.instance().verifySession()) {
230 var a = elem("a", {href:"http://" + globalRootURL + ":"
231 + globalPort + "/" + globalRootPath}, null, "Logout");
232 a.onclick = doLogout;
237 for( var i in arr ) {
238 var row = table.insertRow(table.rows.length);
239 add_css_class(row, "main_nav_row");
240 var cell = row.insertCell(row.cells.length);
241 add_css_class(cell, "main_nav_cell");
242 cell.appendChild(arr[i]);
244 arr[i].setAttribute("target", "_top");
247 /* append to the page */
248 Page.navBox.addItem(table);
249 Page.navBox.finalize();
251 var location = getById("main_page_nav_box");
253 removeChildren(location);
254 location.appendChild(Page.navBox.getNode());
258 return Page.navBox.getNode();
261 Page.prototype.buildDeepLink = function() {
265 } catch(E) { return elem("div"); }
267 var org = globalSelectedLocation;
269 org = globalLocation;
270 if(org) org = org.id();
272 var depth = globalSearchDepth;
274 if(globalPort == "443") globalPort = "80";
275 var prefix = "http://" + globalRootURL + ":" + globalPort + globalRootPath;
277 var string =globalAppFrame.location.href;
278 if(!string.match(/sub_frame/))
279 string += "&sub_frame=1"
282 if(!string.match(/location/))
283 string += "&location=" + org;
287 if(!string.match(/depth/))
288 string += "&depth=" + depth;
291 debug("Redirecting deep link to " + string );
294 { href: prefix + string }, null, "Link to this page"
297 a.setAttribute("target", "_blank");
302 Page.prototype.destroy = function() {
303 for( var x in this ){