3 attachEvt("common", "run", rdetailDraw);
4 attachEvt("rdetail", "recordDrawn", rdetailBuildStatusColumns);
5 attachEvt("rdetail", "recordDrawn", rdetailBuildInfoRows);
8 var cp_statuses = null;
11 var copyRowParent = null;
14 var numStatuses = null;
16 function rdetailDraw() {
19 copyRowParent = G.ui.rdetail.cp_info_row.parentNode;
20 copyRow = copyRowParent.removeChild(G.ui.rdetail.cp_info_row);
21 statusRow = G.ui.rdetail.cp_status.parentNode;
22 statusRow.id = '__rdsrow';
24 G.ui.rdetail.cp_info_local.onclick = rdetailShowLocalCopies;
25 G.ui.rdetail.cp_info_all.onclick = rdetailShowAllCopies;
27 if(getLocation() == globalOrgTree.id())
28 hideMe(G.ui.rdetail.cp_info_all);
30 var req = new Request(FETCH_RMODS, getRid());
31 req.callback(_rdetailDraw);
35 var rdeatilMarcFetched = false;
36 function rdetailViewMarc(r) {
37 hideMe($('rdetail_extras_loading'));
38 $('rdetail_view_marc_box').innerHTML = r.getResultObject();
42 function rdetailShowLocalCopies() {
45 var rows = copyRowParent.getElementsByTagName("tr");
46 for( var r in rows ) {
47 if(rows[r].id == "__rdsrow") continue;
49 if(rows[r].getAttribute && rows[r].getAttribute("local")) {
55 if(!found) unHideMe(G.ui.rdetail.cp_info_none);
56 hideMe(G.ui.rdetail.cp_info_local);
57 unHideMe(G.ui.rdetail.cp_info_all);
60 function rdetailShowAllCopies() {
61 var rows = copyRowParent.getElementsByTagName("tr");
63 if(rows[r].getAttribute && rows[r].getAttribute("hasinfo"))
66 hideMe(G.ui.rdetail.cp_info_all);
67 unHideMe(G.ui.rdetail.cp_info_local);
68 hideMe(G.ui.rdetail.cp_info_none);
72 function _rdetailDraw(r) {
73 record = r.getResultObject();
75 runEvt('rdetail', 'recordRetrieved', record.doc_id());
77 G.ui.rdetail.title.appendChild(text(record.title()));
78 buildSearchLink(STYPE_AUTHOR, record.author(), G.ui.rdetail.author);
79 G.ui.rdetail.isbn.appendChild(text(cleanISBN(record.isbn())));
80 G.ui.rdetail.edition.appendChild(text(record.edition()));
81 G.ui.rdetail.pubdate.appendChild(text(record.pubdate()));
82 G.ui.rdetail.publisher.appendChild(text(record.publisher()));
83 G.ui.rdetail.tor.appendChild(text(record.types_of_resource()[0]));
84 setResourcePic( G.ui.rdetail.tor_pic, record.types_of_resource()[0]);
85 G.ui.rdetail.abstr.appendChild(text(record.synopsis()));
88 $('rdetail_place_hold').setAttribute(
89 'href','javascript:holdsDrawWindow("'+record.doc_id()+'");');
91 G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
92 runEvt("rdetail", "recordDrawn");
93 recordsCache.push(record);
95 var req = new Request(FETCH_ACONT_SUMMARY, cleanISBN(record.isbn()));
96 req.callback(rdetailHandleAddedContent);
99 resultBuildCaches( [ record ] );
100 resultDrawSubjects();
101 //resultDrawAuthors();
106 var rdetailTocFetched = false;
107 var rdetailReviewFetched = false;
108 var rdetailMarcFetched = false;
110 function rdetailShowExtra(type) {
112 hideMe($('rdetail_copy_info_div'));
113 hideMe($('rdetail_reviews_div'));
114 hideMe($('rdetail_toc_div'));
115 hideMe($('rdetail_marc_div'));
120 unHideMe($('rdetail_copy_info_div'));
124 unHideMe($('rdetail_reviews_div'));
125 if(rdetailReviewFetched) break;
126 unHideMe($('rdetail_extras_loading'));
127 rdetailReviewFetched = true;
128 req = new Request(FETCH_REVIEWS, cleanISBN(record.isbn()));
129 req.callback(rdetailShowReviews);
134 unHideMe($('rdetail_toc_div'));
135 if(rdetailTocFetched) break;
136 unHideMe($('rdetail_extras_loading'));
137 rdetailTocFetched = true;
138 var req = new Request(FETCH_TOC, cleanISBN(record.isbn()));
139 req.callback(rdetailShowTOC);
144 unHideMe($('rdetail_marc_div'));
145 if(rdetailMarcFetched) return;
146 unHideMe($('rdetail_extras_loading'));
147 rdetailMarcFetched = true;
148 var req = new Request( FETCH_MARC_HTML, record.doc_id() );
149 req.callback(rdetailViewMarc);
155 function rdetailHandleAddedContent(r) {
156 var resp = r.getResultObject();
157 if( resp.Review == 'true' ) unHideMe($('rdetail_reviews_link'));
158 if( resp.TOC == 'true' ) unHideMe($('rdetail_toc_link'));
162 function rdetailShowReviews(r) {
163 hideMe($('rdetail_extras_loading'));
164 var res = r.getResultObject();
165 var par = $('rdetail_reviews_div');
166 var template = par.removeChild($('rdetail_review_template'));
167 if( res && res.length > 0 ) {
168 unHideMe($('rdetail_reviews_link'));
169 for( var i = 0; i != res.length; i++ ) {
171 if( rev.text && rev.info ) {
172 var node = template.cloneNode(true);
173 $n(node, 'review_header').appendChild(text(rev.info));
174 $n(node, 'review_text').appendChild(text(rev.text));
175 par.appendChild(node);
181 function rdetailShowTOC(r) {
182 hideMe($('rdetail_extras_loading'));
183 var resp = r.getResultObject();
185 unHideMe($('rdetail_toc_link'));
186 $('rdetail_toc_div').innerHTML = resp;
191 function rdetailBuildInfoRows() {
192 var req = new Request(FETCH_COPY_COUNTS_SUMMARY, record.doc_id())
193 req.callback(_rdetailBuildInfoRows);
197 /* pre-allocate the copy info table with all org units in correct order */
198 function _rdetailRows(node) {
202 var row = copyRow.cloneNode(true);
203 row.id = "cp_info_" + node.id();
205 var libtd = findNodeByName( row, config.names.rdetail.lib_cell );
206 var cntd = findNodeByName( row, config.names.rdetail.cn_cell );
207 var cpctd = findNodeByName( row, config.names.rdetail.cp_count_cell );
209 libtd.appendChild(text(node.name()));
210 libtd.setAttribute("style", "padding-left: " + ((findOrgDepth(node) - 1) * 9) + "px;");
212 if(!findOrgType(node.ou_type()).can_have_vols()) {
214 row.removeChild(cntd);
215 row.removeChild(cpctd);
217 libtd.setAttribute("colspan", numStatuses + 2 );
218 libtd.colSpan = numStatuses + 2;
219 addCSSClass(row, 'copy_info_region_row');
222 copyRowParent.appendChild(row);
224 } else { node = globalOrgTree; }
226 for( var c in node.children() )
227 _rdetailRows(node.children()[c]);
230 /* walk through the copy info and build rows where necessary */
231 function _rdetailBuildInfoRows(r) {
235 var summary = r.getResultObject();
238 G.ui.rdetail.cp_info_loading.parentNode.removeChild(
239 G.ui.rdetail.cp_info_loading);
242 for( var i = 0; i < summary.length; i++ ) {
244 var arr = summary[i];
245 var thisOrg = findOrgUnit(arr[0]);
246 var rowNode = $("cp_info_" + thisOrg.id());
248 if(rowNode.getAttribute("used")) {
250 if( rowNode.nextSibling )
251 rowNode = copyRowParent.insertBefore(copyRow.cloneNode(true), rowNode.nextSibling);
253 rowNode = copyRowParent.appendChild(copyRow.cloneNode(true));
254 var n = findNodeByName( rowNode, config.names.rdetail.lib_cell );
255 n.appendChild(text(thisOrg.name()));
256 n.setAttribute("style", "padding-left: " + ((findOrgDepth(thisOrg) - 1) * 9) + "px;");
258 } else rowNode.setAttribute("used", "1");
260 var a = elem("a", {href:'javascript:cnBrowseGo("' + arr[1] + '");' }, arr[1]);
261 addCSSClass(a, 'classic_link');
262 findNodeByName( rowNode, config.names.rdetail.cn_cell ).appendChild(a);
264 //findNodeByName( rowNode, config.names.rdetail.cn_cell ).appendChild(text(arr[1]));
266 var cpc_temp = rowNode.removeChild(
267 findNodeByName(rowNode, config.names.rdetail.cp_count_cell));
269 rdetailApplyStatuses(rowNode, cpc_temp, arr[2]);
272 if( orgIsMine( findOrgUnit(getLocation()), thisOrg ) ) { found = true; isLocal = true; }
273 rdetailSetPath( thisOrg, isLocal );
277 if(!found) unHideMe(G.ui.rdetail.cp_info_none);
281 /* sets the path to org as 'active' and displays the
282 path if it's local */
283 function rdetailSetPath(org, local) {
284 if( findOrgDepth(org) == 0 ) return;
285 var row = $("cp_info_" + org.id());
286 row.setAttribute("hasinfo", "1");
289 row.setAttribute("local", "1");
291 rdetailSetPath(findOrgUnit(org.parent_ou()), local);
294 function rdetailApplyStatuses( row, template, statuses ) {
295 for( var j in _statusPositions ) {
296 var stat = _statusPositions[j];
297 var val = statuses[stat.id()];
298 var nn = template.cloneNode(true);
299 if(val) nn.appendChild(text(val));
300 else nn.appendChild(text(0));
306 /* --------------------------------------------------------------------- */
307 var _statusPositions = {};
309 function rdetailBuildStatusColumns() {
311 rdetailGrabCopyStatuses();
312 var parent = statusRow;
313 var template = parent.removeChild(G.ui.rdetail.cp_status);
316 for( i = 0; i < cp_statuses.length; i++ ) {
318 var c = cp_statuses[i];
320 if(c && c.holdable()) {
323 _statusPositions[i] = c;
324 var node = template.cloneNode(true);
325 var data = findNodeByName( node, config.names.rdetail.cp_status);
327 data.appendChild(text(name));
328 parent.appendChild(node);
333 for(x in _statusPositions) numStatuses++;
336 function rdetailGrabCopyStatuses() {
337 if(cp_statuses) return cp_statuses;
338 var req = new Request(FETCH_COPY_STATUSES);
340 cp_statuses = req.result();
341 cp_statuses = cp_statuses.sort(_rdetailSortStatuses);
344 function _rdetailSortStatuses(a, b) {
345 return parseInt(a.id()) - parseInt(b.id());