|
Server : Apache System : Linux box5719.bluehost.com 5.14.0-687.54.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Oct 6 04:43:47 EDT 2026 x86_64 User : uaeambul ( 1793) PHP Version : 8.3.36 Disable Function : NONE Directory : /home1/uaeambul/www/wp-content/plugins/tm-oneclick/admin/assets/js/components/ | |
|
Path: /home1/uaeambul/www/wp-content/plugins/tm-oneclick/admin/assets/js/components/timber.tm.tabs.js
Size: 4.13 KB
Permissions: 0644
/**
* Timber Component: tabs
* Version: 1.0.0
* URL: @ThemeMountain
* Description: Components
* Requires: jQuery 1.10+
* Author: ThemeMountain
* Copyright: Copyright 2018 ThemeMountain
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/
;(function( $, document, window, undefined ) {
'use strict';
var Tabs = function( element, options ){
// Settings
var settings = $.extend( {}, $.fn.tabs.tmtOpts, options );
// jQuery el
element = $( element );
//Check for event type
var eventType = mobile ? 'touchstart' : 'click';
// Check hash - determine if there is an ID match
var locationHash = {
itemLength: function( item ){
var url = window.location.hash, id = url.indexOf( '#' );
var hash = id != -1 ? url.substring( id ) : '';
if( hash !== '' && item.find( hash ).length ){
return [ true, hash ];
}else{
return false;
}
}
};
// Component
$( element ).each( function(){
var tabLink = $( this ).children( '.tab-nav' ).find( 'li > a' );
var location = locationHash.itemLength( $( this ) );
var itemExists = location[0];
var itemID = location[1];
// Check hash and show appropriate tab/pane
if( itemExists ){
$( this ).find( '.active' ).removeClass( 'active' );
$( this ).find( 'a[href="' + itemID + '"]' ).parent().addClass( 'active' );
$( this ).find( itemID ).addClass( 'active' ).addClass( 'animate-in' );
}else{
$( this ).find( '.tab-panes > .active' ).addClass( 'animate-in' );
}
// Event
tabLink.each( function(){
$( this ).on( eventType , function(){
// Return if disabled
if( $( this ).parent().hasClass( 'disabled' ) ) return false;
// Get references
var tabRef = $( this ).attr( 'href' );
var tabContent = $( this ).closest( element ).find( tabRef );
$( this ).closest( '.tab-nav' ).find( '.active' ).removeClass( 'active' );
$( this ).parent().addClass( 'active' );
$( this ).closest( element ).children( '.tab-panes' ).children( '.active' ).removeClass( 'active animate-in' );
tabContent.addClass( 'active' );
// Force slider resize if a slider is found
// required due to display none of tab panes
if( tabContent.find( '.tm-slider-container' ).length > 0 ){
var tabSlider = tabContent.find( '.tm-slider-container' ).data( 'avalancheSlider' );
tabSlider.resizeSlider();
}
// Set animation timeout
var toggleTimer = null;
clearTimeout( toggleTimer );
toggleTimer = setTimeout( function(){
tabContent.addClass( 'animate-in' );
}, 50 );
return false;
});
if($( this ).parent().hasClass( 'active' )){
$( this ).closest( element ).find( $( this ).attr( 'href' ) ).addClass( 'active' );
}
});
});
$( settings.tabTriggerClick ).each( function(){
$( this ).on( 'click', function(){
var targetTab = $( this ).data( 'target-tab' );
$( element ).find( targetTab ).parent().removeClass( 'disabled' );
$( element ).find( targetTab ).trigger( 'click' );
return false;
});
});
// Add mobile class
// Mobile Check
var mobile = false;
if( navigator.userAgent.match(/Android/i) ||
navigator.userAgent.match(/webOS/i) ||
navigator.userAgent.match(/iPhone/i) ||
navigator.userAgent.match(/iPad/i) ||
navigator.userAgent.match(/iPod/i) ||
navigator.userAgent.match(/BlackBerry/i) ||
navigator.userAgent.match(/Windows Phone/i) ){
mobile = true;
document.getElementsByTagName( 'body' )[0].className+=' mobile';
}
}
// Plugin
$.fn.tabs = function( options ) {
// Iterate through each DOM element and return it
return this.each(function() {
// Element
var element = $( this );
// Return early if this element already has a plugin instance
if ( element.data( 'tabs' ) ) return;
// Pass options
var tabs = new Tabs( this, options );
// Store plugin object in this element's data
element.data( 'tabs', tabs );
});
};
// Default
$.fn.tabs.tmtOpts = {
tabTriggerClick: '.tab-trigger-click'
};
})( jQuery, document, window );