]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/widgets/ListBox.js
removing old opac images and css
[Evergreen.git] / Open-ILS / src / javascript / widgets / ListBox.js
1 /* Top level widget class */
2
3 /* Generic HTML container box. */
4
5 ListBox.prototype                                       = new Box();
6 ListBox.prototype.constructor   = ListBox;
7 ListBox.baseClass                                       = Box.constructor;
8
9 function ListBox() {}
10
11 /* default to no sorting and allowing dups  */
12 ListBox.prototype.listBoxInit = 
13         function(ordered, title, hidden, noDups, maxItems) {
14
15         this.ordered = ordered;
16         this.node = createAppElement("div");
17         this.contentWrapperNode = createAppElement("div");
18         this.node.name = "anode";
19
20         if(this.ordered)
21                 this.contentNode = createAppElement("ol");
22         else
23                 this.contentNode = createAppElement("ul");
24
25
26         add_css_class(this.node, "box");
27         add_css_class(this.node, "list_box");
28         add_css_class(this.contentWrapperNode, "box_content");
29         add_css_class(this.contentWrapperNode, "list_box_content");
30
31         this.node.appendChild(this.contentWrapperNode);
32         this.contentWrapperNode.appendChild(this.contentNode);
33
34         this.items                      = new Array();
35         this.itemCount          = new Array();
36         this.sortCounts = false;
37         this.sortKeys           = false;
38         this.dup                                = true;
39
40         this.title(title);
41         this.noDup(noDups);
42         this.setMax(maxItems);
43         this.setHidden(hidden);
44 }
45
46 /* add a caption below the title */
47 ListBox.prototype.addCaption = function(caption) {
48         if(caption == null) return;
49         var captionNode = createAppElement("div");
50         add_css_class(captionNode, "box_caption");
51         captionNode.appendChild(createAppTextNode(caption));
52         this.node.insertBefore(captionNode, this.contentWrapperNode);
53 }
54
55
56
57 ListBox.prototype.addItem = function(domItem, key) {
58         var boxItem = new ListBoxItem();
59         boxItem.init(domItem, key);
60         this.addRestrictDups(boxItem, key);
61 }
62
63
64 ListBox.prototype.addFooter = function(domItem) {
65         this.footerNode = createAppElement("div");
66         add_css_class(this.footerNode, "box_footer");
67         this.footerNode.appendChild(domItem);
68         this.contentWrapperNode.appendChild(this.footerNode);
69 }
70
71 ListBox.prototype.removeFooter = function() {
72         if( this.footerNode != null )
73                 this.contentWrapperNode.removeChild(
74                         this.footerNode );
75 }
76
77
78 /* ---------------------------------------------------- */
79
80 ListBoxItem.prototype                                   = new BoxItem();
81 ListBoxItem.prototype.constructor       = ListBoxItem;
82 ListBoxItem.baseClass                                   = BoxItem.constructor;
83
84 function ListBoxItem() {}
85
86 ListBoxItem.prototype.init = function(domItem, key) {
87
88         this.item = domItem;
89         this.key  = key;
90
91         this.node = createAppElement("li");
92         this.contentNode = createAppElement("div");
93         this.contentNode.appendChild(domItem);
94         this.node.appendChild(this.contentNode);
95
96         add_css_class( this.node, "list_box_list" );
97         add_css_class( this.contentNode, "box_item" );
98         add_css_class( this.contentNode, "list_box_item" );
99 }
100