2 attachEvt( "common", "locationChanged", updateLoc );
\r
3 attachEvt("common", "run", function(){
\r
4 setSelector(_ds, getLocation()); _newlocation = getLocation();
\r
5 }); // sets default search to home library
\r
6 //attachEvt("common", "run", function(){setSelector(_ds, "1"); _newlocation = "1";});
\r
12 var _newlocation = null;
\r
14 function depthSelInit() {
\r
15 _ds = $('depth_selector');
\r
16 _ds.onchange = depthSelectorChanged;
\r
17 _libselspan = $('lib_selector_span');
\r
18 _libsellink = $('lib_selector_link');
\r
19 _dselspan = $('depth_selector_span');
\r
21 if( getLocation() == globalOrgTree.id() ) {
\r
22 unHideMe( _libselspan );
\r
23 _libsellink.onclick = _opacHandleLocationTagClick;
\r
25 unHideMe( _dselspan );
\r
26 //buildLocationSelector();
\r
31 var orgTreeIsBuilt = false;
\r
32 function _opacHandleLocationTagClick() {
\r
34 swapCanvas(G.ui.common.org_container);
\r
36 if(!orgTreeIsBuilt) {
\r
38 orgTreeIsBuilt = true;
\r
43 function depthSelGetDepth() {
\r
44 var depth = parseInt(_ds.options[_ds.selectedIndex].value);
\r
45 if(isNaN(depth)) depth = 0;
\r
49 function depthSelectorChanged() {
\r
51 _newlocation = _ds.options[_ds.selectedIndex].value;
\r
54 var chooseAnotherNode;
\r
55 function buildLocationSelector(newLoc) {
\r
58 if(newLoc != null) loc = newLoc;
\r
59 else loc = getLocation();
\r
61 if( loc == globalOrgTree.id() ) return;
\r
64 if(!chooseAnotherNode)
\r
65 chooseAnotherNode = selector.removeChild(
\r
66 selector.getElementsByTagName("option")[0]);
\r
67 var node = chooseAnotherNode;
\r
68 removeChildren(selector);
\r
70 var location = findOrgUnit(loc);
\r
72 if (location) type = findOrgType(location.ou_type());
\r
74 while( type && location ) {
\r
75 var n = node.cloneNode(true);
\r
76 n.setAttribute("value", type.depth());
\r
78 n.appendChild(text(type.opac_label()));
\r
79 selector.appendChild(n);
\r
80 location = findOrgUnit(location.parent_ou());
\r
81 if(location) type = findOrgType(location.ou_type());
\r
85 selector.appendChild(node);
\r
88 function getNewSearchDepth() { return newSearchDepth; }
\r
89 function getNewSearchLocation() { return (isNull(_newlocation)) ? LOCATION : _newlocation; }
\r
90 function depthSelGetNewLoc() { return getNewSearchLocation(); }
\r
92 function updateLoc(location, depth) {
\r
93 if( depth != null ) {
\r
95 _libsellink.onclick = _opacHandleLocationTagClick;
\r
96 if( location == globalOrgTree.id() ) {
\r
97 hideMe( _dselspan );
\r
98 unHideMe( _libselspan );
\r
100 buildLocationSelector(location);
\r
101 hideMe( _libselspan );
\r
102 unHideMe( _dselspan );
\r
106 setSelector(_ds, depth);
\r
107 newSearchDepth = depth;
\r
110 _newlocation = location;
\r
111 runEvt('common','locationUpdated', location);
\r