blob: 74d4efced2d0550efc238f4f0055107ff6863558 (
plain)
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
|
$.defineAttributePlugin('tabs', function ($element, options) {
var animating = false,
dataTab,
slideSpeed = options.slideSpeed ? options.slideSpeed : 400;
if (!$element.find("[data-tab-trigger]").hasClass('active')) {
setTimeout(function () { $element.find("[data-tab-trigger]").first().trigger('click'); }, 50);
}
$element.find("[data-tab-trigger]").click(function (e) {
e.preventDefault();
if (animating === true || $(this).hasClass('active')) {
return;
}
animating = true;
$(this).addClass('active').siblings().removeClass('active');
dataTab = $(this).data('tab-trigger');
$('[data-tab-content="' + dataTab + '"]').siblings('.active').slideUp(slideSpeed, function () {
$(this).removeClass('active').removeAttr('style');
});
$('[data-tab-content="' + dataTab + '"]').slideDown(slideSpeed, function () {
$(this).addClass('active').removeAttr('style');
animating = false;
});
});
});
|