r106248 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106247‎ | r106248 | r106249 >
Date:21:53, 14 December 2011
Author:neilk
Status:ok
Tags:
Comment:
MFT r106156 add links to bugzilla for feedback popup
Modified paths:
  • /branches/wmf/1.18wmf1/languages/messages/MessagesEn.php (modified) (history)
  • /branches/wmf/1.18wmf1/maintenance/language/messages.inc (modified) (history)
  • /branches/wmf/1.18wmf1/resources/Resources.php (modified) (history)
  • /branches/wmf/1.18wmf1/resources/mediawiki/mediawiki.feedback.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/maintenance/language/messages.inc
@@ -3463,14 +3463,19 @@
34643464 ),
34653465 'feedback' => array(
34663466 'feedback-note',
 3467+ 'feedback-bugnote',
34673468 'feedback-subject',
3468 - 'feedback-message',
3469 - 'feedback-cancel',
3470 - 'feedback-submit',
3471 - 'feedback-adding',
3472 - 'feedback-error1',
3473 - 'feedback-error2',
3474 - 'feedback-error3',
 3469+ 'feedback-message',
 3470+ 'feedback-cancel',
 3471+ 'feedback-submit',
 3472+ 'feedback-adding',
 3473+ 'feedback-error1',
 3474+ 'feedback-error2',
 3475+ 'feedback-error3',
 3476+ 'feedback-thanks',
 3477+ 'feedback-close',
 3478+ 'feedback-bugcheck',
 3479+ 'feedback-bugnew',
34753480 ),
34763481 );
34773482
Index: branches/wmf/1.18wmf1/languages/messages/MessagesEn.php
@@ -4601,7 +4601,8 @@
46024602
46034603
46044604 # Feedback
4605 -'feedback-note' => 'Your feedback will be posted publicly to the page "[$2 $1]", along with your user name, browser version and operating system.',
 4605+'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.',
 4606+'feedback-bugnote' => 'Or, you can [$1 post a technical bug report] instead.',
46064607 'feedback-subject' => 'Subject:',
46074608 'feedback-message' => 'Message:',
46084609 'feedback-cancel' => 'Cancel',
@@ -4610,4 +4611,8 @@
46114612 'feedback-error1' => 'Error: Unrecognized result from API',
46124613 'feedback-error2' => 'Error: Edit failed',
46134614 'feedback-error3' => 'Error: No response from API',
 4615+'feedback-thanks' => 'Thanks! Your feedback has been posted to the page "[$2 $1]".',
 4616+'feedback-close' => 'Done',
 4617+'feedback-bugcheck' => 'Great! Just check that it is not already one of the [$1 known bugs].',
 4618+'feedback-bugnew' => 'I checked. Report a new bug',
46144619 );
Index: branches/wmf/1.18wmf1/resources/Resources.php
@@ -490,6 +490,7 @@
491491 ),
492492 'messages' => array(
493493 'feedback-note',
 494+ 'feedback-bugnote',
494495 'feedback-subject',
495496 'feedback-message',
496497 'feedback-cancel',
@@ -498,6 +499,10 @@
499500 'feedback-error1',
500501 'feedback-error2',
501502 'feedback-error3',
 503+ 'feedback-thanks',
 504+ 'feedback-close',
 505+ 'feedback-bugcheck',
 506+ 'feedback-bugnew',
502507 ),
503508 ),
504509 'mediawiki.htmlform' => array(
Index: branches/wmf/1.18wmf1/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 if ( this.dialogTitleMessageKey === undefined ) {
6270 this.dialogTitleMessageKey = 'feedback-submit';
6371 }
@@ -67,19 +75,25 @@
6876 setup: function() {
6977 var _this = this;
7078
71 - // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized
72 - _this.buttons = {};
73 - _this.buttons[ mw.msg( 'feedback-cancel' ) ] = function() { _this.cancel(); };
74 - _this.buttons[ mw.msg( 'feedback-submit' ) ] = function() { _this.submit(); };
75 -
76 - var $feedbackPageLink = $j( '<a></a>' ).attr( { 'href': _this.feedbackTitle.getUrl(), 'target': '_blank' } );
 79+
 80+ var $feedbackPageLink = $( '<a></a>' )
 81+ .attr( { 'href': _this.title.getUrl(), 'target': '_blank' } )
 82+ .css( { 'white-space': 'nowrap' } );
 83+
 84+ var $bugNoteLink = $( '<a></a>' ).attr( { 'href': '#', } ).click( function() { _this.displayBugs(); } );
 85+
 86+ var $bugsListLink = $( '<a></a>' ).attr( { 'href': _this.bugsListLink, 'target': '_blank' } );
 87+
7788 this.$dialog =
7889 $( '<div style="position:relative;"></div>' ).append(
79 - $( '<div class="feedback-mode feedback-form"></div>' ).append(
80 - $( '<div style="margin-top:0.4em;"></div>' ).append(
81 - $( '<small></small>' ).msg( 'feedback-note',
82 - _this.feedbackTitle.getNameText(),
83 - $feedbackPageLink )
 90+ $( '<div class="feedback-mode feedback-form"></div>' ).append(
 91+ $( '<small></small>' ).append(
 92+ $( '<p></p>' ).msg(
 93+ 'feedback-note',
 94+ _this.title.getNameText(),
 95+ $feedbackPageLink.clone()
 96+ ),
 97+ $( '<p></p>' ).msg( 'feedback-bugnote', $bugNoteLink )
8498 ),
8599 $( '<div style="margin-top:1em;"></div>' ).append(
86100 mw.msg( 'feedback-subject' ),
@@ -92,16 +106,26 @@
93107 $( '<textarea name="message" class="feedback-message" style="width:99%;" rows="5" cols="60"></textarea>' )
94108 )
95109 ),
 110+ $( '<div class="feedback-mode feedback-bugs"></div>' ).append(
 111+ $( '<p>' ).msg( 'feedback-bugcheck', $bugsListLink )
 112+ ),
96113 $( '<div class="feedback-mode feedback-submitting" style="text-align:center;margin:3em 0;"></div>' ).append(
97114 mw.msg( 'feedback-adding' ),
98115 $( '<br/>' ),
99116 $( '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' )
100117 ),
 118+ $( '<div class="feedback-mode feedback-thanks" style="text-align:center;margin:1em"></div>' ).msg(
 119+ 'feedback-thanks', _this.title.getNameText(), $feedbackPageLink.clone()
 120+ ),
101121 $( '<div class="feedback-mode feedback-error" style="position:relative;"></div>' ).append(
102122 $( '<div class="feedback-error-msg style="color:#990000;margin-top:0.4em;"></div>' )
 123+ )
 124+ );
103125
104 - )
105 - ).dialog({
 126+ // undo some damage from dialog css
 127+ this.$dialog.find( 'a' ).css( { 'color': '#0645ad' } );
 128+
 129+ this.$dialog.dialog({
106130 width: 500,
107131 autoOpen: false,
108132 title: mw.msg( this.dialogTitleMessageKey ),
@@ -111,7 +135,7 @@
112136
113137 this.subjectInput = this.$dialog.find( 'input.feedback-subject' ).get(0);
114138 this.messageInput = this.$dialog.find( 'textarea.feedback-message' ).get(0);
115 - this.displayForm();
 139+
116140 },
117141
118142 display: function( s ) {
@@ -124,6 +148,23 @@
125149 this.display( 'submitting' );
126150 },
127151
 152+ displayBugs: function() {
 153+ var _this = this;
 154+ this.display( 'bugs' );
 155+ var bugsButtons = {};
 156+ bugsButtons[ mw.msg( 'feedback-bugnew' ) ] = function() { window.open( _this.bugsLink, '_blank' ); };
 157+ bugsButtons[ mw.msg( 'feedback-cancel' ) ] = function() { _this.cancel(); };
 158+ this.$dialog.dialog( { buttons: bugsButtons } );
 159+ },
 160+
 161+ displayThanks: function() {
 162+ var _this = this;
 163+ this.display( 'thanks' );
 164+ var closeButton = {};
 165+ closeButton[ mw.msg( 'feedback-close' ) ] = function() { _this.$dialog.dialog( 'close' ); };
 166+ this.$dialog.dialog( { buttons: closeButton } );
 167+ },
 168+
128169 /**
129170 * Display the feedback form
130171 * @param {Object} optional prefilled contents for the feedback form. Object with properties:
@@ -131,11 +172,17 @@
132173 * message: {String}
133174 */
134175 displayForm: function( contents ) {
 176+ var _this = this;
135177 this.subjectInput.value = (contents && contents.subject) ? contents.subject : '';
136178 this.messageInput.value = (contents && contents.message) ? contents.message : '';
137179
138180 this.display( 'form' );
139 - this.$dialog.dialog( { buttons: this.buttons } ); // put the buttons back
 181+
 182+ // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized
 183+ var formButtons = {};
 184+ formButtons[ mw.msg( 'feedback-submit' ) ] = function() { _this.submit(); };
 185+ formButtons[ mw.msg( 'feedback-cancel' ) ] = function() { _this.cancel(); };
 186+ this.$dialog.dialog( { buttons: formButtons } ); // put the buttons back
140187 },
141188
142189 displayError: function( message ) {
@@ -164,7 +211,7 @@
165212 var ok = function( result ) {
166213 if ( result.edit !== undefined ) {
167214 if ( result.edit.result === 'Success' ) {
168 - _this.$dialog.dialog( 'close' ); // edit complete, close dialog box
 215+ _this.displayThanks();
169216 } else {
170217 _this.displayError( 'feedback-error1' ); // unknown API result
171218 }
@@ -177,7 +224,7 @@
178225 displayError( 'feedback-error3' ); // ajax request failed
179226 };
180227
181 - this.api.newSection( this.feedbackTitle, subject, message, ok, err );
 228+ this.api.newSection( this.title, subject, message, ok, err );
182229
183230 }, // close submit button function
184231

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106156add bug reports to feedbackneilk01:26, 14 December 2011

Status & tagging log