frontend.js
4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
(function($) {
FLBuilderTabs = function( settings )
{
this.settings = settings;
this.nodeClass = '.fl-node-' + settings.id;
this._init();
};
FLBuilderTabs.prototype = {
settings : {},
nodeClass : '',
_init: function()
{
var win = $(window);
$(this.nodeClass + ' .fl-tabs-labels .fl-tabs-label').click($.proxy(this._labelClick, this));
$(this.nodeClass + ' .fl-tabs-panels .fl-tabs-label').click($.proxy(this._responsiveLabelClick, this));
if($(this.nodeClass + ' .fl-tabs-vertical').length > 0) {
this._resize();
win.off('resize' + this.nodeClass);
win.on('resize' + this.nodeClass, $.proxy(this._resize, this));
}
FLBuilderLayout.preloadAudio( this.nodeClass + ' .fl-tabs-panel-content' );
},
_labelClick: function(e)
{
var label = $(e.target).closest('.fl-tabs-label'),
index = label.data('index'),
wrap = label.closest('.fl-tabs'),
allIcons = wrap.find('.fl-tabs-panels .fl-tabs-label .fa'),
icon = wrap.find('.fl-tabs-panels .fl-tabs-label[data-index="' + index + '"] .fa');
// Toggle the responsive icons.
allIcons.addClass('fa-plus');
icon.removeClass('fa-plus');
// Toggle the tabs.
wrap.find('.fl-tabs-labels:first > .fl-tab-active').removeClass('fl-tab-active');
wrap.find('.fl-tabs-panels:first > .fl-tabs-panel > .fl-tab-active').removeClass('fl-tab-active');
wrap.find('.fl-tabs-labels:first > .fl-tabs-label[data-index="' + index + '"]').addClass('fl-tab-active');
wrap.find('.fl-tabs-panels:first > .fl-tabs-panel > .fl-tabs-panel-content[data-index="' + index + '"]').addClass('fl-tab-active');
// Gallery module support.
FLBuilderLayout.refreshGalleries( wrap.find('.fl-tabs-panel-content[data-index="' + index + '"]') );
// Grid layout support (uses Masonry)
FLBuilderLayout.refreshGridLayout( wrap.find('.fl-tabs-panel-content[data-index="' + index + '"]') );
// Post Carousel support (uses BxSlider)
FLBuilderLayout.reloadSlider( wrap.find('.fl-tabs-panel-content[data-index="' + index + '"]') );
// WP audio shortcode support
FLBuilderLayout.resizeAudio( wrap.find('.fl-tabs-panel-content[data-index="' + index + '"]') );
},
_responsiveLabelClick: function(e)
{
var label = $(e.target).closest('.fl-tabs-label'),
wrap = label.closest('.fl-tabs'),
index = label.data('index'),
content = label.siblings('.fl-tabs-panel-content'),
activeContent = wrap.find('.fl-tabs-panel-content.fl-tab-active'),
activeIndex = activeContent.data('index'),
allIcons = wrap.find('.fl-tabs-panels .fl-tabs-label > .fa'),
icon = label.find('.fa');
// Should we proceed?
if(index == activeIndex) {
return;
}
if(wrap.hasClass('fl-tabs-animation')) {
return;
}
// Toggle the icons.
allIcons.addClass('fa-plus');
icon.removeClass('fa-plus');
// Run the animations.
wrap.addClass('fl-tabs-animation');
activeContent.slideUp('normal');
content.slideDown('normal', function(){
wrap.find('.fl-tab-active').removeClass('fl-tab-active');
wrap.find('.fl-tabs-label[data-index="' + index + '"]').addClass('fl-tab-active');
content.addClass('fl-tab-active');
wrap.removeClass('fl-tabs-animation');
// Gallery module support.
FLBuilderLayout.refreshGalleries( content );
// Grid layout support (uses Masonry)
FLBuilderLayout.refreshGridLayout( content );
// Post Carousel support (uses BxSlider)
FLBuilderLayout.reloadSlider( content );
// WP audio shortcode support
FLBuilderLayout.resizeAudio( content );
if(label.offset().top < $(window).scrollTop() + 100) {
$('html, body').animate({ scrollTop: label.offset().top - 100 }, 500, 'swing');
}
});
},
_resize: function()
{
$(this.nodeClass + ' .fl-tabs-vertical').each($.proxy(this._resizeVertical, this));
},
_resizeVertical: function(e)
{
var wrap = $(this.nodeClass + ' .fl-tabs-vertical'),
labels = wrap.find('.fl-tabs-labels'),
panels = wrap.find('.fl-tabs-panels');
panels.css('min-height', labels.height() + 'px');
}
};
})(jQuery);