|
24 | 24 | implementedVersion: $('#implementedversion'), |
25 | 25 | implementedToggle: $('.implementedtoggle'), |
26 | 26 | removeVote: $('.removevote'), |
27 | | - status: $('#status'), |
| 27 | + status: $('.change-status'), |
| 28 | + statusLink: $('#status-link'), |
28 | 29 | successVoted: $('.successvoted'), |
29 | 30 | userVoted: $('.user-voted'), |
30 | 31 | votes: $('.votes'), |
|
110 | 111 | }).fail(voteFailure).always(hideLoadingIndicator); |
111 | 112 | }); |
112 | 113 |
|
113 | | - $obj.status.on('change', function() { |
| 114 | + $obj.status.on('click', function(e) { |
| 115 | + e.preventDefault(); |
| 116 | + |
114 | 117 | var $this = $(this), |
115 | 118 | data = { |
116 | | - mode: 'status', |
117 | | - status: $this.val() |
| 119 | + status: $this.attr('data-status') |
118 | 120 | }; |
119 | 121 |
|
120 | 122 | if (!data.status) { |
121 | 123 | return; |
122 | 124 | } |
123 | 125 |
|
124 | 126 | showLoadingIndicator(); |
125 | | - $.get($this.attr('data-url'), data, function(res) { |
| 127 | + $.get($this.attr('href'), data, function(res) { |
126 | 128 | if (res) { |
127 | | - var anchor = $this.prev('a'), |
128 | | - href = anchor.attr('href'); |
129 | | - |
130 | | - href = href.replace(/status=\d/, 'status=' + data.status); |
| 129 | + var href = $obj.statusLink.attr('href').replace(/status=\d/, 'status=' + data.status); |
131 | 130 |
|
132 | | - anchor.attr('href', href) |
133 | | - .text($this.find(':selected').text()) |
| 131 | + $obj.statusLink.attr('href', href) |
| 132 | + .html($this.html()) |
| 133 | + .closest('span') |
134 | 134 | .removeClass() |
135 | | - .addClass('status-badge status-' + $this.find(':selected').val()); |
| 135 | + .addClass('status-badge status-' + data.status); |
136 | 136 |
|
137 | | - $obj.duplicateToggle.toggle(idea_is_duplicate()); |
138 | | - $obj.implementedToggle.toggle(idea_is_implemented()); |
| 137 | + $obj.duplicateToggle.toggle(data.status === '4'); |
| 138 | + $obj.implementedToggle.toggle(data.status === '3'); |
139 | 139 | } |
140 | | - }).always(hideLoadingIndicator); |
| 140 | + }).always([hideLoadingIndicator, hideStatusDropDown]); |
141 | 141 | }); |
142 | 142 |
|
143 | 143 | $obj.rfcEdit.on('click', function(e) { |
|
360 | 360 | })).show(); |
361 | 361 | }; |
362 | 362 |
|
363 | | - /** |
364 | | - * Returns true if idea is a duplicate. Bit hacky. |
365 | | - */ |
366 | | - function idea_is_duplicate() { |
367 | | - var href = $obj.status.prev('a').attr('href'); |
368 | | - return href && href.indexOf('status=4') !== -1; |
369 | | - } |
370 | | - |
371 | | - /** |
372 | | - * Returns true if idea is implemented. Bit hacky. |
373 | | - */ |
374 | | - function idea_is_implemented() { |
375 | | - var href = $obj.status.prev('a').attr('href'); |
376 | | - return href && href.indexOf('status=3') !== -1; |
| 363 | + function hideStatusDropDown() { |
| 364 | + $('.status-dropdown').hide(); |
377 | 365 | } |
378 | 366 |
|
379 | 367 | function displayVoters(data) { |
|
0 commit comments