vendor/assets/javascripts/foundation/jquery.foundation.tabs.js in zurb-foundation-3.2.3 vs vendor/assets/javascripts/foundation/jquery.foundation.tabs.js in zurb-foundation-3.2.4.rc1

- old
+ new

@@ -1,19 +1,22 @@ ;(function ($, window, document, undefined) { 'use strict'; var settings = { callback: $.noop, + deep_linking: true, init: false - }, + }, methods = { init : function (options) { - settings = $.extend({}, options, settings); + settings = $.extend({}, settings, options); return this.each(function () { if (!settings.init) methods.events(); + + if (settings.deep_linking) methods.from_hash(); }); }, events : function () { $(document).on('click.fndtn', '.tabs a', function (e) { @@ -29,20 +32,27 @@ hasHash = /^#/.test(target), $content = $(target + 'Tab'); if (hasHash && $content.length > 0) { // Show tab content - e.preventDefault(); + if (e && !settings.deep_linking) e.preventDefault(); $content.closest('.tabs-content').children('li').removeClass('active').hide(); $content.css('display', 'block').addClass('active'); } // Make active tab $activeTab.removeClass('active'); $tab.addClass('active'); settings.callback(); + }, + + from_hash : function () { + var hash = window.location.hash, + $tab = $('a[href="' + hash + '"]'); + + $tab.trigger('click.fndtn'); } } $.fn.foundationTabs = function (method) { if (methods[method]) { @@ -51,6 +61,6 @@ return methods.init.apply(this, arguments); } else { $.error('Method ' + method + ' does not exist on jQuery.foundationTabs'); } }; -}(jQuery, this, this.document)); \ No newline at end of file +}(jQuery, this, this.document));