]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/javascript/opac/LocationTree.js
web batch update
[Evergreen.git] / Open-ILS / src / javascript / opac / LocationTree.js
1 /* */
2
3 function LocationTree( tree ) {
4         this.orgTree = tree;
5 }
6
7 LocationTree.prototype.buildOrgTreeWidget = function(org_node) {
8
9         var item;
10
11         if(org_node == null) {
12                 org_node = this.orgTree;
13                 item = new WebFXTree(org_node.name());
14                 this.widget = item;
15                 item.setBehavior('classic');
16         } else {
17                 item = new WebFXTreeItem(org_node.name());
18         }
19
20         item.action = "javascript:globalPage.updateSelectedLocation('" + org_node.id() + "');";
21
22         for( var index in org_node.children()) {
23                 var childorg = org_node.children()[index];
24                 if( childorg != null ) {
25                         var tree_node = buildOrgTreeWidget(childorg);
26                         if(tree_node != null)
27                                 item.add(tree_node);
28                 }
29         }
30 }
31
32
33 LocationTree.prototype.hide = function() {
34         /*
35         if(this.treeContainerBox &&  
36                         this.treeContainerBox.className.indexOf("nav_bar_visible") != -1 ) {
37                 swapClass( this.treeContainerBox, "nav_bar_hidden", "nav_bar_visible" );
38         }
39         */
40 }
41
42 LocationTree.prototype.toggle = function(button_div, offsetx, offsety) {
43
44         this.treeContainerBox = getById("ot_nav_widget");
45         this.treeBox = getById("ot_nav_widget_box");
46         swapClass( this.treeContainerBox, "nav_bar_hidden", "nav_bar_visible" );
47
48         if(this.treeBox && this.treeBox.firstChild.nodeType == 3) {
49                 setTimeout("renderTree()", 5 );
50         }
51
52         if( button_div && !offsetx && !offsety) {
53                 var x = findPosX(button_div);
54                 var y = findPosY(button_div);
55                 var height = getObjectHeight(button_div);
56                 var xpos = x - getObjectWidth(this.treeBox) + getObjectWidth(button_div);
57                 offsety = y + height;
58                 offsetx = xpos; 
59         }
60
61         if(IE) { /*HACK XXX*/
62                 offsety = parseInt(offsety) + 15;
63                 offsetx = parseInt(offsetx) + 8;
64         }
65
66         this.treeContainerBox.style.position = "absolute"; 
67         this.treeContainerBox.style.top = offsety; 
68         this.treeContainerBox.style.left = offsetx;
69 }
70
71
72 function renderTree() {
73
74         globalPage.locationTree.treeContainerBox = getById("ot_nav_widget");
75         globalPage.locationTree.treeBox = getById("ot_nav_widget_box");
76
77         if(!globalPage.locationTree.widget)
78                 globalPage.locationTree.buildOrgTreeWidget(); 
79         globalPage.locationTree.treeBox.innerHTML = 
80                 globalPage.locationTree.widget.toString();
81
82 }
83
84