This repository was archived by the owner on Mar 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfluabs.js
More file actions
71 lines (46 loc) · 1.38 KB
/
fluabs.js
File metadata and controls
71 lines (46 loc) · 1.38 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
(function( $ ) {
var methods = {
init: function( _options ) {
return this.each(function() {
var s = $.extend({}, $.fn.fluabs.defaults, _options);
var $el = $(this);
var sEl = $el.find(s.tabs);
$(s.content + ' > div').hide();
for ( var i=0; i<sEl.length; i++ ) {
if ( sEl[i].className === s.current ) {
var openTab = sEl[i].hash;
$(s.content + ' > div[data-tab='+openTab+']').addClass(s.current).show();
}
}
$el.on('click.fluabs', s.tabs, function(e) {
e.preventDefault();
var $el = $(this);
var id = $el.prop('hash');
$el.removeClass(s.current);
$el.addClass(s.current);
$(s.content + ' > div:not([data-tab='+id+'])').removeClass(s.current).hide();
$(s.content + ' > div[data-tab='+id+']').fadeIn().addClass(s.current);
});
});
},
destroy: function( ) {
$(this).off('.fluabs');
}
};
$.fn.fluabs = function( _method ) {
// Method calling logic
if ( methods[_method] ) {
return methods[_method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof _method === 'object' || ! _method ) {
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + _method + ' does not exist on jQuery.fluabs' );
}
}
// default settings
$.fn.fluabs.defaults = {
tabs: 'li a',
current: 'current',
content: '.tabcontent'
};
})(jQuery);