Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -3500,14 +3500,19 @@ |
3501 | 3501 | ), |
3502 | 3502 | 'feedback' => array( |
3503 | 3503 | 'feedback-note', |
| 3504 | + 'feedback-bugnote', |
3504 | 3505 | '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', |
3512 | 3517 | ), |
3513 | 3518 | ); |
3514 | 3519 | |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -4630,14 +4630,18 @@ |
4631 | 4631 | 'newuserlog-byemail' => 'password sent by e-mail', |
4632 | 4632 | |
4633 | 4633 | # 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.', |
4635 | 4636 | 'feedback-subject' => 'Subject:', |
4636 | 4637 | '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', |
4644 | 4648 | ); |
Index: trunk/phase3/resources/Resources.php |
— | — | @@ -539,6 +539,7 @@ |
540 | 540 | ), |
541 | 541 | 'messages' => array( |
542 | 542 | 'feedback-note', |
| 543 | + 'feedback-bugnote', |
543 | 544 | 'feedback-subject', |
544 | 545 | 'feedback-message', |
545 | 546 | 'feedback-cancel', |
— | — | @@ -547,6 +548,10 @@ |
548 | 549 | 'feedback-error1', |
549 | 550 | 'feedback-error2', |
550 | 551 | 'feedback-error3', |
| 552 | + 'feedback-thanks', |
| 553 | + 'feedback-close', |
| 554 | + 'feedback-bugcheck', |
| 555 | + 'feedback-bugnew', |
551 | 556 | ), |
552 | 557 | ), |
553 | 558 | 'mediawiki.htmlform' => array( |
Index: trunk/phase3/resources/mediawiki/mediawiki.feedback.js |
— | — | @@ -19,9 +19,9 @@ |
20 | 20 | * |
21 | 21 | * Not compatible with LiquidThreads. |
22 | 22 | * |
23 | | - * How to use it: |
| 23 | + * Minimal example in how to use it: |
24 | 24 | * |
25 | | - * var feedback = new mw.Feedback( api, myFeedbackPageTitle ); |
| 25 | + * var feedback = new mw.Feedback(); |
26 | 26 | * $( '#myButton' ).click( function() { feedback.launch(); } ); |
27 | 27 | * |
28 | 28 | * You can also launch the feedback form with a prefilled subject and body. |
— | — | @@ -35,6 +35,8 @@ |
36 | 36 | * api: {mw.Api} if omitted, will just create a standard API |
37 | 37 | * title: {mw.Title} the title of the page where you collect feedback. Defaults to "Feedback". |
38 | 38 | * 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 |
39 | 41 | */ |
40 | 42 | mw.Feedback = function( options ) { |
41 | 43 | |
— | — | @@ -54,9 +56,15 @@ |
55 | 57 | options.dialogTitleMessageKey = 'feedback-submit'; |
56 | 58 | } |
57 | 59 | |
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 ); |
61 | 69 | this.setup(); |
62 | 70 | }; |
63 | 71 | |
— | — | @@ -64,19 +72,25 @@ |
65 | 73 | setup: function() { |
66 | 74 | var _this = this; |
67 | 75 | |
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 | + |
74 | 85 | this.$dialog = |
75 | 86 | $( '<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 ) |
81 | 95 | ), |
82 | 96 | $( '<div style="margin-top:1em;"></div>' ).append( |
83 | 97 | mw.msg( 'feedback-subject' ), |
— | — | @@ -89,16 +103,26 @@ |
90 | 104 | $( '<textarea name="message" class="feedback-message" style="width:99%;" rows="5" cols="60"></textarea>' ) |
91 | 105 | ) |
92 | 106 | ), |
| 107 | + $( '<div class="feedback-mode feedback-bugs"></div>' ).append( |
| 108 | + $( '<p>' ).msg( 'feedback-bugcheck', $bugsListLink ) |
| 109 | + ), |
93 | 110 | $( '<div class="feedback-mode feedback-submitting" style="text-align:center;margin:3em 0;"></div>' ).append( |
94 | 111 | mw.msg( 'feedback-adding' ), |
95 | 112 | $( '<br/>' ), |
96 | 113 | $( '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' ) |
97 | 114 | ), |
| 115 | + $( '<div class="feedback-mode feedback-thanks" style="text-align:center;margin:1em"></div>' ).msg( |
| 116 | + 'feedback-thanks', _this.title.getNameText(), $feedbackPageLink.clone() |
| 117 | + ), |
98 | 118 | $( '<div class="feedback-mode feedback-error" style="position:relative;"></div>' ).append( |
99 | 119 | $( '<div class="feedback-error-msg style="color:#990000;margin-top:0.4em;"></div>' ) |
| 120 | + ) |
| 121 | + ); |
100 | 122 | |
101 | | - ) |
102 | | - ).dialog({ |
| 123 | + // undo some damage from dialog css |
| 124 | + this.$dialog.find( 'a' ).css( { 'color': '#0645ad' } ); |
| 125 | + |
| 126 | + this.$dialog.dialog({ |
103 | 127 | width: 500, |
104 | 128 | autoOpen: false, |
105 | 129 | title: mw.msg( this.dialogTitleMessageKey ), |
— | — | @@ -108,7 +132,7 @@ |
109 | 133 | |
110 | 134 | this.subjectInput = this.$dialog.find( 'input.feedback-subject' ).get(0); |
111 | 135 | this.messageInput = this.$dialog.find( 'textarea.feedback-message' ).get(0); |
112 | | - this.displayForm(); |
| 136 | + |
113 | 137 | }, |
114 | 138 | |
115 | 139 | display: function( s ) { |
— | — | @@ -121,6 +145,23 @@ |
122 | 146 | this.display( 'submitting' ); |
123 | 147 | }, |
124 | 148 | |
| 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 | + |
125 | 166 | /** |
126 | 167 | * Display the feedback form |
127 | 168 | * @param {Object} optional prefilled contents for the feedback form. Object with properties: |
— | — | @@ -128,11 +169,17 @@ |
129 | 170 | * message: {String} |
130 | 171 | */ |
131 | 172 | displayForm: function( contents ) { |
| 173 | + var _this = this; |
132 | 174 | this.subjectInput.value = (contents && contents.subject) ? contents.subject : ''; |
133 | 175 | this.messageInput.value = (contents && contents.message) ? contents.message : ''; |
134 | 176 | |
135 | 177 | 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 |
137 | 184 | }, |
138 | 185 | |
139 | 186 | displayError: function( message ) { |
— | — | @@ -161,7 +208,7 @@ |
162 | 209 | var ok = function( result ) { |
163 | 210 | if ( result.edit !== undefined ) { |
164 | 211 | if ( result.edit.result === 'Success' ) { |
165 | | - _this.$dialog.dialog( 'close' ); // edit complete, close dialog box |
| 212 | + _this.displayThanks(); |
166 | 213 | } else { |
167 | 214 | _this.displayError( 'feedback-error1' ); // unknown API result |
168 | 215 | } |
— | — | @@ -174,7 +221,7 @@ |
175 | 222 | displayError( 'feedback-error3' ); // ajax request failed |
176 | 223 | }; |
177 | 224 | |
178 | | - this.api.newSection( this.feedbackTitle, subject, message, ok, err ); |
| 225 | + this.api.newSection( this.title, subject, message, ok, err ); |
179 | 226 | |
180 | 227 | }, // close submit button function |
181 | 228 | |