2 attachEvt( "common", "locationChanged", updateLoc );
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 return parseInt(_ds.options[_ds.selectedIndex].value);
46 function depthSelectorChanged() {
47 var i = _ds.selectedIndex;
48 if( i == _ds.options.length - 1 ) {
49 setSelector( _ds, getDepth() );
50 _opacHandleLocationTagClick();
51 } else { runEvt('common', 'depthChanged'); }
54 var chooseAnotherNode;
55 function buildLocationSelector(newLoc) {
58 if(newLoc != null) loc = newLoc;
59 else loc = getLocation();
61 if( loc == globalOrgTree.id() ) return;
64 if(!chooseAnotherNode)
65 chooseAnotherNode = selector.removeChild(
66 selector.getElementsByTagName("option")[0]);
67 var node = chooseAnotherNode;
68 removeChildren(selector);
70 var location = findOrgUnit(loc);
71 var type = findOrgType(location.ou_type());
73 while( type && location ) {
74 var n = node.cloneNode(true);
75 n.setAttribute("value", type.depth());
77 n.appendChild(text(type.opac_label()));
78 selector.appendChild(n);
79 location = findOrgUnit(location.parent_ou());
80 if(location) type = findOrgType(location.ou_type());
84 selector.appendChild(node);
87 function getNewSearchDepth() { return newSearchDepth; }
88 function getNewSearchLocation() { return _newlocation; }
89 function depthSelGetNewLoc() { return _newlocation; }
91 function updateLoc(location, depth) {
94 _libsellink.onclick = _opacHandleLocationTagClick;
95 if( location == globalOrgTree.id() ) {
97 unHideMe( _libselspan );
99 buildLocationSelector(location);
100 hideMe( _libselspan );
101 unHideMe( _dselspan );
105 setSelector(_ds, depth);
106 newSearchDepth = depth;
109 _newlocation = location;
110 runEvt('common','locationUpdated', location);