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