Total Complexity | 7 |
Complexity/F | 1.4 |
Lines of Code | 34 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | (function($) { |
||
2 | 'use strict'; |
||
3 | $(function() { |
||
4 | var todoListItem = $('.todo-list'); |
||
5 | var todoListInput = $('.todo-list-input'); |
||
6 | $('.todo-list-add-btn').on("click", function(event) { |
||
7 | event.preventDefault(); |
||
8 | |||
9 | var item = $(this).prevAll('.todo-list-input').val(); |
||
10 | |||
11 | if (item) { |
||
12 | todoListItem.append("<li><div class='form-check'><label class='form-check-label'><input class='checkbox' type='checkbox'/>" + item + "<i class='input-helper'></i></label></div><i class='remove ti-trash'></i></li>"); |
||
13 | todoListInput.val(""); |
||
14 | } |
||
15 | |||
16 | }); |
||
17 | |||
18 | todoListItem.on('change', '.checkbox', function() { |
||
19 | if ($(this).attr('checked')) { |
||
20 | $(this).removeAttr('checked'); |
||
21 | } else { |
||
22 | $(this).attr('checked', 'checked'); |
||
23 | } |
||
24 | |||
25 | $(this).closest("li").toggleClass('completed'); |
||
26 | |||
27 | }); |
||
28 | |||
29 | todoListItem.on('click', '.remove', function() { |
||
30 | $(this).parent().remove(); |
||
31 | }); |
||
32 | |||
33 | }); |
||
34 | })(jQuery); |