r106156 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106155‎ | r106156 | r106157 >
Date:01:26, 14 December 2011
Author:neilk
Status:ok (Comments)
Tags:
Comment:
add bug reports to feedback
Modified paths:
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.feedback.js (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -3500,14 +3500,19 @@
35013501 ),
35023502 'feedback' => array(
35033503 'feedback-note',
 3504+ 'feedback-bugnote',
35043505 'feedback-subject',
3505 - 'feedback-message',
3506 - 'feedback-cancel',
3507 - 'feedback-submit',
3508 - 'feedback-adding',
3509 - 'feedback-error1',
3510 - 'feedback-error2',
3511 - 'feedback-error3',
 3506+ 'feedback-message',
 3507+ 'feedback-cancel',
 3508+ 'feedback-submit',
 3509+ 'feedback-adding',
 3510+ 'feedback-error1',
 3511+ 'feedback-error2',
 3512+ 'feedback-error3',
 3513+ 'feedback-thanks',
 3514+ 'feedback-close',
 3515+ 'feedback-bugcheck',
 3516+ 'feedback-bugnew',
35123517 ),
35133518 );
35143519
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -4630,14 +4630,18 @@
46314631 'newuserlog-byemail' => 'password sent by e-mail',
46324632
46334633 # Feedback
4634 -'feedback-note' => 'Your feedback will be posted publicly to the page "[$2 $1]", along with your user name, browser version and operating system.',
 4634+'feedback-note' => 'This form publicly posts a simple comment or suggestion to the page "[$2 $1]", along with your user name, browser version and operating system.',
 4635+'feedback-bugnote' => 'Or, you can [$1 post a technical bug report] instead.',
46354636 'feedback-subject' => 'Subject:',
46364637 'feedback-message' => 'Message:',
4637 -'feedback-cancel' => 'Cancel',
4638 -'feedback-submit' => 'Submit Feedback',
4639 -'feedback-adding' => 'Adding feedback to page...',
4640 -'feedback-error1' => 'Error: Unrecognized result from API',
4641 -'feedback-error2' => 'Error: Edit failed',
4642 -'feedback-error3' => 'Error: No response from API',
4643 -
 4638+'feedback-cancel' => 'Cancel',
 4639+'feedback-submit' => 'Submit Feedback',
 4640+'feedback-adding' => 'Adding feedback to page...',
 4641+'feedback-error1' => 'Error: Unrecognized result from API',
 4642+'feedback-error2' => 'Error: Edit failed',
 4643+'feedback-error3' => 'Error: No response from API',
 4644+'feedback-thanks' => 'Thanks! Your feedback has been posted to the page "[$2 $1]".',
 4645+'feedback-close' => 'Done',
 4646+'feedback-bugcheck' => 'Great! Just check that it is not already one of the [$1 known bugs].',
 4647+'feedback-bugnew' => 'I checked. Report a new bug',
46444648 );
Index: trunk/phase3/resources/Resources.php
@@ -539,6 +539,7 @@
540540 ),
541541 'messages' => array(
542542 'feedback-note',
 543+ 'feedback-bugnote',
543544 'feedback-subject',
544545 'feedback-message',
545546 'feedback-cancel',
@@ -547,6 +548,10 @@
548549 'feedback-error1',
549550 'feedback-error2',
550551 'feedback-error3',
 552+ 'feedback-thanks',
 553+ 'feedback-close',
 554+ 'feedback-bugcheck',
 555+ 'feedback-bugnew',
551556 ),
552557 ),
553558 'mediawiki.htmlform' => array(
Index: trunk/phase3/resources/mediawiki/mediawiki.feedback.js
@@ -19,9 +19,9 @@
2020 *
2121 * Not compatible with LiquidThreads.
2222 *
23 - * How to use it:
 23+ * Minimal example in how to use it:
2424 *
25 - * var feedback = new mw.Feedback( api, myFeedbackPageTitle );
 25+ * var feedback = new mw.Feedback();
2626 * $( '#myButton' ).click( function() { feedback.launch(); } );
2727 *
2828 * You can also launch the feedback form with a prefilled subject and body.
@@ -35,6 +35,8 @@
3636 * api: {mw.Api} if omitted, will just create a standard API
3737 * title: {mw.Title} the title of the page where you collect feedback. Defaults to "Feedback".
3838 * dialogTitleMessageKey: {String} message key for the title of the dialog box
 39+ * bugsLink: {mw.Uri|String} url where bugs can be posted
 40+ * bugsListLink: {mw.Uri|String} url where bugs can be listed
3941 */
4042 mw.Feedback = function( options ) {
4143
@@ -54,9 +56,15 @@
5557 options.dialogTitleMessageKey = 'feedback-submit';
5658 }
5759
58 - this.api = options.api;
59 - this.feedbackTitle = options.title;
60 - this.dialogTitleMessageKey = options.dialogTitleMessageKey;
 60+ if ( options.bugsLink === undefined ) {
 61+ options.bugsLink = '//bugzilla.wikimedia.org/enter_bug.cgi';
 62+ }
 63+
 64+ if ( options.bugsListLink === undefined ) {
 65+ options.bugsListLink = '//bugzilla.wikimedia.org/query.cgi';
 66+ }
 67+
 68+ $.extend( this, options );
6169 this.setup();
6270 };
6371
@@ -64,19 +72,25 @@
6573 setup: function() {
6674 var _this = this;
6775
68 - // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized
69 - _this.buttons = {};
70 - _this.buttons[ mw.msg( 'feedback-cancel' ) ] = function() { _this.cancel(); };
71 - _this.buttons[ mw.msg( 'feedback-submit' ) ] = function() { _this.submit(); };
72 -
73 - var $feedbackPageLink = $j( '<a></a>' ).attr( { 'href': _this.feedbackTitle.getUrl(), 'target': '_blank' } );
 76+
 77+ var $feedbackPageLink = $( '<a></a>' )
 78+ .attr( { 'href': _this.title.getUrl(), 'target': '_blank' } )
 79+ .css( { 'white-space': 'nowrap' } );
 80+
 81+ var $bugNoteLink = $( '<a></a>' ).attr( { 'href': '#', } ).click( function() { _this.displayBugs(); } );
 82+
 83+ var $bugsListLink = $( '<a></a>' ).attr( { 'href': _this.bugsListLink, 'target': '_blank' } );
 84+
7485 this.$dialog =
7586 $( '<div style="position:relative;"></div>' ).append(
76 - $( '<div class="feedback-mode feedback-form"></div>' ).append(
77 - $( '<div style="margin-top:0.4em;"></div>' ).append(
78 - $( '<small></small>' ).msg( 'feedback-note',
79 - _this.feedbackTitle.getNameText(),
80 - $feedbackPageLink )
 87+ $( '<div class="feedback-mode feedback-form"></div>' ).append(
 88+ $( '<small></small>' ).append(
 89+ $( '<p></p>' ).msg(
 90+ 'feedback-note',
 91+ _this.title.getNameText(),
 92+ $feedbackPageLink.clone()
 93+ ),
 94+ $( '<p></p>' ).msg( 'feedback-bugnote', $bugNoteLink )
8195 ),
8296 $( '<div style="margin-top:1em;"></div>' ).append(
8397 mw.msg( 'feedback-subject' ),
@@ -89,16 +103,26 @@
90104 $( '<textarea name="message" class="feedback-message" style="width:99%;" rows="5" cols="60"></textarea>' )
91105 )
92106 ),
 107+ $( '<div class="feedback-mode feedback-bugs"></div>' ).append(
 108+ $( '<p>' ).msg( 'feedback-bugcheck', $bugsListLink )
 109+ ),
93110 $( '<div class="feedback-mode feedback-submitting" style="text-align:center;margin:3em 0;"></div>' ).append(
94111 mw.msg( 'feedback-adding' ),
95112 $( '<br/>' ),
96113 $( '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' )
97114 ),
 115+ $( '<div class="feedback-mode feedback-thanks" style="text-align:center;margin:1em"></div>' ).msg(
 116+ 'feedback-thanks', _this.title.getNameText(), $feedbackPageLink.clone()
 117+ ),
98118 $( '<div class="feedback-mode feedback-error" style="position:relative;"></div>' ).append(
99119 $( '<div class="feedback-error-msg style="color:#990000;margin-top:0.4em;"></div>' )
 120+ )
 121+ );
100122
101 - )
102 - ).dialog({
 123+ // undo some damage from dialog css
 124+ this.$dialog.find( 'a' ).css( { 'color': '#0645ad' } );
 125+
 126+ this.$dialog.dialog({
103127 width: 500,
104128 autoOpen: false,
105129 title: mw.msg( this.dialogTitleMessageKey ),
@@ -108,7 +132,7 @@
109133
110134 this.subjectInput = this.$dialog.find( 'input.feedback-subject' ).get(0);
111135 this.messageInput = this.$dialog.find( 'textarea.feedback-message' ).get(0);
112 - this.displayForm();
 136+
113137 },
114138
115139 display: function( s ) {
@@ -121,6 +145,23 @@
122146 this.display( 'submitting' );
123147 },
124148
 149+ displayBugs: function() {
 150+ var _this = this;
 151+ this.display( 'bugs' );
 152+ var bugsButtons = {};
 153+ bugsButtons[ mw.msg( 'feedback-bugnew' ) ] = function() { window.open( _this.bugsLink, '_blank' ); };
 154+ bugsButtons[ mw.msg( 'feedback-cancel' ) ] = function() { _this.cancel(); };
 155+ this.$dialog.dialog( { buttons: bugsButtons } );
 156+ },
 157+
 158+ displayThanks: function() {
 159+ var _this = this;
 160+ this.display( 'thanks' );
 161+ var closeButton = {};
 162+ closeButton[ mw.msg( 'feedback-close' ) ] = function() { _this.$dialog.dialog( 'close' ); };
 163+ this.$dialog.dialog( { buttons: closeButton } );
 164+ },
 165+
125166 /**
126167 * Display the feedback form
127168 * @param {Object} optional prefilled contents for the feedback form. Object with properties:
@@ -128,11 +169,17 @@
129170 * message: {String}
130171 */
131172 displayForm: function( contents ) {
 173+ var _this = this;
132174 this.subjectInput.value = (contents && contents.subject) ? contents.subject : '';
133175 this.messageInput.value = (contents && contents.message) ? contents.message : '';
134176
135177 this.display( 'form' );
136 - this.$dialog.dialog( { buttons: this.buttons } ); // put the buttons back
 178+
 179+ // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized
 180+ var formButtons = {};
 181+ formButtons[ mw.msg( 'feedback-submit' ) ] = function() { _this.submit(); };
 182+ formButtons[ mw.msg( 'feedback-cancel' ) ] = function() { _this.cancel(); };
 183+ this.$dialog.dialog( { buttons: formButtons } ); // put the buttons back
137184 },
138185
139186 displayError: function( message ) {
@@ -161,7 +208,7 @@
162209 var ok = function( result ) {
163210 if ( result.edit !== undefined ) {
164211 if ( result.edit.result === 'Success' ) {
165 - _this.$dialog.dialog( 'close' ); // edit complete, close dialog box
 212+ _this.displayThanks();
166213 } else {
167214 _this.displayError( 'feedback-error1' ); // unknown API result
168215 }
@@ -174,7 +221,7 @@
175222 displayError( 'feedback-error3' ); // ajax request failed
176223 };
177224
178 - this.api.newSection( this.feedbackTitle, subject, message, ok, err );
 225+ this.api.newSection( this.title, subject, message, ok, err );
179226
180227 }, // close submit button function
181228

Follow-up revisions

RevisionCommit summaryAuthorDate
r106248MFT r106156 add links to bugzilla for feedback popupneilk21:53, 14 December 2011
r106676add docs for feedback messagesneilk19:46, 19 December 2011

Comments

#Comment by Vigilius (talk | contribs)   10:52, 15 December 2011

backported to 1.18wmf, please consider tagging for 1.18

#Comment by Nikerabbit (talk | contribs)   10:00, 16 December 2011

Needs message docs.

#Comment by NeilK (talk | contribs)   19:47, 19 December 2011

fixed in r106676

Status & tagging log