1
|
|
|
Amarkal.settings.sections = { |
|
|
|
|
2
|
|
|
$fields: null, |
3
|
|
|
$links: null, |
4
|
|
|
$loader: null, |
5
|
|
|
sections: null, |
6
|
|
|
activeSection: null, |
7
|
|
|
init: function() { |
8
|
|
|
this.sections = JSON.parse($('#sections-config').text()); |
9
|
|
|
this.$fields = $('.amarkal-settings-field'); |
10
|
|
|
this.$links = $('.amarkal-settings-sections li'); |
11
|
|
|
this.$loader = $('#amarkal-settings-loader'); |
12
|
|
|
|
13
|
|
|
this.initSections(); |
14
|
|
|
}, |
15
|
|
|
initSections: function() { |
16
|
|
|
if(typeof this.sections === 'object' && Object.keys(this.sections).length > 0) { |
17
|
|
|
var _this = this; |
18
|
|
|
this.$links.on('click', function(){ |
19
|
|
|
_this.activate($(this).attr('data-slug')); |
20
|
|
|
}); |
21
|
|
|
this.activateInitialSection(); |
22
|
|
|
this.$loader.hide(); |
23
|
|
|
} |
24
|
|
|
else { |
25
|
|
|
this.$fields.addClass('visible'); |
26
|
|
|
} |
27
|
|
|
}, |
28
|
|
|
activateInitialSection: function() { |
29
|
|
|
if('' !== window.location.hash) { |
30
|
|
|
this.activate(window.location.hash.substring(1)); |
31
|
|
|
} |
32
|
|
|
else { |
33
|
|
|
this.activate($(this.$links[0]).attr('data-slug')); |
34
|
|
|
} |
35
|
|
|
}, |
36
|
|
|
activate: function(sectionSlug) { |
37
|
|
|
this.$links.each(function(){ |
38
|
|
|
$(this).removeClass('active'); |
39
|
|
|
if($(this).attr('data-slug') === sectionSlug) { |
40
|
|
|
$(this).addClass('active'); |
41
|
|
|
} |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
this.$fields.removeClass('visible'); |
45
|
|
|
Amarkal.settings.header.setSectionTitle(this.getTitle(sectionSlug)); |
|
|
|
|
46
|
|
|
Amarkal.settings.header.setSectionSubtitle(this.getSubtitle(sectionSlug)); |
47
|
|
|
this.activeSection = sectionSlug; |
48
|
|
|
|
49
|
|
|
$('.amarkal-settings-field[data-section="'+sectionSlug+'"]') |
50
|
|
|
.addClass('visible') |
51
|
|
|
.find('.amarkal-ui-component') |
52
|
|
|
.amarkalUIComponent('refresh'); |
53
|
|
|
|
54
|
|
|
window.location = '#'+sectionSlug; |
55
|
|
|
}, |
56
|
|
|
deactivate: function() { |
57
|
|
|
var sectionSlug = this.activeSection; |
|
|
|
|
58
|
|
|
this.$links.removeClass('active'); |
59
|
|
|
this.$fields.removeClass('visible'); |
60
|
|
|
}, |
61
|
|
|
flag: function(type, slug) { |
62
|
|
|
this.$links.filter('[data-slug="'+slug+'"]').addClass('flag-'+type); |
63
|
|
|
}, |
64
|
|
|
unflagAll: function() { |
65
|
|
|
this.$links.removeClass('flag-error flag-notice'); |
66
|
|
|
}, |
67
|
|
|
getTitle: function(slug) { |
68
|
|
|
return this.sections[slug].title; |
69
|
|
|
}, |
70
|
|
|
getSubtitle: function(slug) { |
71
|
|
|
return this.sections[slug].subtitle; |
72
|
|
|
} |
73
|
|
|
}; |
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.