diff --git a/javascripts/tabs.js b/javascripts/tabs.js index 8a74b10..d0d5191 100644 --- a/javascripts/tabs.js +++ b/javascripts/tabs.js @@ -8,35 +8,33 @@ */ -$(document).ready(function() { +;(function ( $, window, document, undefined ) { + + var pluginName = 'skeletonTabs', + defaults = { + propertyName: "value" + }; - /* Tabs Activiation - ================================================== */ + function Plugin( element, options ) { + this.element = element; + this.options = $.extend( {}, defaults, options) ; + + this._defaults = defaults; + this._name = pluginName; + + this.init(); + } - var tabs = $('ul.tabs'); + Plugin.prototype.init = function () { - tabs.each(function(i) { + }; - //Get all tabs - var tab = $(this).find('> li > a'); - tab.click(function(e) { + $.fn[pluginName] = function ( options ) { + return this.each(function () { + if (!$.data(this, 'plugin_' + pluginName)) { + $.data(this, 'plugin_' + pluginName, new Plugin( this, options )); + } + }); + } - //Get Location of tab's content - var contentLocation = $(this).attr('href'); - - //Let go if not a hashed one - if(contentLocation.charAt(0)=="#") { - - e.preventDefault(); - - //Make Tab Active - tab.removeClass('active'); - $(this).addClass('active'); - - //Show Tab Content & add active class - $(contentLocation).show().addClass('active').siblings().hide().removeClass('active'); - - } - }); - }); -}); \ No newline at end of file +})(jQuery, window, document); \ No newline at end of file diff --git a/javascripts/tests/runner.html b/javascripts/tests/runner.html index 8af18e9..8865aac 100644 --- a/javascripts/tests/runner.html +++ b/javascripts/tests/runner.html @@ -9,7 +9,18 @@

    -
    test markup, will be hidden
    +
    +
    + +
    The tabs are clean and simple divs and basic CSS.
    +
    The tabs are cross-browser, but don't need a ton of hacky CSS or markup.
    +
    The tabs work like a charm even on mobile devices.
    +
    +