Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.css |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | #fbd-filters { |
5 | 5 | position: absolute; |
6 | 6 | width: 15em; |
7 | | - left: 0px; /* needed for ie6 & ie7 */ |
| 7 | + left: 0; /* needed for ie6 & ie7 */ |
8 | 8 | } |
9 | 9 | |
10 | 10 | #fbd-filters form { |
— | — | @@ -18,7 +18,8 @@ |
19 | 19 | margin-top: 0.5em; |
20 | 20 | } |
21 | 21 | |
22 | | -#fbd-description-text, #fbd-stats { |
| 22 | +#fbd-description-text, |
| 23 | +#fbd-stats { |
23 | 24 | padding: 0 0 1em 0; |
24 | 25 | } |
25 | 26 | |
— | — | @@ -26,7 +27,7 @@ |
27 | 28 | font-size: 1.2em; |
28 | 29 | margin: 0; |
29 | 30 | padding: 0; |
30 | | - border-bottom: solid 1px black; |
| 31 | + border-bottom: 1px solid black; |
31 | 32 | } |
32 | 33 | |
33 | 34 | #fbd-filters-types { |
— | — | @@ -93,8 +94,8 @@ |
94 | 95 | padding: 0; |
95 | 96 | list-style: none; |
96 | 97 | } |
97 | | -.fbd-leaderboard li{ |
98 | | - margin: 0px; |
| 98 | +.fbd-leaderboard li { |
| 99 | + margin: 0; |
99 | 100 | padding: 2px 10px; |
100 | 101 | list-style: none; |
101 | 102 | font-weight:600; |
— | — | @@ -109,12 +110,12 @@ |
110 | 111 | } |
111 | 112 | |
112 | 113 | .fbd-leaderboard-top-responders { |
113 | | - margin-top:15px; |
| 114 | + margin-top: 15px; |
114 | 115 | } |
115 | 116 | |
116 | 117 | .fbd-leaderboard-top-responders h5 { |
117 | | - border-bottom:1px solid #000000; |
118 | | - padding-bottom:0px; |
| 118 | + border-bottom: 1px solid #000000; |
| 119 | + padding-bottom: 0; |
119 | 120 | } |
120 | 121 | |
121 | 122 | /* Tool Tip */ |
— | — | @@ -162,8 +163,8 @@ |
163 | 164 | /* List */ |
164 | 165 | |
165 | 166 | #fbd-list { |
166 | | - margin: 0px 20px 0px 16em; |
167 | | - padding: 0px; |
| 167 | + margin: 0 20px 0 16em; |
| 168 | + padding: 0; |
168 | 169 | min-height: 20em; |
169 | 170 | list-style: none; |
170 | 171 | list-style-image: none; /* ie 7 fix */ |
— | — | @@ -178,15 +179,19 @@ |
179 | 180 | display: none; |
180 | 181 | } |
181 | 182 | |
182 | | -#fbd-list-more, #fbd-list-newer-older { |
| 183 | +#fbd-list-more, |
| 184 | +#fbd-list-newer-older { |
183 | 185 | margin: 1em 0 0 13em; |
184 | 186 | padding: 0.5em; |
185 | 187 | background-color: #e8f2f8; |
186 | 188 | } |
187 | 189 | |
188 | | -#fbd-list-more a, #fbd-list-more span, |
189 | | -#fbd-list-newer a, #fbd-list-older a, |
190 | | -#fbd-list-newer .fbd-page-disabled, #fbd-list-older .fbd-page-disabled { |
| 190 | +#fbd-list-more a, |
| 191 | +#fbd-list-more span, |
| 192 | +#fbd-list-newer a, |
| 193 | +#fbd-list-older a, |
| 194 | +#fbd-list-newer .fbd-page-disabled, |
| 195 | +#fbd-list-older .fbd-page-disabled { |
191 | 196 | font-size: 1.4em; |
192 | 197 | background-repeat: no-repeat; |
193 | 198 | } |
— | — | @@ -206,7 +211,8 @@ |
207 | 212 | float: left; |
208 | 213 | } |
209 | 214 | |
210 | | -#fbd-list-newer a, #fbd-list-newer .fbd-page-disabled { |
| 215 | +#fbd-list-newer a, |
| 216 | +#fbd-list-newer .fbd-page-disabled { |
211 | 217 | background-position: left center; |
212 | 218 | padding-left: 20px; |
213 | 219 | } |
— | — | @@ -217,8 +223,8 @@ |
218 | 224 | } |
219 | 225 | |
220 | 226 | .mw-ajax-loader { |
221 | | - /* Undo padding due to it destroying the layout for inline response */ |
222 | | - padding: 8px 16px 0px 16px !important; |
| 227 | + /* Undo padding due to it destroying the layout for inline response */ |
| 228 | + padding: 8px 16px 0 16px !important; |
223 | 229 | } |
224 | 230 | |
225 | 231 | /* The images here are named -ltr instead of -left and -rtl instead of -right |
— | — | @@ -238,7 +244,8 @@ |
239 | 245 | float: right; |
240 | 246 | } |
241 | 247 | |
242 | | -#fbd-list-older a, #fbd-list-older .fbd-page-disabled { |
| 248 | +#fbd-list-older a, |
| 249 | +#fbd-list-older .fbd-page-disabled { |
243 | 250 | background-position: right center; |
244 | 251 | padding-right: 20px; |
245 | 252 | } |
— | — | @@ -258,7 +265,7 @@ |
259 | 266 | } |
260 | 267 | |
261 | 268 | .fbd-item { |
262 | | - border-bottom: solid 1px silver; |
| 269 | + border-bottom: 1px solid silver; |
263 | 270 | position: relative; |
264 | 271 | padding-top: 0.5em; |
265 | 272 | padding-right: 1em; |
— | — | @@ -309,7 +316,7 @@ |
310 | 317 | |
311 | 318 | .fbd-item-response-icon { |
312 | 319 | float: left; |
313 | | - display: block; |
| 320 | + display: block; |
314 | 321 | height: 56px; |
315 | 322 | width: 56px; |
316 | 323 | background-position: center center; |
— | — | @@ -326,14 +333,14 @@ |
327 | 334 | } |
328 | 335 | |
329 | 336 | .fbd-item-response-success { |
330 | | - /* @embed */ |
| 337 | + /* @embed */ |
331 | 338 | background-image: url(images/response-success.png); |
332 | 339 | } |
333 | | - |
| 340 | + |
334 | 341 | .fbd-item-response-error { |
335 | | - /* @embed */ |
| 342 | + /* @embed */ |
336 | 343 | background-image: url(images/response-error.png); |
337 | | -} |
| 344 | +} |
338 | 345 | |
339 | 346 | .fbd-ajax-response > div > .fbd-ajax-heading { |
340 | 347 | font-size: 1.5em; |
— | — | @@ -378,7 +385,7 @@ |
379 | 386 | } |
380 | 387 | |
381 | 388 | .fbd-item-userLinks{ |
382 | | - font-size: 1em; |
| 389 | + font-size: 1em; |
383 | 390 | } |
384 | 391 | |
385 | 392 | .fbd-item-time { |
— | — | @@ -395,7 +402,7 @@ |
396 | 403 | } |
397 | 404 | |
398 | 405 | .fbd-response-text { |
399 | | - height: 5em; |
| 406 | + height: 5em; |
400 | 407 | overflow: hidden; |
401 | 408 | } |
402 | 409 | |
— | — | @@ -409,13 +416,13 @@ |
410 | 417 | } |
411 | 418 | |
412 | 419 | .fbd-response-preview-block { |
413 | | - width:100%; /* ie7 fix */ |
| 420 | + width:100%; /* ie7 fix */ |
414 | 421 | } |
415 | 422 | |
416 | 423 | .fbd-response-wikitext{ |
417 | 424 | background-color: #FDFFE7; |
418 | | - border: 1px solid #FCEB92; |
419 | | - padding: 5px; |
| 425 | + border: 1px solid #FCEB92; |
| 426 | + padding: 5px; |
420 | 427 | } |
421 | 428 | |
422 | 429 | .fbd-item-permalink, |
— | — | @@ -441,7 +448,6 @@ |
442 | 449 | visibility: visible; |
443 | 450 | } |
444 | 451 | |
445 | | - |
446 | 452 | .fbd-respond-link { |
447 | 453 | font-size: 1.1em; |
448 | 454 | cursor: pointer; |
— | — | @@ -458,19 +464,21 @@ |
459 | 465 | color: silver; |
460 | 466 | } |
461 | 467 | .fbd-response-form { |
462 | | - margin:0em 0px 1em 81px; |
| 468 | + margin: 0em 0 1em 81px; |
463 | 469 | } |
464 | 470 | .fbd-response-form b { |
465 | 471 | font-size: 1em; |
466 | 472 | } |
467 | | -.fbd-response-form small, .fbd-response-form .small{ |
| 473 | +.fbd-response-form small, |
| 474 | +.fbd-response-form .small{ |
468 | 475 | font-size: 0.8em; |
469 | 476 | color: #262626; |
470 | 477 | } |
471 | 478 | .fbd-response-formNote { |
472 | 479 | float: right; |
473 | 480 | } |
474 | | -.fbd-response-submit, .fbd-response-preview { |
| 481 | +.fbd-response-submit, |
| 482 | +.fbd-response-preview { |
475 | 483 | float: right; |
476 | 484 | } |
477 | 485 | .center { |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js |
— | — | @@ -1,50 +1,55 @@ |
2 | 2 | /** |
3 | 3 | * AJAX code for Special:MoodBarFeedback |
4 | 4 | */ |
5 | | -jQuery(function( $ ) { |
| 5 | +jQuery( document ).ready( function ( $ ) { |
6 | 6 | /** |
7 | 7 | * Saved form state |
8 | 8 | */ |
9 | | - var formState = { types: [], username: '', myresponse: null, showunanswered: null }; |
10 | | - |
| 9 | + var formState = { |
| 10 | + types: [], |
| 11 | + username: '', |
| 12 | + myresponse: null, |
| 13 | + showunanswered: null |
| 14 | + }; |
| 15 | + |
11 | 16 | /** |
12 | | - * Save the current form state to formState |
13 | | - */ |
14 | | - function saveFormState() { |
15 | | - formState.types = getSelectedTypes(); |
16 | | - formState.username = $( '#fbd-filters-username' ).val(); |
17 | | - formState.myresponse = $( '#fbd-filters-my-response' ).prop( 'checked' ) ? $( '#fbd-filters-my-response' ).val() : null; |
18 | | - formState.showunanswered = $( '#fbd-filters-show-unanswered' ).prop( 'checked' ) ? $( '#fbd-filters-show-unanswered' ).val() : null; |
19 | | - } |
20 | | - |
21 | | - /** |
22 | 17 | * Figure out which comment type filters have been selected. |
23 | 18 | * @return array of comment types |
24 | 19 | */ |
25 | 20 | function getSelectedTypes() { |
26 | 21 | var types = []; |
27 | | - $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() { |
| 22 | + $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function () { |
28 | 23 | if ( $(this).prop( 'checked' ) ) { |
29 | 24 | types.push( $(this).val() ); |
30 | 25 | } |
31 | 26 | } ); |
32 | 27 | return types; |
33 | 28 | } |
34 | | - |
| 29 | + |
35 | 30 | /** |
| 31 | + * Save the current form state to formState |
| 32 | + */ |
| 33 | + function saveFormState() { |
| 34 | + formState.types = getSelectedTypes(); |
| 35 | + formState.username = $( '#fbd-filters-username' ).val(); |
| 36 | + formState.myresponse = $( '#fbd-filters-my-response' ).prop( 'checked' ) ? $( '#fbd-filters-my-response' ).val() : null; |
| 37 | + formState.showunanswered = $( '#fbd-filters-show-unanswered' ).prop( 'checked' ) ? $( '#fbd-filters-show-unanswered' ).val() : null; |
| 38 | + } |
| 39 | + |
| 40 | + /** |
36 | 41 | * Select all comment type filters. |
37 | 42 | */ |
38 | 43 | function selectAllTypes() { |
39 | | - $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).prop( 'checked', true); |
| 44 | + $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).prop( 'checked', true ); |
40 | 45 | } |
41 | 46 | /** |
42 | 47 | * Set the moodbar-feedback-types and moodbar-feedback-username cookies based on formState. |
43 | 48 | * This function uses the form state saved in formState, so you may want to call saveFormState() first. |
44 | 49 | */ |
45 | 50 | function setCookies() { |
46 | | - $.cookie( 'moodbar-feedback-types', formState.types.join( '|' ), { 'path': '/', 'expires': 7 } ); |
| 51 | + $.cookie( 'moodbar-feedback-types', formState.types.join( '|' ), { path: '/', expires: 7 } ); |
47 | 52 | } |
48 | | - |
| 53 | + |
49 | 54 | /** |
50 | 55 | * Load the form state from the moodbar-feedback-types and moodbar-feedback-username cookies. |
51 | 56 | * This assumes the form is currently blank. |
— | — | @@ -53,14 +58,14 @@ |
54 | 59 | function loadFromCookies() { |
55 | 60 | var cookieTypes = $.cookie( 'moodbar-feedback-types' ), |
56 | 61 | changed = false; |
57 | | - |
| 62 | + |
58 | 63 | if ( cookieTypes ) { |
59 | 64 | // Because calling .indexOf() on an array doesn't work in all browsers, |
60 | 65 | // we'll use cookieTypes.indexOf( '|valueWereLookingFor' ) . In order for |
61 | 66 | // that to work, we need to prepend a pipe first. |
62 | 67 | cookieTypes = '|' + cookieTypes; |
63 | | - $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function() { |
64 | | - if ( !$(this).prop( 'checked' ) && cookieTypes.indexOf( '|' + $(this).val() ) != -1 ) { |
| 68 | + $( '#fbd-filters-type-praise, #fbd-filters-type-confusion, #fbd-filters-type-issues' ).each( function () { |
| 69 | + if ( !$(this).prop( 'checked' ) && cookieTypes.indexOf( '|' + $(this).val() ) !== -1 ) { |
65 | 70 | $(this).prop( 'checked', true ); |
66 | 71 | changed = true; |
67 | 72 | } |
— | — | @@ -70,7 +75,7 @@ |
71 | 76 | } |
72 | 77 | return changed; |
73 | 78 | } |
74 | | - |
| 79 | + |
75 | 80 | /** |
76 | 81 | * Show a message in the box that normally contains the More link. |
77 | 82 | * This will hide the more link, remove any existing <span>s, |
— | — | @@ -92,16 +97,16 @@ |
93 | 98 | * Load a set of 20 comments into the list. In 'filter' mode, the list is |
94 | 99 | * blanked before the new comments are loaded. In 'more' mode, the comments are |
95 | 100 | * loaded at the end of the existing set. |
96 | | - * |
| 101 | + * |
97 | 102 | * This function uses the form state saved in formState, so you may want to call saveFormState() first. |
98 | | - * |
| 103 | + * |
99 | 104 | * @param mode string Either 'filter' or 'more' |
100 | 105 | */ |
101 | 106 | function loadComments( mode ) { |
102 | 107 | var limit = 20, |
103 | 108 | reqData; |
104 | | - |
105 | | - if ( mode == 'filter' ) { |
| 109 | + |
| 110 | + if ( mode === 'filter' ) { |
106 | 111 | $( '#fbd-list' ).empty(); |
107 | 112 | } |
108 | 113 | // Hide the "More" link and put in a spinner |
— | — | @@ -114,18 +119,18 @@ |
115 | 120 | .end() |
116 | 121 | .children( 'span' ) |
117 | 122 | .remove(); // Remove any message added by showMessage() |
118 | | - |
| 123 | + |
119 | 124 | // Build the API request |
120 | | - // FIXME: in 'more' mode, changing the filters then clicking More will use the wrong criteria |
| 125 | + // @todo FIXME: in 'more' mode, changing the filters then clicking More will use the wrong criteria |
121 | 126 | reqData = { |
122 | | - 'action': 'query', |
123 | | - 'list': 'moodbarcomments', |
124 | | - 'format': 'json', |
125 | | - 'mbcprop': 'formatted', |
126 | | - 'mbclimit': limit + 2 // we drop the first and last result |
| 127 | + format: 'json', |
| 128 | + action: 'query', |
| 129 | + list: 'moodbarcomments', |
| 130 | + mbcprop: 'formatted', |
| 131 | + mbclimit: limit + 2 // we drop the first and last result |
127 | 132 | }; |
128 | | - if ( mode == 'more' ) { |
129 | | - reqData.mbccontinue = $( '#fbd-list').find( 'li:last' ).data( 'mbccontinue' ); |
| 133 | + if ( mode === 'more' ) { |
| 134 | + reqData.mbccontinue = $( '#fbd-list' ).find( 'li:last' ).data( 'mbccontinue' ); |
130 | 135 | } |
131 | 136 | if ( formState.types.length ) { |
132 | 137 | reqData.mbctype = formState.types.join( '|' ); |
— | — | @@ -139,37 +144,37 @@ |
140 | 145 | if ( formState.showunanswered ) { |
141 | 146 | reqData.mbcshowunanswered = formState.showunanswered; |
142 | 147 | } |
143 | | - |
| 148 | + |
144 | 149 | $.ajax( { |
145 | | - 'url': mw.util.wikiScript( 'api' ), |
146 | | - 'data': reqData, |
147 | | - 'success': function( data ) { |
| 150 | + url: mw.util.wikiScript( 'api' ), |
| 151 | + data: reqData, |
| 152 | + success: function ( data ) { |
148 | 153 | // Remove the spinner and restore the "More" link |
149 | 154 | $( '#fbd-list-more' ) |
150 | 155 | .removeClass( 'mw-ajax-loader' ) |
151 | 156 | .children( 'a' ) |
152 | 157 | .css( 'visibility', 'visible' ); // Undo visibility: hidden; |
153 | | - |
| 158 | + |
154 | 159 | if ( !data || !data.query || !data.query.moodbarcomments ) { |
155 | 160 | showMessage( mw.msg( 'moodbar-feedback-ajaxerror' ) ); |
156 | 161 | return; |
157 | 162 | } |
158 | | - |
| 163 | + |
159 | 164 | var comments = data.query.moodbarcomments, |
160 | 165 | len = comments.length, |
161 | 166 | $ul = $( '#fbd-list' ), |
162 | 167 | moreResults = false, |
163 | 168 | i; |
164 | 169 | if ( len === 0 ) { |
165 | | - if ( mode == 'more' ) { |
| 170 | + if ( mode === 'more' ) { |
166 | 171 | showMessage( mw.msg( 'moodbar-feedback-nomore' ) ); |
167 | 172 | } else { |
168 | 173 | showMessage( mw.msg( 'moodbar-feedback-noresults' ) ); |
169 | 174 | } |
170 | 175 | return; |
171 | 176 | } |
172 | | - |
173 | | - if ( mode == 'more' ) { |
| 177 | + |
| 178 | + if ( mode === 'more' ) { |
174 | 179 | // Drop the first element because it duplicates the last shown one |
175 | 180 | comments.shift(); |
176 | 181 | len--; |
— | — | @@ -179,158 +184,159 @@ |
180 | 185 | len = limit; |
181 | 186 | moreResults = true; |
182 | 187 | } |
183 | | - |
184 | | - for ( i = 0; i < len; i++ ) { |
| 188 | + |
| 189 | + for ( i = 0; i < len; i+= 1 ) { |
185 | 190 | $ul.append( comments[i].formatted ); |
186 | 191 | } |
187 | | - |
| 192 | + |
188 | 193 | if ( !moreResults ) { |
189 | | - if ( mode == 'more' ) { |
| 194 | + if ( mode === 'more' ) { |
190 | 195 | showMessage( mw.msg( 'moodbar-feedback-nomore' ) ); |
191 | 196 | } else { |
192 | 197 | $( '#fbd-list-more' ).hide(); |
193 | 198 | } |
194 | 199 | } |
195 | 200 | }, |
196 | | - 'error': function( jqXHR, textStatus, errorThrown ) { |
| 201 | + error: function ( jqXHR, textStatus, errorThrown ) { |
197 | 202 | $( '#fbd-list-more' ).removeClass( 'mw-ajax-loader' ); |
198 | | - showMessage( mw.msg( 'moodbar-feedback-ajaxerror' ) ); |
| 203 | + showMessage( mw.msg( 'moodbar-feedback-ajaxerror' ) ); |
199 | 204 | }, |
200 | | - 'dataType': 'json' |
| 205 | + dataType: 'json' |
201 | 206 | } ); |
202 | 207 | } |
203 | | - |
| 208 | + |
204 | 209 | /** |
205 | 210 | * Reload a comment, showing hidden comments if necessary |
206 | 211 | * @param $item jQuery item containing the .fbd-item |
207 | 212 | * @param show Set to true to show the comment despite its hidden status |
208 | 213 | */ |
209 | 214 | function reloadItem( $item, show ) { |
210 | | - var cont = $item.data('mbccontinue'); |
211 | | - |
212 | | - var request = { |
213 | | - 'action' : 'query', |
214 | | - 'list' : 'moodbarcomments', |
215 | | - 'format' : 'json', |
216 | | - 'mbcprop' : 'formatted', |
217 | | - 'mbclimit' : 1, |
218 | | - 'mbccontinue' : cont |
| 215 | + var cont, request; |
| 216 | + cont = $item.data( 'mbccontinue' ); |
| 217 | + |
| 218 | + request = { |
| 219 | + action: 'query', |
| 220 | + list: 'moodbarcomments', |
| 221 | + format: 'json', |
| 222 | + mbcprop: 'formatted', |
| 223 | + mbclimit: 1, |
| 224 | + mbccontinue: cont |
219 | 225 | }; |
220 | | - |
| 226 | + |
221 | 227 | if ( show ) { |
222 | 228 | request.mbcprop = 'formatted|hidden'; |
223 | 229 | } |
224 | | - |
225 | | - $.post( mw.util.wikiScript('api'), request, |
226 | | - function( data ) { |
| 230 | + |
| 231 | + $.post( mw.util.wikiScript( 'api' ), request, |
| 232 | + function ( data ) { |
227 | 233 | if ( data && data.query && data.query.moodbarcomments && |
228 | 234 | data.query.moodbarcomments.length > 0 |
229 | 235 | ) { |
230 | | - var $content = $j(data.query.moodbarcomments[0].formatted); |
231 | | - $item.replaceWith($content); |
| 236 | + var $content = $( data.query.moodbarcomments[0].formatted ); |
| 237 | + $item.replaceWith( $content ); |
232 | 238 | } else { |
233 | 239 | // Failure, just remove the link. |
234 | | - $item.find('.fbd-item-show').remove(); |
235 | | - $item.find('.mw-ajax-loader').remove(); |
| 240 | + $item.find( '.fbd-item-show' ).remove(); |
| 241 | + $item.find( '.mw-ajax-loader' ).remove(); |
236 | 242 | showItemError( $item ); |
237 | 243 | } |
238 | 244 | }, 'json' ) |
239 | | - .error( function() { showItemError( $item ); } ); |
| 245 | + .error( function () { showItemError( $item ); } ); |
240 | 246 | } |
241 | | - |
| 247 | + |
242 | 248 | /** |
243 | 249 | * Show a hidden comment |
244 | 250 | */ |
245 | 251 | function showHiddenItem(e) { |
246 | | - var $item = $(this).closest('.fbd-item'); |
247 | | - |
248 | | - var $spinner = $('<span class="mw-ajax-loader"> </span>'); |
249 | | - $item.find('.fbd-item-show').empty().append( $spinner ); |
250 | | - |
| 252 | + var $item = $(this).closest( '.fbd-item' ); |
| 253 | + |
| 254 | + var $spinner = $( '<span class="mw-ajax-loader"> </span>' ); |
| 255 | + $item.find( '.fbd-item-show' ).empty().append( $spinner ); |
| 256 | + |
251 | 257 | reloadItem( $item, true ); |
252 | | - |
| 258 | + |
253 | 259 | e.preventDefault(); |
254 | 260 | } |
255 | | - |
| 261 | + |
256 | 262 | /** |
257 | 263 | * Show an error on an individual item |
258 | 264 | * @param $item The .fbd-item to show the message on |
259 | 265 | * @param message The message to show (currently ignored) |
260 | 266 | */ |
261 | 267 | function showItemError( $item, message ) { |
262 | | - $item.find('.mw-ajax-loader').remove(); |
263 | | - $('<div class="error"/>') |
264 | | - .text( mw.msg('moodbar-feedback-action-error') ) |
265 | | - .prependTo($item); |
| 268 | + $item.find( '.mw-ajax-loader' ).remove(); |
| 269 | + $( '<div class="error"></div>' ) |
| 270 | + .text( mw.msg( 'moodbar-feedback-action-error' ) ) |
| 271 | + .prependTo( $item ); |
266 | 272 | } |
267 | | - |
| 273 | + |
268 | 274 | /** |
269 | 275 | * Do this before administrative action to confirm action and provide reason |
270 | | - * @param params to store action paramaters |
| 276 | + * @param params to store action paramaters |
271 | 277 | * @param $item jQuery item containing the .fbd-item |
272 | 278 | */ |
273 | | - function confirmAction(params, $item){ |
274 | | - |
275 | | - var inlineForm = $('<span>').attr('class', 'fbd-item-reason') |
276 | | - .append( $('<span>').text(mw.msg( 'moodbar-action-reason' )) ) |
277 | | - .append( $('<input />').attr({'class':'fbd-action-reason', 'name':'fbd-action-reason'}) ) |
278 | | - .append( $('<button>').attr('class', 'fbd-action-confirm').text( mw.msg('moodbar-feedback-action-confirm')) ) |
279 | | - .append( $('<button>').attr('class', 'fbd-action-cancel').text( mw.msg('moodbar-feedback-action-cancel')) ) |
280 | | - .append( $('<span>').attr('class', 'fbd-item-reason-msg') ) |
281 | | - .append( $('<div>').attr('class', 'fbd-item-reason-msg') ); |
| 279 | + function confirmAction( params, $item ) { |
282 | 280 | |
| 281 | + var inlineForm = $( '<span>' ).attr( 'class', 'fbd-item-reason' ) |
| 282 | + .append( $( '<span>' ).text(mw.msg( 'moodbar-action-reason' )) ) |
| 283 | + .append( $( '<input>' ).attr({'class':'fbd-action-reason', 'name':'fbd-action-reason'}) ) |
| 284 | + .append( $( '<button>' ).attr( 'class', 'fbd-action-confirm' ).text( mw.msg( 'moodbar-feedback-action-confirm' )) ) |
| 285 | + .append( $( '<button>' ).attr( 'class', 'fbd-action-cancel' ).text( mw.msg( 'moodbar-feedback-action-cancel' )) ) |
| 286 | + .append( $( '<span>' ).attr( 'class', 'fbd-item-reason-msg' ) ) |
| 287 | + .append( $( '<div>' ).attr( 'class', 'fbd-item-reason-msg' ) ); |
| 288 | + |
283 | 289 | var storedParams = params; |
284 | 290 | var $storedItem = $item; |
285 | | - |
286 | | - $item.find('.fbd-item-hide, .fbd-item-restore, .fbd-item-permalink') |
| 291 | + |
| 292 | + $item.find( '.fbd-item-hide, .fbd-item-restore, .fbd-item-permalink' ) |
287 | 293 | .empty(); |
288 | | - |
289 | | - $item.find('.fbd-item-message') |
| 294 | + |
| 295 | + $item.find( '.fbd-item-message' ) |
290 | 296 | .append(inlineForm); |
291 | | - |
292 | | - $('.fbd-action-confirm').click( function() { |
293 | | - storedParams.reason = $storedItem.find('.fbd-action-reason').val(); |
294 | | - |
295 | | - if( storedParams.reason ) { |
296 | | - doAction(storedParams, $storedItem); |
| 297 | + |
| 298 | + $( '.fbd-action-confirm' ).click( function () { |
| 299 | + storedParams.reason = $storedItem.find( '.fbd-action-reason' ).val(); |
| 300 | + |
| 301 | + if ( storedParams.reason ) { |
| 302 | + doAction( storedParams, $storedItem ); |
297 | 303 | } else { |
298 | | - inlineMessage($storedItem.find('.fbd-item-reason'), mw.msg( 'moodbar-action-reason-required' ), function() { |
| 304 | + inlineMessage( $storedItem.find( '.fbd-item-reason' ), mw.msg( 'moodbar-action-reason-required' ), function () { |
299 | 305 | reloadItem( $storedItem, true ); |
300 | | - }); |
| 306 | + }); |
301 | 307 | } |
302 | | - |
| 308 | + |
303 | 309 | }); |
304 | | - $('.fbd-action-cancel').click( function() { |
| 310 | + $( '.fbd-action-cancel' ).click( function () { |
305 | 311 | reloadItem( $storedItem, true ); |
306 | 312 | }); |
307 | | - |
| 313 | + |
308 | 314 | } |
309 | | - |
| 315 | + |
310 | 316 | /** |
311 | 317 | * Execute an action on an item |
312 | 318 | * @param params contains action parameters |
313 | 319 | * @param $item jQuery item containing the .fbd-item |
314 | 320 | */ |
315 | 321 | function doAction( params, $item ) { |
316 | | - var item_id = $item.data('mbccontinue').split('|')[1]; |
317 | | - |
318 | | - var errorHandler = function(error_str) { |
| 322 | + var item_id = $item.data( 'mbccontinue' ).split( '|' )[1]; |
| 323 | + |
| 324 | + var errorHandler = function ( error_str ) { |
319 | 325 | showItemError( $item, error_str ); |
320 | 326 | }; |
321 | | - |
322 | | - var $spinner = $('<span class="mw-ajax-loader"> </span>'); |
323 | | - $item.find('.fbd-item-hide').empty().append( $spinner ); |
324 | | - |
325 | | - $.post( mw.util.wikiScript('api'), |
| 327 | + |
| 328 | + var $spinner = $( '<span class="mw-ajax-loader"> </span>' ); |
| 329 | + $item.find( '.fbd-item-hide' ).empty().append( $spinner ); |
| 330 | + |
| 331 | + $.post( mw.util.wikiScript( 'api' ), |
326 | 332 | $.extend( { |
327 | | - 'action' : 'feedbackdashboard', |
328 | | - 'token' : mw.user.tokens.get('editToken'), |
329 | | - 'item' : item_id, |
330 | | - 'format' : 'json' |
| 333 | + action: 'feedbackdashboard', |
| 334 | + token: mw.user.tokens.get( 'editToken' ), |
| 335 | + item: item_id, |
| 336 | + format: 'json' |
331 | 337 | }, params ), |
332 | | - function(response) { |
| 338 | + function ( response ) { |
333 | 339 | if ( response && response.feedbackdashboard ) { |
334 | | - if ( response.feedbackdashboard.result == 'success' ) { |
| 340 | + if ( response.feedbackdashboard.result === 'success' ) { |
335 | 341 | reloadItem( $item ); |
336 | 342 | } else { |
337 | 343 | errorHandler( response.feedbackdashboard.error ); |
— | — | @@ -343,178 +349,180 @@ |
344 | 350 | } ) |
345 | 351 | .error( errorHandler ); |
346 | 352 | } |
347 | | - |
| 353 | + |
348 | 354 | /** |
349 | 355 | * Restore a hidden item to full visibility (event handler) |
| 356 | + * @param e {jQuery.Event} |
350 | 357 | */ |
351 | | - function restoreItem(e) { |
352 | | - var $item = $(this).closest('.fbd-item'); |
353 | | - |
354 | | - confirmAction( { 'mbaction' : 'restore' }, $item ); |
| 358 | + function restoreItem( e ) { |
| 359 | + var $item = $(this).closest( '.fbd-item' ); |
| 360 | + |
| 361 | + confirmAction( { mbaction: 'restore' }, $item ); |
355 | 362 | e.preventDefault(); |
356 | 363 | } |
357 | | - |
| 364 | + |
358 | 365 | /** |
359 | 366 | * Hide a item from view (event handler) |
| 367 | + * @param e {jQuery.Event} |
360 | 368 | */ |
361 | | - function hideItem(e) { |
362 | | - var $item = $(this).closest('.fbd-item'); |
363 | | - closeAllResponders(); //if any are open |
364 | | - confirmAction( { 'mbaction' : 'hide' }, $item ); |
| 369 | + function hideItem( e ) { |
| 370 | + var $item = $(this).closest( '.fbd-item' ); |
| 371 | + closeAllResponders(); // If any are open |
| 372 | + confirmAction( { mbaction: 'hide' }, $item ); |
365 | 373 | e.preventDefault(); |
366 | 374 | } |
367 | | - |
| 375 | + |
368 | 376 | /** |
369 | 377 | * Method to close all responders. |
370 | 378 | * Remove all .fbd-response-form from the dashboard |
371 | 379 | */ |
372 | 380 | function closeAllResponders() { |
373 | | - |
374 | | - $( '.fbd-item').each(function(index, value){ |
375 | | - |
376 | | - $link = $( this ).find('.fbd-respond-link'); |
377 | | - if( $link.hasClass('responder-expanded') ) { |
378 | | - |
379 | | - $link.find('.fbd-item-response-expanded') |
380 | | - .addClass('fbd-item-response-collapsed') |
381 | | - .removeClass('fbd-item-response-expanded') |
| 381 | + |
| 382 | + $( '.fbd-item' ).each( function () { |
| 383 | + |
| 384 | + var $link = $( this ).find( '.fbd-respond-link' ); |
| 385 | + if ( $link.hasClass( 'responder-expanded' ) ) { |
| 386 | + |
| 387 | + $link.find( '.fbd-item-response-expanded' ) |
| 388 | + .addClass( 'fbd-item-response-collapsed' ) |
| 389 | + .removeClass( 'fbd-item-response-expanded' ) |
382 | 390 | .end() |
383 | | - .find('.fbd-item-response-collapsed') |
| 391 | + .find( '.fbd-item-response-collapsed' ) |
384 | 392 | .parent() |
385 | | - .removeClass('responder-expanded'); |
| 393 | + .removeClass( 'responder-expanded' ); |
386 | 394 | //remove disabled prop to prevent memory leaks in IE < 9 |
387 | | - $( '.fbd-response-preview, .fbd-response-submit').removeProp('disabled'); |
388 | | - $( this ).find('.fbd-response-form').remove(); |
389 | | - } |
| 395 | + $( '.fbd-response-preview, .fbd-response-submit' ).removeProp( 'disabled' ); |
| 396 | + $( this ).find( '.fbd-response-form' ).remove(); |
| 397 | + } |
390 | 398 | }); |
391 | 399 | } |
392 | | - |
| 400 | + |
393 | 401 | /** |
394 | 402 | * Show the Response form for the item |
395 | 403 | * Build the response form elements once |
396 | | - * |
| 404 | + * @param e {jQuery.Event} |
397 | 405 | */ |
398 | | - function showResponseForm(e){ |
399 | | - |
400 | | - if( $(this).hasClass('responder-expanded') ) { |
401 | | - |
402 | | - closeAllResponders(); |
403 | | - |
404 | | - } else { |
405 | | - |
406 | | - //init terms of use link |
407 | | - var termsLink = mw.html.element ('a', { |
| 406 | + function showResponseForm( e ) { |
| 407 | + |
| 408 | + if ( $(this).hasClass( 'responder-expanded' ) ) { |
| 409 | + |
| 410 | + closeAllResponders(); |
| 411 | + |
| 412 | + } else { |
| 413 | + |
| 414 | + // Init terms of use link |
| 415 | + var termsLink = mw.html.element ( 'a', { |
408 | 416 | 'href': mw.msg( 'moodbar-response-url' ), |
409 | 417 | 'title': mw.msg( 'moodbar-response-link' ), |
410 | 418 | 'target': '_new' |
411 | 419 | }, mw.msg( 'moodbar-response-link' ) ); |
412 | | - |
413 | | - //ULA |
| 420 | + |
| 421 | + // ULA |
414 | 422 | var ula = mw.msg( 'moodbar-response-terms' ) |
415 | 423 | .replace ( /\$1/g, termsLink ); |
416 | | - |
417 | | - //build form |
418 | | - var inlineForm = $('<div>').attr( 'class', 'fbd-response-form' ) |
| 424 | + |
| 425 | + // Build form |
| 426 | + var inlineForm = $( '<div>' ).attr( 'class', 'fbd-response-form' ) |
419 | 427 | .append( |
420 | | - $('<b>').text( mw.msg( 'moodbar-response-add' ) ) |
| 428 | + $( '<b>' ).text( mw.msg( 'moodbar-response-add' ) ) |
421 | 429 | ).append( |
422 | | - $('<small>').attr( 'class', 'fbd-text-gray' ).text( ' (' + mw.msg( 'moodbar-response-desc' ) + ') ' ) |
| 430 | + $( '<small>' ).attr( 'class', 'fbd-text-gray' ).text( ' (' + mw.msg( 'moodbar-response-desc' ) + ') ' ) |
423 | 431 | ).append( |
424 | | - $('<div>').attr( 'class', 'fbd-response-formNote' ) |
425 | | - .append($('<small>') |
| 432 | + $( '<div>' ).attr( 'class', 'fbd-response-formNote' ) |
| 433 | + .append( $( '<small>' ) |
426 | 434 | .append( |
427 | | - $('<span>').attr( 'class', 'fbd-response-charCount' ) |
| 435 | + $( '<span>' ).attr( 'class', 'fbd-response-charCount' ) |
428 | 436 | ).append( |
429 | | - $('<span>').text( mw.msg( 'moodbar-form-note-dynamic' ).replace( /\$1/g, "" ) ) |
| 437 | + $( '<span>' ).text( mw.msg( 'moodbar-form-note-dynamic' ).replace( /\$1/g, "" ) ) |
430 | 438 | ) |
431 | 439 | ) |
432 | 440 | ).append( |
433 | | - $('<textarea>').attr( { 'class':'fbd-response-text', 'name':'fbd-response-text' } ) |
| 441 | + $( '<textarea>' ).attr( { 'class':'fbd-response-text', 'name':'fbd-response-text' } ) |
434 | 442 | ).append( |
435 | | - $('<div />').attr('class', 'fbd-response-preview-spinner') |
436 | | - .append($('<span />').attr('class', 'mw-ajax-loader') |
| 443 | + $( '<div>' ).attr( 'class', 'fbd-response-preview-spinner' ) |
| 444 | + .append( $( '<span>' ).attr( 'class', 'mw-ajax-loader' ) |
437 | 445 | //hack the .mw-ajax-loader styles beacuse they are horrible for reuse |
438 | | - .css({ 'top':'0px','padding':'16px', 'display':'block', 'width':'32px' }).html(' ') |
439 | | - ).hide() |
| 446 | + .css({ 'top':'0px','padding':'16px', 'display':'block', 'width':'32px' }).html( ' ' ) |
| 447 | + ).hide() |
440 | 448 | ).append( |
441 | | - $('<div />').attr('class', 'fbd-response-preview-block') |
| 449 | + $( '<div>' ).attr( 'class', 'fbd-response-preview-block' ) |
442 | 450 | .append( |
443 | | - $('<div />').attr('class', 'fbd-response-wikitext').hide()) |
| 451 | + $( '<div>' ).attr( 'class', 'fbd-response-wikitext' ).hide()) |
444 | 452 | .append( |
445 | | - $('<div>').attr('class', 'ula small').html( ula ).hide()) |
| 453 | + $( '<div>' ).attr( 'class', 'ula small' ).html( ula ).hide()) |
446 | 454 | ).append( |
447 | | - $('<button>').attr( 'class', 'fbd-response-submit' ).html( mw.msg( 'moodbar-response-btn' ) + ' <span class="fbd-item-send-response-icon"></span>' ) |
| 455 | + $( '<button>' ).attr( 'class', 'fbd-response-submit' ).html( mw.msg( 'moodbar-response-btn' ) + ' <span class="fbd-item-send-response-icon"></span>' ) |
448 | 456 | .prop( 'disabled', true ).hide() |
449 | 457 | ).append( |
450 | | - $('<button>').attr('class', 'fbd-response-preview-back').text( mw.msg( 'response-back-text' ) ).hide() |
| 458 | + $( '<button>' ).attr( 'class', 'fbd-response-preview-back' ).text( mw.msg( 'response-back-text' ) ).hide() |
451 | 459 | ).append( |
452 | | - $('<button>').attr( 'class', 'fbd-response-preview').text ( mw.msg( 'response-preview-text' ) ).prop( 'disabled', true ) |
| 460 | + $( '<button>' ).attr( 'class', 'fbd-response-preview' ).text ( mw.msg( 'response-preview-text' ) ).prop( 'disabled', true ) |
453 | 461 | ).append( |
454 | | - $('<div>').attr( 'style', 'clear:both' ) |
| 462 | + $( '<div>' ).attr( 'style', 'clear:both' ) |
455 | 463 | ); |
456 | | - |
457 | | - //get the feedbackItem |
458 | | - var $item = $(this).closest('.fbd-item'); |
459 | | - //close any open responders prior to opening this one. |
| 464 | + |
| 465 | + // Get the feedbackItem |
| 466 | + var $item = $(this).closest( '.fbd-item' ); |
| 467 | + // Close any open responders prior to opening this one. |
460 | 468 | closeAllResponders(); |
461 | | - |
462 | | - $(this).find('.fbd-item-response-collapsed') |
463 | | - .addClass('fbd-item-response-expanded') |
464 | | - .removeClass('fbd-item-response-collapsed') |
| 469 | + |
| 470 | + $(this).find( '.fbd-item-response-collapsed' ) |
| 471 | + .addClass( 'fbd-item-response-expanded' ) |
| 472 | + .removeClass( 'fbd-item-response-collapsed' ) |
465 | 473 | .end() |
466 | | - .find('.fbd-item-response-expanded') |
| 474 | + .find( '.fbd-item-response-expanded' ) |
467 | 475 | .parent() |
468 | | - .addClass('responder-expanded'); |
| 476 | + .addClass( 'responder-expanded' ); |
469 | 477 | |
470 | 478 | $item.append(inlineForm) |
471 | | - .find('.fbd-response-text') |
472 | | - .NobleCount('.fbd-response-charCount', { |
| 479 | + .find( '.fbd-response-text' ) |
| 480 | + .NobleCount( '.fbd-response-charCount', { |
473 | 481 | max_chars:5000, |
474 | 482 | /* |
475 | 483 | * Callbacks: |
476 | 484 | * function on_negative: called when text field is negative in remaining characters. |
477 | | - * @param t_obj is the text object. need to pass to the callback to add modifiers. |
| 485 | + * @param t_obj is the text object. need to pass to the callback to add modifiers. |
478 | 486 | */ |
479 | | - on_negative: function( t_obj ) { |
| 487 | + on_negative: function ( t_obj ) { |
480 | 488 | $( t_obj ) |
481 | 489 | .prev() |
482 | | - .find('span') |
483 | | - .addClass('red-bold'); |
| 490 | + .find( 'span' ) |
| 491 | + .addClass( 'red-bold' ); |
484 | 492 | }, |
485 | 493 | /* |
486 | 494 | * function on_positive: called when text field has available remaining characters. |
487 | | - * @param t_obj is the text object. need to pass to the callback to add modifiers. |
| 495 | + * @param t_obj is the text object. need to pass to the callback to add modifiers. |
488 | 496 | */ |
489 | | - on_positive: function( t_obj ) { |
| 497 | + on_positive: function ( t_obj ) { |
490 | 498 | $( t_obj ) |
491 | 499 | .prev() |
492 | | - .find('span') |
493 | | - .removeClass('red-bold'); |
| 500 | + .find( 'span' ) |
| 501 | + .removeClass( 'red-bold' ); |
494 | 502 | } |
495 | 503 | }) |
496 | 504 | .end() |
497 | | - .find('.fbd-response-text') |
498 | | - .keyup( function(event) { |
499 | | - validateResponse($item); |
| 505 | + .find( '.fbd-response-text' ) |
| 506 | + .keyup( function ( e ) { |
| 507 | + validateResponse( $item ); |
500 | 508 | }) |
501 | 509 | .elastic() |
502 | 510 | .end() |
503 | | - .find('.fbd-response-preview') |
| 511 | + .find( '.fbd-response-preview' ) |
504 | 512 | .click (function () { |
505 | 513 | //toggle preview |
506 | 514 | $item = $(this).parent().parent(); |
507 | | - $item.find('.fbd-response-preview, .fbd-response-text').hide(); |
508 | | - $item.find('.fbd-response-submit, .fbd-response-preview-back, .ula').show(); |
509 | | - var wikitext = $item.find('.fbd-response-text').val(); |
510 | | - wikitext = wikitext.replace(/~{3,5}/g, '') + "\n\n~~~~"; //remove and add signature for |
511 | | - parseWikiText($item, wikitext); |
| 515 | + $item.find( '.fbd-response-preview, .fbd-response-text' ).hide(); |
| 516 | + $item.find( '.fbd-response-submit, .fbd-response-preview-back, .ula' ).show(); |
| 517 | + var wikitext = $item.find( '.fbd-response-text' ).val(); |
| 518 | + wikitext = wikitext.replace( /~{3,5}/g, '' ) + "\n\n~~~~"; // Remove and add signature for |
| 519 | + parseWikiText( $item, wikitext ); |
512 | 520 | }); |
513 | | - } |
| 521 | + } |
514 | 522 | e.preventDefault(); |
515 | 523 | } |
516 | 524 | |
517 | | - function parseWikiText($item, wikitext) { |
518 | | - $item.find('.fbd-response-preview-spinner').show(); |
| 525 | + function parseWikiText( $item, wikitext ) { |
| 526 | + $item.find( '.fbd-response-preview-spinner' ).show(); |
519 | 527 | $.ajax({ |
520 | 528 | url: mw.util.wikiScript( 'api' ), |
521 | 529 | data: { |
— | — | @@ -527,22 +535,22 @@ |
528 | 536 | }, |
529 | 537 | dataType: 'json', |
530 | 538 | type: 'POST', |
531 | | - success: function( data ) { |
| 539 | + success: function ( data ) { |
532 | 540 | $item |
533 | | - .find('.fbd-response-preview-spinner') //fadeout spinner |
| 541 | + .find( '.fbd-response-preview-spinner' ) // Fadeout spinner |
534 | 542 | .hide() |
535 | 543 | .end() |
536 | | - .find('.fbd-response-wikitext') |
| 544 | + .find( '.fbd-response-wikitext' ) |
537 | 545 | .html( data.parse.text['*'] ) |
538 | 546 | .fadeIn() |
539 | 547 | .end(); |
540 | 548 | }, |
541 | | - error: function() { |
542 | | - //handle error |
543 | | - //fadeout spinner |
| 549 | + error: function () { |
| 550 | + // Handle error |
| 551 | + // @todo: Fadeout spinner |
544 | 552 | } |
545 | 553 | }); |
546 | | - } |
| 554 | + } |
547 | 555 | |
548 | 556 | /** |
549 | 557 | * Toggle submit / preview button from enabled to disabled |
— | — | @@ -550,15 +558,15 @@ |
551 | 559 | * @param $item jQuery item containing the .fbd-item |
552 | 560 | * Require at least 1 character and limit to 5000 |
553 | 561 | */ |
554 | | - function validateResponse($item) { |
555 | | - var response = $.trim( $item.find('.fbd-response-text').val() ); |
556 | | - if( response.length > 0 && response.length <= 5000 ) { |
557 | | - $item.find( '.fbd-response-submit, .fbd-response-preview').prop('disabled', false); |
| 562 | + function validateResponse( $item ) { |
| 563 | + var response = $.trim( $item.find( '.fbd-response-text' ).val() ); |
| 564 | + if ( response.length > 0 && response.length <= 5000 ) { |
| 565 | + $item.find( '.fbd-response-submit, .fbd-response-preview' ).prop( 'disabled', false); |
558 | 566 | } else { |
559 | | - $item.find( '.fbd-response-submit, .fbd-response-preview').prop('disabled', true); |
| 567 | + $item.find( '.fbd-response-submit, .fbd-response-preview' ).prop( 'disabled', true); |
560 | 568 | } |
561 | 569 | } |
562 | | - |
| 570 | + |
563 | 571 | /** |
564 | 572 | * Generic inline message, with fadeout |
565 | 573 | * @param $el Element to display message inside |
— | — | @@ -569,7 +577,7 @@ |
570 | 578 | $el.empty() |
571 | 579 | .text( msg ) |
572 | 580 | .delay(2000) |
573 | | - .fadeOut('slow', callback); |
| 581 | + .fadeOut( 'slow', callback); |
574 | 582 | } |
575 | 583 | /** |
576 | 584 | * Set status message for Send Response |
— | — | @@ -578,161 +586,161 @@ |
579 | 587 | * @param head Heading text to be displayed |
580 | 588 | * @param body Body text to be displayed |
581 | 589 | */ |
582 | | - function responseMessage ($el, type, head, body) { |
| 590 | + function responseMessage( $el, type, head, body ) { |
583 | 591 | $el |
584 | | - .find('.mw-ajax-loader') |
585 | | - .addClass('fbd-item-response-' + type) |
586 | | - .removeClass('mw-ajax-loader') |
| 592 | + .find( '.mw-ajax-loader' ) |
| 593 | + .addClass( 'fbd-item-response-' + type ) |
| 594 | + .removeClass( 'mw-ajax-loader' ) |
587 | 595 | .end() |
588 | | - .find('.fbd-ajax-heading') |
589 | | - .text( head ) |
| 596 | + .find( '.fbd-ajax-heading' ) |
| 597 | + .text( head ) |
590 | 598 | .end() |
591 | | - .find('.fbd-ajax-text') |
| 599 | + .find( '.fbd-ajax-text' ) |
592 | 600 | .html( body ) |
593 | 601 | .end(); |
594 | | - setTimeout(function(){ |
595 | | - reloadItem($el, true); |
| 602 | + setTimeout( function () { |
| 603 | + reloadItem( $el, true ); |
596 | 604 | }, 2000); |
597 | 605 | } |
598 | | - /* Display tooltip for response concurrency notification |
| 606 | + |
| 607 | + /** |
| 608 | + * Display tooltip for response concurrency notification |
599 | 609 | * @param $item Feedback item |
600 | | - */ |
601 | | - function loadToolTip($item) { |
602 | | - var tooltip = $('<div>').attr('class', 'fbd-tooltip-overlay-wrap') |
| 610 | + */ |
| 611 | + function loadToolTip( $item ) { |
| 612 | + var tooltip = $( '<div>' ).attr( 'class', 'fbd-tooltip-overlay-wrap' ) |
603 | 613 | .append( |
604 | | - $('<div>').attr('class', 'fbd-tooltip-overlay') |
| 614 | + $( '<div>' ).attr( 'class', 'fbd-tooltip-overlay' ) |
605 | 615 | .append( |
606 | | - $('<div>').attr('class', 'fbd-tooltip-pointy') |
| 616 | + $( '<div>' ).attr( 'class', 'fbd-tooltip-pointy' ) |
607 | 617 | ).append( |
608 | | - $('<div>').attr('class', 'fbd-tooltip-title') |
609 | | - .text( mw.msg( 'response-concurrency-notification' ) ) |
| 618 | + $( '<div>' ).attr( 'class', 'fbd-tooltip-title' ) |
| 619 | + .text( mw.msg( 'response-concurrency-notification' ) ) |
610 | 620 | .prepend( |
611 | | - $('<span>').attr('class', 'fbd-tooltip-close').text('X') |
| 621 | + $( '<span>' ).attr( 'class', 'fbd-tooltip-close' ).text( 'X' ) |
612 | 622 | ) |
613 | 623 | ) |
614 | 624 | ); |
615 | 625 | $item.append( tooltip ); |
616 | | - //close event, closure remembers object |
| 626 | + // Close event, closure remembers object |
617 | 627 | $( '.fbd-tooltip-close' ) |
618 | | - .live( 'click' , function() { |
| 628 | + .live( 'click' , function () { |
619 | 629 | tooltip.remove(); |
620 | 630 | }); |
621 | | - setTimeout( function() { |
622 | | - tooltip.fadeOut(function(tooltip){ |
| 631 | + setTimeout( function () { |
| 632 | + tooltip.fadeOut(function ( tooltip ) { |
623 | 633 | tooltip.remove(); |
624 | 634 | }); |
625 | | - }, 1500 ); |
| 635 | + }, 1500 ); |
626 | 636 | |
627 | 637 | } |
| 638 | + |
628 | 639 | // On-load stuff |
629 | | - |
630 | | - $('.fbd-item-show a').live( 'click', showHiddenItem ); |
631 | | - |
632 | | - $('.fbd-item-hide a').live( 'click', hideItem ); |
633 | | - |
634 | | - $('.fbd-item-restore').live( 'click', restoreItem ); |
635 | | - |
636 | | - $('.fbd-respond-link').live ('click', showResponseForm ); |
637 | | - |
638 | | - //handle preview back button |
639 | | - $('.fbd-response-preview-back').live('click', function(){ |
640 | | - $item = $(this).parent().parent(); |
641 | | - $item.find('.fbd-response-submit, .fbd-response-wikitext, .fbd-response-preview-back, .ula').hide(); |
642 | | - $item.find('.fbd-response-preview, .fbd-response-text').show(); |
| 640 | + $( '.fbd-item-show a' ).live( 'click', showHiddenItem ); |
| 641 | + $( '.fbd-item-hide a' ).live( 'click', hideItem ); |
| 642 | + $( '.fbd-item-restore' ).live( 'click', restoreItem ); |
| 643 | + $( '.fbd-respond-link' ).live ( 'click', showResponseForm ); |
| 644 | + |
| 645 | + // Handle preview back button |
| 646 | + $( '.fbd-response-preview-back' ).live( 'click', function () { |
| 647 | + var $item = $(this).parent().parent(); |
| 648 | + $item.find( '.fbd-response-submit, .fbd-response-wikitext, .fbd-response-preview-back, .ula' ).hide(); |
| 649 | + $item.find( '.fbd-response-preview, .fbd-response-text' ).show(); |
643 | 650 | }); |
644 | 651 | |
645 | | - //handle response submit |
646 | | - $('.fbd-response-submit').live('click', function () { |
647 | | - $item = $(this).parent().parent(); |
648 | | - var fbResponse = $item.find('.fbd-response-text').val(); |
649 | | - if( fbResponse ){ |
| 652 | + // Handle response submit |
| 653 | + $( '.fbd-response-submit' ).live( 'click', function () { |
| 654 | + var $item = $(this).parent().parent(); |
| 655 | + var fbResponse = $item.find( '.fbd-response-text' ).val(); |
| 656 | + if ( fbResponse ) { |
650 | 657 | var clientData = $.client.profile(), |
651 | | - item_id = $item.data('mbccontinue').split('|')[1], |
| 658 | + item_id = $item.data( 'mbccontinue' ).split( '|' )[1], |
652 | 659 | resData = { |
653 | | - 'action':'feedbackdashboardresponse', |
654 | | - 'useragent': clientData.name + '/' + clientData.versionNumber, |
655 | | - 'system': clientData.platform, |
656 | | - 'token': mw.user.tokens.get( 'editToken' ), |
657 | | - 'response': fbResponse, |
658 | | - 'feedback': item_id, |
659 | | - 'format':'json' |
| 660 | + action: 'feedbackdashboardresponse', |
| 661 | + useragent: clientData.name + '/' + clientData.versionNumber, |
| 662 | + system: clientData.platform, |
| 663 | + token: mw.user.tokens.get( 'editToken' ), |
| 664 | + response: fbResponse, |
| 665 | + feedback: item_id, |
| 666 | + format: 'json' |
660 | 667 | }; |
661 | | - |
662 | | - var $responseStatus = $('<div />').attr('class', 'fbd-ajax-response') |
663 | | - .append($('<span />').attr('class','mw-ajax-loader fbd-item-response-icon').html(' ') ) |
664 | | - .append($('<div />') |
665 | | - .append($('<span />').attr('class', 'fbd-ajax-heading').text( mw.msg( 'response-ajax-action-head' ) ) ) |
666 | | - .append($('<span />').attr('class', 'fbd-ajax-text').text( mw.msg( 'response-ajax-action-body' ) ) ) |
| 668 | + |
| 669 | + var $responseStatus = $( '<div>' ).attr( 'class', 'fbd-ajax-response' ) |
| 670 | + .append( $( '<span>' ).attr( 'class','mw-ajax-loader fbd-item-response-icon' ).html( ' ' ) ) |
| 671 | + .append( $( '<div>' ) |
| 672 | + .append( $( '<span>' ).attr( 'class', 'fbd-ajax-heading' ).text( mw.msg( 'response-ajax-action-head' ) ) ) |
| 673 | + .append( $( '<span>' ).attr( 'class', 'fbd-ajax-text' ).text( mw.msg( 'response-ajax-action-body' ) ) ) |
667 | 674 | ); |
668 | 675 | |
669 | | - $responseForm = $item.find('.fbd-response-form'); |
| 676 | + var $responseForm = $item.find( '.fbd-response-form' ); |
670 | 677 | $responseForm.empty().append( $responseStatus ); |
671 | 678 | |
672 | | - //send response |
| 679 | + // Send response |
673 | 680 | $.ajax( { |
674 | | - 'type': 'POST', |
675 | | - 'url': mw.util.wikiScript( 'api' ), |
676 | | - 'data': resData, |
677 | | - 'success': function (data) { |
678 | | - if('error' in data) { //if rejected |
679 | | - responseMessage ($item, 'error', mw.msg( 'response-ajax-error-head' ), data.error.info ); |
680 | | - } else if('feedbackdashboardresponse' in data) { //if successful |
681 | | - responseMessage ($item, 'success', mw.msg( 'response-ajax-success-head' ), mw.msg( 'response-ajax-success-body' ) ); |
| 681 | + type: 'POST', |
| 682 | + url: mw.util.wikiScript( 'api' ), |
| 683 | + data: resData, |
| 684 | + success: function (data) { |
| 685 | + // If rejected |
| 686 | + if ( data.error !== undefined ) { |
| 687 | + responseMessage( $item, 'error', mw.msg( 'response-ajax-error-head' ), data.error.info ); |
| 688 | + } else if ( data.feedbackdashboardresponse !== undefined ) { |
| 689 | + responseMessage( $item, 'success', mw.msg( 'response-ajax-success-head' ), mw.msg( 'response-ajax-success-body' ) ); |
682 | 690 | } |
683 | 691 | }, |
684 | | - 'error': function( jqXHR, textStatus, errorThrown ) { |
685 | | - responseMessage ($item, 'error', mw.msg( 'response-ajax-error-head' ), mw.msg( 'response-ajax-error-body' ) ); |
| 692 | + error: function ( jqXHR, textStatus, errorThrown ) { |
| 693 | + responseMessage( $item, 'error', mw.msg( 'response-ajax-error-head' ), mw.msg( 'response-ajax-error-body' ) ); |
686 | 694 | }, |
687 | | - 'dataType': 'json' |
| 695 | + dataType: 'json' |
688 | 696 | } ); |
689 | | - |
| 697 | + |
690 | 698 | } |
691 | | - }); |
| 699 | + }); |
692 | 700 | |
693 | | - $( '#fbd-filters' ).children( 'form' ).submit( function( e ) { |
| 701 | + $( '#fbd-filters' ).children( 'form' ).submit( function ( e ) { |
694 | 702 | e.preventDefault(); |
695 | 703 | saveFormState(); |
696 | 704 | setCookies(); |
697 | 705 | loadComments( 'filter' ); |
698 | 706 | } ); |
699 | | - |
700 | | - $( '#fbd-list-more' ).children( 'a' ).click( function( e ) { |
| 707 | + |
| 708 | + $( '#fbd-list-more' ).children( 'a' ).click( function ( e ) { |
701 | 709 | e.preventDefault(); |
702 | 710 | // We don't call saveFormState() here because we want to use the state of the form |
703 | 711 | // at the time it was last filtered. Otherwise, you would see strange behavior if |
704 | 712 | // you changed the form state then clicked More. |
705 | 713 | loadComments( 'more' ); |
706 | 714 | } ); |
707 | | - |
708 | | - $( '#fbd-filters-types input[type=checkbox]' ).click( function() { |
| 715 | + |
| 716 | + $( '#fbd-filters-types input[type=checkbox]' ).click( function () { |
709 | 717 | var types = getSelectedTypes(); |
710 | | - if(types.length === 0) { //check for 0 because onclick it will already have unchecked itself. |
711 | | - $(this).prop('checked', true); |
| 718 | + if ( types.length === 0 ) { //check for 0 because onclick it will already have unchecked itself. |
| 719 | + $(this).prop( 'checked', true); |
712 | 720 | } |
713 | 721 | }); |
714 | | - |
| 722 | + |
715 | 723 | //only allow one of the secondary filters to be checked |
716 | | - $( 'input[type=checkbox].fbd-filters-check').click(function(){ |
| 724 | + $( 'input[type=checkbox].fbd-filters-check' ).click(function () { |
717 | 725 | $( 'input[type=checkbox].fbd-filters-check' ).not( this ).prop( 'checked', false ); |
718 | 726 | }); |
719 | 727 | |
720 | | - $( '#fbd-list' ).delegate( '.fbd-item', 'hover', function (){ |
721 | | - $(this).toggleClass('fbd-hover'); |
| 728 | + $( '#fbd-list' ).delegate( '.fbd-item', 'hover', function () { |
| 729 | + $(this).toggleClass( 'fbd-hover' ); |
722 | 730 | }); |
723 | 731 | |
724 | | - $( '#fbd-list' ).delegate( '.fbd-item', 'mouseleave', function (){ |
725 | | - $(this).removeClass('fbd-hover'); |
| 732 | + $( '#fbd-list' ).delegate( '.fbd-item', 'mouseleave', function () { |
| 733 | + $(this).removeClass( 'fbd-hover' ); |
726 | 734 | }); |
727 | 735 | |
728 | 736 | //zebra stripe leaderboard |
729 | | - $('.fbd-leaderboard li:nth-child(even)').addClass('even'); |
| 737 | + $( '.fbd-leaderboard li:nth-child(even)' ).addClass( 'even' ); |
730 | 738 | |
731 | 739 | saveFormState(); |
732 | 740 | var filterType = $( '#fbd-filters' ).children( 'form' ).data( 'filtertype' ); |
733 | 741 | // If filtering already happened on the PHP side, don't load the form state from cookies |
734 | | - if ( filterType != 'filtered' ) { |
| 742 | + if ( filterType !== 'filtered' ) { |
735 | 743 | // Don't do an AJAX filter if we're on an ID view, or if the form is still blank after loadFromCookies() |
736 | | - if ( loadFromCookies() && filterType != 'id' ) { |
| 744 | + if ( loadFromCookies() && filterType !== 'id' ) { |
737 | 745 | saveFormState(); |
738 | 746 | loadComments( 'filter' ); |
739 | 747 | } |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -189,6 +189,7 @@ |
190 | 190 | 'scripts' => 'ext.moodBar.dashboard/ext.moodBar.dashboard.js', |
191 | 191 | 'dependencies' => array( |
192 | 192 | 'mediawiki.util', |
| 193 | + 'user.tokens', |
193 | 194 | 'jquery.NobleCount', |
194 | 195 | 'jquery.elastic' |
195 | 196 | ), |