--- /dev/null
+\r
+attachEvt( "common", "locationChanged", updateLoc );\r
+attachEvt("common", "run", function(){\r
+ setSelector(_ds, getLocation()); _newlocation = getLocation();\r
+}); // sets default search to home library\r
+//attachEvt("common", "run", function(){setSelector(_ds, "1"); _newlocation = "1";});\r
+\r
+var _ds;\r
+var _libselspan;\r
+var _libselslink;\r
+var _dselspan;\r
+var _newlocation = null;\r
+\r
+function depthSelInit() {\r
+ _ds = $('depth_selector'); \r
+ _ds.onchange = depthSelectorChanged;\r
+ _libselspan = $('lib_selector_span');\r
+ _libsellink = $('lib_selector_link');\r
+ _dselspan = $('depth_selector_span');\r
+\r
+ if( getLocation() == globalOrgTree.id() ) {\r
+ unHideMe( _libselspan );\r
+ _libsellink.onclick = _opacHandleLocationTagClick;\r
+ } else {\r
+ unHideMe( _dselspan );\r
+ //buildLocationSelector();\r
+ }\r
+}\r
+\r
+\r
+var orgTreeIsBuilt = false;\r
+function _opacHandleLocationTagClick() {\r
+\r
+ swapCanvas(G.ui.common.org_container);\r
+\r
+ if(!orgTreeIsBuilt) {\r
+ drawOrgTree();\r
+ orgTreeIsBuilt = true;\r
+ }\r
+\r
+}\r
+\r
+function depthSelGetDepth() {\r
+ var depth = parseInt(_ds.options[_ds.selectedIndex].value);\r
+ if(isNaN(depth)) depth = 0;\r
+ return depth;\r
+}\r
+\r
+function depthSelectorChanged() {\r
+ if(!_ds) return;\r
+ _newlocation = _ds.options[_ds.selectedIndex].value;\r
+}\r
+\r
+var chooseAnotherNode;\r
+function buildLocationSelector(newLoc) {\r
+\r
+ var loc;\r
+ if(newLoc != null) loc = newLoc;\r
+ else loc = getLocation();\r
+\r
+ if( loc == globalOrgTree.id() ) return;\r
+\r
+ var selector = _ds;\r
+ if(!chooseAnotherNode) \r
+ chooseAnotherNode = selector.removeChild(\r
+ selector.getElementsByTagName("option")[0]);\r
+ var node = chooseAnotherNode;\r
+ removeChildren(selector);\r
+ \r
+ var location = findOrgUnit(loc);\r
+ var type;\r
+ if (location) type = findOrgType(location.ou_type());\r
+\r
+ while( type && location ) {\r
+ var n = node.cloneNode(true); \r
+ n.setAttribute("value", type.depth());\r
+ removeChildren(n);\r
+ n.appendChild(text(type.opac_label()));\r
+ selector.appendChild(n);\r
+ location = findOrgUnit(location.parent_ou());\r
+ if(location) type = findOrgType(location.ou_type());\r
+ else type = null;\r
+ }\r
+\r
+ selector.appendChild(node);\r
+}\r
+\r
+function getNewSearchDepth() { return newSearchDepth; }\r
+function getNewSearchLocation() { return (isNull(_newlocation)) ? LOCATION : _newlocation; }\r
+function depthSelGetNewLoc() { return getNewSearchLocation(); }\r
+\r
+function updateLoc(location, depth) {\r
+ if( depth != null ) {\r
+ if(depth != 0 ){\r
+ _libsellink.onclick = _opacHandleLocationTagClick;\r
+ if( location == globalOrgTree.id() ) {\r
+ hideMe( _dselspan );\r
+ unHideMe( _libselspan );\r
+ } else {\r
+ buildLocationSelector(location);\r
+ hideMe( _libselspan );\r
+ unHideMe( _dselspan );\r
+ }\r
+ }\r
+\r
+ setSelector(_ds, depth);\r
+ newSearchDepth = depth;\r
+ }\r
+\r
+ _newlocation = location;\r
+ runEvt('common','locationUpdated', location);\r
+}\r