]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/opac/skin/default/js/sidebar.js
39e221909dcd4d74f136c636fb54443a91710c32
[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
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
48 /*
49 function loginDance() {
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                 return true;
57         }
58         return false;
59 }
60 */
61
62 function initLogin() {
63
64         var loginDance = function() {
65                 if(doLogin()) {
66                         showCanvas();
67                         G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
68                         unHideMe(G.ui.sidebar.logoutbox);
69                         unHideMe(G.ui.sidebar.logged_in_as);
70                         hideMe(G.ui.sidebar.loginbox);
71                         runEvt("common", "loggedIn");
72                 }
73         }
74
75         G.ui.login.button.onclick = loginDance;
76         G.ui.login.username.onkeydown = 
77                 function(evt) {if(userPressedEnter(evt)) loginDance();};
78         G.ui.login.password.onkeydown = 
79                 function(evt) {if(userPressedEnter(evt)) loginDance();};
80
81         if(loginBoxVisible) {
82                 showCanvas();
83         } else {
84                 swapCanvas(G.ui.login.box);
85                 try{G.ui.login.username.focus();}catch(e){}
86         }
87
88         loginBoxVisible = !loginBoxVisible;
89         G.ui.login.cancel.onclick = showCanvas;
90 }
91
92 function setSidebarLinks() {
93         G.ui.sidebar.home_link.setAttribute("href", buildOPACLink({page:HOME}));
94         G.ui.sidebar.advanced_link.setAttribute("href", buildOPACLink({page:ADVANCED}));
95         G.ui.sidebar.myopac_link.setAttribute("href", buildOPACLink({page:MYOPAC}, false, true));
96 }
97
98