1 /* set up the colors in the sidebar
2 Disables/Enables certain components based on various state data */
4 attachEvt("common", "init", initSideBar);
5 attachEvt("common", "init", setSidebarLinks);
7 attachEvt("common", "unload", sidebarTreesFree );
9 function initSideBar() {
10 var page = findCurrentPage();
13 unHideMe($("sidebar_results_wrapper"));
15 if( page == RRESULT ) {
16 unHideMe($("sidebar_results_wrapper"));
17 unHideMe(G.ui.sidebar[MRESULT]);
18 $("sidebar_title_group_results").setAttribute("href", buildOPACLink({ page: MRESULT }));
21 if( page == RDETAIL ) {
22 unHideMe($("sidebar_results_wrapper"));
23 $("sidebar_title_group_results").setAttribute("href", buildOPACLink({ page: MRESULT }));
24 unHideMe(G.ui.sidebar[MRESULT]);
25 $("sidebar_title_results").setAttribute("href", buildOPACLink({ page : RRESULT }));
26 unHideMe(G.ui.sidebar[RRESULT]);
29 unHideMe(G.ui.sidebar[page]);
30 addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
32 /* if we're logged in, show it and replace the Login link with the Logout link */
34 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
35 unHideMe(G.ui.sidebar.logoutbox);
36 unHideMe(G.ui.sidebar.logged_in_as);
37 hideMe(G.ui.sidebar.loginbox);
40 if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
41 if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout;
43 if(isXUL()) hideMe( G.ui.sidebar.logoutbox );
46 /* sets up the login ui components */
47 var loginBoxVisible = false;
49 function loginDance() {
52 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
53 unHideMe(G.ui.sidebar.logoutbox);
54 unHideMe(G.ui.sidebar.logged_in_as);
55 hideMe(G.ui.sidebar.loginbox);
56 runEvt("common", "loggedIn");
60 function initLogin() {
62 G.ui.login.button.onclick = loginDance;
63 G.ui.login.username.onkeydown =
64 function(evt) {if(userPressedEnter(evt)) loginDance();};
65 G.ui.login.password.onkeydown =
66 function(evt) {if(userPressedEnter(evt)) loginDance();};
71 swapCanvas(G.ui.login.box);
72 try{G.ui.login.username.focus();}catch(e){}
75 loginBoxVisible = !loginBoxVisible;
76 G.ui.login.cancel.onclick = showCanvas;
77 if(findCurrentPage() == MYOPAC)
78 G.ui.login.cancel.onclick = goHome;
81 function setSidebarLinks() {
82 G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
83 G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
84 G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
87 function sidebarTreesFree() {
88 removeChildren($(subjectSidebarTree.rootid));
89 removeChildren($(authorSidebarTree.rootid));
90 removeChildren($(seriesSidebarTree.rootid));
91 subjectSidebarTree = null;
92 authorSidebarTree = null;
93 seriesSidebarTree = null;