Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $.fn.fabtabs = function() {
- var target = $(this);
- this.fabtab.init(target);
- return this;
- };
- // Some local storage..
- $.fn.fabtab = {
- init: function(target) {
- $.fn.fabtab.menu = jQuery("a", target);
- $.fn.fabtab.show($.fn.fabtab.getInitialTab());
- $.fn.fabtab.menu.bind("click", $.fn.fabtab.activate);
- },
- show: function(target) {
- target.addClass("active-tab");
- $(target.attr("href")).addClass("active-tab-body").show();
- },
- hide: function(target) {
- $(target).removeClass("active-tab");
- $($(target).attr("href")).removeClass("active-tab-body").hide();
- },
- activate: function(e) {
- var element = $(this);
- if (element.hasClass("nostop")) return this;
- if (!element.hasClass("anchor")) e.preventDefault();
- if (element.hasClass("cam-trigger")) play_surfcam();
- $.fn.fabtab.show(element);
- $.fn.fabtab.menu.not(element).each(function() {
- $.fn.fabtab.hide(this);
- });
- },
- getInitialTab: function() {
- if ($(".active-tab", $.fn.fabtab.menu).length > 0) {
- return $(".active-tab", $.fn.fabtab.menu);
- } else {
- if (document.location.href.match(/(#\w.+)/)) {
- var loc = document.location.href.match(/(#\w.+)/)[1];
- var element = $.fn.fabtab.menu.filter("a[href=\#" + loc + "]");
- return (element.length > 0) ? element : $.fn.fabtab.menu.first();
- } else {
- return $.fn.fabtab.menu.first();
- }
- }
- }
- };
- })(jQuery);
Add Comment
Please, Sign In to add comment