From: Michael M Slusarz Date: Tue, 10 Feb 2009 00:40:52 +0000 (-0700) Subject: Update login javascript X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=462e365377b2007a82788103e713b90d8601f373;p=horde.git Update login javascript --- diff --git a/imp/js/login.js b/imp/js/login.js index 5554363bf..9f5822281 100644 --- a/imp/js/login.js +++ b/imp/js/login.js @@ -1 +1 @@ -function setFocus(){if(!$F("imapuser")){$("imapuser").focus()}else{$("pass").focus()}}function imp_reload(){window.top.document.location=autologin_url+$F("server_key")}function submit_login(){if(show_list&&$F("server_key").startsWith("_")){return false}if(!$F("imapuser")){alert(IMP.text.login_username);$("imapuser").focus();return false}else{if(!$F("pass")){alert(IMP.text.login_password);$("pass").focus();return false}else{$("loginButton").disable();if(ie_clientcaps){try{$("ie_version").setValue(objCCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid"))}catch(a){}}$("imp_login").submit();return true}}}function selectLang(){if(!$F("imapuser")&&!$F("pass")){var a={new_lang:$F("new_lang")};if(lang_url!==null){a.url=lang_url}self.location="login.php?"+Object.toQueryString(a)}}function removeHash(a){return(Object.isString(a)&&a.startsWith("#"))?a.substring(1):a}document.observe("dom:loaded",function(){if(imp_auth){if(parent.frames.horde_main){if(nomenu){parent.location=self.location}else{document.imp_login.target="_parent"}}}if(location.hash){$("anchor_string").setValue(removeHash(location.hash))}}); \ No newline at end of file +var ImpLogin={_reload:function(){window.top.document.location=this.autologin_url+$F("server_key")},submit:function(){if(this.show_list&&$F("server_key").startsWith("_")){return}if(!$F("imapuser")){alert(IMP.text.login_username);$("imapuser").focus()}else{if(!$F("pass")){alert(IMP.text.login_password);$("pass").focus()}else{$("loginButton").disable();if(this.ie_clientcaps){try{$("ie_version").setValue(objCCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid"))}catch(a){}}$("imp_login").submit()}}},_selectLang:function(){if(!$F("imapuser")&&!$F("pass")){var a={new_lang:$F("new_lang")};if(this.lang_url){a.url=this.lang_url}self.location="login.php?"+Object.toQueryString(a)}},_removeHash:function(a){return(Object.isString(a)&&a.startsWith("#"))?a.substring(1):a},onDomLoad:function(){if(this.imp_auth){if(parent.frames.horde_main){if(this.nomenu){parent.location=self.location}else{document.imp_login.target="_parent"}}}document.observe("change",this._changeHandler.bindAsEventListner(this));document.observe("click",this._clickHandler.bindAsEventListner(this));if(location.hash){$("anchor_string").setValue(this._removeHash(location.hash))}if(!$F("imapuser")){$("imapuser").focus()}else{$("pass").focus()}if(this.reloadmenu&&window.parent.frames.horde_menu){window.parent.frames.horde_menu.location.reload()}},_changeHandler:function(a){switch(a.element().readAttribute("id")){case"new_lang":this._selectLang();break;case"server_key":this._reload();break}},_clickHandler:function(a){switch(a.element().readAttribute("id")){case"btn_login":this._reload();break;case"loginButton":this._submit();break}}};document.observe("dom:loaded",ImpLogin.onDomLoad.bin(ImpLogin)); \ No newline at end of file diff --git a/imp/js/src/login.js b/imp/js/src/login.js index 8ee82746e..62c481fe5 100644 --- a/imp/js/src/login.js +++ b/imp/js/src/login.js @@ -5,77 +5,114 @@ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. */ -function setFocus() -{ - if (!$F('imapuser')) { - $('imapuser').focus(); - } else { - $('pass').focus(); - } -} +var ImpLogin = { + // The following variables are defined in login.php: + // autologin_url, imp_auth, lang_url, show_list -function imp_reload() -{ - window.top.document.location = autologin_url + $F('server_key'); -} + _reload: function() + { + window.top.document.location = this.autologin_url + $F('server_key'); + }, -function submit_login() -{ - if (show_list && $F('server_key').startsWith('_')) { - return false; - } - if (!$F('imapuser')) { - alert(IMP.text.login_username); - $('imapuser').focus(); - return false; - } else if (!$F('pass')) { - alert(IMP.text.login_password); - $('pass').focus(); - return false; - } else { - $('loginButton').disable(); - if (ie_clientcaps) { - try { - $('ie_version').setValue(objCCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid")); - } catch (e) { } + submit: function() + { + if (this.show_list && $F('server_key').startsWith('_')) { + return; } - $('imp_login').submit(); - return true; - } -} - -function selectLang() -{ - // We need to reload the login page here, but only if the user hasn't - // already entered a username and password. - if (!$F('imapuser') && !$F('pass')) { - var params = { new_lang: $F('new_lang') }; - if (lang_url !== null) { - params.url = lang_url; + + if (!$F('imapuser')) { + alert(IMP.text.login_username); + $('imapuser').focus(); + } else if (!$F('pass')) { + alert(IMP.text.login_password); + $('pass').focus(); + } else { + $('loginButton').disable(); + if (this.ie_clientcaps) { + try { + $('ie_version').setValue(objCCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid")); + } catch (e) { } + } + $('imp_login').submit(); } - self.location = 'login.php?' + Object.toQueryString(params); - } -} - -/* Removes any leading hash that might be on a location string. */ -function removeHash(h) -{ - return (Object.isString(h) && h.startsWith("#")) ? h.substring(1) : h; -} - -document.observe('dom:loaded', function() { - if (imp_auth) { - if (parent.frames.horde_main) { - if (nomenu) { - parent.location = self.location; - } else { - document.imp_login.target = '_parent'; + }, + + _selectLang: function() + { + // We need to reload the login page here, but only if the user hasn't + // already entered a username and password. + if (!$F('imapuser') && !$F('pass')) { + var params = { new_lang: $F('new_lang') }; + if (this.lang_url) { + params.url = this.lang_url; } + self.location = 'login.php?' + Object.toQueryString(params); } - } + }, + + /* Removes any leading hash that might be on a location string. */ + _removeHash: function(h) + { + return (Object.isString(h) && h.startsWith("#")) ? h.substring(1) : h; + }, + + onDomLoad: function() + { + if (this.imp_auth) { + if (parent.frames.horde_main) { + if (this.nomenu) { + parent.location = self.location; + } else { + document.imp_login.target = '_parent'; + } + } + } + + document.observe('change', this._changeHandler.bindAsEventListner(this)); + document.observe('click', this._clickHandler.bindAsEventListner(this)); - // Need to capture hash information if it exists in URL - if (location.hash) { - $('anchor_string').setValue(removeHash(location.hash)); + // Need to capture hash information if it exists in URL + if (location.hash) { + $('anchor_string').setValue(this._removeHash(location.hash)); + } + + if (!$F('imapuser')) { + $('imapuser').focus(); + } else { + $('pass').focus(); + } + + if (this.reloadmenu && window.parent.frames.horde_menu) { + window.parent.frames.horde_menu.location.reload(); + } + }, + + _changeHandler: function(e) + { + switch (e.element().readAttribute('id')) { + case 'new_lang': + this._selectLang(); + break; + + case 'server_key': + this._reload(); + break; + } + }, + + _clickHandler: function(e) + { + switch (e.element().readAttribute('id')) { + case 'btn_login': + this._reload(); + break; + + case 'loginButton': + this._submit(); + break; + } } -}); + +}; + +document.observe('dom:loaded', ImpLogin.onDomLoad.bin(ImpLogin)); diff --git a/imp/login.php b/imp/login.php index 9e4a96f9a..cf1976bd9 100644 --- a/imp/login.php +++ b/imp/login.php @@ -141,12 +141,6 @@ if (!$logout_reason && IMP_Session::canAutoLogin($server_key, $autologin)) { exit; } -if ($logout_reason && $imp_auth && $conf['menu']['always']) { - $notification->push('setFocus();if (window.parent.frames.horde_menu) window.parent.frames.horde_menu.location.reload();', 'javascript'); -} else { - $notification->push('setFocus()', 'javascript'); -} - $reason = $auth->getLogoutReasonString(); $title = sprintf(_("Welcome to %s"), $registry->get('name', ($imp_auth) ? 'horde' : null)); @@ -332,14 +326,18 @@ $login_page = true; Horde::addScriptFile('prototype.js', 'horde', true); Horde::addScriptFile('login.js', 'imp', true); require IMP_TEMPLATES . '/common-header.inc'; + +$charset = NLS::getCharset(); IMP::addInlineScript(array( - 'var autologin_url = \'' . Util::addParameter(Horde::selfUrl(), array('autologin' => $autologin, 'server_key' => '')) . '\'', - 'var show_list = ' . intval($show_list), - 'var ie_clientcaps = ' . intval($t->get('ie_clientcaps')), - 'var lang_url = ' . ((is_null($lang_url)) ? 'null' : '\'' . $lang_url . '\''), - 'var imp_auth = ' . intval($imp_auth), - 'var nomenu = ' . intval(empty($conf['menu']['always'])), + 'ImpLogin.autologin_url = ' . Horde_Serialize::serialize(Util::addParameter(Horde::selfUrl(), array('autologin' => $autologin, 'server_key' => '')), SERIALIZE_JSON, $charset), + 'ImpLogin.ie_clientcaps = ' . intval($t->get('ie_clientcaps')), + 'ImpLogin.imp_auth = ' . intval($imp_auth), + 'ImpLogin.lang_url = ' . Horde_Serialize::serialize($lang_url, SERIALIZE_JSON, $charset), + 'ImpLogin.nomenu = ' . intval(empty($conf['menu']['always'])), + 'ImpLogin.reloadmenu = ' . (boolean) ($logout_reason && $imp_auth && $conf['menu']['always']), + 'ImpLogin.show_list = ' . intval($show_list), )); + echo $t->fetch(IMP_TEMPLATES . '/login/login.html'); Horde::loadConfiguration('motd.php', null, null, true); diff --git a/imp/templates/login/login.html b/imp/templates/login/login.html index 6ba1e2652..756562331 100644 --- a/imp/templates/login/login.html +++ b/imp/templates/login/login.html @@ -32,12 +32,12 @@ - - + @@ -73,7 +73,7 @@ - @@ -98,7 +98,7 @@   - +