Title / Description
Code // thumbnail control buttons section // declare 2 buttons var btnLogIn = window.external.msSiteModeAddThumbBarButton('http://i.hebimage.com/1211/4eebc7a8c0539.ico', 'Sign In'); var btnRegister = window.external.msSiteModeAddThumbBarButton('http://i.hebimage.com/1211/4eebc7f1305a2.ico', 'Register'); // declare 2 styles for button 1 var styleLogIn = 0; var styleLogOut = window.external.msSiteModeAddButtonStyle(btnLogIn, 'http://i.hebimage.com/1211/4eebc7a8c0539.ico', 'Sign Out'); // declare flag for log-in detection var loggedIn = false; if (window.external.msIsSiteMode()) { // if pinned // add event listener (traditional IE style) for responding mouse clicks on buttons document.attachEvent('onmsthumbnailclick', onButtonClicked); window.attachEvent('onunload', onBodyUnloaded); } // detect log-in status by checking the existence of log-in module (Members Area) if (document.getElementById("login-module")) { loggedIn = false; } else { loggedIn = true; } if (loggedIn == false) { // if not logged in window.external.msSiteModeShowButtonStyle(btnLogIn, styleLogIn); window.external.msSiteModeUpdateThumbBarButton(btnRegister, true, true); } else { // if already logged in window.external.msSiteModeShowButtonStyle(btnLogIn, styleLogOut); window.external.msSiteModeUpdateThumbBarButton(btnRegister, false, true); } window.external.msSiteModeShowThumbBar(); } // code for clicking buttons function onButtonClicked(btn) { // button 1 (Sign In) if (btn.buttonID == btnLogIn) { if (loggedIn == false) { // if not logged in window.location = "/apps/auth/login?try=1&next="; } else { // if already logged in window.location = "/apps/auth/logout"; } } // button 2 (Register) else if (btn.buttonID == btnRegister) { window.location = "/apps/auth/signup"; } } // code to hide buttons after clicking them function onBodyUnloaded() { window.external.msSiteModeUpdateThumbBarButton(btnLogIn, true, false); window.external.msSiteModeUpdateThumbBarButton(btnRegister, true, false); }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code