]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/opac/skin/default/js/sidebar.js
c421ee1ba81feb7774a9f2acae6db4b409c083a4
[working/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         unHideMe(G.ui.sidebar[page]);
10
11         //addCSSClass(G.ui.sidebar[page], config.css.color_2);
12         //addCSSClass(G.ui.sidebar[page], config.css.encircled);
13         addCSSClass(G.ui.sidebar[page], "sidebar_item_active");
14
15         /* if we're logged in, show it and replace the Login link with the Logout link */
16         if(grabUser()) {
17                 G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
18                 unHideMe(G.ui.sidebar.logoutbox);
19                 unHideMe(G.ui.sidebar.logged_in_as);
20                 hideMe(G.ui.sidebar.loginbox);
21         }
22
23         if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
24         if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout; 
25 }
26
27 /* sets up the login ui components */
28 var loginBoxVisible = false;
29 function initLogin() {
30
31         var loginDance = function() {
32                 if(doLogin()) {
33                         showCanvas();
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);
38                 }
39         }
40
41         G.ui.login.button.onclick = loginDance;
42         G.ui.login.username.onkeydown = 
43                 function(evt) {if(userPressedEnter(evt)) loginDance();};
44         G.ui.login.password.onkeydown = 
45                 function(evt) {if(userPressedEnter(evt)) loginDance();};
46
47         if(loginBoxVisible) {
48                 showCanvas();
49         } else {
50                 swapCanvas(G.ui.login.box);
51                 G.ui.login.username.focus();
52         }
53
54         loginBoxVisible = !loginBoxVisible;
55         G.ui.login.cancel.onclick = showCanvas;
56 }
57
58 function setSidebarLinks() {
59         G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
60         G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
61         G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
62 }
63
64