]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/opac/simple.js
LP#1053397 TPAC metarecord search and holds UI
[Evergreen.git] / Open-ILS / web / js / ui / default / opac / simple.js
1 /* Keep this dead simple. No dojo. */
2 function $(s) { return document.getElementById(s); }
3 function removeClass(node, cls) {
4     if (!node || !node.className) return;
5     node.className =
6         node.className.replace(new RegExp("\\b" + cls + "\\b", "g"), "");
7 }
8 function addClass(node, cls) {
9     if (!node) return;
10     removeClass(node, cls);
11     if (!node.className) node.className = cls;
12     else node.className += ' ' + cls;
13 }
14 function unHideMe(node) { removeClass(node, "hide_me"); }
15 function hideMe(node) { addClass(node, "hide_me"); }
16
17 var _search_row_template, _expert_row_template;
18 function addSearchRow() {
19     if (!_search_row_template) {
20         t = $("adv_global_row").cloneNode(true);
21         t.id = null;
22         _search_row_template = t;
23     }
24
25     $("adv_global_tbody").insertBefore(
26         _search_row_template.cloneNode(true),
27         $("adv_global_addrow")
28     );
29 }
30 function addExpertRow() {
31     if (!_expert_row_template) {
32         t = $("adv_expert_row").cloneNode(true);
33         t.id = null;
34         _expert_row_template = t;
35     }
36
37     $("adv_expert_rows_here").appendChild(
38         _expert_row_template.cloneNode(true)
39     );
40 }
41 function killRowIfAtLeast(min, link) {
42     var row = link.parentNode.parentNode;
43     if (row.parentNode.getElementsByTagName("tr").length > min)
44         row.parentNode.removeChild(row);
45     return false;
46 }
47 function print_node(node_id) {
48     var iframe = document.createElement("iframe");
49     var source_node = $(node_id);
50     source_node.parentNode.appendChild(iframe);
51
52     var iwin = iframe.contentWindow;
53
54     /* These next three statements are only needed by IE, but they don't
55      * hurt FF/Chrome. */
56     iwin.document.open();
57     iwin.document.write(    /* XXX make better/customizable? */
58         "<html><head><title>Receipt</title></head><body></body></html>"
59     );
60     iwin.document.close();
61
62     iwin.document.body.innerHTML = source_node.innerHTML;
63     iframe.focus();
64
65     try { iframe.print(); } catch (e) { iwin.print(); }
66     setTimeout(function() { iframe.style.display = "none"; }, 3500);
67 }
68 function select_all_checkboxes(name, checked) {
69     var all = document.getElementsByTagName("input");
70     for (var i = 0; i < all.length; i++) {
71         if (all[i].type == "checkbox" && all[i].name == name) {
72             all[i].checked = checked;
73         }
74     }
75 }
76
77 function search_modifier_onchange(type, checkbox, submitOnChange) {
78     if (checkbox.form._adv && !checkbox.checked) {
79         var search_box = $('search_box');
80         var reg = new RegExp('#' + type + ' ?', 'g');
81         search_box.value = search_box.value.replace(reg, "");
82     }
83
84     if (submitOnChange) {  
85         checkbox.form.submit(); 
86     }
87 }