]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/javascript/lib/js/opac/result_common.js
opac, here we come
[working/Evergreen.git] / Open-ILS / src / javascript / lib / js / opac / result_common.js
1
2 function resultSetInfo() { 
3         var c;  
4         if( getDisplayCount() > (getHitCount() - getOffset()))  c = getHitCount();
5         else c = getDisplayCount() + getOffset();
6
7         var pages = parseInt(getHitCount() / getDisplayCount()) + 1;
8         G.ui.result.current_page.appendChild(text( (getOffset()/getDisplayCount()) + 1));
9         G.ui.result.num_pages.appendChild(text(pages + ")"));
10
11         var o = getOffset();
12
13         if( !((o + getDisplayCount()) >= getHitCount()) ) {
14
15                 var args = {};
16                 args[PARAM_OFFSET] = o + getDisplayCount();
17                 G.ui.result.next_link.setAttribute("href", buildOPACLink(args)); 
18                 addCSSClass(G.ui.result.next_link, config.css.result.nav_active);
19
20                 args[PARAM_OFFSET] = getHitCount() - (getHitCount() % getDisplayCount());
21                 G.ui.result.end_link.setAttribute("href", buildOPACLink(args)); 
22                 addCSSClass(G.ui.result.end_link, config.css.result.nav_active);
23         }
24
25         if( o > 0 ) {
26
27                 var args = {};
28                 args[PARAM_OFFSET] = o - getDisplayCount();
29                 G.ui.result.prev_link.setAttribute( "href", buildOPACLink(args)); 
30                 addCSSClass(G.ui.result.prev_link, config.css.result.nav_active);
31
32                 args[PARAM_OFFSET] = 0;
33                 G.ui.result.home_link.setAttribute( "href", buildOPACLink(args)); 
34                 addCSSClass(G.ui.result.home_link, config.css.result.nav_active);
35         }
36
37         G.ui.result.offset_start.appendChild(text(o + 1));
38         G.ui.result.offset_end.appendChild(text(c));
39         G.ui.result.result_count.appendChild(text(getHitCount()));
40
41
42 }
43
44
45 function resultDisplayRecord(rec, rowtemplate, is_mr) {
46
47         if(rec == null) rec = new mvr(); /* if we return we won't build some important UI components */
48
49         /* hide the 'now loading...' message */
50         hideMe(G.ui.all.loading);
51
52         var r = rowtemplate.cloneNode(true);
53
54         var pic = findNodeByName(r, config.names.result.item_jacket);
55         pic.setAttribute("src", buildISBNSrc(cleanISBN(rec.isbn())));
56
57
58         var title_link = findNodeByName(r, config.names.result.item_title);
59         var author_link = findNodeByName(r, config.names.result.item_author);
60
61         if( is_mr )  buildTitleLink(rec, title_link); 
62         buildAuthorLink(rec, author_link); 
63
64         var countsrow = findNodeByName(r, config.names.result.counts_row);
65
66         /* adjust the width according to how many org counts are added */
67         findNodeByName(r, "result_table_title_cell").width = 
68                 resultAddCopyCounts(countsrow, rec) + "%";
69
70         table.appendChild(r);
71
72 }
73
74
75 /* -------------------------------------------------------------------- */
76 /* dynamically add the copy count rows based on the org type 
77         'countsrow' is the row into which we will add TD's to hold
78         the copy counts 
79         This code generates copy count cells with an id of
80
81         'copy_count_cell_<depth>_<record_id>' for later insertion
82         of copy counts
83
84         return the percent width left over after the each count is added. 
85         if 3 counts are added, returns 100 - (cell.width * 3)
86  */
87
88 function resultAddCopyCounts(countsrow, rec) {
89
90         var ccell = findNodeByName(countsrow, config.names.result.count_cell);
91
92
93         var nodes = orgNodeTrail(findOrgUnit(getLocation()));
94         var node = nodes[0];
95         var type = findOrgType(node.ou_type());
96         ccell.id = "copy_count_cell_" + type.depth() + "_" + rec.doc_id();
97         ccell.title = type.opac_label();
98         addCSSClass(ccell, "copy_count_cell_even");
99
100
101         var lastcell = ccell;
102
103         if(nodes[1]) {
104
105                 var x = 1;
106                 var d = findOrgDepth(nodes[1]);
107                 var d2 = findOrgDepth(nodes[nodes.length -1]);
108
109                 for( var i = d; i <= d2 ; i++ ) {
110         
111                         ccell = ccell.cloneNode(true);
112
113                         if((i % 2))
114                                 removeCSSClass(ccell, "copy_count_cell_even");
115                         else
116                                 addCSSClass(ccell, "copy_count_cell_even");
117
118                         var node = nodes[x++];
119                         var type = findOrgType(node.ou_type());
120         
121                         ccell.id = "copy_count_cell_" + type.depth() + "_" + rec.doc_id();
122                         ccell.title = type.opac_label();
123                         countsrow.insertBefore(ccell, lastcell);
124                         lastcell = ccell;
125
126                 }
127         }
128
129         return 100 - (nodes.length * 8);
130
131 }
132
133
134
135