Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -102,6 +102,7 @@ |
103 | 103 | 'moodbar-restore-header' => "Restore this item's visibility", |
104 | 104 | 'moodbar-restore-intro' => '', |
105 | 105 | 'moodbar-invalid-item' => 'The system was unable to find the correct feedback item.', |
| 106 | + 'moodbar-feedback-action-error' => 'An error occurred when trying to perform this action.', |
106 | 107 | // Mood types |
107 | 108 | 'moodbar-type-happy' => 'Happy', |
108 | 109 | 'moodbar-type-sad' => 'Sad', |
Index: trunk/extensions/MoodBar/modules/ext.moodBar.dashboard/ext.moodBar.dashboard.js |
— | — | @@ -224,8 +224,11 @@ |
225 | 225 | } else { |
226 | 226 | // Failure, just remove the link. |
227 | 227 | $item.find('.fbd-item-show').remove(); |
| 228 | + $item.find('.mw-ajax-loader').remove(); |
| 229 | + showItemError( $item ); |
228 | 230 | } |
229 | | - }, 'json' ); |
| 231 | + }, 'json' ) |
| 232 | + .error( function() { showItemError( $item ); } ); |
230 | 233 | } |
231 | 234 | |
232 | 235 | /** |
— | — | @@ -243,11 +246,27 @@ |
244 | 247 | } |
245 | 248 | |
246 | 249 | /** |
| 250 | + * Show an error on an individual item |
| 251 | + * @param $item The .fbd-item to show the message on |
| 252 | + * @param message The message to show (currently ignored) |
| 253 | + */ |
| 254 | + function showItemError( $item, message ) { |
| 255 | + $item.find('.mw-ajax-loader').remove(); |
| 256 | + $('<div class="error"/>') |
| 257 | + .text( mw.msg('moodbar-feedback-action-error') ) |
| 258 | + .prependTo($item); |
| 259 | + } |
| 260 | + |
| 261 | + /** |
247 | 262 | * Execute an action on an item |
248 | 263 | */ |
249 | 264 | function doAction( params, $item ) { |
250 | 265 | var item_id = $item.data('mbccontinue').split('|')[1]; |
251 | 266 | |
| 267 | + var errorHandler = function(error_str) { |
| 268 | + showItemError( $item, error_str ); |
| 269 | + }; |
| 270 | + |
252 | 271 | $.post( mw.util.wikiScript('api'), |
253 | 272 | $.extend( { |
254 | 273 | 'action' : 'feedbackdashboard', |
— | — | @@ -260,12 +279,15 @@ |
261 | 280 | if ( response.feedbackdashboard.result == 'success' ) { |
262 | 281 | reloadItem( $item ); |
263 | 282 | } else { |
264 | | - alert( response.feedbackdashboard.error ); |
| 283 | + errorHandler( response.feedbackdashboard.error ); |
265 | 284 | } |
| 285 | + } else if ( response && response.error ) { |
| 286 | + errorHandler( response.error.message ); |
266 | 287 | } else { |
267 | | - alert('Unknown error'); |
| 288 | + errorHandler(); |
268 | 289 | } |
269 | | - } ); |
| 290 | + } ) |
| 291 | + .error( errorHandler ); |
270 | 292 | } |
271 | 293 | |
272 | 294 | /** |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -141,7 +141,8 @@ |
142 | 142 | 'messages' => array( |
143 | 143 | 'moodbar-feedback-nomore', |
144 | 144 | 'moodbar-feedback-noresults', |
145 | | - 'moodbar-feedback-ajaxerror' |
| 145 | + 'moodbar-feedback-ajaxerror', |
| 146 | + 'moodbar-feedback-action-error', |
146 | 147 | ), |
147 | 148 | ); |
148 | 149 | |