Index: trunk/extensions/AjaxLogin/AjaxLogin.php |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | * @file |
7 | 7 | * @ingroup Extensions |
8 | | - * @version 2.0.0 |
| 8 | + * @version 2.1.0 |
9 | 9 | * @author Inez Korczyński <korczynski(at)gmail(dot)com> |
10 | 10 | * @author Jack Phoenix <jack@countervandalism.net> |
11 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | $wgExtensionCredits['other'][] = array( |
20 | 20 | 'path' => __FILE__, |
21 | 21 | 'name' => 'AjaxLogin', |
22 | | - 'version' => '2.0.0', |
| 22 | + 'version' => '2.1.0', |
23 | 23 | 'author' => array( 'Inez Korczyński', 'Jack Phoenix' ), |
24 | 24 | 'description' => 'Dynamic box which allow users to login and remind password', |
25 | 25 | 'url' => 'http://www.mediawiki.org/wiki/Extension:AjaxLogin', |
— | — | @@ -52,16 +52,16 @@ |
53 | 53 | * @return true |
54 | 54 | */ |
55 | 55 | function AjaxLoginJS( OutputPage $out ) { |
56 | | - global $wgEnableAjaxLogin, $wgScriptPath; |
| 56 | + global $wgEnableAjaxLogin, $wgScriptPath, $wgTitle; |
57 | 57 | |
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' ) ) { |
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Our custom CSS |
64 | 64 | $out->addExtensionStyle( $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.css' ); |
65 | | - // JQuery and JQModal scripts |
| 65 | + // jQuery and JQModal scripts |
66 | 66 | $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jquery-1.3.2.js' ); |
67 | 67 | $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jqModal.js' ); |
68 | 68 | $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.js' ); |
— | — | @@ -90,50 +90,54 @@ |
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | | - * Gets the AjaxLogin form |
| 94 | + * Adds the AjaxLogin form to the skin output for anonymous users on non-login |
| 95 | + * pages |
95 | 96 | * |
96 | 97 | * @param $data The data, AjaxLogin form in this case, to be added to the HTML output of a page |
97 | 98 | * @return true |
98 | 99 | */ |
99 | 100 | function GetAjaxLoginForm( &$data ) { |
100 | 101 | 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 | + ) { |
102 | 107 | $titleObj = SpecialPage::getTitleFor( 'Userlogin' ); |
103 | | - $link = $titleObj->getLocalUrl( 'type=signup' ); |
| 108 | + $link = $titleObj->getLocalURL( 'type=signup' ); |
104 | 109 | $wgOut->addHTML( '<!--[if lt IE 9]><style type="text/css">#userloginRound { width: 350px !important; }</style><![endif]--> |
105 | 110 | <div id="userloginRound" class="roundedDiv jqmWindow"> |
106 | 111 | <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b> |
107 | 112 | <div class="r_boxContent"> |
108 | 113 | <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> |
113 | 116 | </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> |
117 | 119 | <label>' . wfMsg( 'loginprompt' ) . '</label><br /><br /> |
118 | 120 | <label for="wpName1">' . wfMsg( 'yourname' ) . '</label><br /> |
119 | 121 | <input type="text" class="loginText" name="wpName" id="wpName1" tabindex="101" size="20" /><br /> |
120 | 122 | <label for="wpPassword1">' . wfMsg( 'yourpassword' ) . '</label><br /> |
121 | 123 | <input type="password" class="loginPassword" name="wpPassword" id="wpPassword1" tabindex="102" size="20" /><br /> |
122 | | - <div style="padding-bottom:3px"> |
| 124 | + <div id="ajaxLoginRememberMe"> |
123 | 125 | <input type="checkbox" name="wpRemember" tabindex="104" value="1" id="wpRemember1"' . ( $wgUser->getOption( 'rememberpassword' ) ? ' checked="checked"' : '' ) . ' /> |
124 | 126 | <label for="wpRemember1">' . wfMsg( 'remembermypassword' ) . '</label><br /> |
125 | 127 | </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" |
127 | 129 | ); |
128 | 130 | 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" ); |
130 | 132 | } |
131 | 133 | // Originally this used core message 'nologinlink' but it wouldn't work too well for Finnish, so I changed it. --Jack Phoenix |
132 | 134 | 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> |
134 | 137 | </form> |
135 | 138 | </div> |
136 | 139 | <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 | + ); |
138 | 142 | } |
139 | 143 | return true; |
140 | 144 | } |
\ 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 | + |
3 | 4 | /* styles copied from monaco/css/header.css */ |
4 | | -#userloginRound_c { z-index: 2000 !important; } |
5 | | -#userloginRound_mask { z-index: 1000 !important; } |
6 | | - |
7 | 5 | #userloginRound .r_boxContent { |
8 | 6 | background-color: #fff; |
9 | 7 | color: #000000; |
— | — | @@ -11,13 +9,12 @@ |
12 | 10 | |
13 | 11 | #userloginRound .boxHeader { |
14 | 12 | padding: 3px 5px; |
15 | | - font-size: 12px; /* Jack: added this */ |
| 13 | + font-size: 12px; |
16 | 14 | } |
17 | 15 | |
18 | 16 | #userloginRound form { |
19 | 17 | padding: 3px; |
20 | 18 | font-size: 12px; |
21 | | -/* font-size: 0.9em; original -- doesn't look too good on monobook*/ |
22 | 19 | } |
23 | 20 | |
24 | 21 | /* copied from monaco/css/root.css */ |
— | — | @@ -25,10 +22,50 @@ |
26 | 23 | background-color: #36C; |
27 | 24 | color: white; |
28 | 25 | } |
| 26 | + |
29 | 27 | .color2 { |
30 | 28 | background-color: #F5F5F5; |
31 | 29 | } |
32 | 30 | |
| 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 | + |
33 | 70 | .jqmWindow { |
34 | 71 | display: none; |
35 | 72 | position: fixed; |
— | — | @@ -40,7 +77,9 @@ |
41 | 78 | border: 1px solid black; |
42 | 79 | } |
43 | 80 | |
44 | | -.jqmOverlay { background-color: #000; } |
| 81 | +.jqmOverlay { |
| 82 | + background-color: #000; |
| 83 | +} |
45 | 84 | |
46 | 85 | /* Fixed posistioning emulation for IE6 |
47 | 86 | * Star selector used to hide definition from browsers other than IE6 |
Index: trunk/extensions/AjaxLogin/AjaxLogin.js |
— | — | @@ -13,27 +13,27 @@ |
14 | 14 | }; |
15 | 15 | |
16 | 16 | mediawiki.AjaxLogin.prototype.initialize = function() { |
17 | | - this._loginPanel = $("#userloginRound"); |
18 | | - this._loginForm = $("#userajaxloginform"); |
| 17 | + this._loginPanel = $('#userloginRound'); |
| 18 | + this._loginForm = $('#userajaxloginform'); |
19 | 19 | if( this._loginPanel.length > 0 ) { |
20 | 20 | this._loginPanel.jqm({modal : true, toTop : true}); |
21 | 21 | var that = this; |
22 | | - $("#pt-anonlogin, #pt-login").click( function( event ) { |
| 22 | + $('#pt-anonlogin, #pt-login').click( function( event ) { |
23 | 23 | event.preventDefault(); |
24 | 24 | that.showLoginPanel(); |
25 | 25 | }); |
26 | | - $("#wpLoginattempt").click(function( event ) { |
| 26 | + $('#wpLoginattempt').click(function( event ) { |
27 | 27 | event.preventDefault(); |
28 | 28 | that.postAjax( 'wpLoginattempt' ); |
29 | 29 | }); |
30 | | - $("#wpMailmypassword").click(function( event ) { |
| 30 | + $('#wpMailmypassword').click(function( event ) { |
31 | 31 | event.preventDefault(); |
32 | 32 | that.postAjax( 'wpMailmypassword' ); |
33 | 33 | }); |
34 | | - $("#wpAjaxRegister").click(function( event ) { |
| 34 | + $('#wpAjaxRegister').click(function( event ) { |
35 | 35 | that.doRegister( event ); |
36 | 36 | }); |
37 | | - $("#wpClose").click(function( event ) { |
| 37 | + $('#wpClose').click(function( event ) { |
38 | 38 | that.doClose( event ); |
39 | 39 | }); |
40 | 40 | } |
— | — | @@ -58,9 +58,9 @@ |
59 | 59 | success : function( data ) { |
60 | 60 | that.requestSuccess( data ); |
61 | 61 | }, |
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' ) { |
65 | 65 | console.log( 'Error in AjaxLogin.js!' ); |
66 | 66 | } |
67 | 67 | } |
— | — | @@ -68,31 +68,31 @@ |
69 | 69 | }; |
70 | 70 | |
71 | 71 | 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'); |
79 | 79 | }; |
80 | 80 | |
81 | 81 | 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'); |
89 | 89 | }; |
90 | 90 | |
91 | 91 | mediawiki.AjaxLogin.prototype.displayReason = function( reason ) { |
92 | | - $("#wpError").html(reason + '<br /><br />').show(); |
| 92 | + $('#wpError').html(reason + '<br /><br />').show(); |
93 | 93 | }; |
94 | 94 | |
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 ) { |
97 | 97 | if( typeof( ajaxLogin2 ) != 'undefined' && !confirm( ajaxLogin2 ) ) { |
98 | 98 | event.preventDefault(); |
99 | 99 | } |
— | — | @@ -100,13 +100,13 @@ |
101 | 101 | }; |
102 | 102 | |
103 | 103 | mediawiki.AjaxLogin.prototype.refreshForm = function() { |
104 | | - $("#wpName1").val(''); |
105 | | - $("#wpPassword1").val(''); |
106 | | - $("#wpError").html(''); |
| 104 | + $('#wpName1').val(''); |
| 105 | + $('#wpPassword1').val(''); |
| 106 | + $('#wpError').html(''); |
107 | 107 | this.enableForm(); |
108 | 108 | }; |
109 | 109 | |
110 | | -mediawiki.AjaxLogin.prototype.doClose = function( event ){ |
| 110 | +mediawiki.AjaxLogin.prototype.doClose = function( event ) { |
111 | 111 | this._loginPanel.jqmHide(); |
112 | 112 | }; |
113 | 113 | |
— | — | @@ -114,7 +114,7 @@ |
115 | 115 | var responseResult = data.ajaxlogin.result; |
116 | 116 | switch( responseResult ) { |
117 | 117 | case 'Reset': |
118 | | - if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) { |
| 118 | + if( $('#wpPreview').length > 0 && $('#wpLogin').length > 0 ) { |
119 | 119 | if( typeof( ajaxLogin1 ) != 'undefined' && !confirm( ajaxLogin1 ) ) { |
120 | 120 | break; |
121 | 121 | } |
— | — | @@ -126,14 +126,14 @@ |
127 | 127 | this.enableForm(); |
128 | 128 | break; |
129 | 129 | 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(); |
133 | 133 | } else { |
134 | | - if( $("#wikiPreview") && $("#wikiPreview").children.length == 0 ) { |
135 | | - $("#wpLogin").val( 1 ); |
| 134 | + if( $('#wikiPreview') && $('#wikiPreview').children.length == 0 ) { |
| 135 | + $('#wpLogin').val( 1 ); |
136 | 136 | } |
137 | | - $("#wpPreview").click(); |
| 137 | + $('#wpPreview').click(); |
138 | 138 | } |
139 | 139 | } else { |
140 | 140 | if( wgCanonicalSpecialPageName == 'Userlogout' ) { |
— | — | @@ -145,13 +145,13 @@ |
146 | 146 | break; |
147 | 147 | case 'NotExists': |
148 | 148 | this.enableForm(); |
149 | | - $("#wpName1").value = ''; |
150 | | - $("#wpPassword1").value = ''; |
151 | | - $("#wpName1").focus(); |
| 149 | + $('#wpName1').value = ''; |
| 150 | + $('#wpPassword1').value = ''; |
| 151 | + $('#wpName1').focus(); |
152 | 152 | case 'WrongPass': |
153 | 153 | this.enableForm(); |
154 | | - $("#wpPassword1").val(''); |
155 | | - $("#wpPassword1").focus(); |
| 154 | + $('#wpPassword1').val(''); |
| 155 | + $('#wpPassword1').focus(); |
156 | 156 | default: |
157 | 157 | this.enableForm(); |
158 | 158 | this.displayReason( data.ajaxlogin.text ); |