Total Complexity | 13 |
Complexity/F | 1.3 |
Lines of Code | 46 |
Function Count | 10 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | Amarkal.settings.fields = { |
||
|
|||
2 | $fields: null, |
||
3 | init: function () { |
||
4 | this.$fields = $('.amarkal-settings-field'); |
||
5 | }, |
||
6 | hideAll: function () { |
||
7 | this.hide(this.$fields); |
||
8 | }, |
||
9 | showAll: function () { |
||
10 | this.show(this.$fields); |
||
11 | }, |
||
12 | showBySection: function (slug) { |
||
13 | this.hideAll(); |
||
14 | this.show(this.$fields.filter('[data-section="'+slug+'"]')); |
||
15 | }, |
||
16 | search: function(query) { |
||
17 | var matches = []; |
||
18 | |||
19 | this.$fields.each(function(){ |
||
20 | var $field = $(this), |
||
21 | title = $field.find('h3').text().toLowerCase(), |
||
22 | help = $field.find('.help-content').text(); |
||
23 | description = $field.find('.description').text(); |
||
24 | |||
25 | // Check query against the field's title |
||
26 | if(title.match(query) || description.match(query) || help.match(query)) { |
||
27 | matches.push($field); |
||
28 | } |
||
29 | }); |
||
30 | |||
31 | // Convert the matches array to a jQuery object |
||
32 | return $(matches).map(function(){return this.toArray();}); |
||
33 | }, |
||
34 | show: function($fields) { |
||
35 | $fields |
||
36 | .addClass('visible') |
||
37 | .find('.amarkal-ui-component') |
||
38 | .amarkalUIComponent('refresh'); |
||
39 | }, |
||
40 | hide: function($fields) { |
||
41 | $fields.removeClass('visible'); |
||
42 | }, |
||
43 | flag: function(type, fieldName) { |
||
44 | this.$fields.filter('[data-name="'+fieldName+'"]').addClass('flag-'+type); |
||
45 | } |
||
46 | }; |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.