Index: trunk/extensions/UploadWizard/UploadWizard.config.php |
— | — | @@ -241,6 +241,7 @@ |
242 | 242 | // Set skipTutorial to true to always skip tutorial step |
243 | 243 | 'skipTutorial' => false, |
244 | 244 | |
245 | | - 'feedbackPage' => 'Commons:Prototype upload wizard feedback', |
| 245 | + // Wiki page for leaving Upload Wizard feedback, for example 'Commons:Upload wizard feedback' |
| 246 | + 'feedbackPage' => '', |
246 | 247 | |
247 | 248 | ); |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -294,7 +294,16 @@ |
295 | 295 | 'mwe-upwiz-help-popup', |
296 | 296 | 'mwe-upwiz-help-popup-title', |
297 | 297 | 'mwe-upwiz-thumbnail-failed', |
298 | | - 'mwe-upwiz-unparseable-filename' |
| 298 | + 'mwe-upwiz-unparseable-filename', |
| 299 | + 'mwe-upwiz-feedback-note', |
| 300 | + 'mwe-upwiz-feedback-subject', |
| 301 | + 'mwe-upwiz-feedback-message', |
| 302 | + 'mwe-upwiz-feedback-title', |
| 303 | + 'mwe-upwiz-feedback-cancel', |
| 304 | + 'mwe-upwiz-feedback-submit', |
| 305 | + 'mwe-upwiz-feedback-adding', |
| 306 | + 'mwe-upwiz-feedback-error1', |
| 307 | + 'mwe-upwiz-feedback-error2' |
299 | 308 | ), |
300 | 309 | 'group' => 'ext.uploadWizard' |
301 | 310 | ), |
Index: trunk/extensions/UploadWizard/UploadWizard.i18n.php |
— | — | @@ -246,8 +246,19 @@ |
247 | 247 | 'mwe-upwiz-help-popup' => 'Help', |
248 | 248 | 'mwe-upwiz-help-popup-title' => 'Title', |
249 | 249 | 'mwe-upwiz-thumbnail-failed' => 'The upload succeeded, but the server could not get a preview thumbnail', |
250 | | - 'mwe-upwiz-unparseable-filename' => 'Could not understand the file name "$1"' |
| 250 | + 'mwe-upwiz-unparseable-filename' => 'Could not understand the file name "$1"', |
251 | 251 | |
| 252 | + /* Feedback interface */ |
| 253 | + 'mwe-upwiz-feedback-note' => 'Your feedback will be posted to $1.', |
| 254 | + 'mwe-upwiz-feedback-subject' => 'Subject:', |
| 255 | + 'mwe-upwiz-feedback-message' => 'Message (without a signature):', |
| 256 | + 'mwe-upwiz-feedback-title' => 'Leave feedback about Upload Wizard', |
| 257 | + 'mwe-upwiz-feedback-cancel' => 'Cancel', |
| 258 | + 'mwe-upwiz-feedback-submit' => 'Submit Feedback', |
| 259 | + 'mwe-upwiz-feedback-adding' => 'Adding feedback to page...', |
| 260 | + 'mwe-upwiz-feedback-error1' => 'Error: Unknown result from API', |
| 261 | + 'mwe-upwiz-feedback-error2' => 'Error: Edit failed' |
| 262 | + |
252 | 263 | ); |
253 | 264 | |
254 | 265 | /** Message documentation (Message documentation) |
— | — | @@ -294,6 +305,11 @@ |
295 | 306 | 'mwe-upwiz-categories-add' => '{{Identical|Add}}', |
296 | 307 | 'mwe-upwiz-help-popup' => '{{Identical|Help}}', |
297 | 308 | 'mwe-upwiz-help-popup-title' => '{{Identical|Title}}', |
| 309 | + 'mwe-upwiz-feedback-subject' => 'Label for a text input', |
| 310 | + 'mwe-upwiz-feedback-message' => 'Label for a textarea; signature referrs to a Wikitext signature.', |
| 311 | + 'mwe-upwiz-feedback-cancel' => 'Button label', |
| 312 | + 'mwe-upwiz-feedback-cancel' => 'Button label', |
| 313 | + 'mwe-upwiz-feedback-adding' => 'Progress notice' |
298 | 314 | ); |
299 | 315 | |
300 | 316 | /** Afrikaans (Afrikaans) |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -533,12 +533,14 @@ |
534 | 534 | $j( '#mwe-first-spinner' ).remove(); |
535 | 535 | |
536 | 536 | // feedback request |
537 | | - $j( '#contentSub' ).html('<i>Please <a id="mwe-upwiz-feedback" href="#">let us know</a> what you think of Upload Wizard!</i>'); |
538 | | - $j( '#mwe-upwiz-feedback') |
539 | | - .click( function() { |
540 | | - _this.launchFeedback(); |
541 | | - return false; |
542 | | - } ); |
| 537 | + if ( UploadWizardConfig['feedbackPage'] != '' ) { |
| 538 | + $j( '#contentSub' ).html('<i>Please <a id="mwe-upwiz-feedback" href="#">let us know</a> what you think of Upload Wizard!</i>'); |
| 539 | + $j( '#mwe-upwiz-feedback') |
| 540 | + .click( function() { |
| 541 | + _this.launchFeedback(); |
| 542 | + return false; |
| 543 | + } ); |
| 544 | + } |
543 | 545 | |
544 | 546 | // construct the arrow steps from the UL in the HTML |
545 | 547 | $j( '#mwe-upwiz-steps' ) |
— | — | @@ -1199,51 +1201,66 @@ |
1200 | 1202 | } ); |
1201 | 1203 | }, |
1202 | 1204 | |
| 1205 | + /** |
| 1206 | + * Build interface for collecting user feedback on Upload Wizard |
| 1207 | + */ |
1203 | 1208 | launchFeedback: function() { |
1204 | 1209 | _this = this; |
| 1210 | + |
| 1211 | + // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized |
| 1212 | + var cancelButton = gM( 'mwe-upwiz-feedback-cancel' ); |
| 1213 | + var submitButton = gM( 'mwe-upwiz-feedback-submit' ); |
| 1214 | + var buttonSettings = {}; |
| 1215 | + buttonSettings[cancelButton] = function() { $(this).dialog("close"); }; |
| 1216 | + buttonSettings[submitButton] = function() { |
| 1217 | + $feedbackForm.dialog({buttons:{}}); |
| 1218 | + $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
| 1219 | + $('#mwe-upwiz-feedback-form').append ( $('<div style="text-align:center;margin:3em 0;"></div>').append( gM( 'mwe-upwiz-feedback-adding' ), $( '<br/>' ), $('<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' ) ) ); |
| 1220 | + var subject = $('#mwe-upwiz-feedback-subject').val(); |
| 1221 | + var message = $('#mwe-upwiz-feedback-message').val(); |
| 1222 | + if ( message.indexOf('~~~~') == -1 ) { |
| 1223 | + message = message+' ~~~~'; |
| 1224 | + } |
| 1225 | + var useTokenToPost = function( token ) { |
| 1226 | + $.ajax({ |
| 1227 | + url: wgScriptPath + '/api.php?', |
| 1228 | + data: 'action=edit&title='+encodeURIComponent(mw.UploadWizard.config['feedbackPage'])+'§ion=new&summary='+encodeURIComponent(subject)+'&text='+encodeURIComponent(message)+'&format=json&token='+encodeURIComponent(token), |
| 1229 | + dataType: 'json', |
| 1230 | + type: 'POST', |
| 1231 | + success: function( data ) { |
| 1232 | + if ( data.edit.result == "Success" ) { |
| 1233 | + $feedbackForm.dialog("close"); |
| 1234 | + } else { |
| 1235 | + $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
| 1236 | + $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').msg( 'mwe-upwiz-feedback-error1' ) ); |
| 1237 | + } |
| 1238 | + }, |
| 1239 | + error: function( xhr ) { |
| 1240 | + $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
| 1241 | + $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').msg( 'mwe-upwiz-feedback-error2' ) ); |
| 1242 | + } |
| 1243 | + }); // close Ajax request |
| 1244 | + }; // close useTokenToPost function |
| 1245 | + _this.api.getEditToken( useTokenToPost ); |
| 1246 | + }; // close submit button function |
| 1247 | + |
| 1248 | + // Construct the feedback form |
| 1249 | + var feedbackLink = '<a href="'+wgArticlePath.replace( '$1', mw.UploadWizard.config['feedbackPage'].replace( /\s/g, '_' ) )+'" target="_blank">'+mw.UploadWizard.config['feedbackPage']+'</a>'; |
1205 | 1250 | $feedbackForm = $('<div id="mwe-upwiz-feedback-form" style="position:relative;"></div>') |
1206 | | - .append( $('<div style="margin-top:0.4em;"></div>').html( '<small>Your feedback will be posted to <a href="'+wgArticlePath.replace( '$1', mw.UploadWizard.config['feedbackPage'].replace( /\s/g, '_' ) )+'" target="_blank">'+mw.UploadWizard.config['feedbackPage']+'</a>.</small>' ) ) |
1207 | | - .append( $('<div style="margin-top:1em;"></div>').html( 'Subject:<br/>' ).append( $('<input type="text" id="mwe-upwiz-feedback-subject" name="subject" maxlength="60" style="width:99%;"/>') ) ) |
1208 | | - .append( $('<div style="margin-top:0.4em;"></div>').html( 'Message (without a signature):<br/>' ).append( $('<textarea name="message" id="mwe-upwiz-feedback-message" style="width:99%;" rows="4" cols="60"></textarea>') ) ) |
| 1251 | + .append( $('<div style="margin-top:0.4em;"></div>').append( $( '<small></small>' ).msg( 'mwe-upwiz-feedback-note', feedbackLink ) ) ) |
| 1252 | + .append( $('<div style="margin-top:1em;"></div>').append( gM( 'mwe-upwiz-feedback-subject' ), $( '<br/>' ), $('<input type="text" id="mwe-upwiz-feedback-subject" name="subject" maxlength="60" style="width:99%;"/>') ) ) |
| 1253 | + .append( $('<div style="margin-top:0.4em;"></div>').append( gM( 'mwe-upwiz-feedback-message' ), $( '<br/>' ), $('<textarea name="message" id="mwe-upwiz-feedback-message" style="width:99%;" rows="4" cols="60"></textarea>') ) ) |
1209 | 1254 | .dialog({ |
1210 | 1255 | width: 500, |
1211 | 1256 | autoOpen: false, |
1212 | | - title: 'Leave feedback on Upload Wizard', |
| 1257 | + title: gM( 'mwe-upwiz-feedback-title' ), |
1213 | 1258 | modal: true, |
1214 | | - buttons: { |
1215 | | - "Cancel": function() { $(this).dialog("close"); }, |
1216 | | - "Submit Feedback": function() { |
1217 | | - $(this).dialog({buttons:{}}); |
1218 | | - $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
1219 | | - $('#mwe-upwiz-feedback-form').append ( $('<div style="text-align:center;margin:3em 0;"></div>').html( 'Adding feedback to page...<br/><img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' ) ); |
1220 | | - var subject = $('#mwe-upwiz-feedback-subject').val(); |
1221 | | - var message = $('#mwe-upwiz-feedback-message').val() +' ~~~~'; |
1222 | | - var useTokenToPost = function( token ) { // form, summary, template |
1223 | | - $.ajax({ |
1224 | | - url: wgScriptPath + '/api.php?', |
1225 | | - data: 'action=edit&title='+encodeURIComponent(mw.UploadWizard.config['feedbackPage'])+'§ion=new&summary='+encodeURIComponent(subject)+'&text='+encodeURIComponent(message)+'&format=json&token='+encodeURIComponent(token), |
1226 | | - dataType: 'json', |
1227 | | - type: 'POST', |
1228 | | - success: function( data ) { |
1229 | | - if ( data.edit.result == "Success" ) { |
1230 | | - $feedbackForm.dialog("close"); |
1231 | | - } else { |
1232 | | - $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
1233 | | - $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').html( 'Error: Unknown result from API' ) ); |
1234 | | - } |
1235 | | - }, |
1236 | | - error: function( xhr ) { |
1237 | | - $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
1238 | | - $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').html( 'Error: Edit failed' ) ); |
1239 | | - } |
1240 | | - }); |
1241 | | - }; |
1242 | | - _this.api.getEditToken( useTokenToPost ); |
1243 | | - } |
1244 | | - } |
1245 | | - }); |
| 1259 | + buttons: buttonSettings |
| 1260 | + }); // close dialog, end $feedbackForm definition |
| 1261 | + |
1246 | 1262 | $feedbackForm.dialog('open'); |
1247 | | - }, |
| 1263 | + |
| 1264 | + }, // close launchFeedback function |
1248 | 1265 | |
1249 | 1266 | /** |
1250 | 1267 | * Set a cookie which lets the user skip the tutorial step in the future |