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 while( type && location ) {
82 var n = node.cloneNode(true);
83 n.setAttribute("value", type.depth());
85 n.appendChild(text(type.opac_label()));
86 selector.appendChild(n);
87 location = findOrgUnit(location.parent_ou());
88 if(location) type = findOrgType(location.ou_type());
92 selector.appendChild(node);
95 function getNewSearchDepth() { return newSearchDepth; }
96 function getNewSearchLocation() { return (isNull(_newlocation)) ? LOCATION : _newlocation; }
97 function depthSelGetNewLoc() { return getNewSearchLocation(); }
99 function updateLoc(location, depth) {
100 if( depth != null ) {
102 _libsellink.onclick = _opacHandleLocationTagClick;
103 if( location == globalOrgTree.id() ) {
105 unHideMe( _libselspan );
107 buildLocationSelector(location);
108 hideMe( _libselspan );
109 unHideMe( _dselspan );
113 setSelector(_ds, depth);
114 newSearchDepth = depth;
117 _newlocation = location;
118 runEvt('common','locationUpdated', location);