]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/opac/skin/default/js/sidebar.js
new front page
[Evergreen.git] / Open-ILS / web / opac / skin / default / js / sidebar.js
1 /* set up the colors in the sidebar 
2         Disables/Enables certain components based on various state data */
3
4 attachEvt("common", "init", initSideBar);
5 attachEvt("common", "init", setSidebarLinks);
6
7 function initSideBar() {
8         var page = findCurrentPage();
9
10         if( page == MRESULT ) 
11                 unHideMe(getId("sidebar_results_wrapper"));
12
13         if( page == RRESULT ) {
14                 unHideMe(getId("sidebar_results_wrapper"));
15                 unHideMe(G.ui.sidebar[MRESULT]);
16                 getId("sidebar_title_group_results").setAttribute("href", buildOPACLink({ page: MRESULT }));
17         }
18
19         if( page == RDETAIL ) {
20                 unHideMe(getId("sidebar_results_wrapper"));
21                 getId("sidebar_title_group_results").setAttribute("href", buildOPACLink({ page: MRESULT }));
22                 unHideMe(G.ui.sidebar[MRESULT]);
23                 getId("sidebar_title_results").setAttribute("href", buildOPACLink({ page : RRESULT }));
24                 unHideMe(G.ui.sidebar[RRESULT]);
25         }
26
27         unHideMe(G.ui.sidebar[page]);
28
29         //addCSSClass(G.ui.sidebar[page], config.css.color_2);
30         //addCSSClass(G.ui.sidebar[page], config.css.encircled);
31         addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
32
33         /* if we're logged in, show it and replace the Login link with the Logout link */
34         if(grabUser()) {
35                 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
36                 unHideMe(G.ui.sidebar.logoutbox);
37                 unHideMe(G.ui.sidebar.logged_in_as);
38                 hideMe(G.ui.sidebar.loginbox);
39         }
40
41         if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
42         if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout; 
43 }
44
45 /* sets up the login ui components */
46 var loginBoxVisible = false;
47 function initLogin() {
48
49         var loginDance = function() {
50                 if(doLogin()) {
51                         showCanvas();
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                 }
57         }
58
59         G.ui.login.button.onclick = loginDance;
60         G.ui.login.username.onkeydown = 
61                 function(evt) {if(userPressedEnter(evt)) loginDance();};
62         G.ui.login.password.onkeydown = 
63                 function(evt) {if(userPressedEnter(evt)) loginDance();};
64
65         if(loginBoxVisible) {
66                 showCanvas();
67         } else {
68                 swapCanvas(G.ui.login.box);
69                 G.ui.login.username.focus();
70         }
71
72         loginBoxVisible = !loginBoxVisible;
73         G.ui.login.cancel.onclick = showCanvas;
74 }
75
76 function setSidebarLinks() {
77         G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
78         G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
79         G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
80 }
81
82