|
169 | 169 |
|
170 | 170 | $this.hide(); |
171 | 171 |
|
172 | | - $obj.rfcEdit.text(function() { |
173 | | - return value ? $(this).attr('data-l-edit') : $(this).attr('data-l-add'); |
174 | | - }).prepend($('<i class="fa fa-fw"></i>').addClass(function() { |
175 | | - return value ? 'fa-pencil' : 'fa-plus-circle'; |
176 | | - })).show(); |
| 172 | + $obj.rfcEdit.toggleAddEdit(value); |
177 | 173 | } |
178 | 174 | }); |
179 | 175 | } else if (e.keyCode === keymap.ESC) { |
|
227 | 223 |
|
228 | 224 | $this.hide(); |
229 | 225 |
|
230 | | - $obj.ticketEdit.text(function() { |
231 | | - return value ? $(this).attr('data-l-edit') : $(this).attr('data-l-add'); |
232 | | - }).prepend($('<i class="fa fa-fw"></i>').addClass(function() { |
233 | | - return value ? 'fa-pencil' : 'fa-plus-circle'; |
234 | | - })).show(); |
| 226 | + $obj.ticketEdit.toggleAddEdit(value); |
235 | 227 | } |
236 | 228 |
|
237 | 229 | }); |
|
288 | 280 |
|
289 | 281 | $this.hide(); |
290 | 282 |
|
291 | | - $obj.duplicateEdit.text(function() { |
292 | | - return value ? $(this).attr('data-l-edit') : $(this).attr('data-l-add'); |
293 | | - }).prepend($('<i class="fa fa-fw"></i>').addClass(function() { |
294 | | - return value ? 'fa-pencil' : 'fa-plus-circle'; |
295 | | - })).show(); |
| 283 | + $obj.duplicateEdit.toggleAddEdit(value); |
296 | 284 | } |
297 | 285 | }); |
298 | 286 | } else if (e.keyCode === keymap.ESC) { |
|
341 | 329 |
|
342 | 330 | $this.hide(); |
343 | 331 |
|
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(); |
| 332 | + $obj.implementedEdit.toggleAddEdit(value); |
349 | 333 | } |
350 | 334 | }); |
351 | 335 | } else if (e.keyCode === keymap.ESC) { |
|
360 | 344 | } |
361 | 345 | }); |
362 | 346 |
|
| 347 | + $.fn.toggleAddEdit = function(value) { |
| 348 | + $(this).text(function() { |
| 349 | + return value ? $(this).attr('data-l-edit') : $(this).attr('data-l-add'); |
| 350 | + }).prepend($('<i class="fa fa-fw"></i>').addClass(function() { |
| 351 | + return value ? 'fa-pencil' : 'fa-plus-circle'; |
| 352 | + })).show(); |
| 353 | + }; |
| 354 | + |
363 | 355 | /** |
364 | 356 | * Returns true if idea is a duplicate. Bit hacky. |
365 | 357 | */ |
|
0 commit comments