Index: trunk/extensions/AjaxLogin/AjaxLogin.php |
— | — | @@ -28,7 +28,8 @@ |
29 | 29 | // Array of skins for which AjaxLogin is enabled. |
30 | 30 | // Key is: 'skinname' => (true or false) |
31 | 31 | $wgEnableAjaxLogin = array( |
32 | | - 'monobook' => true |
| 32 | + 'monobook' => true, |
| 33 | + 'vector' => true |
33 | 34 | ); |
34 | 35 | |
35 | 36 | // Autoload AjaxLogin API interface |
— | — | @@ -51,16 +52,15 @@ |
52 | 53 | * @return true |
53 | 54 | */ |
54 | 55 | function AjaxLoginJS( OutputPage $out ) { |
55 | | - global $wgEnableAjaxLogin, $wgScriptPath, $wgJsMimeType; |
| 56 | + global $wgEnableAjaxLogin, $wgScriptPath; |
56 | 57 | |
57 | 58 | # Don't load anything if AjaxLogin isn't enabled |
58 | 59 | if ( !isset( $wgEnableAjaxLogin ) ) { |
59 | 60 | return true; |
60 | 61 | } |
61 | 62 | |
62 | | - |
63 | 63 | // Our custom CSS |
64 | | - $out->addStyle( '../..' . $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.css' ); |
| 64 | + $out->addExtensionStyle( $wgScriptPath . '/extensions/AjaxLogin/AjaxLogin.css' ); |
65 | 65 | // JQuery and JQModal scripts |
66 | 66 | $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jquery-1.3.2.min.js' ); |
67 | 67 | $out->addScriptFile( $wgScriptPath . '/extensions/AjaxLogin/jqModal.js' ); |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b> |
107 | 107 | <div class="r_boxContent"> |
108 | 108 | <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> |
| 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 | 110 | </div> |
111 | 111 | <div class="boxHeader color1"> |
112 | 112 | ' . wfMsg( 'login' ) . ' |
— | — | @@ -136,4 +136,4 @@ |
137 | 137 | </div>' ); |
138 | 138 | } |
139 | 139 | return true; |
140 | | -} |
| 140 | +} |
\ No newline at end of file |
Index: trunk/extensions/AjaxLogin/AjaxLogin.css |
— | — | @@ -12,7 +12,6 @@ |
13 | 13 | #userloginRound .boxHeader { |
14 | 14 | padding: 3px 5px; |
15 | 15 | font-size: 12px; /* Jack: added this */ |
16 | | - |
17 | 16 | } |
18 | 17 | |
19 | 18 | #userloginRound form { |
— | — | @@ -32,26 +31,22 @@ |
33 | 32 | |
34 | 33 | .jqmWindow { |
35 | 34 | display: none; |
36 | | - |
37 | 35 | position: fixed; |
38 | 36 | top: 30%; |
39 | 37 | left: 60%; |
40 | | - |
41 | 38 | margin-left: -300px; |
42 | | - |
43 | 39 | background-color: #EEE; |
44 | 40 | color: #333; |
45 | 41 | border: 1px solid black; |
46 | 42 | } |
47 | 43 | |
48 | | - |
49 | 44 | .jqmOverlay { background-color: #000; } |
50 | 45 | |
51 | 46 | /* Fixed posistioning emulation for IE6 |
52 | 47 | * Star selector used to hide definition from browsers other than IE6 |
53 | | - * For valid CSS, use a conditional include instead */ |
| 48 | + * For valid CSS, use a conditional include instead |
| 49 | + */ |
54 | 50 | * html .jqmWindow { |
55 | 51 | position: absolute; |
56 | 52 | top: expression((document.documentElement.scrollTop || document.body.scrollTop) + Math.round(17 * (document.documentElement.offsetHeight || document.body.clientHeight) / 100) + 'px'); |
57 | | -} |
58 | | - |
| 53 | +} |
\ No newline at end of file |
Index: trunk/extensions/AjaxLogin/AjaxLogin.js |
— | — | @@ -1,4 +1,10 @@ |
2 | | -(function($) { |
| 2 | +/** |
| 3 | + * JavaScript for AjaxLogin extension |
| 4 | + * @file |
| 5 | + * @author Chamindu Munasinghe <chamindu@calcey.com> |
| 6 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 7 | + */ |
| 8 | +(function( $ ) { |
3 | 9 | mediawiki = new Object; |
4 | 10 | |
5 | 11 | mediawiki.AjaxLogin = function() { |
— | — | @@ -9,26 +15,26 @@ |
10 | 16 | mediawiki.AjaxLogin.prototype.initialize = function() { |
11 | 17 | this._loginPanel = $("#userloginRound"); |
12 | 18 | this._loginForm = $("#userajaxloginform"); |
13 | | - if(this._loginPanel.length > 0) { |
| 19 | + if( this._loginPanel.length > 0 ) { |
14 | 20 | this._loginPanel.jqm({modal : true, toTop : true}); |
15 | 21 | var that = this; |
16 | | - $("#pt-anonlogin, #pt-login").click( function(event) { |
| 22 | + $("#pt-anonlogin, #pt-login").click( function( event ) { |
17 | 23 | event.preventDefault(); |
18 | 24 | that.showLoginPanel(); |
19 | 25 | }); |
20 | | - $("#wpLoginattempt").click(function(event) { |
| 26 | + $("#wpLoginattempt").click(function( event ) { |
21 | 27 | event.preventDefault(); |
22 | | - that.postAjax("wpLoginattempt"); |
| 28 | + that.postAjax( 'wpLoginattempt' ); |
23 | 29 | }); |
24 | | - $("#wpMailmypassword").click(function(event) { |
| 30 | + $("#wpMailmypassword").click(function( event ) { |
25 | 31 | event.preventDefault(); |
26 | | - that.postAjax("wpMailmypassword"); |
| 32 | + that.postAjax( 'wpMailmypassword' ); |
27 | 33 | }); |
28 | | - $("#wpAjaxRegister").click(function(event) { |
29 | | - that.doRegister(event); |
| 34 | + $("#wpAjaxRegister").click(function( event ) { |
| 35 | + that.doRegister( event ); |
30 | 36 | }); |
31 | | - $("#wpClose").click(function(event) { |
32 | | - that.doClose(event); |
| 37 | + $("#wpClose").click(function( event ) { |
| 38 | + that.doClose( event ); |
33 | 39 | }); |
34 | 40 | } |
35 | 41 | }; |
— | — | @@ -38,93 +44,94 @@ |
39 | 45 | this._loginPanel.jqmShow(); |
40 | 46 | }; |
41 | 47 | |
42 | | -mediawiki.AjaxLogin.prototype.postAjax = function(action) { |
| 48 | +mediawiki.AjaxLogin.prototype.postAjax = function( action ) { |
43 | 49 | var actionURL = wgServer + wgScriptPath + '/api.php?action=ajaxlogin&format=json'; |
44 | 50 | var dataString = this._loginForm.serialize(); |
45 | | - dataString += "&" + action + "=" + action; |
| 51 | + dataString += '&' + action + '=' + action; |
46 | 52 | this.disableForm(); |
47 | 53 | var that = this; |
48 | 54 | $.ajax({ |
49 | | - type : "POST" , |
| 55 | + type : 'POST', |
50 | 56 | url : actionURL, |
51 | | - dataType : "json", |
| 57 | + dataType : 'json', |
52 | 58 | data : dataString, |
53 | | - success : function(data) { |
54 | | - that.requestSuccess(data); |
| 59 | + success : function( data ) { |
| 60 | + that.requestSuccess( data ); |
55 | 61 | }, |
56 | | - error : function(XMLHttpRequest, textStatus, errorThrown) |
57 | | - { |
| 62 | + error : function( XMLHttpRequest, textStatus, errorThrown ){ |
58 | 63 | //TODO : add error handling here |
| 64 | + if( typeof console != 'undefined' ){ |
| 65 | + console_log( 'Error in AjaxLogin.js!' ); |
| 66 | + } |
59 | 67 | } |
60 | 68 | }); |
61 | 69 | }; |
62 | 70 | |
63 | 71 | mediawiki.AjaxLogin.prototype.enableForm = function() { |
64 | | - $("#wpName1").removeAttr("disabled"); |
65 | | - $("#wpPassword1").removeAttr("disabled"); |
66 | | - $("#wpLoginattempt").removeAttr("disabled"); |
67 | | - $("#wpRemember").removeAttr("disabled"); |
68 | | - $("#wpMailmypassword").removeAttr("disabled"); |
69 | | - $("#wpPassword1").removeAttr("disabled"); |
70 | | - $("#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'); |
71 | 79 | }; |
72 | 80 | |
73 | 81 | mediawiki.AjaxLogin.prototype.disableForm = function() { |
74 | | - $("#wpName1").attr("disabled", "disabled"); |
75 | | - $("#wpPassword1").attr("disabled", "disabled"); |
76 | | - $("#wpLoginattempt").attr("disabled", "disabled"); |
77 | | - $("#wpRemember").attr("disabled", "disabled"); |
78 | | - $("#wpMailmypassword").attr("disabled", "disabled"); |
79 | | - $("#wpPassword1").attr("disabled", "disabled"); |
80 | | - $("#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'); |
81 | 89 | }; |
82 | 90 | |
83 | | -mediawiki.AjaxLogin.prototype.displayReason = function(reason) { |
84 | | - $("#wpError").html(reason + "<br /><br />").show(); |
| 91 | +mediawiki.AjaxLogin.prototype.displayReason = function( reason ) { |
| 92 | + $("#wpError").html(reason + '<br /><br />').show(); |
85 | 93 | }; |
86 | 94 | |
87 | | -mediawiki.AjaxLogin.prototype.doRegister = function(event){ |
88 | | - if($("#wpPreview").length > 0 && $("#wpLogin").length > 0) { |
89 | | - if( typeof(ajaxLogin2) != 'undefined' && !confirm(ajaxLogin2)) { |
| 95 | +mediawiki.AjaxLogin.prototype.doRegister = function( event ){ |
| 96 | + if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) { |
| 97 | + if( typeof( ajaxLogin2 ) != 'undefined' && !confirm( ajaxLogin2 ) ) { |
90 | 98 | event.preventDefault(); |
91 | 99 | } |
92 | 100 | } |
93 | 101 | }; |
94 | 102 | |
95 | 103 | mediawiki.AjaxLogin.prototype.refreshForm = function() { |
96 | | - $("#wpName1").val(""); |
97 | | - $("#wpPassword1").val(""); |
98 | | - $("#wpError").html(""); |
| 104 | + $("#wpName1").val(''); |
| 105 | + $("#wpPassword1").val(''); |
| 106 | + $("#wpError").html(''); |
99 | 107 | this.enableForm(); |
100 | | - |
101 | 108 | }; |
102 | 109 | |
103 | | -mediawiki.AjaxLogin.prototype.doClose = function(event){ |
| 110 | +mediawiki.AjaxLogin.prototype.doClose = function( event ){ |
104 | 111 | this._loginPanel.jqmHide(); |
105 | 112 | }; |
106 | 113 | |
107 | | -mediawiki.AjaxLogin.prototype.requestSuccess = function(data) { |
| 114 | +mediawiki.AjaxLogin.prototype.requestSuccess = function( data ) { |
108 | 115 | var responseResult = data.ajaxlogin.result; |
109 | | - switch(responseResult) { |
110 | | - case "Reset": |
111 | | - if($("#wpPreview").length > 0 && $("#wpLogin").length > 0) { |
112 | | - if(typeof(ajaxLogin1) != 'undefined' && !confirm(ajaxLogin1)) { |
| 116 | + switch( responseResult ) { |
| 117 | + case 'Reset': |
| 118 | + if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) { |
| 119 | + if( typeof( ajaxLogin1 ) != 'undefined' && !confirm( ajaxLogin1 ) ) { |
113 | 120 | break; |
114 | 121 | } |
115 | 122 | } |
116 | | - this._loginForm.attr("action", wgServer + wgScriptPath + "/index.php?title=Special:Userlogin&action=submitlogin&type=login"); |
117 | | - this._loginForm.unbind("submit"); |
| 123 | + this._loginForm.attr('action', wgServer + wgScriptPath + '/index.php?title=Special:Userlogin&action=submitlogin&type=login'); |
| 124 | + this._loginForm.unbind('submit'); |
118 | 125 | this.disableForm(); |
119 | 126 | this._loginForm.submit(); |
120 | 127 | this.enableForm(); |
121 | 128 | break; |
122 | | - case "Success": |
123 | | - if($("#wpPreview").length > 0 && $("#wpLogin").length > 0) { |
124 | | - if($("#wikiDiff").length > 0 && ($("#wikiDiff").children.length > 0) ) { |
| 129 | + case 'Success': |
| 130 | + if( $("#wpPreview").length > 0 && $("#wpLogin").length > 0 ) { |
| 131 | + if( $("#wikiDiff").length > 0 && ( $("#wikiDiff").children.length > 0 ) ) { |
125 | 132 | $("#wpDiff").click(); |
126 | 133 | } else { |
127 | 134 | if( $("#wikiPreview") && $("#wikiPreview").children.length == 0 ) { |
128 | | - $("#wpLogin").val(1); |
| 135 | + $("#wpLogin").val( 1 ); |
129 | 136 | } |
130 | 137 | $("#wpPreview").click(); |
131 | 138 | } |
— | — | @@ -132,32 +139,31 @@ |
133 | 140 | if( wgCanonicalSpecialPageName == 'Userlogout' ) { |
134 | 141 | window.location.href = wgServer + wgScriptPath; |
135 | 142 | } else { |
136 | | - window.location.reload(true); |
| 143 | + window.location.reload( true ); |
137 | 144 | } |
138 | 145 | } |
139 | 146 | break; |
140 | | - case "NotExists": |
| 147 | + case 'NotExists': |
141 | 148 | this.enableForm(); |
142 | | - $("#wpName1").value = ""; |
143 | | - $("#wpPassword1").value = ""; |
| 149 | + $("#wpName1").value = ''; |
| 150 | + $("#wpPassword1").value = ''; |
144 | 151 | $("#wpName1").focus(); |
145 | | - case "WrongPass": |
| 152 | + case 'WrongPass': |
146 | 153 | this.enableForm(); |
147 | | - $("#wpPassword1").val(""); |
| 154 | + $("#wpPassword1").val(''); |
148 | 155 | $("#wpPassword1").focus(); |
149 | 156 | default: |
150 | 157 | this.enableForm(); |
151 | | - this.displayReason(data.ajaxlogin.text); |
| 158 | + this.displayReason( data.ajaxlogin.text ); |
152 | 159 | break; |
153 | 160 | } |
154 | 161 | }; |
155 | 162 | |
156 | 163 | $(document).ready( function() { |
157 | | - if( typeof wgEnableAjaxLogin != 'undefined' && wgEnableAjaxLogin ) |
158 | | - { |
| 164 | + if( typeof wgEnableAjaxLogin != 'undefined' && wgEnableAjaxLogin ) { |
159 | 165 | var ajaxLogin = new mediawiki.AjaxLogin(); |
160 | 166 | ajaxLogin.initialize(); |
161 | 167 | } |
162 | 168 | }); |
163 | 169 | |
164 | | -})(jQuery); |
| 170 | +})(jQuery); |
\ No newline at end of file |
Index: trunk/extensions/AjaxLogin/ApiAjaxLogin.php |
— | — | @@ -94,10 +94,10 @@ |
95 | 95 | if ( !$wgAuth->allowPasswordChange() ) { |
96 | 96 | $result['result'] = 'resetpass_forbidden'; |
97 | 97 | $result['text'] = wfMsg( 'resetpass_forbidden' ); |
98 | | - } else if ( $wgUser->isBlocked() ) { |
| 98 | + } elseif ( $wgUser->isBlocked() ) { |
99 | 99 | $result['result'] = 'blocked-mailpassword'; |
100 | 100 | $result['text'] = wfMsg( 'blocked-mailpassword' ); |
101 | | - } else if ( '' == $loginForm->mName ) { |
| 101 | + } elseif ( '' == $loginForm->mName ) { |
102 | 102 | $result['result'] = 'noname'; |
103 | 103 | $result['text'] = wfMsg( 'noname' ); |
104 | 104 | } else { |
— | — | @@ -105,11 +105,11 @@ |
106 | 106 | if ( is_null( $u ) ) { |
107 | 107 | $result['result'] = 'noname'; |
108 | 108 | $result['text'] = wfMsg( 'noname' ); |
109 | | - } else if ( 0 == $u->getID() ) { |
| 109 | + } elseif ( 0 == $u->getID() ) { |
110 | 110 | $result['result'] = 'nosuchuser'; |
111 | 111 | wfLoadExtensionMessages( 'AjaxLogin' ); |
112 | 112 | $result['text'] = wfMsg( 'al-nosuchuser', $u->getName() ); |
113 | | - } else if ( $u->isPasswordReminderThrottled() ) { |
| 113 | + } elseif ( $u->isPasswordReminderThrottled() ) { |
114 | 114 | global $wgPasswordReminderResendTime; |
115 | 115 | $result['result'] = 'throttled-mailpassword'; |
116 | 116 | $result['text'] = wfMsg( 'throttled-mailpassword', round( $wgPasswordReminderResendTime, 3 ) ); |
— | — | @@ -145,4 +145,4 @@ |
146 | 146 | public function getVersion() { |
147 | 147 | return __CLASS__ . ': $Id$'; |
148 | 148 | } |
149 | | -} |
| 149 | +} |
\ No newline at end of file |
Index: trunk/extensions/AjaxLogin/README |
— | — | @@ -7,15 +7,14 @@ |
8 | 8 | |
9 | 9 | Some code hacks were written by Jack Phoenix <jack@countervandalism.net>. |
10 | 10 | |
11 | | -Replaced YUI with JQuery - Chamindu Munasinghe <chamindu@calcey.com>. |
| 11 | +Replaced YUI with jQuery - Chamindu Munasinghe <chamindu@calcey.com>. |
12 | 12 | |
13 | 13 | ==License== |
14 | 14 | GNU General Public License 2.0 or later |
15 | 15 | |
16 | 16 | ==Dependency== |
| 17 | +jQuery |
17 | 18 | |
18 | | -JQuery |
19 | | - |
20 | 19 | ==Manual modifications== |
21 | 20 | You will need to modify one core MediaWiki file, includes/EditPage.php, if you want users to be able to log in with AjaxLogin |
22 | 21 | on edit view (?action=edit) without losing their changes. |
— | — | @@ -25,13 +24,7 @@ |
26 | 25 | <input type='hidden' value=\"\" name=\"wpLogin\" id=\"wpLogin\" /> |
27 | 26 | |
28 | 27 | ==To-do & bugs== |
29 | | -This extension is right now a major hack. It requires YUI and isn't pretty in any case, |
30 | | -but it works and has been tested on MediaWiki 1.14alpha. |
31 | | - |
32 | | -The JavaScript file should be rewritten so that the YUI dependency could be removed. |
33 | | -Obviously YAHOOTools.js should also be killed in the process. |
34 | | - |
35 | 28 | Patches are more than welcome and they can be submitted either through Bugzilla <https://bugzilla.wikimedia.org> or emailed to me |
36 | 29 | <jack@countervandalism.net> directly. |
37 | 30 | |
\ No newline at end of file |
| 31 | +--Jack Phoenix, September 2009 |
\ No newline at end of file |