1
|
|
|
Amarkal.settings.fields = { |
|
|
|
|
2
|
|
|
$form: null, |
3
|
|
|
$fields: null, |
4
|
|
|
init: function () { |
5
|
|
|
this.$form = $('#amarkal-settings-form'); |
6
|
|
|
this.$fields = this.$form.find('.amarkal-settings-field'); |
7
|
|
|
|
8
|
|
|
var _this = this; |
9
|
|
|
$('.amarkal-ui-component').on('amarkal.change',function(e, component){ |
10
|
|
|
if($(this).amarkalUIComponent('changed')) { |
11
|
|
|
Amarkal.settings.fields.flag('notice', component.props.name); |
|
|
|
|
12
|
|
|
} |
13
|
|
|
else { |
14
|
|
|
Amarkal.settings.fields.unflag('notice', component.props.name); |
15
|
|
|
} |
16
|
|
|
if(Amarkal.settings.sections.changed(component.props.section)) { |
17
|
|
|
Amarkal.settings.sections.flag('notice', component.props.section); |
18
|
|
|
} |
19
|
|
|
else { |
20
|
|
|
Amarkal.settings.sections.unflag('notice', component.props.section); |
21
|
|
|
} |
22
|
|
|
if(_this.$form.amarkalUIForm('changed')) { |
23
|
|
|
Amarkal.settings.notifier.notice("Settings have changed, click \"Save\" to apply them."); |
24
|
|
|
} |
25
|
|
|
else { |
26
|
|
|
Amarkal.settings.notifier.clearNotifications(); |
27
|
|
|
} |
28
|
|
|
}).on('amarkal.hide', function(){ |
29
|
|
|
Amarkal.settings.fields.hide($(this).parents('.amarkal-settings-field')); |
|
|
|
|
30
|
|
|
}).on('amarkal.show', function(){ |
31
|
|
|
if($(this).parents('.amarkal-settings-field').attr('data-section') === Amarkal.settings.sections.activeSection) { |
|
|
|
|
32
|
|
|
Amarkal.settings.fields.show($(this).parents('.amarkal-settings-field')); |
33
|
|
|
} |
34
|
|
|
}); |
35
|
|
|
}, |
36
|
|
|
search: function(query) { |
37
|
|
|
var matches = []; |
38
|
|
|
var $form = this.$form; |
39
|
|
|
|
40
|
|
|
this.$fields.each(function(){ |
41
|
|
|
var $field = $(this), |
42
|
|
|
name = $field.attr('data-name'), |
43
|
|
|
title = $field.find('h3').text().toLowerCase(), |
44
|
|
|
help = $field.find('.help-content').text(); |
45
|
|
|
description = $field.find('.description').text(); |
|
|
|
|
46
|
|
|
|
47
|
|
|
// Don't add fields that are currently hidden |
48
|
|
|
if('' !== name && !$form.amarkalUIForm('isVisible', name)) return; |
|
|
|
|
49
|
|
|
|
50
|
|
|
// Check query against the field's title |
51
|
|
|
if(title.match(query) || description.match(query) || help.match(query)) { |
52
|
|
|
matches.push($field); |
53
|
|
|
} |
54
|
|
|
}); |
55
|
|
|
|
56
|
|
|
// Convert the matches array to a jQuery object |
57
|
|
|
return $(matches).map(function(){return this.toArray();}); |
58
|
|
|
}, |
59
|
|
|
show: function($fields) { |
60
|
|
|
var _this = this; |
61
|
|
|
$fields.each(function(){ |
62
|
|
|
var $comp = $(this).find('.amarkal-ui-component'), |
63
|
|
|
name = $comp.amarkalUIComponent('getName'); |
64
|
|
|
|
65
|
|
|
// Only show components whose visibility condition is satisfied |
66
|
|
|
if(!name || _this.$form.amarkalUIForm('isVisible', name)) { |
67
|
|
|
$(this).addClass('visible'); |
68
|
|
|
$comp.amarkalUIComponent('refresh'); |
69
|
|
|
} |
70
|
|
|
}); |
71
|
|
|
}, |
72
|
|
|
hide: function($fields) { |
73
|
|
|
$fields.removeClass('visible'); |
74
|
|
|
}, |
75
|
|
|
hideAll: function () { |
76
|
|
|
this.hide(this.$fields); |
77
|
|
|
}, |
78
|
|
|
showAll: function () { |
79
|
|
|
this.show(this.$fields); |
80
|
|
|
}, |
81
|
|
|
flag: function(type, fieldName) { |
82
|
|
|
this.$fields.filter('[data-name="'+fieldName+'"]').addClass('flag-'+type); |
83
|
|
|
}, |
84
|
|
|
unflag: function(type, fieldName) { |
85
|
|
|
this.$fields.filter('[data-name="'+fieldName+'"]').removeClass('flag-'+type); |
86
|
|
|
}, |
87
|
|
|
unflagAll: function() { |
88
|
|
|
this.$fields.removeClass('flag-error flag-notice'); |
89
|
|
|
} |
90
|
|
|
}; |
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.