Index: trunk/extensions/Push/Push.i18n.php |
— | — | @@ -30,6 +30,7 @@ |
31 | 31 | 'push-button-text' => 'Push', |
32 | 32 | 'push-tab-desc' => 'This tab allows you to push the current revision of this page to one or more other wikis.', |
33 | 33 | 'push-button-pushing' => 'Pushing', |
| 34 | + 'push-button-pushing-files' => 'Pushing files', |
34 | 35 | 'push-button-completed' => 'Push completed', |
35 | 36 | 'push-button-failed' => 'Push failed', |
36 | 37 | 'push-tab-title' => 'Pushing $1', |
Index: trunk/extensions/Push/Push.php |
— | — | @@ -81,6 +81,7 @@ |
82 | 82 | 'push-tab-last-edit', |
83 | 83 | 'push-tab-not-created', |
84 | 84 | 'push-err-captcha-page', |
| 85 | + 'push-button-pushing-files', |
85 | 86 | ); |
86 | 87 | |
87 | 88 | // For backward compatibility with MW < 1.17. |
Index: trunk/extensions/Push/includes/Push_Tab.php |
— | — | @@ -244,7 +244,14 @@ |
245 | 245 | 'id' => 'targetinfo' . $targetId, |
246 | 246 | 'style' => 'display:none' |
247 | 247 | ) |
248 | | - ) |
| 248 | + ) . |
| 249 | + Html::element( |
| 250 | + 'div', |
| 251 | + array( |
| 252 | + 'id' => 'targeterrors' . $targetId, |
| 253 | + 'style' => 'display:none; color:darkred' |
| 254 | + ) |
| 255 | + ) |
249 | 256 | ) . |
250 | 257 | Html::rawElement( |
251 | 258 | 'td', |
Index: trunk/extensions/Push/includes/ext.push.tab.js |
— | — | @@ -36,6 +36,9 @@ |
37 | 37 | this.disabled = true; |
38 | 38 | this.innerHTML = mediaWiki.msg( 'push-button-pushing' ); |
39 | 39 | |
| 40 | + var errorDiv = $( '#targeterrors' + $(this).attr( 'targetid' ) ); |
| 41 | + errorDiv.fadeOut( 'fast' ); |
| 42 | + |
40 | 43 | if ( $('#checkIncTemplates').attr('checked') ) { |
41 | 44 | pages = window.wgPushTemplates; |
42 | 45 | pages.unshift( $('#pageName').attr('value') ); |
— | — | @@ -133,42 +136,22 @@ |
134 | 137 | handleError( sender, targetUrl, { info: mediaWiki.msg( 'push-err-captacha', targetName ) } ); |
135 | 138 | } |
136 | 139 | else { |
137 | | - sender.innerHTML = mediaWiki.msg( 'push-button-completed' ); |
138 | | - setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 ); |
| 140 | + if ( $('#checkIncFiles').length != 0 && $('#checkIncFiles').attr('checked') ) { |
| 141 | + setButtonToImgPush( sender, targetUrl, targetName ); |
| 142 | + } |
| 143 | + else { |
| 144 | + sender.innerHTML = mediaWiki.msg( 'push-button-completed' ); |
| 145 | + setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 ); |
| 146 | + } |
139 | 147 | } |
140 | 148 | } |
141 | 149 | ); |
142 | 150 | } |
143 | 151 | |
144 | | - function reEnableButton( button, targetUrl, targetName ) { |
145 | | - button.innerHTML = mediaWiki.msg( 'push-button-text' ); |
146 | | - button.disabled = false; |
147 | | - |
148 | | - var pushAllButton = $('#push-all-button'); |
149 | | - |
150 | | - // If there is a "push all" button, make sure to reset it |
151 | | - // when all other buttons have been reset. |
152 | | - if ( typeof pushAllButton === "undefined" ) { |
153 | | - imagePushRequests.push( { 'sender': button, 'targetUrl': targetUrl, 'targetName': targetName } ); |
154 | | - startImagesPush(); |
155 | | - } |
156 | | - else { |
157 | | - var hasDisabled = false; |
158 | | - |
159 | | - $.each($(".push-button"), function(i,v) { |
160 | | - if ( v.disabled ) { |
161 | | - hasDisabled = true; |
162 | | - } |
163 | | - }); |
164 | | - |
165 | | - if ( !hasDisabled ) { |
166 | | - pushAllButton.attr( "disabled", false ); |
167 | | - pushAllButton.text( mediaWiki.msg( 'push-button-all' ) ); |
168 | | - |
169 | | - imagePushRequests.push( { 'sender': button, 'targetUrl': targetUrl, 'targetName': targetName } ); |
170 | | - startImagesPush(); |
171 | | - } |
172 | | - } |
| 152 | + function setButtonToImgPush( button, targetUrl, targetName ) { |
| 153 | + button.innerHTML = mediaWiki.msg( 'push-button-pushing-files' ); |
| 154 | + imagePushRequests.push( { 'sender': button, 'targetUrl': targetUrl, 'targetName': targetName } ); |
| 155 | + startImagesPush(); |
173 | 156 | } |
174 | 157 | |
175 | 158 | function getIncludedImages() { |
— | — | @@ -222,23 +205,61 @@ |
223 | 206 | 'targets': targetUrl |
224 | 207 | }, |
225 | 208 | function( data ) { |
226 | | - if ( data.upload ) { |
227 | | - |
| 209 | + var fail = false; |
| 210 | + |
| 211 | + for ( i in data.upload ) { |
| 212 | + if ( data.error ) { |
| 213 | + handleError( sender, targetUrl, data.error ); |
| 214 | + fail = true; |
| 215 | + break; |
| 216 | + } |
| 217 | + else if ( !data.upload ) { |
| 218 | + handleError( sender, targetUrl, { info: 'Unknown error' } ); // TODO |
| 219 | + fail = true; |
| 220 | + break; |
| 221 | + } |
228 | 222 | } |
229 | | - else if ( data.error ) { |
230 | | - // TODO |
| 223 | + |
| 224 | + if ( !fail ) { |
| 225 | + sender.innerHTML = mediaWiki.msg( 'push-button-completed' ); |
| 226 | + setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 ); |
231 | 227 | } |
232 | | - else { |
233 | | - // TODO |
234 | | - } |
235 | 228 | } |
236 | 229 | ); |
237 | 230 | } |
238 | 231 | |
| 232 | + function reEnableButton( button, targetUrl, targetName ) { |
| 233 | + button.innerHTML = mediaWiki.msg( 'push-button-text' ); |
| 234 | + button.disabled = false; |
| 235 | + |
| 236 | + var pushAllButton = $('#push-all-button'); |
| 237 | + |
| 238 | + // If there is a "push all" button, make sure to reset it |
| 239 | + // when all other buttons have been reset. |
| 240 | + if ( typeof pushAllButton !== "undefined" ) { |
| 241 | + var hasDisabled = false; |
| 242 | + |
| 243 | + $.each($(".push-button"), function(i,v) { |
| 244 | + if ( v.disabled ) { |
| 245 | + hasDisabled = true; |
| 246 | + } |
| 247 | + }); |
| 248 | + |
| 249 | + if ( !hasDisabled ) { |
| 250 | + pushAllButton.attr( "disabled", false ); |
| 251 | + pushAllButton.text( mediaWiki.msg( 'push-button-all' ) ); |
| 252 | + } |
| 253 | + } |
| 254 | + } |
| 255 | + |
239 | 256 | function handleError( sender, targetUrl, error ) { |
240 | | - alert( error.info ); |
| 257 | + var errorDiv = $( '#targeterrors' + $(sender).attr( 'targetid' ) ); |
| 258 | + |
| 259 | + errorDiv.text( error.info ); |
| 260 | + errorDiv.fadeIn( 'slow' ); |
| 261 | + |
241 | 262 | sender.innerHTML = mediaWiki.msg( 'push-button-failed' ); |
242 | | - setTimeout( function() {reEnableButton( sender );}, 3000 ); |
| 263 | + setTimeout( function() {reEnableButton( sender );}, 2500 ); |
243 | 264 | } |
244 | 265 | |
245 | 266 | } ); })(jQuery); |
\ No newline at end of file |