Index: trunk/phase3/resources/mediawiki/mediawiki.feedback.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -/** |
| 2 | +/** |
3 | 3 | * mediawiki.Feedback |
4 | 4 | * |
5 | 5 | * @author Ryan Kaldari, 2010 |
— | — | @@ -6,40 +6,38 @@ |
7 | 7 | * @since 1.19 |
8 | 8 | * |
9 | 9 | * This is a way of getting simple feedback from users. It's useful |
10 | | - * for testing new features -- users can give you feedback without |
| 10 | + * for testing new features -- users can give you feedback without |
11 | 11 | * the difficulty of opening a whole new talk page. For this reason, |
12 | 12 | * it also tends to collect a wider range of both positive and negative |
13 | | - * comments. However you do need to tend to the feedback page. It will |
14 | | - * get long relatively quickly, and you often get multiple messages |
| 13 | + * comments. However you do need to tend to the feedback page. It will |
| 14 | + * get long relatively quickly, and you often get multiple messages |
15 | 15 | * reporting the same issue. |
16 | 16 | * |
17 | 17 | * It takes the form of thing on your page which, when clicked, opens a small |
18 | | - * dialog box. Submitting that dialog box appends its contents to a |
| 18 | + * dialog box. Submitting that dialog box appends its contents to a |
19 | 19 | * wiki page that you specify, as a new section. |
20 | 20 | * |
21 | 21 | * Not compatible with LiquidThreads. |
22 | | - * |
| 22 | + * |
23 | 23 | * Minimal example in how to use it: |
24 | | - * |
| 24 | + * |
25 | 25 | * var feedback = new mw.Feedback(); |
26 | | - * $( '#myButton' ).click( function() { feedback.launch(); } ); |
27 | | - * |
28 | | - * You can also launch the feedback form with a prefilled subject and body. |
29 | | - * See the docs for the launch() method. |
| 26 | + * $( '#myButton' ).click( function() { feedback.launch(); } ); |
| 27 | + * |
| 28 | + * You can also launch the feedback form with a prefilled subject and body. |
| 29 | + * See the docs for the launch() method. |
30 | 30 | */ |
31 | 31 | ( function( mw, $, undefined ) { |
32 | | - |
33 | 32 | /** |
34 | 33 | * Thingy for collecting user feedback on a wiki page |
35 | 34 | * @param {Array} options -- optional, all properties optional. |
36 | | - * api: {mw.Api} if omitted, will just create a standard API |
| 35 | + * api: {mw.Api} if omitted, will just create a standard API |
37 | 36 | * title: {mw.Title} the title of the page where you collect feedback. Defaults to "Feedback". |
38 | 37 | * dialogTitleMessageKey: {String} message key for the title of the dialog box |
39 | 38 | * bugsLink: {mw.Uri|String} url where bugs can be posted |
40 | 39 | * bugsListLink: {mw.Uri|String} url where bugs can be listed |
41 | 40 | */ |
42 | 41 | mw.Feedback = function( options ) { |
43 | | - |
44 | 42 | if ( options === undefined ) { |
45 | 43 | options = {}; |
46 | 44 | } |
— | — | @@ -72,7 +70,6 @@ |
73 | 71 | setup: function() { |
74 | 72 | var _this = this; |
75 | 73 | |
76 | | - |
77 | 74 | var $feedbackPageLink = $( '<a></a>' ) |
78 | 75 | .attr( { 'href': _this.title.getUrl(), 'target': '_blank' } ) |
79 | 76 | .css( { 'white-space': 'nowrap' } ); |
— | — | @@ -81,40 +78,40 @@ |
82 | 79 | |
83 | 80 | var $bugsListLink = $( '<a></a>' ).attr( { 'href': _this.bugsListLink, 'target': '_blank' } ); |
84 | 81 | |
85 | | - this.$dialog = |
86 | | - $( '<div style="position:relative;"></div>' ).append( |
| 82 | + this.$dialog = |
| 83 | + $( '<div style="position:relative;"></div>' ).append( |
87 | 84 | $( '<div class="feedback-mode feedback-form"></div>' ).append( |
88 | | - $( '<small></small>' ).append( |
89 | | - $( '<p></p>' ).msg( |
90 | | - 'feedback-bugornote', |
| 85 | + $( '<small></small>' ).append( |
| 86 | + $( '<p></p>' ).msg( |
| 87 | + 'feedback-bugornote', |
91 | 88 | $bugNoteLink, |
92 | | - _this.title.getNameText(), |
93 | | - $feedbackPageLink.clone() |
| 89 | + _this.title.getNameText(), |
| 90 | + $feedbackPageLink.clone() |
94 | 91 | ) |
95 | 92 | ), |
96 | | - $( '<div style="margin-top:1em;"></div>' ).append( |
97 | | - mw.msg( 'feedback-subject' ), |
98 | | - $( '<br/>' ), |
99 | | - $( '<input type="text" class="feedback-subject" name="subject" maxlength="60" style="width:99%;"/>' ) |
| 93 | + $( '<div style="margin-top:1em;"></div>' ).append( |
| 94 | + mw.msg( 'feedback-subject' ), |
| 95 | + $( '<br/>' ), |
| 96 | + $( '<input type="text" class="feedback-subject" name="subject" maxlength="60" style="width:99%;"/>' ) |
100 | 97 | ), |
101 | | - $( '<div style="margin-top:0.4em;"></div>' ).append( |
102 | | - mw.msg( 'feedback-message' ), |
103 | | - $( '<br/>' ), |
104 | | - $( '<textarea name="message" class="feedback-message" style="width:99%;" rows="5" cols="60"></textarea>' ) |
| 98 | + $( '<div style="margin-top:0.4em;"></div>' ).append( |
| 99 | + mw.msg( 'feedback-message' ), |
| 100 | + $( '<br/>' ), |
| 101 | + $( '<textarea name="message" class="feedback-message" style="width:99%;" rows="5" cols="60"></textarea>' ) |
105 | 102 | ) |
106 | 103 | ), |
107 | | - $( '<div class="feedback-mode feedback-bugs"></div>' ).append( |
| 104 | + $( '<div class="feedback-mode feedback-bugs"></div>' ).append( |
108 | 105 | $( '<p>' ).msg( 'feedback-bugcheck', $bugsListLink ) |
109 | 106 | ), |
110 | | - $( '<div class="feedback-mode feedback-submitting" style="text-align:center;margin:3em 0;"></div>' ).append( |
111 | | - mw.msg( 'feedback-adding' ), |
112 | | - $( '<br/>' ), |
113 | | - $( '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' ) |
| 107 | + $( '<div class="feedback-mode feedback-submitting" style="text-align:center;margin:3em 0;"></div>' ).append( |
| 108 | + mw.msg( 'feedback-adding' ), |
| 109 | + $( '<br/>' ), |
| 110 | + $( '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' ) |
114 | 111 | ), |
115 | 112 | $( '<div class="feedback-mode feedback-thanks" style="text-align:center;margin:1em"></div>' ).msg( |
116 | | - 'feedback-thanks', _this.title.getNameText(), $feedbackPageLink.clone() |
| 113 | + 'feedback-thanks', _this.title.getNameText(), $feedbackPageLink.clone() |
117 | 114 | ), |
118 | | - $( '<div class="feedback-mode feedback-error" style="position:relative;"></div>' ).append( |
| 115 | + $( '<div class="feedback-mode feedback-error" style="position:relative;"></div>' ).append( |
119 | 116 | $( '<div class="feedback-error-msg style="color:#990000;margin-top:0.4em;"></div>' ) |
120 | 117 | ) |
121 | 118 | ); |
— | — | @@ -128,7 +125,7 @@ |
129 | 126 | title: mw.msg( this.dialogTitleMessageKey ), |
130 | 127 | modal: true, |
131 | 128 | buttons: _this.buttons |
132 | | - }); |
| 129 | + }); |
133 | 130 | |
134 | 131 | this.subjectInput = this.$dialog.find( 'input.feedback-subject' ).get(0); |
135 | 132 | this.messageInput = this.$dialog.find( 'textarea.feedback-message' ).get(0); |
— | — | @@ -138,10 +135,10 @@ |
139 | 136 | display: function( s ) { |
140 | 137 | this.$dialog.dialog( { buttons:{} } ); // hide the buttons |
141 | 138 | this.$dialog.find( '.feedback-mode' ).hide(); // hide everything |
142 | | - this.$dialog.find( '.feedback-' + s ).show(); // show the desired div |
| 139 | + this.$dialog.find( '.feedback-' + s ).show(); // show the desired div |
143 | 140 | }, |
144 | 141 | |
145 | | - displaySubmitting: function() { |
| 142 | + displaySubmitting: function() { |
146 | 143 | this.display( 'submitting' ); |
147 | 144 | }, |
148 | 145 | |
— | — | @@ -158,7 +155,7 @@ |
159 | 156 | var _this = this; |
160 | 157 | this.display( 'thanks' ); |
161 | 158 | var closeButton = {}; |
162 | | - closeButton[ mw.msg( 'feedback-close' ) ] = function() { _this.$dialog.dialog( 'close' ); }; |
| 159 | + closeButton[ mw.msg( 'feedback-close' ) ] = function() { _this.$dialog.dialog( 'close' ); }; |
163 | 160 | this.$dialog.dialog( { buttons: closeButton } ); |
164 | 161 | }, |
165 | 162 | |
— | — | @@ -172,9 +169,9 @@ |
173 | 170 | var _this = this; |
174 | 171 | this.subjectInput.value = (contents && contents.subject) ? contents.subject : ''; |
175 | 172 | this.messageInput.value = (contents && contents.message) ? contents.message : ''; |
176 | | - |
177 | | - this.display( 'form' ); |
178 | 173 | |
| 174 | + this.display( 'form' ); |
| 175 | + |
179 | 176 | // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized |
180 | 177 | var formButtons = {}; |
181 | 178 | formButtons[ mw.msg( 'feedback-submit' ) ] = function() { _this.submit(); }; |
— | — | @@ -184,10 +181,10 @@ |
185 | 182 | |
186 | 183 | displayError: function( message ) { |
187 | 184 | this.display( 'error' ); |
188 | | - this.$dialog.find( '.feedback-error-msg' ).msg( message ); |
| 185 | + this.$dialog.find( '.feedback-error-msg' ).msg( message ); |
189 | 186 | }, |
190 | 187 | |
191 | | - cancel: function() { |
| 188 | + cancel: function() { |
192 | 189 | this.$dialog.dialog( 'close' ); |
193 | 190 | }, |
194 | 191 | |
— | — | @@ -220,12 +217,10 @@ |
221 | 218 | var err = function( code, info ) { |
222 | 219 | displayError( 'feedback-error3' ); // ajax request failed |
223 | 220 | }; |
224 | | - |
225 | | - this.api.newSection( this.title, subject, message, ok, err ); |
226 | 221 | |
| 222 | + this.api.newSection( this.title, subject, message, ok, err ); |
227 | 223 | }, // close submit button function |
228 | 224 | |
229 | | - |
230 | 225 | /** |
231 | 226 | * Modify the display form, and then open it, focusing interface on the subject. |
232 | 227 | * @param {Object} optional prefilled contents for the feedback form. Object with properties: |
— | — | @@ -236,9 +231,8 @@ |
237 | 232 | this.displayForm( contents ); |
238 | 233 | this.$dialog.dialog( 'open' ); |
239 | 234 | this.subjectInput.focus(); |
240 | | - } |
| 235 | + } |
241 | 236 | |
242 | 237 | }; |
243 | 238 | |
244 | | - |
245 | 239 | } )( window.mediaWiki, jQuery ); |