|
32 | 32 | voteDown: $('.minivotedown'), |
33 | 33 | voteUp: $('.minivoteup'), |
34 | 34 | voteRemove: $('#vote-remove') |
35 | | - }; |
| 35 | + }, $loadingIndicator; |
36 | 36 |
|
37 | 37 | function voteSuccess(result, $this) { |
38 | 38 | if (typeof result === 'string') { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 |
|
| 79 | + showLoadingIndicator(); |
79 | 80 | $.get(url, {v: vote}, function(data) { |
80 | 81 | voteSuccess(data, $this); |
81 | 82 | resetVoteButtons($this); |
82 | 83 | $obj.voteRemove.show(); |
83 | | - }).fail(voteFailure); |
| 84 | + }).fail(voteFailure).always(hideLoadingIndicator); |
84 | 85 | }); |
85 | 86 |
|
86 | 87 | $obj.votes.on('click', function(e) { |
|
101 | 102 | return false; |
102 | 103 | } |
103 | 104 |
|
| 105 | + showLoadingIndicator(); |
104 | 106 | $.get(url, function(data) { |
105 | 107 | voteSuccess(data, $this); |
106 | 108 | resetVoteButtons(); |
107 | 109 | $obj.voteRemove.hide(); |
108 | | - }).fail(voteFailure); |
| 110 | + }).fail(voteFailure).always(hideLoadingIndicator); |
109 | 111 | }); |
110 | 112 |
|
111 | 113 | $obj.status.on('change', function() { |
|
119 | 121 | return; |
120 | 122 | } |
121 | 123 |
|
| 124 | + showLoadingIndicator(); |
122 | 125 | $.get($this.attr('data-url'), data, function(res) { |
123 | 126 | if (res) { |
124 | 127 | var anchor = $this.prev('a'), |
|
134 | 137 | $obj.duplicateToggle.toggle(idea_is_duplicate()); |
135 | 138 | $obj.implementedToggle.toggle(idea_is_implemented()); |
136 | 139 | } |
137 | | - }); |
| 140 | + }).always(hideLoadingIndicator); |
138 | 141 | }); |
139 | 142 |
|
140 | 143 | $obj.rfcEdit.on('click', function(e) { |
|
159 | 162 | return; |
160 | 163 | } |
161 | 164 |
|
| 165 | + showLoadingIndicator(); |
162 | 166 | $.get(url, {rfc: value}, function(res) { |
163 | 167 | if (res) { |
164 | 168 | $obj.rfcLink.text(value) |
|
172 | 176 |
|
173 | 177 | $obj.rfcEdit.toggleAddEdit(value); |
174 | 178 | } |
175 | | - }); |
| 179 | + }).always(hideLoadingIndicator); |
176 | 180 | } else if (e.keyCode === keymap.ESC) { |
177 | 181 | e.preventDefault(); |
178 | 182 |
|
|
213 | 217 | value = 'PHPBB3-' + info[1]; |
214 | 218 | } |
215 | 219 |
|
| 220 | + showLoadingIndicator(); |
216 | 221 | $.get(url, {ticket: value && info[1]}, function(res) { |
217 | 222 | if (res) { |
218 | 223 | $obj.ticketLink.text(value) |
|
227 | 232 | $obj.ticketEdit.toggleAddEdit(value); |
228 | 233 | } |
229 | 234 |
|
230 | | - }); |
| 235 | + }).always(hideLoadingIndicator); |
231 | 236 | } else if (e.keyCode === keymap.ESC) { |
232 | 237 | e.preventDefault(); |
233 | 238 |
|
|
263 | 268 | return; |
264 | 269 | } |
265 | 270 |
|
| 271 | + showLoadingIndicator(); |
266 | 272 | $.get(url, {duplicate: Number(value)}, function(res) { |
267 | 273 | if (res) { |
268 | 274 | if (value) { |
|
283 | 289 |
|
284 | 290 | $obj.duplicateEdit.toggleAddEdit(value); |
285 | 291 | } |
286 | | - }); |
| 292 | + }).always(hideLoadingIndicator); |
287 | 293 | } else if (e.keyCode === keymap.ESC) { |
288 | 294 | e.preventDefault(); |
289 | 295 |
|
|
320 | 326 | return; |
321 | 327 | } |
322 | 328 |
|
| 329 | + showLoadingIndicator(); |
323 | 330 | $.get(url, {implemented: value}, function(res) { |
324 | 331 | if (res) { |
325 | 332 | $obj.implementedVersion.text(value); |
|
332 | 339 |
|
333 | 340 | $obj.implementedEdit.toggleAddEdit(value); |
334 | 341 | } |
335 | | - }); |
| 342 | + }).always(hideLoadingIndicator); |
336 | 343 | } else if (e.keyCode === keymap.ESC) { |
337 | 344 | e.preventDefault(); |
338 | 345 |
|
|
408 | 415 | } |
409 | 416 | } |
410 | 417 |
|
| 418 | + function showLoadingIndicator() { |
| 419 | + $loadingIndicator = phpbb.loadingIndicator(); |
| 420 | + } |
| 421 | + |
| 422 | + function hideLoadingIndicator() { |
| 423 | + if ($loadingIndicator && $loadingIndicator.is(':visible')) { |
| 424 | + $loadingIndicator.fadeOut(phpbb.alertTime); |
| 425 | + } |
| 426 | + } |
| 427 | + |
411 | 428 | })(jQuery); // Avoid conflicts with other libraries |
0 commit comments