diff --git a/client-vendor/after-body/jquery.tabs/jquery.tabs.js b/client-vendor/after-body/jquery.tabs/jquery.tabs.js index 2264cebb9..f6b945c2d 100755 --- a/client-vendor/after-body/jquery.tabs/jquery.tabs.js +++ b/client-vendor/after-body/jquery.tabs/jquery.tabs.js @@ -2,29 +2,69 @@ * Author: CM */ (function($) { - $.fn.tabs = function() { + + /** + * @param {jQuery} $buttonsContainer + * @constructor + */ + var Tabs = function($buttonsContainer) { + this.$buttonsContainer = $buttonsContainer; + this.$contentContainer = this.$buttonsContainer.next('.tabs-content'); + if (!this.$contentContainer.length) { + throw new Error('No tabs contents found'); + } + + var self = this; + this.$buttonsContainer.on('click', 'a', function(event) { + self.showTab($(this).closest('.tabs > *')); + }); + + var $tabs = this.$buttonsContainer.find('> *'); + var $activeTab = $tabs.filter('.active'); + if (!$activeTab.length) { + $activeTab = $tabs.first(); + } + this.showTab($activeTab); + }; + + Tabs.prototype = { + $buttonsContainer: null, + $contentContainer: null, + + showTabByName: function(tab) { + var $tab = this.$buttonsContainer.children('[data-tab="' + tab + '"]:first'); + if (!$tab.length) { + throw new Error('No tab with name `' + tab + '` found'); + } + this.showTab($tab); + }, + + showTab: function($tab) { + var index = $tab.index(); + $tab.addClass('active').siblings().removeClass('active'); + var $tabContent = this.$contentContainer.find('> *').eq(index); + $tabContent.addClass('active').show().find(':focusable:first').focus(); + $tabContent.siblings().removeClass('active').hide(); + } + }; + + /** + * @param {String} [tab] + * @return {jQuery} + */ + $.fn.tabs = function(tab) { return this.each(function() { - var $buttonsContainer = $(this); - var $contentContainer = $buttonsContainer.next('.tabs-content'); - if (!$contentContainer.length) { - return; + var $self = $(this); + var tabs = $self.data('tabs'); + + if (!tabs) { + tabs = new Tabs($self); + $self.data('tabs', tabs); } - $buttonsContainer.on('click', 'a', function(event) { - var $activeTab = $(this).closest('.tabs > *'); - var index = $activeTab.index(); - $activeTab.addClass('active').siblings().removeClass('active'); - var $activeTabContent = $contentContainer.find('> *').eq(index); - $activeTabContent.addClass('active').show().find(':focusable:first').focus(); - $activeTabContent.siblings().removeClass('active').hide(); - }); - - var $tabs = $buttonsContainer.find('> *'); - var $activeTab = $tabs.filter('.active'); - if (!$activeTab.length) { - $activeTab = $tabs.first(); + if (tab) { + tabs.showTabByName(tab); } - $activeTab.find('> a').click(); }); }; })(jQuery); diff --git a/client-vendor/after-body/query-string/query-string.js b/client-vendor/after-body/query-string/query-string.js new file mode 100644 index 000000000..610c73019 --- /dev/null +++ b/client-vendor/after-body/query-string/query-string.js @@ -0,0 +1,66 @@ +/*! + query-string + Parse and stringify URL query strings + https://github.com/sindresorhus/query-string + by Sindre Sorhus + MIT License +*/ +(function () { + 'use strict'; + var queryString = {}; + + queryString.parse = function (str) { + if (typeof str !== 'string') { + return {}; + } + + str = str.trim().replace(/^\?/, ''); + + if (!str) { + return {}; + } + + return str.trim().split('&').reduce(function (ret, param) { + var parts = param.replace(/\+/g, ' ').split('='); + var key = parts[0]; + var val = parts[1]; + + key = decodeURIComponent(key); + // missing `=` should be `null`: + // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters + val = val === undefined ? null : decodeURIComponent(val); + + if (!ret.hasOwnProperty(key)) { + ret[key] = val; + } else if (Array.isArray(ret[key])) { + ret[key].push(val); + } else { + ret[key] = [ret[key], val]; + } + + return ret; + }, {}); + }; + + queryString.stringify = function (obj) { + return obj ? Object.keys(obj).map(function (key) { + var val = obj[key]; + + if (Array.isArray(val)) { + return val.map(function (val2) { + return encodeURIComponent(key) + '=' + encodeURIComponent(val2); + }).join('&'); + } + + return encodeURIComponent(key) + '=' + encodeURIComponent(val); + }).join('&') : ''; + }; + + if (typeof define === 'function' && define.amd) { + define([], queryString); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = queryString; + } else { + window.queryString = queryString; + } +})(); diff --git a/layout/default/Component/Example/default.tpl b/layout/default/Component/Example/default.tpl index 30bfc0ef5..f4d54e10f 100644 --- a/layout/default/Component/Example/default.tpl +++ b/layout/default/Component/Example/default.tpl @@ -1,11 +1,11 @@ -