3 function LocationTree( tree, box_id, container_id ) {
6 this.treeContainerBoxId = container_id;
7 this.treeBoxId = box_id;
9 this.treeBuilder = buildOrgTreeWidget;
13 LocationTree.prototype.setObjects = function() {
14 if(this.treeContainerBoxId)
15 this.treeContainerBox = getById(this.treeContainerBoxId);
17 this.treeContainerBox = getById("ot_nav_widget");
20 this.treeBox = getById(this.treeBoxId);
22 this.treeBox = getById("ot_nav_widget_box");
26 LocationTree.prototype.buildOrgTreeWidget = function() {
28 debug("Somebody called buildOrgTreeWidget on me...");
30 //this.widget = buildOrgTreeWidget(globalOrgTree, true);
31 this.widget = this.treeBuilder(globalOrgTree, true);
35 function buildOrgTreeWidget(org_node, root) {
40 item = new WebFXTree(org_node.name());
41 item.setBehavior('classic');
43 item = new WebFXTreeItem(org_node.name());
46 /* make org tree re-submit search on click */
48 "javascript:globalPage.updateSelectedLocation('" + org_node.id() + "');" +
49 "globalPage.locationTree.hide();";
51 for( var index in org_node.children()) {
52 var childorg = org_node.children()[index];
53 if( childorg != null ) {
54 var tree_node = buildOrgTreeWidget(childorg);
64 LocationTree.prototype.hide = function() {
66 this.widget = this.treeBuilder(globalOrgTree, true);
67 if(this.treeContainerBox &&
68 this.treeContainerBox.className.indexOf("show_me") != -1 ) {
69 swapClass( this.treeContainerBox, "hide_me", "show_me" );
75 LocationTree.prototype.toggle = function(button_div, offsetx, offsety, relative) {
78 debug("Tree container " + this.treeContainerBox );
79 debug("Tree box " + this.treeBox );
81 swapClass( this.treeContainerBox, "hide_me", "show_me" );
84 if( (this.treeBox && this.treeBox.firstChild &&
85 this.treeBox.firstChild.nodeType == 3) ||
86 (this.treeBox && !this.treeBox.firstChild)) {
88 debug("location tree has not been rendered... rendering..");
89 //setTimeout(function() { renderTree(obj); }, 5 );
93 //alert(this.treeBox.firstChild.nodeType);
96 ((offsetx == null && offsety == null) || relative) ) {
98 var x = findPosX(button_div);
99 var y = findPosY(button_div);
100 var height = getObjectHeight(button_div);
101 var xpos = x - getObjectWidth(this.treeBox) + getObjectWidth(button_div);
103 if(offsety == null) offsety = 0;
104 if(offsetx == null) offsetx = 0;
106 offsety = y + height + offsety;
107 offsetx = xpos + offsetx;
110 if(IE) { /*HACK XXX*/
111 offsety = parseInt(offsety) + 15;
112 offsetx = parseInt(offsetx) + 8;
116 debug("TREE OFFSET y: " + offsety + " x: " + offsetx );
118 this.treeContainerBox.style.position = "absolute";
119 this.treeContainerBox.style.top = offsety;
120 this.treeContainerBox.style.left = offsetx;
124 function renderTree(tree) {
126 if(!tree.widget) tree.buildOrgTreeWidget();
128 debug("Spitting tree out to the treeBox:\n" +
129 tree.widget.toString() ); */
130 tree.treeBox.innerHTML = tree.widget.toString();
135 /* generates a new chunk within with the tree is inserted */
136 LocationTree.prototype.newSpot = function(box_id, container_id) {
138 var cont = elem("div", { id : this.treeContainerBoxId } );
139 var box = elem("div", { id : this.treeBoxId } );
140 var expando_line = elem("div");
141 var expando = elem("div");
142 var expand_all = elem("a", null, null, "Expand All");
143 var collapse_all = elem("a", null, null, "Collapse All");
145 add_css_class(cont, "nav_widget");
146 add_css_class(cont, "hide_me");
147 add_css_class(box, "ot_nav_widget_box");
148 add_css_class(expando_line, "expando_links");
149 add_css_class(expando, "expando_links");
152 cont.appendChild(expando_line);
153 cont.appendChild(expando);
154 cont.appendChild(elem("br"));
155 cont.appendChild(box);
157 expando_line.appendChild(elem("br"));
159 expand_all.onclick = function() { obj.widget.expandAll(); };
160 collapse_all.onclick = function() {
161 obj.widget.collapseAll();
162 obj.widget.expand();};
164 expando.appendChild(expand_all);
165 expando.appendChild(createAppTextNode(" "));
166 expando.appendChild(collapse_all);
167 expando.appendChild(createAppTextNode(" "));