|
19 | 19 | rfcEdit: $('#rfcedit'), |
20 | 20 | rfcEditInput: $('#rfceditinput'), |
21 | 21 | rfcLink: $('#rfclink'), |
| 22 | + implementedEdit: $('#implementededit'), |
| 23 | + implementedEditInput: $('#implementededitinput'), |
| 24 | + implementedVersion: $('#implementedversion'), |
| 25 | + implementedToggle: $('.implementedtoggle'), |
22 | 26 | removeVote: $('.removevote'), |
23 | 27 | status: $('#status'), |
24 | 28 | successVoted: $('.successvoted'), |
|
126 | 130 | .removeClass() |
127 | 131 | .addClass('status-badge status-' + $this.find(':selected').val()); |
128 | 132 |
|
129 | | - if (idea_is_duplicate()) { |
130 | | - $obj.duplicateToggle.show(); |
131 | | - } else { |
132 | | - $obj.duplicateToggle.hide(); |
133 | | - } |
| 133 | + $obj.duplicateToggle.toggle(idea_is_duplicate()); |
| 134 | + $obj.implementedToggle.toggle(idea_is_implemented()); |
134 | 135 | } |
135 | 136 | }); |
136 | 137 | }); |
|
308 | 309 | } |
309 | 310 | }); |
310 | 311 |
|
| 312 | + $obj.implementedEdit.on('click', function(e) { |
| 313 | + e.preventDefault(); |
| 314 | + |
| 315 | + $obj.implementedEdit.add($obj.implementedVersion).hide(); |
| 316 | + $obj.implementedEditInput.show().focus(); |
| 317 | + }); |
| 318 | + |
| 319 | + $obj.implementedEditInput.on('keydown', function(e) { |
| 320 | + if (e.keyCode === keymap.ENTER) { |
| 321 | + e.preventDefault(); |
| 322 | + e.stopPropagation(); |
| 323 | + |
| 324 | + var $this = $(this), |
| 325 | + find = /^\d\.\d\.\d+(\-\w+)?$/, |
| 326 | + url = $obj.implementedEdit.attr('href'), |
| 327 | + value = $this.val(); |
| 328 | + |
| 329 | + if (value && !find.test(value)) { |
| 330 | + phpbb.alert($this.attr('data-l-err'), $this.attr('data-l-msg')); |
| 331 | + return; |
| 332 | + } |
| 333 | + |
| 334 | + $.get(url, {implemented: value}, function(res) { |
| 335 | + if (res) { |
| 336 | + $obj.implementedVersion.text(value); |
| 337 | + |
| 338 | + if (value) { |
| 339 | + $obj.implementedVersion.show(); |
| 340 | + } |
| 341 | + |
| 342 | + $this.hide(); |
| 343 | + |
| 344 | + $obj.implementedEdit.text(function() { |
| 345 | + return value ? $(this).attr('data-l-edit') : $(this).attr('data-l-add'); |
| 346 | + }).prepend($('<i class="fa fa-fw"></i>').addClass(function() { |
| 347 | + return value ? 'fa-pencil' : 'fa-plus-circle'; |
| 348 | + })).show(); |
| 349 | + } |
| 350 | + }); |
| 351 | + } else if (e.keyCode === keymap.ESC) { |
| 352 | + e.preventDefault(); |
| 353 | + |
| 354 | + $(this).hide(); |
| 355 | + $obj.implementedEdit.show(); |
| 356 | + |
| 357 | + if ($obj.implementedVersion.text()) { |
| 358 | + $obj.implementedVersion.show(); |
| 359 | + } |
| 360 | + } |
| 361 | + }); |
| 362 | + |
311 | 363 | /** |
312 | 364 | * Returns true if idea is a duplicate. Bit hacky. |
313 | 365 | */ |
|
316 | 368 | return href && href.indexOf('status=4') !== -1; |
317 | 369 | } |
318 | 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; |
| 377 | + } |
| 378 | + |
319 | 379 | function displayVoters(data) { |
320 | 380 |
|
321 | 381 | var upVoters = [], |
|
0 commit comments