http://www.mediawiki.org/wiki/Special:Code/MediaWiki/61469
Revision: 61469 Author: ashley Date: 2010-01-24 18:20:12 +0000 (Sun, 24 Jan 2010) Log Message: ----------- AjaxLogin: *don't load any AjaxLogin stuff for Special:UserLogin *move inline styles to CSS file *replace deprecated font tag with span + CSS styling *bump version number Modified Paths: -------------- trunk/extensions/AjaxLogin/AjaxLogin.css trunk/extensions/AjaxLogin/AjaxLogin.js trunk/extensions/AjaxLogin/AjaxLogin.php Modified: trunk/extensions/AjaxLogin/AjaxLogin.css =================================================================== --- trunk/extensions/AjaxLogin/AjaxLogin.css 2010-01-24 17:15:21 UTC (rev 61468) +++ trunk/extensions/AjaxLogin/AjaxLogin.css 2010-01-24 18:20:12 UTC (rev 61469) @@ -1,8 +1,6 @@ -/*** AJAX LOGIN ***/ +/* CSS for AjaxLogin extension */ + /* styles copied from monaco/css/header.css */ -#userloginRound_c { z-index: 2000 !important; } -#userloginRound_mask { z-index: 1000 !important; } - #userloginRound .r_boxContent { background-color: #fff; color: #000000; @@ -11,13 +9,12 @@ #userloginRound .boxHeader { padding: 3px 5px; - font-size: 12px; /* Jack: added this */ + font-size: 12px; } #userloginRound form { padding: 3px; font-size: 12px; -/* font-size: 0.9em; original -- doesn't look too good on monobook*/ } /* copied from monaco/css/root.css */ @@ -25,10 +22,50 @@ background-color: #36C; color: white; } + .color2 { background-color: #F5F5F5; } +#userajaxloginform { + margin: 5px; +} + +#wpClose { + float: right; + cursor: pointer; +} + +#wpClose span { + font-size: 2em; + font-weight: bold; + color: #FFFFFF; +} + +#wpLoginattempt { + margin: 0; + padding: 0 .25em; + width: auto; + overflow: visible; +} + +#wpError { + width: 250px; + line-height: 1.4em; +} + +#ajaxLoginRememberMe { + padding-bottom: 3px; +} + +#wpMailmypassword { + margin: 3px 0; + padding: 0 .25em; + width: auto; + overflow: visible; + font-size: 0.9em; +} + .jqmWindow { display: none; position: fixed; @@ -40,7 +77,9 @@ border: 1px solid black; } -.jqmOverlay { background-color: #000; } +.jqmOverlay { + background-color: #000; +} /* Fixed posistioning emulation for IE6 * Star selector used to hide definition from browsers other than IE6 Modified: trunk/extensions/AjaxLogin/AjaxLogin.js =================================================================== --- trunk/extensions/AjaxLogin/AjaxLogin.js 2010-01-24 17:15:21 UTC (rev 61468) +++ trunk/extensions/AjaxLogin/AjaxLogin.js 2010-01-24 18:20:12 UTC (rev 61469) @@ -13,27 +13,27 @@ }; mediawiki.AjaxLogin.prototype.initialize = function() { - this._loginPanel = $("#userloginRound"); - this._loginForm = $("#userajaxloginform"); + this._loginPanel = $('#userloginRound'); + this._loginForm = $('#userajaxloginform'); if( this._loginPanel.length > 0 ) { this._loginPanel.jqm({modal : true, toTop : true}); var that = this; - $("#pt-anonlogin, #pt-login").click( function( event ) { + $('#pt-anonlogin, #pt-login').click( function( event ) { event.preventDefault(); that.showLoginPanel(); }); - $("#wpLoginattempt").click(function( event ) { + $('#wpLoginattempt').click(function( event ) { event.preventDefault(); that.postAjax( 'wpLoginattempt' ); }); - $("#wpMailmypassword").click(function( event ) { + $('#wpMailmypassword').click(function( event ) { event.preventDefault(); that.postAjax( 'wpMailmypassword' ); }); - $("#wpAjaxRegister").click(function( event ) { + $('#wpAjaxRegister').click(function( event ) { that.doRegister( event ); }); - $("#wpClose").click(function( event ) { + $('#wpClose').click(function( event ) { that.doClose( event ); }); } @@ -58,9 +58,9 @@ success : function( data ) { that.requestSuccess( data ); }, - error : function( XMLHttpRequest, textStatus, errorThrown ){ - //TODO : add error handling here - if( typeof console != 'undefined' ){ + error : function( XMLHttpRequest, textStatus, errorThrown ) { + // TODO : add error handling here + if( typeof console != 'undefined' ) { console.log( 'Error in AjaxLogin.js!' ); } } @@ -68,31 +68,31 @@ }; mediawiki.AjaxLogin.prototype.enableForm = function() { - $("#wpName1").removeAttr('disabled'); - $("#wpPassword1").removeAttr('disabled'); - $("#wpLoginattempt").removeAttr('disabled'); - $("#wpRemember").removeAttr('disabled'); - $("#wpMailmypassword").removeAttr('disabled'); - $("#wpPassword1").removeAttr('disabled'); - $("#wpClose").removeAttr('disabled'); + $('#wpName1').removeAttr('disabled'); + $('#wpPassword1').removeAttr('disabled'); + $('#wpLoginattempt').removeAttr('disabled'); + $('#wpRemember').removeAttr('disabled'); + $('#wpMailmypassword').removeAttr('disabled'); + $('#wpPassword1').removeAttr('disabled'); + $('#wpClose').removeAttr('disabled'); }; mediawiki.AjaxLogin.prototype.disableForm = function() { - $("#wpName1").attr('disabled', 'disabled'); - $("#wpPassword1").attr('disabled', 'disabled'); - $("#wpLoginattempt").attr('disabled', 'disabled'); - $("#wpRemember").attr('disabled', 'disabled'); - $("#wpMailmypassword").attr('disabled', 'disabled'); - $("#wpPassword1").attr('disabled', 'disabled'); - $("#wpClose").attr('disabled', 'disabled'); + $('#wpName1').attr('disabled', 'disabled'); + $('#wpPassword1').attr('disabled', 'disabled'); + $('#wpLoginattempt').attr('disabled', 'disabled'); + $('#wpRemember').attr('disabled', 'disabled'); + $('#wpMailmypassword').attr('disabled', 'disabled'); + $('#wpPassword1').attr('disabled', 'disabled'); + $('#wpClose').attr('disabled', 'disabled'); }; mediawiki.AjaxLogin.prototype.displayReason = function( reason ) { - $("#wpError").html(reason + '<br /><br />').show(); + $('#wpError').html(reason + '<br /><br />').show(); }; -mediawiki.AjaxLogin.prototype.doRegister = function( event ){ - if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) { +mediawiki.AjaxLogin.prototype.doRegister = function( event ) { + if( $('#wpPreview').length > 0 && $('#wpLogin').length > 0 ) { if( typeof( ajaxLogin2 ) != 'undefined' && !confirm( ajaxLogin2 ) ) { event.preventDefault(); } @@ -100,13 +100,13 @@ }; mediawiki.AjaxLogin.prototype.refreshForm = function() { - $("#wpName1").val(''); - $("#wpPassword1").val(''); - $("#wpError").html(''); + $('#wpName1').val(''); + $('#wpPassword1').val(''); + $('#wpError').html(''); this.enableForm(); }; -mediawiki.AjaxLogin.prototype.doClose = function( event ){ +mediawiki.AjaxLogin.prototype.doClose = function( event ) { this._loginPanel.jqmHide(); }; @@ -114,7 +114,7 @@ var responseResult = data.ajaxlogin.result; switch( responseResult ) { case 'Reset': - if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) { + if( $('#wpPreview').length > 0 && $('#wpLogin').length > 0 ) { if( typeof( ajaxLogin1 ) != 'undefined' && !confirm( ajaxLogin1 ) ) { break; } @@ -126,14 +126,14 @@ this.enableForm(); break; case 'Success': - if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) { - if( $("#wikiDiff").length > 0 && ( $("#wikiDiff").children.length > 0 ) ) { - $("#wpDiff").click(); + if( $('#wpPreview').length > 0 && $('#wpLogin').length > 0 ) { + if( $('#wikiDiff').length > 0 && ( $('#wikiDiff').children.length > 0 ) ) { + $('#wpDiff').click(); } else { - if( $("#wikiPreview") && $("#wikiPreview").children.length == 0 ) { - $("#wpLogin").val( 1 ); + if( $('#wikiPreview') && $('#wikiPreview').children.length == 0 ) { + $('#wpLogin').val( 1 ); } - $("#wpPreview").click(); + $('#wpPreview').click(); } } else { if( wgCanonicalSpecialPageName == 'Userlogout' ) { @@ -145,13 +145,13 @@ break; case 'NotExists': this.enableForm(); - $("#wpName1").value = ''; - $("#wpPassword1").value = ''; - $("#wpName1").focus(); + $('#wpName1').value = ''; + $('#wpPassword1').value = ''; + $('#wpName1').focus(); case 'WrongPass': this.enableForm(); - $("#wpPassword1").val(''); - $("#wpPassword1").focus(); + $('#wpPassword1').val(''); + $('#wpPassword1').focus(); default: this.enableForm(); this.displayReason( data.ajaxlogin.text ); Modified: trunk/extensions/AjaxLogin/AjaxLogin.php =================================================================== --- trunk/extensions/AjaxLogin/AjaxLogin.php 2010-01-24 17:15:21 UTC (rev 61468) +++ trunk/extensions/AjaxLogin/AjaxLogin.php 2010-01-24 18:20:12 UTC (rev 61469) @@ -4,7 +4,7 @@ * * @file * @ingroup Extensions - * @version 2.0.0 + * @version 2.1.0 * @author Inez Korczyński <korczynski(at)gmail(dot)com> * @author Jack Phoenix <j...@countervandalism.net> * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later @@ -18,7 +18,7 @@ $wgExtensionCredits['other'][] = array( 'path' => __FILE__, 'name' => 'AjaxLogin', - 'version' => '2.0.0', + 'version' => '2.1.0', 'author' => array( 'Inez Korczyński', 'Jack Phoenix' ), 'description' => 'Dynamic box which allow users to login and remind password', 'url' => 'http://www.mediawiki.org/wiki/Extension:AjaxLogin', @@ -52,16 +52,16 @@ * @return true */ function AjaxLoginJS( OutputPage $out ) { - global $wgEnableAjaxLogin, $wgScriptPath; + global $wgEnableAjaxLogin, $wgScriptPath, $wgTitle; - # Don't load anything if AjaxLogin isn't enabled - if ( !isset( $wgEnableAjaxLogin ) ) { + # Don't load anything if AjaxLogin isn't enabled or if we're on login page + if ( !isset( $wgEnableAjaxLogin ) || $wgTitle->isSpecial( 'Userlogin' ) ) { return true; } // Our custom CSS $out->addExtensionStyle( $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.css' ); - // JQuery and JQModal scripts + // jQuery and JQModal scripts $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jquery-1.3.2.js' ); $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jqModal.js' ); $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.js' ); @@ -90,50 +90,54 @@ } /** - * Gets the AjaxLogin form + * Adds the AjaxLogin form to the skin output for anonymous users on non-login + * pages * * @param $data The data, AjaxLogin form in this case, to be added to the HTML output of a page * @return true */ function GetAjaxLoginForm( &$data ) { global $wgAuth, $wgEnableEmail, $wgOut, $wgTitle, $wgUser; - if ( $wgUser->isAnon() && $wgTitle->getNamespace() != 8 && $wgTitle->getDBkey() != 'Userlogin' ) { + global $wgEnableAjaxLogin; + if ( + isset( $wgEnableAjaxLogin ) && $wgUser->isAnon() && + $wgTitle->getNamespace() != 8 && !$wgTitle->isSpecial( 'Userlogin' ) + ) { $titleObj = SpecialPage::getTitleFor( 'Userlogin' ); - $link = $titleObj->getLocalUrl( 'type=signup' ); + $link = $titleObj->getLocalURL( 'type=signup' ); $wgOut->addHTML( '<!--[if lt IE 9]><style type="text/css">#userloginRound { width: 350px !important; }</style><![endif]--> <div id="userloginRound" class="roundedDiv jqmWindow"> <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b> <div class="r_boxContent"> <div> - <div name="wpClose" id="wpClose" value="' . wfMsg( 'close' ) . '" style ="float:right;cursor:pointer;"><a href="#" tabindex="108"><font size="4" color="white"><b>X</b></font></a> - </div> - <div class="boxHeader color1"> - ' . wfMsg( 'login' ) . ' + <div id="wpClose"><a href="#" tabindex="108"><span>X</span></a></div> + <div class="boxHeader color1">' . wfMsg( 'login' ) . '</div> </div> - </div> - <form action="" method="post" name="userajaxloginform" id="userajaxloginform" style="margin:5px"> - <div id="wpError" style="width: 250px; line-height: 1.4em;"></div> + <form action="" method="post" name="userajaxloginform" id="userajaxloginform"> + <div id="wpError"></div> <label>' . wfMsg( 'loginprompt' ) . '</label><br /><br /> <label for="wpName1">' . wfMsg( 'yourname' ) . '</label><br /> <input type="text" class="loginText" name="wpName" id="wpName1" tabindex="101" size="20" /><br /> <label for="wpPassword1">' . wfMsg( 'yourpassword' ) . '</label><br /> <input type="password" class="loginPassword" name="wpPassword" id="wpPassword1" tabindex="102" size="20" /><br /> - <div style="padding-bottom:3px"> + <div id="ajaxLoginRememberMe"> <input type="checkbox" name="wpRemember" tabindex="104" value="1" id="wpRemember1"' . ( $wgUser->getOption( 'rememberpassword' ) ? ' checked="checked"' : '' ) . ' /> <label for="wpRemember1">' . wfMsg( 'remembermypassword' ) . '</label><br /> </div> - <input style="margin:0;padding:0 .25em;width:auto;overflow:visible;" type="submit" name="wpLoginattempt" id="wpLoginattempt" tabindex="105" value="' . wfMsg( 'login' ) . '" />' + <input type="submit" name="wpLoginattempt" id="wpLoginattempt" tabindex="105" value="' . wfMsg( 'login' ) . '" />' . "\n" ); if ( $wgEnableEmail && $wgAuth->allowPasswordChange() ) { - $wgOut->addHTML( '<br /><input style="margin:3px 0;padding:0 .25em;width:auto;overflow:visible;font-size:0.9em" type="submit" name="wpMailmypassword" id="wpMailmypassword" tabindex="106" value="' . wfMsg( 'mailmypassword' ) . '" />' ); + $wgOut->addHTML( "\t\t\t" . '<br /><input type="submit" name="wpMailmypassword" id="wpMailmypassword" tabindex="106" value="' . wfMsg( 'mailmypassword' ) . '" />' . "\n\t\t\t" ); } // Originally this used core message 'nologinlink' but it wouldn't work too well for Finnish, so I changed it. --Jack Phoenix wfLoadExtensionMessages( 'AjaxLogin' ); - $wgOut->addHTML( '<br /><a id="wpAjaxRegister" tabindex="107" href="' . htmlspecialchars( $link ) . '">' . wfMsg( 'ajaxlogin-create' ) . '</a> + $wgOut->addHTML( + '<br /><a id="wpAjaxRegister" tabindex="107" href="' . htmlspecialchars( $link ) . '">' . wfMsg( 'ajaxlogin-create' ) . '</a> </form> </div> <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b> -</div>' ); + </div>' . "\n" + ); } return true; } \ No newline at end of file _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs