moved sidebar code out for ease of use
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 15 Aug 2005 20:22:08 +0000 (20:22 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 15 Aug 2005 20:22:08 +0000 (20:22 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1657 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/javascript/lib/js/opac/sidebar.js [new file with mode: 0644]

diff --git a/Open-ILS/src/javascript/lib/js/opac/sidebar.js b/Open-ILS/src/javascript/lib/js/opac/sidebar.js
new file mode 100644 (file)
index 0000000..37b5463
--- /dev/null
@@ -0,0 +1,55 @@
+/* set up the colors in the sidebar 
+       Disables/Enables certain components based on various state data */
+function initSideBar() {
+
+       for( var p in G.ui.sidebar ) 
+               removeCSSClass(p, config.css.color_2);
+
+       var page = findCurrentPage();
+       unHideMe(G.ui.sidebar[page]);
+       addCSSClass(G.ui.sidebar[page], config.css.color_2);
+
+       /* if we're logged in, show it and replace the Login link with the Logout link */
+       if(grabUser()) {
+               G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
+               unHideMe(G.ui.sidebar.logoutbox);
+               unHideMe(G.ui.sidebar.logged_in_as);
+               hideMe(G.ui.sidebar.loginbox);
+       }
+
+       if(G.ui.sidebar.login) G.ui.sidebar.login.onclick = initLogin;
+       if(G.ui.sidebar.logout) G.ui.sidebar.logout.onclick = doLogout; 
+
+}
+
+/* sets up the login ui components */
+var loginBoxVisible = false;
+function initLogin() {
+
+       var loginDance = function() {
+               if(doLogin()) {
+                       showCanvas();
+                       G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
+                       unHideMe(G.ui.sidebar.logoutbox);
+                       unHideMe(G.ui.sidebar.logged_in_as);
+                       hideMe(G.ui.sidebar.loginbox);
+               }
+       }
+
+       G.ui.login.button.onclick = loginDance;
+       G.ui.login.username.onkeydown = 
+               function(evt) {if(userPressedEnter(evt)) loginDance();};
+       G.ui.login.password.onkeydown = 
+               function(evt) {if(userPressedEnter(evt)) loginDance();};
+
+       if(loginBoxVisible) {
+               showCanvas();
+       } else {
+               swapCanvas(G.ui.login.box);
+               G.ui.login.username.focus();
+       }
+       loginBoxVisible = !loginBoxVisible;
+       G.ui.login.cancel.onclick = showCanvas;
+}
+
+