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