2 attachEvt( "common", "locationChanged", updateLoc );
8 var _newlocation = null;
10 function depthSelInit() {
11 _ds = $('depth_selector');
12 _ds.onchange = depthSelectorChanged;
13 _libselspan = $('lib_selector_span');
14 _libsellink = $('lib_selector_link');
15 _dselspan = $('depth_selector_span');
17 if( getLocation() == globalOrgTree.id() ) {
18 unHideMe( _libselspan );
19 _libsellink.onclick = _opacHandleLocationTagClick;
21 unHideMe( _dselspan );
22 buildLocationSelector();
25 setSelector(_ds, getDepth());
26 _newlocation = getLocation();
30 var orgTreeIsBuilt = false;
31 function _opacHandleLocationTagClick() {
33 swapCanvas(G.ui.common.org_container);
37 orgTreeIsBuilt = true;
42 function depthSelGetDepth() {
43 var depth = parseInt(_ds.options[_ds.selectedIndex].value);
44 if(isNaN(depth)) depth = 0;
48 function depthSelectorChanged() {
49 var i = _ds.selectedIndex;
50 if( i == _ds.options.length - 1 ) {
51 setSelector( _ds, getDepth() );
52 _opacHandleLocationTagClick();
54 /* this re-submits the search when they change the search range
55 disabled for testing...
57 /*runEvt('common', 'depthChanged');*/
61 var chooseAnotherNode;
62 function buildLocationSelector(newLoc) {
65 if(newLoc != null) loc = newLoc;
66 else loc = getLocation();
68 if( loc == globalOrgTree.id() ) return;
71 if(!chooseAnotherNode)
72 chooseAnotherNode = selector.removeChild(
73 selector.getElementsByTagName("option")[0]);
74 var node = chooseAnotherNode;
75 removeChildren(selector);
77 var location = findOrgUnit(loc);
79 if (location) type = findOrgType(location.ou_type());
81 var orgHiding = checkOrgHiding();
82 while( type && location ) {
83 var n = node.cloneNode(true);
84 n.setAttribute("value", type.depth());
86 n.appendChild(text(type.opac_label()));
87 selector.appendChild(n);
88 location = findOrgUnit(location.parent_ou());
90 type = findOrgType(location.ou_type());
91 if (orgHiding && orgHiding.depth > type.depth()) {
99 selector.appendChild(node);
102 function getNewSearchDepth() { return newSearchDepth; }
103 function getNewSearchLocation() { return (isNull(_newlocation)) ? LOCATION : _newlocation; }
104 function depthSelGetNewLoc() { return getNewSearchLocation(); }
106 function updateLoc(location, depth) {
107 if( depth != null ) {
109 _libsellink.onclick = _opacHandleLocationTagClick;
110 if( location == globalOrgTree.id() ) {
112 unHideMe( _libselspan );
114 buildLocationSelector(location);
115 hideMe( _libselspan );
116 unHideMe( _dselspan );
120 setSelector(_ds, depth);
121 newSearchDepth = depth;
124 _newlocation = location;
125 runEvt('common','locationUpdated', location);