File: /var/www/www-root/data/www/automoon.click/tds/files/lib/jquery.responsiveTabs.js
/**
* scrollTo
* Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
* Licensed under MIT
* @author Ariel Flesler
* @version 1.4.13
*/
;(function(k){'use strict';k(['jquery'],function($){var j=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};j.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:!0};j.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(f,g,h){if(typeof g=='object'){h=g;g=0}if(typeof h=='function')h={onAfter:h};if(f=='max')f=9e9;h=$.extend({},j.defaults,h);g=g||h.duration;h.queue=h.queue&&h.axis.length>1;if(h.queue)g/=2;h.offset=both(h.offset);h.over=both(h.over);return this._scrollable().each(function(){if(f==null)return;var d=this,$elem=$(d),targ=f,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=win?$(targ):$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}var e=$.isFunction(h.offset)&&h.offset(d,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=j.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=e[pos]||0;if(h.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*h.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&h.queue){if(old!=attr[key])animate(h.onAfterFirst);delete attr[key]}});animate(h.onAfter);function animate(a){$elem.animate(attr,g,h.easing,a&&function(){a.call(this,targ,h)})}}).end()};j.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||typeof a=='object'?a:{top:a,left:a}}return j})}(typeof define==='function'&&define.amd?define:function(a,b){if(typeof module!=='undefined'&&module.exports){module.exports=b(require('jquery'))}else{b(jQuery)}}));
/* https://github.com/jellekralt/Responsive-Tabs
* Project: Accordion to tabs
* Description: Presente content sections like accordion on smaller devices and like tabs on larger devices
* Author: laurentperroteau.com
* License: MIT
*/
;(function ( $, window, document, undefined ) {
// Create the defaults once
var pluginName = 'accordionToTabs',
defaults = {
classMenuSmaller: '.tab-menu-mobile',
classMenuHigher: '.tab-menu',
classMenuHigherTrigger: '.tab-menu--trigger',
classTabsSection: '.tab-container--section',
breakpoint: '990px', // can be px, ems, rems
duration: 0,
tabOffset: 0
};
// The actual plugin constructor
function Plugin( element, options ) {
this.element = element;
this.options = $.extend( {}, defaults, options) ;
this._defaults = defaults;
this._name = pluginName;
this.init();
}
Plugin.prototype = {
init: function () {
// Place initialization logic here
this.activeTab();
},
cache: {
flagTabOpen: 'firstTime'
},
activeTab: function(idTabToActivate) {
var $container = $( this.element );
// Si une ID est passé, on active la tab correspondante
if( idTabToActivate !== undefined )
{
if( matchMedia('only screen and (max-width: '+ this.options.breakpoint +')').matches )
{
this._actionOnClickSmaller( idTabToActivate, $container );
}
else {
this._actionOnClickHigher( idTabToActivate, $container );
}
}
else {
// Activer la première tab si pas mobile
if( matchMedia('only screen and (min-width: '+ this.options.breakpoint +')').matches )
{
var $parentMenu = $( this.options.classMenuHigher );
// Sur le menu
for (var i = 0; i < $parentMenu.length; i++) {
$parentMenu.eq(i).find( this.options.classMenuHigherTrigger ).first().addClass('is-active');
};
// Et sur la tab
$container.find( this.options.classTabsSection ).first().addClass('is-visible');
}
var self = this;
// Action en mobile
$container.find( this.options.classMenuSmaller ).on('click', function(e) {
// Check if anchor
if( $(this).attr('href')[0] == '#' ) {
e.preventDefault();
self._actionOnClickSmaller( $(this), $container );
}
});
// Action en tablet/desktop
var firstIdTab = $container.find( this.options.classTabsSection ).first().attr('id');
// A partir de la ID de la première tab,
// on retrouve sont trigger,
// on remonte à son parent
// et on ajouter l'event sur tous les liens
$('a[href="#'+ firstIdTab +'"]'+ this.options.classMenuHigherTrigger)
.closest( this.options.classMenuHigher )
.find( this.options.classMenuHigherTrigger )
.on('click', function(e) {
e.preventDefault();
self._actionOnClickHigher( $(this), $container );
});
}
},
/**
* Action sur les petits devices
* ==============================
* @param {object/string} $trigger => si utilisation de la méthode activeTab() en déhors du plugin, $trigger est la ID de la tab à ouvrir
* @param {object} $container => les conteneurs des tabs
*/
_actionOnClickSmaller: function($trigger, $container) {
var tabId;
if ( typeof $trigger === 'string' )
{
tabId = '#'+ $trigger;
$trigger = $(this.options.classMenuSmaller +'[href="'+ tabId +'"]');
}
else {
tabId = $trigger.attr('href');
}
var $tabToShow = $(tabId);
if( $tabToShow.length > 1 )
console.error('Une id est dupliqué');
// Désactiver tous les menus
$container.find( this.options.classMenuSmaller ).removeClass('is-active');
// Si courant ouvert, on ferme tout : sinon on ouvre le courant
if( $tabToShow.hasClass('is-visible') ) {
this._closeAllTabs( $tabToShow, $container );
//скрываем кнопку с задержкой
setTimeout(function(){
$('.hide').removeClass('show');}, 600);
}
else {
$trigger.addClass('is-active');
// Activer aussi le lien pour higher
$('a[href="'+ tabId +'"]'+ this.options.classMenuHigherTrigger).addClass('is-active');
this._switchTabs( $tabToShow, $container );
}
},
/**
* Action sur les grands devices
* ==============================
* @param {object/string} $trigger => si utilisation de la méthode activeTab() en déhors du plugin, $trigger est la ID de la tab à ouvrir
* @param {object} $container => les conteneurs des tabs
*/
_actionOnClickHigher: function($trigger, $container) {
var tabId;
if ( typeof $trigger === 'string' )
{
tabId = '#'+ $trigger;
$trigger = $(this.options.classMenuHigherTrigger +'[href="'+ tabId +'"]');
}
else {
tabId = $trigger.attr('href');
}
var $tabToShow = $(tabId);
if( $tabToShow.length > 1 )
console.error('Une id est dupliqué');
// Activer la tab du menu
$trigger.closest( this.options.classMenuHigher ).find( this.options.classMenuHigherTrigger ).removeClass('is-active');
$trigger.addClass('is-active');
this._switchTabs($tabToShow, $container);
},
_closeAllTabs: function($styleTab, $container) {
if( $container.length)
$container.find( this.options.classTabsSection ).removeClass('is-visible');
},
_switchTabs: function($tab, $container) {
this._closeAllTabs($tab, $container);
$tab.addClass('is-visible');
// Si petit device on scroll jusqu'à l'élément et ce n'est pas la première action
if( matchMedia('only screen and (max-width: '+ this.options.breakpoint +')').matches
&& this.cache.flagTabOpen != false )
{
$('.hide').addClass('show');//показываем кнопку
if( this.cache.flagTabOpen.length || this.cache.flagTabOpen == 'firstTime' ) {
var wait = this.options.duration;
if( this.cache.flagTabOpen != 'firstTime' )
if( this.cache.flagTabOpen.index() < $tab.index() )
var wait = wait * 2;
var _this = this;
setTimeout(function() {
$.scrollTo(
'#'+ $tab.attr('id'),
_this.options.duration,
{offset: _this.options.tabOffset}
);
}, wait);
}
else {
this.cache.flagTabOpen = false;
}
}
// Garde en mémoire la tab ouverte
this.cache.flagTabOpen = $tab;
}
};
// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations and allowing any
// public function (ie. a function whose name doesn't start
// with an underscore) to be called via the jQuery plugin,
// e.g. $(element).defaultPluginName('functionName', arg1, arg2)
$.fn[pluginName] = function ( options ) {
var args = arguments;
if (options === undefined || typeof options === 'object') {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName))
$.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
});
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init')
{
var returns;
this.each(function () {
var instance = $.data(this, 'plugin_' + pluginName);
if (instance instanceof Plugin && typeof instance[options] === 'function')
returns = instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) );
// Allow instances to be destroyed via the 'destroy' method
if (options === 'destroy') {
$.data(this, 'plugin_' + pluginName, null);
}
});
return returns !== undefined ? returns : this;
}
};
}(jQuery, window, document));