r61469 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61468‎ | r61469 | r61470 >
Date:18:20, 24 January 2010
Author:ashley
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /trunk/extensions/AjaxLogin/AjaxLogin.js (modified) (history)
  • /trunk/extensions/AjaxLogin/AjaxLogin.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AjaxLogin/AjaxLogin.php
@@ -4,7 +4,7 @@
55 *
66 * @file
77 * @ingroup Extensions
8 - * @version 2.0.0
 8+ * @version 2.1.0
99 * @author Inez Korczyński <korczynski(at)gmail(dot)com>
1010 * @author Jack Phoenix <jack@countervandalism.net>
1111 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
@@ -18,7 +18,7 @@
1919 $wgExtensionCredits['other'][] = array(
2020 'path' => __FILE__,
2121 'name' => 'AjaxLogin',
22 - 'version' => '2.0.0',
 22+ 'version' => '2.1.0',
2323 'author' => array( 'Inez Korczyński', 'Jack Phoenix' ),
2424 'description' => 'Dynamic box which allow users to login and remind password',
2525 'url' => 'http://www.mediawiki.org/wiki/Extension:AjaxLogin',
@@ -52,16 +52,16 @@
5353 * @return true
5454 */
5555 function AjaxLoginJS( OutputPage $out ) {
56 - global $wgEnableAjaxLogin, $wgScriptPath;
 56+ global $wgEnableAjaxLogin, $wgScriptPath, $wgTitle;
5757
58 - # Don't load anything if AjaxLogin isn't enabled
59 - if ( !isset( $wgEnableAjaxLogin ) ) {
 58+ # Don't load anything if AjaxLogin isn't enabled or if we're on login page
 59+ if ( !isset( $wgEnableAjaxLogin ) || $wgTitle->isSpecial( 'Userlogin' ) ) {
6060 return true;
6161 }
6262
6363 // Our custom CSS
6464 $out->addExtensionStyle( $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.css' );
65 - // JQuery and JQModal scripts
 65+ // jQuery and JQModal scripts
6666 $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jquery-1.3.2.js' );
6767 $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jqModal.js' );
6868 $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.js' );
@@ -90,50 +90,54 @@
9191 }
9292
9393 /**
94 - * Gets the AjaxLogin form
 94+ * Adds the AjaxLogin form to the skin output for anonymous users on non-login
 95+ * pages
9596 *
9697 * @param $data The data, AjaxLogin form in this case, to be added to the HTML output of a page
9798 * @return true
9899 */
99100 function GetAjaxLoginForm( &$data ) {
100101 global $wgAuth, $wgEnableEmail, $wgOut, $wgTitle, $wgUser;
101 - if ( $wgUser->isAnon() && $wgTitle->getNamespace() != 8 && $wgTitle->getDBkey() != 'Userlogin' ) {
 102+ global $wgEnableAjaxLogin;
 103+ if (
 104+ isset( $wgEnableAjaxLogin ) && $wgUser->isAnon() &&
 105+ $wgTitle->getNamespace() != 8 && !$wgTitle->isSpecial( 'Userlogin' )
 106+ ) {
102107 $titleObj = SpecialPage::getTitleFor( 'Userlogin' );
103 - $link = $titleObj->getLocalUrl( 'type=signup' );
 108+ $link = $titleObj->getLocalURL( 'type=signup' );
104109 $wgOut->addHTML( '<!--[if lt IE 9]><style type="text/css">#userloginRound { width: 350px !important; }</style><![endif]-->
105110 <div id="userloginRound" class="roundedDiv jqmWindow">
106111 <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
107112 <div class="r_boxContent">
108113 <div>
109 - <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>
110 - </div>
111 - <div class="boxHeader color1">
112 - ' . wfMsg( 'login' ) . '
 114+ <div id="wpClose"><a href="#" tabindex="108"><span>X</span></a></div>
 115+ <div class="boxHeader color1">' . wfMsg( 'login' ) . '</div>
113116 </div>
114 - </div>
115 - <form action="" method="post" name="userajaxloginform" id="userajaxloginform" style="margin:5px">
116 - <div id="wpError" style="width: 250px; line-height: 1.4em;"></div>
 117+ <form action="" method="post" name="userajaxloginform" id="userajaxloginform">
 118+ <div id="wpError"></div>
117119 <label>' . wfMsg( 'loginprompt' ) . '</label><br /><br />
118120 <label for="wpName1">' . wfMsg( 'yourname' ) . '</label><br />
119121 <input type="text" class="loginText" name="wpName" id="wpName1" tabindex="101" size="20" /><br />
120122 <label for="wpPassword1">' . wfMsg( 'yourpassword' ) . '</label><br />
121123 <input type="password" class="loginPassword" name="wpPassword" id="wpPassword1" tabindex="102" size="20" /><br />
122 - <div style="padding-bottom:3px">
 124+ <div id="ajaxLoginRememberMe">
123125 <input type="checkbox" name="wpRemember" tabindex="104" value="1" id="wpRemember1"' . ( $wgUser->getOption( 'rememberpassword' ) ? ' checked="checked"' : '' ) . ' />
124126 <label for="wpRemember1">' . wfMsg( 'remembermypassword' ) . '</label><br />
125127 </div>
126 - <input style="margin:0;padding:0 .25em;width:auto;overflow:visible;" type="submit" name="wpLoginattempt" id="wpLoginattempt" tabindex="105" value="' . wfMsg( 'login' ) . '" />'
 128+ <input type="submit" name="wpLoginattempt" id="wpLoginattempt" tabindex="105" value="' . wfMsg( 'login' ) . '" />' . "\n"
127129 );
128130 if ( $wgEnableEmail && $wgAuth->allowPasswordChange() ) {
129 - $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' ) . '" />' );
 131+ $wgOut->addHTML( "\t\t\t" . '<br /><input type="submit" name="wpMailmypassword" id="wpMailmypassword" tabindex="106" value="' . wfMsg( 'mailmypassword' ) . '" />' . "\n\t\t\t" );
130132 }
131133 // Originally this used core message 'nologinlink' but it wouldn't work too well for Finnish, so I changed it. --Jack Phoenix
132134 wfLoadExtensionMessages( 'AjaxLogin' );
133 - $wgOut->addHTML( '<br /><a id="wpAjaxRegister" tabindex="107" href="' . htmlspecialchars( $link ) . '">' . wfMsg( 'ajaxlogin-create' ) . '</a>
 135+ $wgOut->addHTML(
 136+ '<br /><a id="wpAjaxRegister" tabindex="107" href="' . htmlspecialchars( $link ) . '">' . wfMsg( 'ajaxlogin-create' ) . '</a>
134137 </form>
135138 </div>
136139 <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
137 -</div>' );
 140+ </div>' . "\n"
 141+ );
138142 }
139143 return true;
140144 }
\ No newline at end of file
Index: trunk/extensions/AjaxLogin/AjaxLogin.css
@@ -1,8 +1,6 @@
2 -/*** AJAX LOGIN ***/
 2+/* CSS for AjaxLogin extension */
 3+
34 /* styles copied from monaco/css/header.css */
4 -#userloginRound_c { z-index: 2000 !important; }
5 -#userloginRound_mask { z-index: 1000 !important; }
6 -
75 #userloginRound .r_boxContent {
86 background-color: #fff;
97 color: #000000;
@@ -11,13 +9,12 @@
1210
1311 #userloginRound .boxHeader {
1412 padding: 3px 5px;
15 - font-size: 12px; /* Jack: added this */
 13+ font-size: 12px;
1614 }
1715
1816 #userloginRound form {
1917 padding: 3px;
2018 font-size: 12px;
21 -/* font-size: 0.9em; original -- doesn't look too good on monobook*/
2219 }
2320
2421 /* copied from monaco/css/root.css */
@@ -25,10 +22,50 @@
2623 background-color: #36C;
2724 color: white;
2825 }
 26+
2927 .color2 {
3028 background-color: #F5F5F5;
3129 }
3230
 31+#userajaxloginform {
 32+ margin: 5px;
 33+}
 34+
 35+#wpClose {
 36+ float: right;
 37+ cursor: pointer;
 38+}
 39+
 40+#wpClose span {
 41+ font-size: 2em;
 42+ font-weight: bold;
 43+ color: #FFFFFF;
 44+}
 45+
 46+#wpLoginattempt {
 47+ margin: 0;
 48+ padding: 0 .25em;
 49+ width: auto;
 50+ overflow: visible;
 51+}
 52+
 53+#wpError {
 54+ width: 250px;
 55+ line-height: 1.4em;
 56+}
 57+
 58+#ajaxLoginRememberMe {
 59+ padding-bottom: 3px;
 60+}
 61+
 62+#wpMailmypassword {
 63+ margin: 3px 0;
 64+ padding: 0 .25em;
 65+ width: auto;
 66+ overflow: visible;
 67+ font-size: 0.9em;
 68+}
 69+
3370 .jqmWindow {
3471 display: none;
3572 position: fixed;
@@ -40,7 +77,9 @@
4178 border: 1px solid black;
4279 }
4380
44 -.jqmOverlay { background-color: #000; }
 81+.jqmOverlay {
 82+ background-color: #000;
 83+}
4584
4685 /* Fixed posistioning emulation for IE6
4786 * Star selector used to hide definition from browsers other than IE6
Index: trunk/extensions/AjaxLogin/AjaxLogin.js
@@ -13,27 +13,27 @@
1414 };
1515
1616 mediawiki.AjaxLogin.prototype.initialize = function() {
17 - this._loginPanel = $("#userloginRound");
18 - this._loginForm = $("#userajaxloginform");
 17+ this._loginPanel = $('#userloginRound');
 18+ this._loginForm = $('#userajaxloginform');
1919 if( this._loginPanel.length > 0 ) {
2020 this._loginPanel.jqm({modal : true, toTop : true});
2121 var that = this;
22 - $("#pt-anonlogin, #pt-login").click( function( event ) {
 22+ $('#pt-anonlogin, #pt-login').click( function( event ) {
2323 event.preventDefault();
2424 that.showLoginPanel();
2525 });
26 - $("#wpLoginattempt").click(function( event ) {
 26+ $('#wpLoginattempt').click(function( event ) {
2727 event.preventDefault();
2828 that.postAjax( 'wpLoginattempt' );
2929 });
30 - $("#wpMailmypassword").click(function( event ) {
 30+ $('#wpMailmypassword').click(function( event ) {
3131 event.preventDefault();
3232 that.postAjax( 'wpMailmypassword' );
3333 });
34 - $("#wpAjaxRegister").click(function( event ) {
 34+ $('#wpAjaxRegister').click(function( event ) {
3535 that.doRegister( event );
3636 });
37 - $("#wpClose").click(function( event ) {
 37+ $('#wpClose').click(function( event ) {
3838 that.doClose( event );
3939 });
4040 }
@@ -58,9 +58,9 @@
5959 success : function( data ) {
6060 that.requestSuccess( data );
6161 },
62 - error : function( XMLHttpRequest, textStatus, errorThrown ){
63 - //TODO : add error handling here
64 - if( typeof console != 'undefined' ){
 62+ error : function( XMLHttpRequest, textStatus, errorThrown ) {
 63+ // TODO : add error handling here
 64+ if( typeof console != 'undefined' ) {
6565 console.log( 'Error in AjaxLogin.js!' );
6666 }
6767 }
@@ -68,31 +68,31 @@
6969 };
7070
7171 mediawiki.AjaxLogin.prototype.enableForm = function() {
72 - $("#wpName1").removeAttr('disabled');
73 - $("#wpPassword1").removeAttr('disabled');
74 - $("#wpLoginattempt").removeAttr('disabled');
75 - $("#wpRemember").removeAttr('disabled');
76 - $("#wpMailmypassword").removeAttr('disabled');
77 - $("#wpPassword1").removeAttr('disabled');
78 - $("#wpClose").removeAttr('disabled');
 72+ $('#wpName1').removeAttr('disabled');
 73+ $('#wpPassword1').removeAttr('disabled');
 74+ $('#wpLoginattempt').removeAttr('disabled');
 75+ $('#wpRemember').removeAttr('disabled');
 76+ $('#wpMailmypassword').removeAttr('disabled');
 77+ $('#wpPassword1').removeAttr('disabled');
 78+ $('#wpClose').removeAttr('disabled');
7979 };
8080
8181 mediawiki.AjaxLogin.prototype.disableForm = function() {
82 - $("#wpName1").attr('disabled', 'disabled');
83 - $("#wpPassword1").attr('disabled', 'disabled');
84 - $("#wpLoginattempt").attr('disabled', 'disabled');
85 - $("#wpRemember").attr('disabled', 'disabled');
86 - $("#wpMailmypassword").attr('disabled', 'disabled');
87 - $("#wpPassword1").attr('disabled', 'disabled');
88 - $("#wpClose").attr('disabled', 'disabled');
 82+ $('#wpName1').attr('disabled', 'disabled');
 83+ $('#wpPassword1').attr('disabled', 'disabled');
 84+ $('#wpLoginattempt').attr('disabled', 'disabled');
 85+ $('#wpRemember').attr('disabled', 'disabled');
 86+ $('#wpMailmypassword').attr('disabled', 'disabled');
 87+ $('#wpPassword1').attr('disabled', 'disabled');
 88+ $('#wpClose').attr('disabled', 'disabled');
8989 };
9090
9191 mediawiki.AjaxLogin.prototype.displayReason = function( reason ) {
92 - $("#wpError").html(reason + '<br /><br />').show();
 92+ $('#wpError').html(reason + '<br /><br />').show();
9393 };
9494
95 -mediawiki.AjaxLogin.prototype.doRegister = function( event ){
96 - if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) {
 95+mediawiki.AjaxLogin.prototype.doRegister = function( event ) {
 96+ if( $('#wpPreview').length > 0 && $('#wpLogin').length > 0 ) {
9797 if( typeof( ajaxLogin2 ) != 'undefined' && !confirm( ajaxLogin2 ) ) {
9898 event.preventDefault();
9999 }
@@ -100,13 +100,13 @@
101101 };
102102
103103 mediawiki.AjaxLogin.prototype.refreshForm = function() {
104 - $("#wpName1").val('');
105 - $("#wpPassword1").val('');
106 - $("#wpError").html('');
 104+ $('#wpName1').val('');
 105+ $('#wpPassword1').val('');
 106+ $('#wpError').html('');
107107 this.enableForm();
108108 };
109109
110 -mediawiki.AjaxLogin.prototype.doClose = function( event ){
 110+mediawiki.AjaxLogin.prototype.doClose = function( event ) {
111111 this._loginPanel.jqmHide();
112112 };
113113
@@ -114,7 +114,7 @@
115115 var responseResult = data.ajaxlogin.result;
116116 switch( responseResult ) {
117117 case 'Reset':
118 - if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) {
 118+ if( $('#wpPreview').length > 0 && $('#wpLogin').length > 0 ) {
119119 if( typeof( ajaxLogin1 ) != 'undefined' && !confirm( ajaxLogin1 ) ) {
120120 break;
121121 }
@@ -126,14 +126,14 @@
127127 this.enableForm();
128128 break;
129129 case 'Success':
130 - if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) {
131 - if( $("#wikiDiff").length > 0 && ( $("#wikiDiff").children.length > 0 ) ) {
132 - $("#wpDiff").click();
 130+ if( $('#wpPreview').length > 0 && $('#wpLogin').length > 0 ) {
 131+ if( $('#wikiDiff').length > 0 && ( $('#wikiDiff').children.length > 0 ) ) {
 132+ $('#wpDiff').click();
133133 } else {
134 - if( $("#wikiPreview") && $("#wikiPreview").children.length == 0 ) {
135 - $("#wpLogin").val( 1 );
 134+ if( $('#wikiPreview') && $('#wikiPreview').children.length == 0 ) {
 135+ $('#wpLogin').val( 1 );
136136 }
137 - $("#wpPreview").click();
 137+ $('#wpPreview').click();
138138 }
139139 } else {
140140 if( wgCanonicalSpecialPageName == 'Userlogout' ) {
@@ -145,13 +145,13 @@
146146 break;
147147 case 'NotExists':
148148 this.enableForm();
149 - $("#wpName1").value = '';
150 - $("#wpPassword1").value = '';
151 - $("#wpName1").focus();
 149+ $('#wpName1').value = '';
 150+ $('#wpPassword1').value = '';
 151+ $('#wpName1').focus();
152152 case 'WrongPass':
153153 this.enableForm();
154 - $("#wpPassword1").val('');
155 - $("#wpPassword1").focus();
 154+ $('#wpPassword1').val('');
 155+ $('#wpPassword1').focus();
156156 default:
157157 this.enableForm();
158158 this.displayReason( data.ajaxlogin.text );

Status & tagging log