]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/serial/common.js
LP 2061136 follow-up: ng lint --fix
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / serial / common.js
1 String.prototype.trim = function() {return this.replace(/^\s*(.+)\s*$/,"$1");}
2
3 /**
4  * hard_empty() is needed because dojo.empty() doesn't seem to work on
5  * XUL nodes. This also means that dojo.place() with a position argument of
6  * "only" doesn't do what it should, but calling hard_empty() on the refnode
7  * first will do the trick.
8  */
9 function hard_empty(node) {
10     if (typeof(node) == "string")
11         node = dojo.byId(node);
12     if (node)
13         dojo.forEach(node.childNodes, dojo.destroy);
14 }
15
16 function hide(e) {
17     if (typeof(e) == "string") e = dojo.byId(e);
18     openils.Util.addCSSClass(e, "hideme");
19 }
20
21 function show(e) {
22     if (typeof(e) == "string") e = dojo.byId(e);
23     openils.Util.removeCSSClass(e, "hideme");
24 }
25
26 function hide_table_cell(e) {
27     if (typeof(e) == "string") e = dojo.byId(e);
28
29     e.style.display = "none";
30     e.style.visibility = "hidden";
31 }
32
33 function show_table_cell(e) {
34     if (typeof(e) == "string") e = dojo.byId(e);
35     e.style.display = "table-cell";
36     e.style.visibility = "visible";
37 }
38
39 function soft_hide(e) { /* doesn't disrupt XUL grid alignment */
40     if (typeof(e) == "string") e = dojo.byId(e);
41     e.style.visibility = "hidden";
42 }
43
44 function soft_show(e) {
45     if (typeof(e) == "string") e = dojo.byId(e);
46     e.style.visibility = "visible";
47 }
48
49 function busy(on) {
50     if (typeof(busy._window) == "undefined")
51         busy._window = dojo.query("window")[0];
52     busy._window.style.cursor = on ? "wait" : "auto";
53 }
54
55 function T(s) { return document.createTextNode(s); }
56 function D(s) {return s ? openils.Util.timeStamp(s, {"selector":"date"}) : "";}
57 function node_by_name(s, ctx) {return dojo.query("[name='" + s + "']", ctx)[0];}
58
59 function num_sort(a, b) {
60     [a, b] = [Number(a), Number(b)];
61     return a > b ? 1 : (a < b ? -1 : 0);
62 }