]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/widgets/PopupBox.js
removing old opac images and css
[Evergreen.git] / Open-ILS / src / javascript / widgets / PopupBox.js
1 /* @target is the object next to which the box should pop up.
2         */
3 function PopupBox(target, body) {
4         this.target = target;
5         this.div = elem("div");
6         add_css_class(this.div,"popup_box");
7         add_css_class(this.div,"hide_me");
8         if(body) this.div.appendChild(body);
9         getDocument().body.appendChild(this.div);
10 }
11
12 PopupBox.prototype.setBody = function(body) {
13         if(body) this.div.appendChild(body);
14 }
15
16 PopupBox.prototype.addNode = function(node) {
17         if(node) {
18                 this.div.appendChild(node);
19                 this.lines();
20         }
21 }
22
23 PopupBox.prototype.addText = function(text) {
24         if(text) {
25                 this.div.appendChild(mktext(text));
26                 this.lines();
27         }
28 }
29
30 PopupBox.prototype.lines = function(count) {
31         if(count == null) count = 1;
32         for( var x = 0; x < count; x++ ) {
33                 this.div.appendChild(elem("br"));
34         }
35 }
36
37 PopupBox.prototype.title = function(title) {
38
39         if(title != null) {
40
41                 var div = elem("div");
42                 add_css_class(div, "popup_box_title");
43                 div.appendChild(mktext(title));
44                 this.lines();
45
46                 if(this.div.firstChild)
47                         this.div.insertBefore(div, this.div.firstChild);
48                 else
49                         this.div.appendChild(div);
50         }
51 }
52
53
54 PopupBox.prototype.show = function() {
55
56         remove_css_class(this.div,"hide_me");
57
58         var A = getXYOffsets(this.target, this.div);
59         var newx = A[0];
60         var newy = A[1];
61
62         var W = getWindowSize();
63         var wx = W[0];
64         var wy = W[1];
65
66         var x =  getObjectWidth(this.div);
67         var y =  getObjectHeight(this.div);
68
69         //alert(wx + " : " + wy + " : " + x + " : " + y + " : " + newx + " : " + newy);
70
71         if( (newx + x) > wx )
72                 newx = newx - x;
73
74         if( (newy + y) > wy )
75                 newy = newy - y - getObjectHeight(this.target);
76
77         this.div.style.left = newx;
78         this.div.style.top = newy;
79
80         add_css_class(this.div,"show_me");
81 }
82
83 PopupBox.prototype.hide = function() {
84         remove_css_class(this.div,"show_me");
85         add_css_class(this.div,"hide_me");
86 }
87
88 /* pass in an array of DOM nodes and they will
89         be displayed as a group along the box */
90 PopupBox.prototype.makeGroup = function(group) {
91
92         var center = elem("center");
93         var table = elem("table");
94         center.appendChild(table);
95         add_css_class(table, "popup_box_group");
96         var row = table.insertRow(0);
97
98         for(var i = 0; i!= group.length; i++) {
99                 var cell = row.insertCell(row.cells.length);
100                 cell.appendChild(group[i]);
101         }
102
103         this.div.appendChild(elem("br"));
104         this.div.appendChild(center);
105 }