Total Complexity | 7 |
Complexity/F | 1.4 |
Lines of Code | 68 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | var Editor = |
||
2 | { |
||
3 | 'el':null, |
||
4 | 'form':null, |
||
5 | 'textarea':null, |
||
6 | |||
7 | Toggle:function(hash) |
||
8 | { |
||
9 | this.DetectElement(hash); |
||
10 | |||
11 | if(this.el.hasClass('active')) |
||
12 | { |
||
13 | this.el.removeClass('active'); |
||
14 | this.el.addClass('inactive'); |
||
15 | this.form.hide(); |
||
16 | } |
||
17 | else |
||
18 | { |
||
19 | this.el.addClass('active'); |
||
20 | this.el.removeClass('inactive'); |
||
21 | this.form.show(); |
||
22 | |||
23 | this.textarea.focus(); |
||
24 | } |
||
25 | }, |
||
26 | |||
27 | Confirm:function(hash) |
||
28 | { |
||
29 | this.DetectElement(hash); |
||
30 | |||
31 | var value = this.textarea.val(); |
||
32 | value = value.trim(); |
||
33 | |||
34 | if(value == '') { |
||
35 | this.textarea.focus(); |
||
36 | return; |
||
37 | } |
||
38 | |||
39 | // save the trimmed value |
||
40 | this.textarea.val(value); |
||
41 | |||
42 | this.el.find('TD.string-status').html('<i class="fa fa-check text-success"></i>'); |
||
43 | this.el.find('TD.string-text').html(value); |
||
44 | this.el.addClass('table-success'); |
||
45 | |||
46 | this.Toggle(hash); |
||
47 | }, |
||
48 | |||
49 | DetectElement:function(hash) |
||
50 | { |
||
51 | this.el = $("tr[data-hash='"+hash+"']"); |
||
52 | this.form = this.el.next(); |
||
53 | this.textarea = this.form.find('textarea'); |
||
54 | }, |
||
55 | |||
56 | Start:function() |
||
57 | { |
||
58 | $('[data-toggle="tooltip"]').tooltip({ |
||
59 | 'delay':500, |
||
60 | 'container':'body' |
||
61 | }); |
||
62 | } |
||
63 | }; |
||
64 | |||
65 | $('document').ready(function() |
||
66 | { |
||
67 | Editor.Start(); |
||
68 | }); |