// source --> https://esneux.mr.be/wp-content/plugins/responsive-lightbox/js/front.js?ver=2.2.2 ( function ( $ ) { // parse query string var parse_str = function( name, str ) { var regex = new RegExp( '[?&]' + name.replace( /[\[\]]/g, '\\$&' ) + '(=([^&#]*)|&|#|$)' ), results = regex.exec( '&' + str ); return ( ! results || ! results[2] ? '' : decodeURIComponent( results[2].replace( /\+/g, ' ' ) ) ); } // observe DOM changes var observe_script_dom = ( function () { var MutationObserver = window.MutationObserver || window.WebKitMutationObserver, eventListenerSupported = window.addEventListener; return function ( obj, only_added, callback ) { if ( MutationObserver ) { // define a new observer var obs = new MutationObserver( function ( mutations, observer ) { if ( only_added ) { if ( mutations[0].addedNodes.length ) callback(); } else { if ( mutations[0].addedNodes.length || mutations[0].removedNodes.length ) callback(); } } ); // have the observer observe for changes in children obs.observe( obj, { childList: true, subtree: true } ); } else if ( eventListenerSupported ) { obj.addEventListener( 'DOMNodeInserted', callback, false ); if ( !only_added ) { obj.addEventListener( 'DOMNodeRemoved', callback, false ); } } } } )(); // ready event handler $( document ).on( 'ready' + rlArgs.customEvents, function () { var containers = []; // check for infinite galleries $( '.rl-gallery-container' ).each( function() { var container = $( this ); // is it ifinite scroll gallery? if ( container.hasClass( 'rl-pagination-infinite' ) ) { containers.push( container ); } else { // remove loading class container.removeClass( 'rl-loading' ); } } ); // any infinite galleries? if ( containers.length > 0 ) { for ( var i = 0; i < containers.length; i++ ) { var container = containers[i], gallery = container.find( '.rl-gallery' ), gallery_id = parseInt( container.data( 'gallery_id' ) ), gallery_scroll_type = container.find( '.rl-pagination-bottom' ).data( 'button' ), gallery_button = typeof gallery_scroll_type !== 'undefined' && gallery_scroll_type === 'manually'; // initialize infinite scroll gallery.infiniteScroll( { path: '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-pagination-bottom .next', append: '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-gallery-item' + ( gallery.hasClass( 'rl-masonry-gallery' ) || gallery.hasClass( 'rl-basicmasonry-gallery' ) ? '-no-append' : '' ), status: false, hideNav: '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-pagination-bottom', prefill: ! gallery_button, loadOnScroll: true, scrollThreshold: gallery_button ? false : 0, button: gallery_button ? '.rl-gallery-container[data-gallery_id="' + gallery_id + '"] .rl-load-more' : false, debug: false, history: false, onInit: function() { // infinite with button? if ( container.hasClass( 'rl-pagination-infinite' ) && gallery_button ) { // remove loading class container.removeClass( 'rl-loading' ); } // store gallery ID for append event var _gallery_id = gallery_id; // request event this.on( 'request', function( path ) { // add loading class container.addClass( 'rl-loading' ); } ); // append event this.on( 'append', function ( response, path, items ) { // remove loading class container.removeClass( 'rl-loading' ); $.event.trigger( { type: 'doResponsiveLightbox', script: rlArgs.script, selector: rlArgs.selector, args: rlArgs, pagination_type: 'infinite', gallery_id: _gallery_id, masonry: gallery.hasClass( 'rl-masonry-gallery' ) || gallery.hasClass( 'rl-basicmasonry-gallery' ), infinite: { gallery: gallery, response: response, items: items } } ); } ); } } ); } } // initialize event $.event.trigger( { type: 'doResponsiveLightbox', script: rlArgs.script, selector: rlArgs.selector, args: rlArgs } ); } ); // pagination $( document ).on( 'click', '.rl-pagination a.page-numbers', function ( e ) { var link = $( this ), container = link.closest( '.rl-gallery-container' ); // ajax type pagination? if ( container.hasClass( 'rl-pagination-ajax' ) ) { e.preventDefault(); e.stopPropagation(); var gallery_id = container.data( 'gallery_id' ); // add loading class container.addClass( 'rl-loading' ); $.post( rlArgs.ajaxurl, { action: 'rl-get-gallery-page-content', gallery_id: gallery_id, page: parse_str( 'rl_page', link.prop( 'href' ) ), nonce: rlArgs.nonce } ).done( function ( response ) { // replace container with new content container.replaceWith( $( response ).removeClass( 'rl-loading' ) ); // trigger main event $.event.trigger( { type: 'doResponsiveLightbox', script: rlArgs.script, selector: rlArgs.selector, args: rlArgs, pagination_type: 'ajax', gallery_id: gallery_id } ); } ).fail( function () { container.removeClass( 'rl-loading' ); } ); return false; } } ); // this is similar to the WP function add_action(); $( document ).on( 'doResponsiveLightbox', function ( event ) { if ( typeof event.masonry !== 'undefined' && event.masonry === true ) { return false; } var script = event.script, selector = event.selector, args = event.args; if ( typeof script === 'undefined' || typeof selector === 'undefined' ) { return false; } rl_view_image = function ( script, url ) { $.event.trigger( { type: 'doLightboxViewImage', script: script, url: url } ); } rl_hide_image = function ( script, url ) { $.event.trigger( { type: 'doLightboxHideImage', script: script, url: url } ); } // WooCommerce 3.0+ compatibility setTimeout( function () { var flex = $( '.flex-viewport' ); // if ( flex.length ) // flex.css( 'cursor', 'pointer' ); if ( args.woocommerce_gallery === '1' ) { var gallery = $( '.woocommerce-product-gallery' ); if ( gallery.find( '.woocommerce-product-gallery__trigger' ).length === 0 ) { gallery.prepend( '🔍' ); gallery.on( 'click', '.woocommerce-product-gallery__trigger', function( e ) { e.preventDefault(); e.stopPropagation(); if ( flex.length ) flex.find( '.flex-active-slide a[data-rel]' ).trigger( 'click' ); else gallery.find( 'a[data-rel]' ).first().trigger( 'click' ); } ); } } }, 10 ); // init lightbox switch ( script ) { case 'swipebox': var slide = $( '#swipebox-overlay' ).find( '.slide.current' ), image_source = '', allow_hide = false, close_executed = false; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).swipebox( { useCSS: ( args.animation === '1' ? true : false ), useSVG: ( args.useSVG === '1' ? true : false ), hideCloseButtonOnMobile: ( args.hideCloseButtonOnMobile === '1' ? true : false ), removeBarsOnMobile: ( args.removeBarsOnMobile === '1' ? true : false ), hideBarsDelay: ( args.hideBars === '1' ? parseInt( args.hideBarsDelay ) : 0 ), videoMaxWidth: parseInt( args.videoMaxWidth ), loopAtEnd: ( args.loopAtEnd === '1' ? true : false ), afterOpen: function () { close_executed = false; // update current slide container slide = $( '#swipebox-overlay' ).find( '.slide.current' ); // get image source var image = slide.find( 'img' ).attr( 'src' ); // valid image source? if ( typeof image !== 'undefined' ) { image_source = image; // trigger image view rl_view_image( script, image_source ); } else { image_source = ''; } // add current slide observer observe_script_dom( document.getElementById( 'swipebox-slider' ), false, function () { if ( image_source === '' ) { // get image source var image = slide.find( 'img' ).attr( 'src' ); // valid image source? if ( typeof image !== 'undefined' ) { image_source = image; // trigger image view rl_view_image( script, image_source ); } else { image_source = ''; } } } ); }, nextSlide: function () { // update current slide container slide = $( '#swipebox-overlay' ).find( '.slide.current' ); // get image source var image = slide.find( 'img' ).attr( 'src' ); // valid image source? if ( typeof image !== 'undefined' ) { image_source = image; // trigger image view rl_view_image( script, image_source ); } else { image_source = ''; } }, prevSlide: function () { // update current slide container slide = $( '#swipebox-overlay' ).find( '.slide.current' ); // get image source var image = slide.find( 'img' ).attr( 'src' ); // valid image source? if ( typeof image !== 'undefined' ) { image_source = image; // trigger image view rl_view_image( script, image_source ); } else { image_source = ''; } }, afterClose: function () { // afterClose event executed close_executed = true; // allow to hide image? if ( allow_hide ) { // trigger image hide rl_hide_image( script, image_source ); allow_hide = false; } } } ); // additional event to prevent rl_hide_image to execure while opening modal $( window ).on( 'resize', function () { if ( !close_executed ) { allow_hide = true; } } ); break; case 'prettyphoto': var view_disabled = false, last_image = ''; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function () { var el = $( this ); // set description el.attr( 'title', el.data( 'rl_caption' ) ); // set title el.find( 'img' ).attr( 'alt', el.data( 'rl_title' ) ); } ); $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).prettyPhoto( { hook: 'data-rel', animation_speed: args.animationSpeed, slideshow: ( args.slideshow === '1' ? parseInt( args.slideshowDelay ) : false ), autoplay_slideshow: ( args.slideshowAutoplay === '1' ? true : false ), opacity: args.opacity, show_title: ( args.showTitle === '1' ? true : false ), allow_resize: ( args.allowResize === '1' ? true : false ), allow_expand: ( args.allowExpand === '1' ? true : false ), default_width: parseInt( args.width ), default_height: parseInt( args.height ), counter_separator_label: args.separator, theme: args.theme, horizontal_padding: parseInt( args.horizontalPadding ), hideflash: ( args.hideFlash === '1' ? true : false ), wmode: args.wmode, autoplay: ( args.videoAutoplay === '1' ? true : false ), modal: ( args.modal === '1' ? true : false ), deeplinking: ( args.deeplinking === '1' ? true : false ), overlay_gallery: ( args.overlayGallery === '1' ? true : false ), keyboard_shortcuts: ( args.keyboardShortcuts === '1' ? true : false ), social_tools: ( args.social === '1' ? '
' : '' ), ie6_fallback: true, changepicturecallback: function () { // is view disabled? if ( view_disabled ) { // enable view view_disabled = false; return; } last_image = $( '#pp_full_res' ).find( 'img' ).attr( 'src' ); // trigger image view rl_view_image( script, last_image ); // is expanding allowed? if ( args.allowExpand === '1' ) { // disable changepicturecallback event after expanding $( 'a.pp_expand' ).on( 'click', function () { view_disabled = true; } ); } }, callback: function () { // trigger image hide rl_hide_image( script, last_image ); } } ); break; case 'fancybox': var last_image = ''; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).fancybox( { modal: ( args.modal === '1' ? true : false ), overlayShow: ( args.showOverlay === '1' ? true : false ), showCloseButton: ( args.showCloseButton === '1' ? true : false ), enableEscapeButton: ( args.enableEscapeButton === '1' ? true : false ), hideOnOverlayClick: ( args.hideOnOverlayClick === '1' ? true : false ), hideOnContentClick: ( args.hideOnContentClick === '1' ? true : false ), cyclic: ( args.cyclic === '1' ? true : false ), showNavArrows: ( args.showNavArrows === '1' ? true : false ), autoScale: ( args.autoScale === '1' ? true : false ), scrolling: args.scrolling, centerOnScroll: ( args.centerOnScroll === '1' ? true : false ), opacity: ( args.opacity === '1' ? true : false ), overlayOpacity: parseFloat( args.overlayOpacity / 100 ), overlayColor: args.overlayColor, titleShow: ( args.titleShow === '1' ? true : false ), titlePosition: args.titlePosition, transitionIn: args.transitions, transitionOut: args.transitions, easingIn: args.easings, easingOut: args.easings, speedIn: parseInt( args.speeds ), speedOut: parseInt( args.speeds ), changeSpeed: parseInt( args.changeSpeed ), changeFade: parseInt( args.changeFade ), padding: parseInt( args.padding ), margin: parseInt( args.margin ), width: parseInt( args.videoWidth ), height: parseInt( args.videoHeight ), onComplete: function () { last_image = $( '#fancybox-content' ).find( 'img' ).attr( 'src' ); // trigger image view rl_view_image( script, last_image ); }, onClosed: function () { // trigger image hide rl_hide_image( script, last_image ); } } ); break; case 'nivo': $.each( $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ), function () { var attr = $( this ).attr( 'data-rel' ); // check data-rel attribute first if ( typeof attr === 'undefined' || attr == false ) { // if not found then try to check rel attribute for backward compatibility attr = $( this ).attr( 'rel' ); } // for some browsers, `attr` is undefined; for others, `attr` is false. Check for both. if ( typeof attr !== 'undefined' && attr !== false ) { var match = attr.match( new RegExp( selector + '\\-(gallery\\-(?:[\\da-z]{1,4}))', 'ig' ) ); if ( match !== null ) { $( this ).attr( 'data-lightbox-gallery', match[0] ); } } } ); var observer_initialized = false, change_allowed = true, last_image = ''; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).nivoLightbox( { effect: args.effect, clickOverlayToClose: ( args.clickOverlayToClose === '1' ? true : false ), keyboardNav: ( args.keyboardNav === '1' ? true : false ), errorMessage: args.errorMessage, afterShowLightbox: function ( lightbox ) { var content = $( lightbox )[0].find( '.nivo-lightbox-content' ); // is observer initialized? if ( !observer_initialized ) { // turn it off observer_initialized = true; // add content observer observe_script_dom( document.getElementsByClassName( 'nivo-lightbox-content' )[0], true, function () { if ( change_allowed ) { last_image = content.find( '.nivo-lightbox-image img' ).attr( 'src' ); // trigger image view rl_view_image( script, last_image ); // disallow observer changes change_allowed = false; } } ); } }, afterHideLightbox: function () { // allow observer changes change_allowed = true; // trigger image hide rl_hide_image( script, last_image ); }, onPrev: function ( element ) { // disallow observer changes change_allowed = false; last_image = element[0].attr( 'href' ); // trigger image view rl_view_image( script, last_image ); }, onNext: function ( element ) { // disallow observer changes change_allowed = false; last_image = element[0].attr( 'href' ); // trigger image view rl_view_image( script, last_image ); } } ); break; case 'imagelightbox': var selectors = [ ], last_image = ''; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function ( i, item ) { var attr = $( item ).attr( 'data-rel' ); // check data-rel attribute first if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); // if not found then try to check rel attribute for backward compatibility else { attr = $( item ).attr( 'rel' ); if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); } } ); if ( selectors.length > 0 ) { // make unique selectors = $.unique( selectors ); $( selectors ).each( function ( i, item ) { if ( typeof event.pagination_type !== 'undefined' ) { $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() { $( this ).off( 'click.imageLightbox' ); } ); } $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).imageLightbox( { animationSpeed: parseInt( args.animationSpeed ), preloadNext: ( args.preloadNext === '1' ? true : false ), enableKeyboard: ( args.enableKeyboard === '1' ? true : false ), quitOnEnd: ( args.quitOnEnd === '1' ? true : false ), quitOnImgClick: ( args.quitOnImageClick === '1' ? true : false ), quitOnDocClick: ( args.quitOnDocumentClick === '1' ? true : false ), onLoadEnd: function () { last_image = $( '#imagelightbox' ).attr( 'src' ); // trigger image view rl_view_image( script, last_image ); }, onEnd: function () { // trigger image hide rl_hide_image( script, last_image ); } } ); } ); } break; case 'tosrus': var selectors = [ ], last_image = ''; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function ( i, item ) { var attr = $( item ).attr( 'data-rel' ); // check data-rel attribute first if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); // if not found then try to check rel attribute for backward compatibility else { attr = $( item ).attr( 'rel' ); if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); } } ); if ( selectors.length > 0 ) { // make unique selectors = $.unique( selectors ); $( selectors ).each( function ( i, item ) { if ( typeof event.pagination_type !== 'undefined' ) { $( 'body' ).find( '.tosrus-' + item ).remove(); $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() { $( this ).off( 'click.tos' ); } ); } var tos = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).tosrus( { infinite: ( args.infinite === '1' ? true : false ), autoplay: { play: ( args.autoplay === '1' ? true : false ), pauseOnHover: ( args.pauseOnHover === '1' ? true : false ), timeout: args.timeout }, effect: args.effect, keys: { prev: ( args.keys === '1' ? true : false ), next: ( args.keys === '1' ? true : false ), close: ( args.keys === '1' ? true : false ) }, pagination: { add: ( args.pagination === '1' ? true : false ), type: args.paginationType }, // forced show: false, buttons: true, caption: { add: true, attributes: [ "title" ] }, wrapper: { classes: 'tosrus-' + item, onClick: args.closeOnClick === '1' ? 'close' : 'toggleUI' } } ); tos.bind( 'sliding.tos', function ( event, number ) { last_image = $( $( event.target ).find( '.tos-slider .tos-slide' )[number] ).find( 'img' ).attr( 'src' ); // trigger image view rl_view_image( script, last_image ); } ); tos.bind( 'closing.tos', function () { // trigger image hide rl_hide_image( script, last_image ); } ); } ); } break; case 'featherlight': var selectors = [ ], last_image = ''; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function ( i, item ) { var attr = $( item ).attr( 'data-rel' ); // check data-rel attribute first if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); // if not found then try to check rel attribute for backward compatibility else { attr = $( item ).attr( 'rel' ); if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); } } ); if ( selectors.length > 0 ) { // make unique selectors = $.unique( selectors ); // set defaults $.extend( $.featherlight.defaults, { openSpeed: parseInt( args.openSpeed ), closeSpeed: parseInt( args.closeSpeed ), closeOnClick: args.closeOnClick, closeOnEsc: ( args.closeOnEsc === '1' ? true : false ), afterOpen: function ( event ) { last_image = event.currentTarget.href; // trigger image view rl_view_image( script, last_image ); }, afterClose: function () { // trigger image hide rl_hide_image( script, last_image ); } } ); $( selectors ).each( function ( i, item ) { if ( typeof event.pagination_type !== 'undefined' ) { $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).each( function() { $( this ).off( 'click.featherlight' ); } ); } // gallery? if ( /-gallery-/.test( item ) ) { $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlightGallery( { galleryFadeIn: parseInt( args.galleryFadeIn ), galleryFadeOut: parseInt( args.galleryFadeOut ), previousIcon: '❮', nextIcon: '❯' } ); // video? } else if ( /-video-/.test( item ) ) { $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight(); // single image? } else { $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ).featherlight(); } } ); } break; case 'magnific': var selectors = [ ], last_image = ''; $( 'a[rel*="' + selector + '"], a[data-rel*="' + selector + '"]' ).each( function ( i, item ) { var attr = $( item ).attr( 'data-rel' ); // check data-rel attribute first if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); // if not found then try to check rel attribute for backward compatibility else { attr = $( item ).attr( 'rel' ); if ( typeof attr !== 'undefined' && attr !== false && attr !== 'norl' ) selectors.push( attr ); } } ); if ( selectors.length > 0 ) { // make unique selectors = $.unique( selectors ); $( selectors ).each( function ( i, item ) { var subselector = $( 'a[data-rel="' + item + '"], a[rel="' + item + '"]' ), element = $( subselector[0] ), media_type = element.data( 'magnific_type' ), content_type = element.data( 'rl_content' ); // check content type first if ( typeof content_type !== 'undefined' ) { media_type = content_type; } // then media type if needed if ( typeof media_type === 'undefined' ) { media_type = 'image'; } subselector.magnificPopup( { type: media_type === 'gallery' ? 'image' : ( media_type === 'video' ? 'iframe' : media_type ), disableOn: args.disableOn, midClick: args.midClick === '1', preloader: args.preloader === '1', closeOnContentClick: args.closeOnContentClick === '1', closeOnBgClick: args.closeOnBgClick === '1', closeBtnInside: args.closeBtnInside === '1', showCloseBtn: args.showCloseBtn === '1', enableEscapeKey: args.enableEscapeKey === '1', alignTop: args.alignTop === '1', autoFocusLast: args.autoFocusLast === '1', fixedContentPos: args.fixedContentPos === 'auto' ? 'auto' : ( args.fixedContentPos === '1' ), fixedBgPos: args.fixedBgPos === 'auto' ? 'auto' : ( args.fixedBgPos === '1' ), image: { titleSrc: function ( item ) { return item.el.attr( 'data-rl_title' ) + '' + item.el.attr( 'data-rl_caption' ) + ''; } }, gallery: { enabled: subselector.length > 1 && media_type === 'gallery', navigateByImgClick: true, preload: [0,1] }, callbacks: { close: function() { rl_hide_image( script, this.currItem.src ); }, imageLoadComplete: function() { // trigger image view rl_view_image( script, this.currItem.src ); } } } ); } ); } break; } } ); } )( jQuery ); // source --> https://esneux.mr.be/wp-content/plugins/team_awesome/front/js/mobileevents.js?ver=a3db3f8ceb41c2e8645e66c599606b9f /*! * jQuery Mobile Events * by Ben Major (www.ben-major.co.uk) * * Copyright 2011, Ben Major * Licensed under the MIT License: * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ (function ($) { $.attrFn = $.attrFn || {}; // navigator.userAgent.toLowerCase() isn't reliable for Chrome installs // on mobile devices. As such, we will create a boolean isChromeDesktop // The reason that we need to do this is because Chrome annoyingly // purports support for touch events even if the underlying hardware // does not! var agent = navigator.userAgent.toLowerCase(), isChromeDesktop = (agent.indexOf('chrome') > -1 && ((agent.indexOf('windows') > -1) || (agent.indexOf('macintosh') > -1) || (agent.indexOf('linux') > -1)) && agent.indexOf('mobile') < 0 && agent.indexOf('android') < 0), settings = { tap_pixel_range: 5, swipe_h_threshold: 50, swipe_v_threshold: 50, taphold_threshold: 750, doubletap_int: 300, touch_capable: ('ontouchstart' in window && !isChromeDesktop), orientation_support: ('orientation' in window && 'onorientationchange' in window), startevent: ('ontouchstart' in window && !isChromeDesktop) ? 'touchstart' : 'mousedown', endevent: ('ontouchstart' in window && !isChromeDesktop) ? 'touchend' : 'mouseup', moveevent: ('ontouchstart' in window && !isChromeDesktop) ? 'touchmove' : 'mousemove', tapevent: ('ontouchstart' in window && !isChromeDesktop) ? 'tap' : 'click', scrollevent: ('ontouchstart' in window && !isChromeDesktop) ? 'touchmove' : 'scroll', hold_timer: null, tap_timer: null }; // Convenience functions: $.isTouchCapable = function () { return settings.touch_capable; }; $.getStartEvent = function () { return settings.startevent; }; $.getEndEvent = function () { return settings.endevent; }; $.getMoveEvent = function () { return settings.moveevent; }; $.getTapEvent = function () { return settings.tapevent; }; $.getScrollEvent = function () { return settings.scrollevent; }; // Add Event shortcuts: $.each(['tapstart', 'tapend', 'tapmove', 'tap', 'tap2', 'tap3', 'tap4', 'singletap', 'doubletap', 'taphold', 'swipe', 'swipeup', 'swiperight', 'swipedown', 'swipeleft', 'swipeend', 'scrollstart', 'scrollend', 'orientationchange'], function (i, name) { $.fn[name] = function (fn) { return fn ? this.on(name, fn) : this.trigger(name); }; $.attrFn[name] = true; }); // tapstart Event: $.event.special.tapstart = { setup: function () { var thisObject = this, $this = $(thisObject); $this.on(settings.startevent, function (e) { $this.data('callee', arguments.callee); if (e.which && e.which !== 1) { return false; } var origEvent = e.originalEvent, touchData = { 'position': { 'x': ((settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX), 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; triggerCustomEvent(thisObject, 'tapstart', e, touchData); return true; }); }, remove: function () { $(this).off(settings.startevent, $(this).data.callee); } }; // tapmove Event: $.event.special.tapmove = { setup: function () { var thisObject = this, $this = $(thisObject); $this.on(settings.moveevent, function (e) { $this.data('callee', arguments.callee); var origEvent = e.originalEvent, touchData = { 'position': { 'x': ((settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX), 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; triggerCustomEvent(thisObject, 'tapmove', e, touchData); return true; }); }, remove: function () { $(this).off(settings.moveevent, $(this).data.callee); } } // tapend Event: $.event.special.tapend = { setup: function () { var thisObject = this, $this = $(thisObject); $this.on(settings.endevent, function (e) { // Touch event data: $this.data('callee', arguments.callee); var origEvent = e.originalEvent; var touchData = { 'position': { 'x': (settings.touch_capable) ? origEvent.changedTouches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.changedTouches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX - origEvent.changedTouches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY - origEvent.changedTouches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; triggerCustomEvent(thisObject, 'tapend', e, touchData); return true; }); }, remove: function () { $(this).off(settings.endevent, $(this).data.callee); } }; // taphold Event: $.event.special.taphold = { setup: function () { var thisObject = this, $this = $(thisObject), origTarget, timer, start_pos = { x: 0, y: 0 }, end_x = 0, end_y = 0; $this.on(settings.startevent, function (e) { if (e.which && e.which !== 1) { return false; } else { $this.data('tapheld', false); origTarget = e.target; var origEvent = e.originalEvent; var start_time = Date.now(), startPosition = { 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY }, startOffset = { 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY }; start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX; start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY; end_x = start_pos.x; end_y = start_pos.y; settings.hold_timer = window.setTimeout(function () { var diff_x = (start_pos.x - end_x), diff_y = (start_pos.y - end_y); if (e.target == origTarget && ((start_pos.x == end_x && start_pos.y == end_y) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) { $this.data('tapheld', true); var end_time = Date.now(), endPosition = { 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY }, endOffset = { 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY }; duration = end_time - start_time; // Build the touch data: var touchData = { 'startTime': start_time, 'endTime': end_time, 'startPosition': startPosition, 'startOffset': startOffset, 'endPosition': endPosition, 'endOffset': endOffset, 'duration': duration, 'target': e.target } $this.data('callee1', arguments.callee); triggerCustomEvent(thisObject, 'taphold', e, touchData); } }, settings.taphold_threshold); return true; } }).on(settings.endevent, function () { $this.data('callee2', arguments.callee); $this.data('tapheld', false); window.clearTimeout(settings.hold_timer); }) .on(settings.moveevent, function (e) { $this.data('callee3', arguments.callee); end_x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX; end_y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY; }); }, remove: function () { $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2).off(settings.moveevent, $(this).data.callee3); } }; // doubletap Event: $.event.special.doubletap = { setup: function () { var thisObject = this, $this = $(thisObject), origTarget, action, firstTap, origEvent, cooloff, cooling = false; $this.on(settings.startevent, function (e) { if (e.which && e.which !== 1) { return false; } $this.data('doubletapped', false); origTarget = e.target; $this.data('callee1', arguments.callee); origEvent = e.originalEvent; firstTap = { 'position': { 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; return true; }).on(settings.endevent, function (e) { var now = Date.now(); var lastTouch = $this.data('lastTouch') || now + 1; var delta = now - lastTouch; window.clearTimeout(action); $this.data('callee2', arguments.callee); if (delta < settings.doubletap_int && (e.target == origTarget) && delta > 100) { $this.data('doubletapped', true); window.clearTimeout(settings.tap_timer); // Now get the current event: var lastTap = { 'position': { 'x': (settings.touch_capable) ? e.originalEvent.changedTouches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? e.originalEvent.changedTouches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? e.originalEvent.changedTouches[0].pageX - e.originalEvent.changedTouches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? e.originalEvent.changedTouches[0].pageY - e.originalEvent.changedTouches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target } var touchData = { 'firstTap': firstTap, 'secondTap': lastTap, 'interval': lastTap.time - firstTap.time }; if (!cooling) { triggerCustomEvent(thisObject, 'doubletap', e, touchData); } cooling = true; cooloff = window.setTimeout(function (e) { cooling = false; }, settings.doubletap_int); } else { $this.data('lastTouch', now); action = window.setTimeout(function (e) { window.clearTimeout(action); }, settings.doubletap_int, [e]); } $this.data('lastTouch', now); }); }, remove: function () { $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2); } }; // singletap Event: // This is used in conjuction with doubletap when both events are needed on the same element $.event.special.singletap = { setup: function () { var thisObject = this, $this = $(thisObject), origTarget = null, startTime = null, start_pos = { x: 0, y: 0 }; $this.on(settings.startevent, function (e) { if (e.which && e.which !== 1) { return false; } else { startTime = Date.now(); origTarget = e.target; $this.data('callee1', arguments.callee); // Get the start x and y position: start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX; start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY; return true; } }).on(settings.endevent, function (e) { $this.data('callee2', arguments.callee); if (e.target == origTarget) { // Get the end point: end_pos_x = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX; end_pos_y = (e.originalEvent.changedTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY; // We need to check if it was a taphold: settings.tap_timer = window.setTimeout(function () { if (!$this.data('doubletapped') && !$this.data('tapheld') && (start_pos.x == end_pos_x) && (start_pos.y == end_pos_y)) { var origEvent = e.originalEvent; var touchData = { 'position': { 'x': (settings.touch_capable) ? origEvent.changedTouches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.changedTouches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX - origEvent.changedTouches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY - origEvent.changedTouches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; // Was it a taphold? if ((touchData.time - startTime) < settings.taphold_threshold) { triggerCustomEvent(thisObject, 'singletap', e, touchData); } } }, settings.doubletap_int); } }); }, remove: function () { $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2); } }; // tap Event: $.event.special.tap = { setup: function () { var thisObject = this, $this = $(thisObject), started = false, origTarget = null, start_time, start_pos = { x: 0, y: 0 }, touches; $this.on(settings.startevent, function (e) { $this.data('callee1', arguments.callee); if (e.which && e.which !== 1) { return false; } else { started = true; start_pos.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX; start_pos.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY; start_time = Date.now(); origTarget = e.target; touches = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches : [e]; return true; } }).on(settings.endevent, function (e) { $this.data('callee2', arguments.callee); // Only trigger if they've started, and the target matches: var end_x = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageX : e.pageX, end_y = (e.originalEvent.targetTouches) ? e.originalEvent.changedTouches[0].pageY : e.pageY, diff_x = (start_pos.x - end_x), diff_y = (start_pos.y - end_y), eventName; if (origTarget == e.target && started && ((Date.now() - start_time) < settings.taphold_threshold) && ((start_pos.x == end_x && start_pos.y == end_y) || (diff_x >= -(settings.tap_pixel_range) && diff_x <= settings.tap_pixel_range && diff_y >= -(settings.tap_pixel_range) && diff_y <= settings.tap_pixel_range))) { var origEvent = e.originalEvent; var touchData = []; for (var i = 0; i < touches.length; i++) { var touch = { 'position': { 'x': (settings.touch_capable) ? origEvent.changedTouches[i].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.changedTouches[i].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.changedTouches[i].pageX - origEvent.changedTouches[i].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.changedTouches[i].pageY - origEvent.changedTouches[i].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; touchData.push(touch); } switch (touches.length) { case 1: eventName = 'tap'; break; case 2: eventName = 'tap2'; break; case 3: eventName = 'tap3'; break; case 4: eventName = 'tap4'; break; } triggerCustomEvent(thisObject, eventName, e, touchData); } }); }, remove: function () { $(this).off(settings.startevent, $(this).data.callee1).off(settings.endevent, $(this).data.callee2); } }; // swipe Event (also handles swipeup, swiperight, swipedown and swipeleft): $.event.special.swipe = { setup: function () { var thisObject = this, $this = $(thisObject), started = false, hasSwiped = false, originalCoord = { x: 0, y: 0 }, finalCoord = { x: 0, y: 0 }, startEvnt; // Screen touched, store the original coordinate function touchStart(e) { $this = $(e.target); $this.data('callee1', arguments.callee); originalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX; originalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY; finalCoord.x = originalCoord.x; finalCoord.y = originalCoord.y; started = true; var origEvent = e.originalEvent; // Read event data into our startEvt: startEvnt = { 'position': { 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; } // Store coordinates as finger is swiping function touchMove(e) { $this = $(e.target); $this.data('callee2', arguments.callee); finalCoord.x = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageX : e.pageX; finalCoord.y = (e.originalEvent.targetTouches) ? e.originalEvent.targetTouches[0].pageY : e.pageY; var swipedir; // We need to check if the element to which the event was bound contains a data-xthreshold | data-vthreshold: var ele_x_threshold = $this.data('xthreshold'), ele_y_threshold = $this.data('ythreshold'), h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold, v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold; if (originalCoord.y > finalCoord.y && (originalCoord.y - finalCoord.y > v_threshold)) { swipedir = 'swipeup'; } if (originalCoord.x < finalCoord.x && (finalCoord.x - originalCoord.x > h_threshold)) { swipedir = 'swiperight'; } if (originalCoord.y < finalCoord.y && (finalCoord.y - originalCoord.y > v_threshold)) { swipedir = 'swipedown'; } if (originalCoord.x > finalCoord.x && (originalCoord.x - finalCoord.x > h_threshold)) { swipedir = 'swipeleft'; } if (swipedir != undefined && started) { originalCoord.x = 0; originalCoord.y = 0; finalCoord.x = 0; finalCoord.y = 0; started = false; // Read event data into our endEvnt: var origEvent = e.originalEvent; endEvnt = { 'position': { 'x': (settings.touch_capable) ? origEvent.touches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.touches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.touches[0].pageX - origEvent.touches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.touches[0].pageY - origEvent.touches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; // Calculate the swipe amount (normalized): var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x), yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y); var touchData = { 'startEvnt': startEvnt, 'endEvnt': endEvnt, 'direction': swipedir.replace('swipe', ''), 'xAmount': xAmount, 'yAmount': yAmount, 'duration': endEvnt.time - startEvnt.time } hasSwiped = true; $this.trigger('swipe', touchData).trigger(swipedir, touchData); } } function touchEnd(e) { $this = $(e.target); var swipedir = ""; $this.data('callee3', arguments.callee); if (hasSwiped) { // We need to check if the element to which the event was bound contains a data-xthreshold | data-vthreshold: var ele_x_threshold = $this.data('xthreshold'), ele_y_threshold = $this.data('ythreshold'), h_threshold = (typeof ele_x_threshold !== 'undefined' && ele_x_threshold !== false && parseInt(ele_x_threshold)) ? parseInt(ele_x_threshold) : settings.swipe_h_threshold, v_threshold = (typeof ele_y_threshold !== 'undefined' && ele_y_threshold !== false && parseInt(ele_y_threshold)) ? parseInt(ele_y_threshold) : settings.swipe_v_threshold; var origEvent = e.originalEvent; endEvnt = { 'position': { 'x': (settings.touch_capable) ? origEvent.changedTouches[0].screenX : e.screenX, 'y': (settings.touch_capable) ? origEvent.changedTouches[0].screenY : e.screenY }, 'offset': { 'x': (settings.touch_capable) ? origEvent.changedTouches[0].pageX - origEvent.changedTouches[0].target.offsetLeft : e.offsetX, 'y': (settings.touch_capable) ? origEvent.changedTouches[0].pageY - origEvent.changedTouches[0].target.offsetTop : e.offsetY }, 'time': Date.now(), 'target': e.target }; // Read event data into our endEvnt: if (startEvnt.position.y > endEvnt.position.y && (startEvnt.position.y - endEvnt.position.y > v_threshold)) { swipedir = 'swipeup'; } if (startEvnt.position.x < endEvnt.position.x && (endEvnt.position.x - startEvnt.position.x > h_threshold)) { swipedir = 'swiperight'; } if (startEvnt.position.y < endEvnt.position.y && (endEvnt.position.y - startEvnt.position.y > v_threshold)) { swipedir = 'swipedown'; } if (startEvnt.position.x > endEvnt.position.x && (startEvnt.position.x - endEvnt.position.x > h_threshold)) { swipedir = 'swipeleft'; } // Calculate the swipe amount (normalized): var xAmount = Math.abs(startEvnt.position.x - endEvnt.position.x), yAmount = Math.abs(startEvnt.position.y - endEvnt.position.y); var touchData = { 'startEvnt': startEvnt, 'endEvnt': endEvnt, 'direction': swipedir.replace('swipe', ''), 'xAmount': xAmount, 'yAmount': yAmount, 'duration': endEvnt.time - startEvnt.time } $this.trigger('swipeend', touchData); } started = false; hasSwiped = false; } $this.on(settings.startevent, touchStart); $this.on(settings.moveevent, touchMove); $this.on(settings.endevent, touchEnd); }, remove: function () { $(this).off(settings.startevent, $(this).data.callee1).off(settings.moveevent, $(this).data.callee2).off(settings.endevent, $(this).data.callee3); } }; // scrollstart Event (also handles scrollend): $.event.special.scrollstart = { setup: function () { var thisObject = this, $this = $(thisObject), scrolling, timer; function trigger(event, state) { scrolling = state; triggerCustomEvent(thisObject, scrolling ? 'scrollstart' : 'scrollend', event); } // iPhone triggers scroll after a small delay; use touchmove instead $this.on(settings.scrollevent, function (event) { $this.data('callee', arguments.callee); if (!scrolling) { trigger(event, true); } clearTimeout(timer); timer = setTimeout(function () { trigger(event, false); }, 50); }); }, remove: function () { $(this).off(settings.scrollevent, $(this).data.callee); } }; // This is the orientation change (largely borrowed from jQuery Mobile): var win = $(window), special_event, get_orientation, last_orientation, initial_orientation_is_landscape, initial_orientation_is_default, portrait_map = { '0': true, '180': true }; if (settings.orientation_support) { var ww = window.innerWidth || win.width(), wh = window.innerHeight || win.height(), landscape_threshold = 50; initial_orientation_is_landscape = ww > wh && (ww - wh) > landscape_threshold; initial_orientation_is_default = portrait_map[window.orientation]; if ((initial_orientation_is_landscape && initial_orientation_is_default) || (!initial_orientation_is_landscape && !initial_orientation_is_default)) { portrait_map = { '-90': true, '90': true }; } } $.event.special.orientationchange = special_event = { setup: function () { // If the event is supported natively, return false so that jQuery // will on to the event using DOM methods. if (settings.orientation_support) { return false; } // Get the current orientation to avoid initial double-triggering. last_orientation = get_orientation(); win.on('throttledresize', handler); return true; }, teardown: function () { if (settings.orientation_support) { return false; } win.off('throttledresize', handler); return true; }, add: function (handleObj) { // Save a reference to the bound event handler. var old_handler = handleObj.handler; handleObj.handler = function (event) { event.orientation = get_orientation(); return old_handler.apply(this, arguments); }; } }; // If the event is not supported natively, this handler will be bound to // the window resize event to simulate the orientationchange event. function handler() { // Get the current orientation. var orientation = get_orientation(); if (orientation !== last_orientation) { // The orientation has changed, so trigger the orientationchange event. last_orientation = orientation; win.trigger("orientationchange"); } } $.event.special.orientationchange.orientation = get_orientation = function () { var isPortrait = true, elem = document.documentElement; if (settings.orientation_support) { isPortrait = portrait_map[window.orientation]; } else { isPortrait = elem && elem.clientWidth / elem.clientHeight < 1.1; } return isPortrait ? 'portrait' : 'landscape'; }; // throttle Handler: $.event.special.throttledresize = { setup: function () { $(this).on('resize', throttle_handler); }, teardown: function () { $(this).off('resize', throttle_handler); } }; var throttle = 250, throttle_handler = function () { curr = Date.now(); diff = curr - lastCall; if (diff >= throttle) { lastCall = curr; $(this).trigger('throttledresize'); } else { if (heldCall) { window.clearTimeout(heldCall); } // Promise a held call will still execute heldCall = window.setTimeout(handler, throttle - diff); } }, lastCall = 0, heldCall, curr, diff; // Trigger a custom event: function triggerCustomEvent(obj, eventType, event, touchData) { var originalType = event.type; event.type = eventType; $.event.dispatch.call(obj, event, touchData); event.type = originalType; } // Correctly on anything we've overloaded: $.each({ scrollend: 'scrollstart', swipeup: 'swipe', swiperight: 'swipe', swipedown: 'swipe', swipeleft: 'swipe', swipeend: 'swipe', tap2: 'tap' }, function (e, srcE, touchData) { $.event.special[e] = { setup: function () { $(this).on(srcE, $.noop); } }; }); })(jQuery); // source --> https://esneux.mr.be/wp-content/plugins/team_awesome/front/js/jquery.easing.js?ver=a3db3f8ceb41c2e8645e66c599606b9f /* * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ * * Uses the built in easing capabilities added In jQuery 1.1 * to offer multiple easing options * * TERMS OF USE - jQuery Easing * * Open source under the BSD License. * * Copyright 2008 George McGinley Smith * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the author nor the names of contributors may be used to endorse * or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */ // t: current time, b: begInnIng value, c: change In value, d: duration jQuery.easing['jswing'] = jQuery.easing['swing']; jQuery.extend( jQuery.easing, { def: 'easeOutQuad', swing: function (x, t, b, c, d) { //alert(jQuery.easing.default); return jQuery.easing[jQuery.easing.def](x, t, b, c, d); }, easeInQuad: function (x, t, b, c, d) { return c*(t/=d)*t + b; }, easeOutQuad: function (x, t, b, c, d) { return -c *(t/=d)*(t-2) + b; }, easeInOutQuad: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; }, easeInCubic: function (x, t, b, c, d) { return c*(t/=d)*t*t + b; }, easeOutCubic: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t + 1) + b; }, easeInOutCubic: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; }, easeInQuart: function (x, t, b, c, d) { return c*(t/=d)*t*t*t + b; }, easeOutQuart: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b; }, easeInOutQuart: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b; }, easeInQuint: function (x, t, b, c, d) { return c*(t/=d)*t*t*t*t + b; }, easeOutQuint: function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; }, easeInOutQuint: function (x, t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; }, easeInSine: function (x, t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b; }, easeOutSine: function (x, t, b, c, d) { return c * Math.sin(t/d * (Math.PI/2)) + b; }, easeInOutSine: function (x, t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; }, easeInExpo: function (x, t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; }, easeOutExpo: function (x, t, b, c, d) { return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; }, easeInOutExpo: function (x, t, b, c, d) { if (t==0) return b; if (t==d) return b+c; if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; }, easeInCirc: function (x, t, b, c, d) { return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; }, easeOutCirc: function (x, t, b, c, d) { return c * Math.sqrt(1 - (t=t/d-1)*t) + b; }, easeInOutCirc: function (x, t, b, c, d) { if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; }, easeInElastic: function (x, t, b, c, d) { var s=1.70158;var p=0;var a=c; if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; }, easeOutElastic: function (x, t, b, c, d) { var s=1.70158;var p=0;var a=c; if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; }, easeInOutElastic: function (x, t, b, c, d) { var s=1.70158;var p=0;var a=c; if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); if (a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; }, easeInBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c*(t/=d)*t*((s+1)*t - s) + b; }, easeOutBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; }, easeInOutBack: function (x, t, b, c, d, s) { if (s == undefined) s = 1.70158; if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; }, easeInBounce: function (x, t, b, c, d) { return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; }, easeOutBounce: function (x, t, b, c, d) { if ((t/=d) < (1/2.75)) { return c*(7.5625*t*t) + b; } else if (t < (2/2.75)) { return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t < (2.5/2.75)) { return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else { return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; } }, easeInOutBounce: function (x, t, b, c, d) { if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; } }); /* * * TERMS OF USE - EASING EQUATIONS * * Open source under the BSD License. * * Copyright 2001 Robert Penner * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. * * Neither the name of the author nor the names of contributors may be used to endorse * or promote products derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * */; // source --> https://esneux.mr.be/wp-content/plugins/team_awesome/front/js/scroll.js?ver=a3db3f8ceb41c2e8645e66c599606b9f /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh) * Licensed under the MIT License (LICENSE.txt). * * Version: 3.1.9 * * Requires: jQuery 1.2.2+ */ (function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], factory); } else if (typeof exports === 'object') { // Node/CommonJS style for Browserify module.exports = factory; } else { // Browser globals factory(jQuery); } }(function ($) { var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'], toBind = ('onwheel' in document || document.documentMode >= 9) ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'], slice = Array.prototype.slice, nullLowestDeltaTimeout, lowestDelta; if ($.event.fixHooks) { for (var i = toFix.length; i; ) { $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks; } } var special = $.event.special.mousewheel = { version: '3.1.9', setup: function () { if (this.addEventListener) { for (var i = toBind.length; i; ) { this.addEventListener(toBind[--i], handler, false); } } else { this.onmousewheel = handler; } // Store the line height and page height for this particular element $.data(this, 'mousewheel-line-height', special.getLineHeight(this)); $.data(this, 'mousewheel-page-height', special.getPageHeight(this)); }, teardown: function () { if (this.removeEventListener) { for (var i = toBind.length; i; ) { this.removeEventListener(toBind[--i], handler, false); } } else { this.onmousewheel = null; } }, getLineHeight: function (elem) { return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10); }, getPageHeight: function (elem) { return $(elem).height(); }, settings: { adjustOldDeltas: true } }; $.fn.extend({ mousewheel: function (fn) { return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel'); }, unmousewheel: function (fn) { return this.unbind('mousewheel', fn); } }); function handler(event) { var orgEvent = event || window.event, args = slice.call(arguments, 1), delta = 0, deltaX = 0, deltaY = 0, absDelta = 0; event = $.event.fix(orgEvent); event.type = 'mousewheel'; // Old school scrollwheel delta if ('detail' in orgEvent) { deltaY = orgEvent.detail * -1; } if ('wheelDelta' in orgEvent) { deltaY = orgEvent.wheelDelta; } if ('wheelDeltaY' in orgEvent) { deltaY = orgEvent.wheelDeltaY; } if ('wheelDeltaX' in orgEvent) { deltaX = orgEvent.wheelDeltaX * -1; } // Firefox < 17 horizontal scrolling related to DOMMouseScroll event if ('axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) { deltaX = deltaY * -1; deltaY = 0; } // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy delta = deltaY === 0 ? deltaX : deltaY; // New school wheel delta (wheel event) if ('deltaY' in orgEvent) { deltaY = orgEvent.deltaY * -1; delta = deltaY; } if ('deltaX' in orgEvent) { deltaX = orgEvent.deltaX; if (deltaY === 0) { delta = deltaX * -1; } } // No change actually happened, no reason to go any further if (deltaY === 0 && deltaX === 0) { return; } // Need to convert lines and pages to pixels if we aren't already in pixels // There are three delta modes: // * deltaMode 0 is by pixels, nothing to do // * deltaMode 1 is by lines // * deltaMode 2 is by pages if (orgEvent.deltaMode === 1) { var lineHeight = $.data(this, 'mousewheel-line-height'); delta *= lineHeight; deltaY *= lineHeight; deltaX *= lineHeight; } else if (orgEvent.deltaMode === 2) { var pageHeight = $.data(this, 'mousewheel-page-height'); delta *= pageHeight; deltaY *= pageHeight; deltaX *= pageHeight; } // Store lowest absolute delta to normalize the delta values absDelta = Math.max(Math.abs(deltaY), Math.abs(deltaX)); if (!lowestDelta || absDelta < lowestDelta) { lowestDelta = absDelta; // Adjust older deltas if necessary if (shouldAdjustOldDeltas(orgEvent, absDelta)) { lowestDelta /= 40; } } // Adjust older deltas if necessary if (shouldAdjustOldDeltas(orgEvent, absDelta)) { // Divide all the things by 40! delta /= 40; deltaX /= 40; deltaY /= 40; } // Get a whole, normalized value for the deltas delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta); deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta); deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta); // Add information to the event object event.deltaX = deltaX; event.deltaY = deltaY; event.deltaFactor = lowestDelta; // Go ahead and set deltaMode to 0 since we converted to pixels // Although this is a little odd since we overwrite the deltaX/Y // properties with normalized deltas. event.deltaMode = 0; // Add event and delta to the front of the arguments args.unshift(event, delta, deltaX, deltaY); // Clearout lowestDelta after sometime to better // handle multiple device types that give different // a different lowestDelta // Ex: trackpad = 3 and mouse wheel = 120 if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); } nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200); return ($.event.dispatch || $.event.handle).apply(this, args); } function nullLowestDelta() { lowestDelta = null; } function shouldAdjustOldDeltas(orgEvent, absDelta) { // If this is an older event and the delta is divisable by 120, // then we are assuming that the browser is treating this as an // older mouse wheel event and that we should divide the deltas // by 40 to try and get a more usable deltaFactor. // Side note, this actually impacts the reported scroll distance // in older browsers and can cause scrolling to be slower than native. // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false. return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0; } })); /*! * jScrollPane - v2.0.21 - 2015-02-24 * http://jscrollpane.kelvinluck.com/ * * Copyright (c) 2014 Kelvin Luck * Dual licensed under the MIT or GPL licenses. */ // Script: jScrollPane - cross browser customisable scrollbars // // *Version: 2.0.21, Last updated: 2015-02-24* // // Project Home - http://jscrollpane.kelvinluck.com/ // GitHub - http://github.com/vitch/jScrollPane // Source - http://github.com/vitch/jScrollPane/raw/master/script/jquery.jscrollpane.js // (Minified) - http://github.com/vitch/jScrollPane/raw/master/script/jquery.jscrollpane.min.js // // About: License // // Copyright (c) 2014 Kelvin Luck // Dual licensed under the MIT or GPL Version 2 licenses. // http://jscrollpane.kelvinluck.com/MIT-LICENSE.txt // http://jscrollpane.kelvinluck.com/GPL-LICENSE.txt // // About: Examples // // All examples and demos are available through the jScrollPane example site at: // http://jscrollpane.kelvinluck.com/ // // About: Support and Testing // // This plugin is tested on the browsers below and has been found to work reliably on them. If you run // into a problem on one of the supported browsers then please visit the support section on the jScrollPane // website (http://jscrollpane.kelvinluck.com/) for more information on getting support. You are also // welcome to fork the project on GitHub if you can contribute a fix for a given issue. // // jQuery Versions - tested in 1.4.2+ - reported to work in 1.3.x // Browsers Tested - Firefox 3.6.8, Safari 5, Opera 10.6, Chrome 5.0, IE 6, 7, 8 // // About: Release History // // 2.0.21 - (2015-02-24) Simplify UMD pattern: fixes browserify when loading jQuery outside of bundle // 2.0.20 - (2014-10-23) Adds AMD support (thanks @carlosrberto) and support for overflow-x/overflow-y (thanks @darimpulso) // 2.0.19 - (2013-11-16) Changes for more reliable scroll amount with latest mousewheel plugin (thanks @brandonaaron) // 2.0.18 - (2013-10-23) Fix for issue with gutters and scrollToElement (thanks @Dubiy) // 2.0.17 - (2013-08-17) Working correctly when box-sizing is set to border-box (thanks @pieht) // 2.0.16 - (2013-07-30) Resetting left position when scroll is removed. Fixes #189 // 2.0.15 - (2013-07-29) Fixed issue with scrollToElement where the destX and destY are undefined. // 2.0.14 - (2013-05-01) Updated to most recent mouse wheel plugin (see #106) and related changes for sensible scroll speed // 2.0.13 - (2013-05-01) Switched to semver compatible version name // 2.0.0beta12 - (2012-09-27) fix for jQuery 1.8+ // 2.0.0beta11 - (2012-05-14) // 2.0.0beta10 - (2011-04-17) cleaner required size calculation, improved keyboard support, stickToBottom/Left, other small fixes // 2.0.0beta9 - (2011-01-31) new API methods, bug fixes and correct keyboard support for FF/OSX // 2.0.0beta8 - (2011-01-29) touchscreen support, improved keyboard support // 2.0.0beta7 - (2011-01-23) scroll speed consistent (thanks Aivo Paas) // 2.0.0beta6 - (2010-12-07) scrollToElement horizontal support // 2.0.0beta5 - (2010-10-18) jQuery 1.4.3 support, various bug fixes // 2.0.0beta4 - (2010-09-17) clickOnTrack support, bug fixes // 2.0.0beta3 - (2010-08-27) Horizontal mousewheel, mwheelIntent, keyboard support, bug fixes // 2.0.0beta2 - (2010-08-21) Bug fixes // 2.0.0beta1 - (2010-08-17) Rewrite to follow modern best practices and enable horizontal scrolling, initially hidden // elements and dynamically sized elements. // 1.x - (2006-12-31 - 2010-07-31) Initial version, hosted at googlecode, deprecated (function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], factory); } else if (typeof exports === 'object') { // Node/CommonJS style for Browserify module.exports = factory(require('jquery')); } else { // Browser globals factory(jQuery); } }(function ($) { $.fn.jScrollPane = function (settings) { // JScrollPane "class" - public methods are available through $('selector').data('jsp') function JScrollPane(elem, s) { var settings, jsp = this, pane, paneWidth, paneHeight, container, contentWidth, contentHeight, percentInViewH, percentInViewV, isScrollableV, isScrollableH, verticalDrag, dragMaxY, verticalDragPosition, horizontalDrag, dragMaxX, horizontalDragPosition, verticalBar, verticalTrack, scrollbarWidth, verticalTrackHeight, verticalDragHeight, arrowUp, arrowDown, horizontalBar, horizontalTrack, horizontalTrackWidth, horizontalDragWidth, arrowLeft, arrowRight, reinitialiseInterval, originalPadding, originalPaddingTotalWidth, previousContentWidth, wasAtTop = true, wasAtLeft = true, wasAtBottom = false, wasAtRight = false, originalElement = elem.clone(false, false).empty(), mwEvent = $.fn.mwheelIntent ? 'mwheelIntent.jsp' : 'mousewheel.jsp'; if (elem.css('box-sizing') === 'border-box') { originalPadding = 0; originalPaddingTotalWidth = 0; } else { originalPadding = elem.css('paddingTop') + ' ' + elem.css('paddingRight') + ' ' + elem.css('paddingBottom') + ' ' + elem.css('paddingLeft'); originalPaddingTotalWidth = (parseInt(elem.css('paddingLeft'), 10) || 0) + (parseInt(elem.css('paddingRight'), 10) || 0); } function initialise(s) { var /*firstChild, lastChild, */isMaintainingPositon, lastContentX, lastContentY, hasContainingSpaceChanged, originalScrollTop, originalScrollLeft, maintainAtBottom = false, maintainAtRight = false; settings = s; if (pane === undefined) { originalScrollTop = elem.scrollTop(); originalScrollLeft = elem.scrollLeft(); elem.css( { overflow: 'hidden', padding: 0 } ); // TODO: Deal with where width/ height is 0 as it probably means the element is hidden and we should // come back to it later and check once it is unhidden... paneWidth = elem.innerWidth() + originalPaddingTotalWidth; paneHeight = elem.innerHeight(); elem.width(paneWidth); pane = $('
').css('padding', originalPadding).append(elem.children()); container = $('
') .css({ 'width': paneWidth + 'px', 'height': paneHeight + 'px' } ).append(pane).appendTo(elem); /* // Move any margins from the first and last children up to the container so they can still // collapse with neighbouring elements as they would before jScrollPane firstChild = pane.find(':first-child'); lastChild = pane.find(':last-child'); elem.css( { 'margin-top': firstChild.css('margin-top'), 'margin-bottom': lastChild.css('margin-bottom') } ); firstChild.css('margin-top', 0); lastChild.css('margin-bottom', 0); */ } else { elem.css('width', ''); maintainAtBottom = settings.stickToBottom && isCloseToBottom(); maintainAtRight = settings.stickToRight && isCloseToRight(); hasContainingSpaceChanged = elem.innerWidth() + originalPaddingTotalWidth != paneWidth || elem.outerHeight() != paneHeight; if (hasContainingSpaceChanged) { paneWidth = elem.innerWidth() + originalPaddingTotalWidth; paneHeight = elem.innerHeight(); container.css({ width: paneWidth + 'px', height: paneHeight + 'px' }); } // If nothing changed since last check... if (!hasContainingSpaceChanged && previousContentWidth == contentWidth && pane.outerHeight() == contentHeight) { elem.width(paneWidth); return; } previousContentWidth = contentWidth; pane.css('width', ''); elem.width(paneWidth); container.find('>.jspVerticalBar,>.jspHorizontalBar').remove().end(); } pane.css('overflow', 'auto'); if (s.contentWidth) { contentWidth = s.contentWidth; } else { contentWidth = pane[0].scrollWidth; } contentHeight = pane[0].scrollHeight; pane.css('overflow', ''); percentInViewH = contentWidth / paneWidth; percentInViewV = contentHeight / paneHeight; isScrollableV = percentInViewV > 1; isScrollableH = percentInViewH > 1; //console.log(paneWidth, paneHeight, contentWidth, contentHeight, percentInViewH, percentInViewV, isScrollableH, isScrollableV); if (!(isScrollableH || isScrollableV)) { elem.removeClass('jspScrollable'); pane.css({ top: 0, left: 0, width: container.width() - originalPaddingTotalWidth }); removeMousewheel(); removeFocusHandler(); removeKeyboardNav(); removeClickOnTrack(); } else { elem.addClass('jspScrollable'); isMaintainingPositon = settings.maintainPosition && (verticalDragPosition || horizontalDragPosition); if (isMaintainingPositon) { lastContentX = contentPositionX(); lastContentY = contentPositionY(); } initialiseVerticalScroll(); initialiseHorizontalScroll(); resizeScrollbars(); if (isMaintainingPositon) { scrollToX(maintainAtRight ? (contentWidth - paneWidth) : lastContentX, false); scrollToY(maintainAtBottom ? (contentHeight - paneHeight) : lastContentY, false); } initFocusHandler(); initMousewheel(); initTouch(); if (settings.enableKeyboardNavigation) { initKeyboardNav(); } if (settings.clickOnTrack) { initClickOnTrack(); } observeHash(); if (settings.hijackInternalLinks) { hijackInternalLinks(); } } if (settings.autoReinitialise && !reinitialiseInterval) { reinitialiseInterval = setInterval( function () { initialise(settings); }, settings.autoReinitialiseDelay ); } else if (!settings.autoReinitialise && reinitialiseInterval) { clearInterval(reinitialiseInterval); } originalScrollTop && elem.scrollTop(0) && scrollToY(originalScrollTop, false); originalScrollLeft && elem.scrollLeft(0) && scrollToX(originalScrollLeft, false); elem.trigger('jsp-initialised', [isScrollableH || isScrollableV]); } function initialiseVerticalScroll() { if (isScrollableV) { container.append( $('
').append( $('
'), $('
').append( $('
').append( $('
'), $('
') ) ), $('
') ) ); verticalBar = container.find('>.jspVerticalBar'); verticalTrack = verticalBar.find('>.jspTrack'); verticalDrag = verticalTrack.find('>.jspDrag'); if (settings.showArrows) { arrowUp = $('').bind( 'mousedown.jsp', getArrowScroll(0, -1) ).bind('click.jsp', nil); arrowDown = $('').bind( 'mousedown.jsp', getArrowScroll(0, 1) ).bind('click.jsp', nil); if (settings.arrowScrollOnHover) { arrowUp.bind('mouseover.jsp', getArrowScroll(0, -1, arrowUp)); arrowDown.bind('mouseover.jsp', getArrowScroll(0, 1, arrowDown)); } appendArrows(verticalTrack, settings.verticalArrowPositions, arrowUp, arrowDown); } verticalTrackHeight = paneHeight; container.find('>.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow').each( function () { verticalTrackHeight -= $(this).outerHeight(); } ); verticalDrag.hover( function () { verticalDrag.addClass('jspHover'); }, function () { verticalDrag.removeClass('jspHover'); } ).bind( 'mousedown.jsp', function (e) { // Stop IE from allowing text selection $('html').bind('dragstart.jsp selectstart.jsp', nil); verticalDrag.addClass('jspActive'); var startY = e.pageY - verticalDrag.position().top; $('html').bind( 'mousemove.jsp', function (e) { positionDragY(e.pageY - startY, false); } ).bind('mouseup.jsp mouseleave.jsp', cancelDrag); return false; } ); sizeVerticalScrollbar(); } } function sizeVerticalScrollbar() { verticalTrack.height(verticalTrackHeight + 'px'); verticalDragPosition = 0; scrollbarWidth = settings.verticalGutter + verticalTrack.outerWidth(); // Make the pane thinner to allow for the vertical scrollbar pane.width(paneWidth - scrollbarWidth - originalPaddingTotalWidth); // Add margin to the left of the pane if scrollbars are on that side (to position // the scrollbar on the left or right set it's left or right property in CSS) try { if (verticalBar.position().left === 0) { pane.css('margin-left', scrollbarWidth + 'px'); } } catch (err) { } } function initialiseHorizontalScroll() { if (isScrollableH) { container.append( $('
').append( $('
'), $('
').append( $('
').append( $('
'), $('
') ) ), $('
') ) ); horizontalBar = container.find('>.jspHorizontalBar'); horizontalTrack = horizontalBar.find('>.jspTrack'); horizontalDrag = horizontalTrack.find('>.jspDrag'); if (settings.showArrows) { arrowLeft = $('').bind( 'mousedown.jsp', getArrowScroll(-1, 0) ).bind('click.jsp', nil); arrowRight = $('').bind( 'mousedown.jsp', getArrowScroll(1, 0) ).bind('click.jsp', nil); if (settings.arrowScrollOnHover) { arrowLeft.bind('mouseover.jsp', getArrowScroll(-1, 0, arrowLeft)); arrowRight.bind('mouseover.jsp', getArrowScroll(1, 0, arrowRight)); } appendArrows(horizontalTrack, settings.horizontalArrowPositions, arrowLeft, arrowRight); } horizontalDrag.hover( function () { horizontalDrag.addClass('jspHover'); }, function () { horizontalDrag.removeClass('jspHover'); } ).bind( 'mousedown.jsp', function (e) { // Stop IE from allowing text selection $('html').bind('dragstart.jsp selectstart.jsp', nil); horizontalDrag.addClass('jspActive'); var startX = e.pageX - horizontalDrag.position().left; $('html').bind( 'mousemove.jsp', function (e) { positionDragX(e.pageX - startX, false); } ).bind('mouseup.jsp mouseleave.jsp', cancelDrag); return false; } ); horizontalTrackWidth = container.innerWidth(); sizeHorizontalScrollbar(); } } function sizeHorizontalScrollbar() { container.find('>.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow').each( function () { horizontalTrackWidth -= $(this).outerWidth(); } ); horizontalTrack.width(horizontalTrackWidth + 'px'); horizontalDragPosition = 0; } function resizeScrollbars() { if (isScrollableH && isScrollableV) { var horizontalTrackHeight = horizontalTrack.outerHeight(), verticalTrackWidth = verticalTrack.outerWidth(); verticalTrackHeight -= horizontalTrackHeight; $(horizontalBar).find('>.jspCap:visible,>.jspArrow').each( function () { horizontalTrackWidth += $(this).outerWidth(); } ); horizontalTrackWidth -= verticalTrackWidth; paneHeight -= verticalTrackWidth; paneWidth -= horizontalTrackHeight; horizontalTrack.parent().append( $('
').css('width', horizontalTrackHeight + 'px') ); sizeVerticalScrollbar(); sizeHorizontalScrollbar(); } // reflow content if (isScrollableH) { pane.width((container.outerWidth() - originalPaddingTotalWidth) + 'px'); } contentHeight = pane.outerHeight(); percentInViewV = contentHeight / paneHeight; if (isScrollableH) { horizontalDragWidth = Math.ceil(1 / percentInViewH * horizontalTrackWidth); if (horizontalDragWidth > settings.horizontalDragMaxWidth) { horizontalDragWidth = settings.horizontalDragMaxWidth; } else if (horizontalDragWidth < settings.horizontalDragMinWidth) { horizontalDragWidth = settings.horizontalDragMinWidth; } horizontalDrag.width(horizontalDragWidth + 'px'); dragMaxX = horizontalTrackWidth - horizontalDragWidth; _positionDragX(horizontalDragPosition); // To update the state for the arrow buttons } if (isScrollableV) { verticalDragHeight = Math.ceil(1 / percentInViewV * verticalTrackHeight); if (verticalDragHeight > settings.verticalDragMaxHeight) { verticalDragHeight = settings.verticalDragMaxHeight; } else if (verticalDragHeight < settings.verticalDragMinHeight) { verticalDragHeight = settings.verticalDragMinHeight; } verticalDrag.height(verticalDragHeight + 'px'); dragMaxY = verticalTrackHeight - verticalDragHeight; _positionDragY(verticalDragPosition); // To update the state for the arrow buttons } } function appendArrows(ele, p, a1, a2) { var p1 = "before", p2 = "after", aTemp; // Sniff for mac... Is there a better way to determine whether the arrows would naturally appear // at the top or the bottom of the bar? if (p == "os") { p = /Mac/.test(navigator.platform) ? "after" : "split"; } if (p == p1) { p2 = p; } else if (p == p2) { p1 = p; aTemp = a1; a1 = a2; a2 = aTemp; } ele[p1](a1)[p2](a2); } function getArrowScroll(dirX, dirY, ele) { return function () { arrowScroll(dirX, dirY, this, ele); this.blur(); return false; }; } function arrowScroll(dirX, dirY, arrow, ele) { arrow = $(arrow).addClass('jspActive'); var eve, scrollTimeout, isFirst = true, doScroll = function () { if (dirX !== 0) { jsp.scrollByX(dirX * settings.arrowButtonSpeed); } if (dirY !== 0) { jsp.scrollByY(dirY * settings.arrowButtonSpeed); } scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.arrowRepeatFreq); isFirst = false; }; doScroll(); eve = ele ? 'mouseout.jsp' : 'mouseup.jsp'; ele = ele || $('html'); ele.bind( eve, function () { arrow.removeClass('jspActive'); scrollTimeout && clearTimeout(scrollTimeout); scrollTimeout = null; ele.unbind(eve); } ); } function initClickOnTrack() { removeClickOnTrack(); if (isScrollableV) { verticalTrack.bind( 'mousedown.jsp', function (e) { if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) { var clickedTrack = $(this), offset = clickedTrack.offset(), direction = e.pageY - offset.top - verticalDragPosition, scrollTimeout, isFirst = true, doScroll = function () { var offset = clickedTrack.offset(), pos = e.pageY - offset.top - verticalDragHeight / 2, contentDragY = paneHeight * settings.scrollPagePercent, dragY = dragMaxY * contentDragY / (contentHeight - paneHeight); if (direction < 0) { if (verticalDragPosition - dragY > pos) { jsp.scrollByY(-contentDragY); } else { positionDragY(pos); } } else if (direction > 0) { if (verticalDragPosition + dragY < pos) { jsp.scrollByY(contentDragY); } else { positionDragY(pos); } } else { cancelClick(); return; } scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq); isFirst = false; }, cancelClick = function () { scrollTimeout && clearTimeout(scrollTimeout); scrollTimeout = null; $(document).unbind('mouseup.jsp', cancelClick); }; doScroll(); $(document).bind('mouseup.jsp', cancelClick); return false; } } ); } if (isScrollableH) { horizontalTrack.bind( 'mousedown.jsp', function (e) { if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) { var clickedTrack = $(this), offset = clickedTrack.offset(), direction = e.pageX - offset.left - horizontalDragPosition, scrollTimeout, isFirst = true, doScroll = function () { var offset = clickedTrack.offset(), pos = e.pageX - offset.left - horizontalDragWidth / 2, contentDragX = paneWidth * settings.scrollPagePercent, dragX = dragMaxX * contentDragX / (contentWidth - paneWidth); if (direction < 0) { if (horizontalDragPosition - dragX > pos) { jsp.scrollByX(-contentDragX); } else { positionDragX(pos); } } else if (direction > 0) { if (horizontalDragPosition + dragX < pos) { jsp.scrollByX(contentDragX); } else { positionDragX(pos); } } else { cancelClick(); return; } scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq); isFirst = false; }, cancelClick = function () { scrollTimeout && clearTimeout(scrollTimeout); scrollTimeout = null; $(document).unbind('mouseup.jsp', cancelClick); }; doScroll(); $(document).bind('mouseup.jsp', cancelClick); return false; } } ); } } function removeClickOnTrack() { if (horizontalTrack) { horizontalTrack.unbind('mousedown.jsp'); } if (verticalTrack) { verticalTrack.unbind('mousedown.jsp'); } } function cancelDrag() { $('html').unbind('dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp'); if (verticalDrag) { verticalDrag.removeClass('jspActive'); } if (horizontalDrag) { horizontalDrag.removeClass('jspActive'); } } function positionDragY(destY, animate) { if (!isScrollableV) { return; } if (destY < 0) { destY = 0; } else if (destY > dragMaxY) { destY = dragMaxY; } // can't just check if(animate) because false is a valid value that could be passed in... if (animate === undefined) { animate = settings.animateScroll; } if (animate) { jsp.animate(verticalDrag, 'top', destY, _positionDragY); } else { verticalDrag.css('top', destY); _positionDragY(destY); } } function _positionDragY(destY) { if (destY === undefined) { destY = verticalDrag.position().top; } container.scrollTop(0); verticalDragPosition = destY || 0; var isAtTop = verticalDragPosition === 0, isAtBottom = verticalDragPosition == dragMaxY, percentScrolled = destY / dragMaxY, destTop = -percentScrolled * (contentHeight - paneHeight); if (wasAtTop != isAtTop || wasAtBottom != isAtBottom) { wasAtTop = isAtTop; wasAtBottom = isAtBottom; elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]); } updateVerticalArrows(isAtTop, isAtBottom); pane.css('top', destTop); elem.trigger('jsp-scroll-y', [-destTop, isAtTop, isAtBottom]).trigger('scroll'); } function positionDragX(destX, animate) { if (!isScrollableH) { return; } if (destX < 0) { destX = 0; } else if (destX > dragMaxX) { destX = dragMaxX; } if (animate === undefined) { animate = settings.animateScroll; } if (animate) { jsp.animate(horizontalDrag, 'left', destX, _positionDragX); } else { horizontalDrag.css('left', destX); _positionDragX(destX); } } function _positionDragX(destX) { if (destX === undefined) { destX = horizontalDrag.position().left; } container.scrollTop(0); horizontalDragPosition = destX || 0; var isAtLeft = horizontalDragPosition === 0, isAtRight = horizontalDragPosition == dragMaxX, percentScrolled = destX / dragMaxX, destLeft = -percentScrolled * (contentWidth - paneWidth); if (wasAtLeft != isAtLeft || wasAtRight != isAtRight) { wasAtLeft = isAtLeft; wasAtRight = isAtRight; elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]); } updateHorizontalArrows(isAtLeft, isAtRight); pane.css('left', destLeft); elem.trigger('jsp-scroll-x', [-destLeft, isAtLeft, isAtRight]).trigger('scroll'); } function updateVerticalArrows(isAtTop, isAtBottom) { if (settings.showArrows) { arrowUp[isAtTop ? 'addClass' : 'removeClass']('jspDisabled'); arrowDown[isAtBottom ? 'addClass' : 'removeClass']('jspDisabled'); } } function updateHorizontalArrows(isAtLeft, isAtRight) { if (settings.showArrows) { arrowLeft[isAtLeft ? 'addClass' : 'removeClass']('jspDisabled'); arrowRight[isAtRight ? 'addClass' : 'removeClass']('jspDisabled'); } } function scrollToY(destY, animate) { var percentScrolled = destY / (contentHeight - paneHeight); positionDragY(percentScrolled * dragMaxY, animate); } function scrollToX(destX, animate) { var percentScrolled = destX / (contentWidth - paneWidth); positionDragX(percentScrolled * dragMaxX, animate); } function scrollToElement(ele, stickToTop, animate) { var e, eleHeight, eleWidth, eleTop = 0, eleLeft = 0, viewportTop, viewportLeft, maxVisibleEleTop, maxVisibleEleLeft, destY, destX; // Legal hash values aren't necessarily legal jQuery selectors so we need to catch any // errors from the lookup... try { e = $(ele); } catch (err) { return; } eleHeight = e.outerHeight(); eleWidth = e.outerWidth(); container.scrollTop(0); container.scrollLeft(0); // loop through parents adding the offset top of any elements that are relatively positioned between // the focused element and the jspPane so we can get the true distance from the top // of the focused element to the top of the scrollpane... while (!e.is('.jspPane')) { eleTop += e.position().top; eleLeft += e.position().left; e = e.offsetParent(); if (/^body|html$/i.test(e[0].nodeName)) { // we ended up too high in the document structure. Quit! return; } } viewportTop = contentPositionY(); maxVisibleEleTop = viewportTop + paneHeight; if (eleTop < viewportTop || stickToTop) { // element is above viewport destY = eleTop - settings.horizontalGutter; } else if (eleTop + eleHeight > maxVisibleEleTop) { // element is below viewport destY = eleTop - paneHeight + eleHeight + settings.horizontalGutter; } if (!isNaN(destY)) { scrollToY(destY, animate); } viewportLeft = contentPositionX(); maxVisibleEleLeft = viewportLeft + paneWidth; if (eleLeft < viewportLeft || stickToTop) { // element is to the left of viewport destX = eleLeft - settings.horizontalGutter; } else if (eleLeft + eleWidth > maxVisibleEleLeft) { // element is to the right viewport destX = eleLeft - paneWidth + eleWidth + settings.horizontalGutter; } if (!isNaN(destX)) { scrollToX(destX, animate); } } function contentPositionX() { return -pane.position().left; } function contentPositionY() { return -pane.position().top; } function isCloseToBottom() { var scrollableHeight = contentHeight - paneHeight; return (scrollableHeight > 20) && (scrollableHeight - contentPositionY() < 10); } function isCloseToRight() { var scrollableWidth = contentWidth - paneWidth; return (scrollableWidth > 20) && (scrollableWidth - contentPositionX() < 10); } function initMousewheel() { container.unbind(mwEvent).bind( mwEvent, function (event, delta, deltaX, deltaY) { if (!horizontalDragPosition) horizontalDragPosition = 0; if (!verticalDragPosition) verticalDragPosition = 0; var dX = horizontalDragPosition, dY = verticalDragPosition, factor = event.deltaFactor || settings.mouseWheelSpeed; jsp.scrollBy(deltaX * factor, -deltaY * factor, false); // return true if there was no movement so rest of screen can scroll return dX == horizontalDragPosition && dY == verticalDragPosition; } ); } function removeMousewheel() { container.unbind(mwEvent); } function nil() { return false; } function initFocusHandler() { pane.find(':input,a').unbind('focus.jsp').bind( 'focus.jsp', function (e) { scrollToElement(e.target, false); } ); } function removeFocusHandler() { pane.find(':input,a').unbind('focus.jsp'); } function initKeyboardNav() { var keyDown, elementHasScrolled, validParents = []; isScrollableH && validParents.push(horizontalBar[0]); isScrollableV && validParents.push(verticalBar[0]); // IE also focuses elements that don't have tabindex set. pane.focus( function () { elem.focus(); } ); elem.attr('tabindex', 0) .unbind('keydown.jsp keypress.jsp') .bind( 'keydown.jsp', function (e) { if (e.target !== this && !(validParents.length && $(e.target).closest(validParents).length)) { return; } var dX = horizontalDragPosition, dY = verticalDragPosition; switch (e.keyCode) { case 40: // down case 38: // up case 34: // page down case 32: // space case 33: // page up case 39: // right case 37: // left keyDown = e.keyCode; keyDownHandler(); break; case 35: // end scrollToY(contentHeight - paneHeight); keyDown = null; break; case 36: // home scrollToY(0); keyDown = null; break; } elementHasScrolled = e.keyCode == keyDown && dX != horizontalDragPosition || dY != verticalDragPosition; return !elementHasScrolled; } ).bind( 'keypress.jsp', // For FF/ OSX so that we can cancel the repeat key presses if the JSP scrolls... function (e) { if (e.keyCode == keyDown) { keyDownHandler(); } return !elementHasScrolled; } ); if (settings.hideFocus) { elem.css('outline', 'none'); if ('hideFocus' in container[0]) { elem.attr('hideFocus', true); } } else { elem.css('outline', ''); if ('hideFocus' in container[0]) { elem.attr('hideFocus', false); } } function keyDownHandler() { var dX = horizontalDragPosition, dY = verticalDragPosition; switch (keyDown) { case 40: // down jsp.scrollByY(settings.keyboardSpeed, false); break; case 38: // up jsp.scrollByY(-settings.keyboardSpeed, false); break; case 34: // page down case 32: // space jsp.scrollByY(paneHeight * settings.scrollPagePercent, false); break; case 33: // page up jsp.scrollByY(-paneHeight * settings.scrollPagePercent, false); break; case 39: // right jsp.scrollByX(settings.keyboardSpeed, false); break; case 37: // left jsp.scrollByX(-settings.keyboardSpeed, false); break; } elementHasScrolled = dX != horizontalDragPosition || dY != verticalDragPosition; return elementHasScrolled; } } function removeKeyboardNav() { elem.attr('tabindex', '-1') .removeAttr('tabindex') .unbind('keydown.jsp keypress.jsp'); } function observeHash() { if (location.hash && location.hash.length > 1) { var e, retryInt, hash = escape(location.hash.substr(1)) // hash must be escaped to prevent XSS ; try { e = $('#' + hash + ', a[name="' + hash + '"]'); } catch (err) { return; } if (e.length && pane.find(hash)) { // nasty workaround but it appears to take a little while before the hash has done its thing // to the rendered page so we just wait until the container's scrollTop has been messed up. if (container.scrollTop() === 0) { retryInt = setInterval( function () { if (container.scrollTop() > 0) { scrollToElement(e, true); $(document).scrollTop(container.position().top); clearInterval(retryInt); } }, 50 ); } else { scrollToElement(e, true); $(document).scrollTop(container.position().top); } } } } function hijackInternalLinks() { // only register the link handler once if ($(document.body).data('jspHijack')) { return; } // remember that the handler was bound $(document.body).data('jspHijack', true); // use live handler to also capture newly created links $(document.body).delegate('a[href*=#]', 'click', function (event) { // does the link point to the same page? // this also takes care of cases with a -Tag or Links not starting with the hash # // e.g. when the current url already is index.html var href = this.href.substr(0, this.href.indexOf('#')), locationHref = location.href, hash, element, container, jsp, scrollTop, elementTop; if (location.href.indexOf('#') !== -1) { locationHref = location.href.substr(0, location.href.indexOf('#')); } if (href !== locationHref) { // the link points to another page return; } // check if jScrollPane should handle this click event hash = escape(this.href.substr(this.href.indexOf('#') + 1)); // find the element on the page element; try { element = $('#' + hash + ', a[name="' + hash + '"]'); } catch (e) { // hash is not a valid jQuery identifier return; } if (!element.length) { // this link does not point to an element on this page return; } container = element.closest('.jspScrollable'); jsp = container.data('jsp'); // jsp might be another jsp instance than the one, that bound this event // remember: this event is only bound once for all instances. jsp.scrollToElement(element, true); if (container[0].scrollIntoView) { // also scroll to the top of the container (if it is not visible) scrollTop = $(window).scrollTop(); elementTop = element.offset().top; if (elementTop < scrollTop || elementTop > scrollTop + $(window).height()) { container[0].scrollIntoView(); } } // jsp handled this event, prevent the browser default (scrolling :P) event.preventDefault(); }); } // Init touch on iPad, iPhone, iPod, Android function initTouch() { var startX, startY, touchStartX, touchStartY, moved, moving = false; container.unbind('touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick').bind( 'touchstart.jsp', function (e) { var touch = e.originalEvent.touches[0]; startX = contentPositionX(); startY = contentPositionY(); touchStartX = touch.pageX; touchStartY = touch.pageY; moved = false; moving = true; } ).bind( 'touchmove.jsp', function (ev) { if (!moving) { return; } var touchPos = ev.originalEvent.touches[0], dX = horizontalDragPosition, dY = verticalDragPosition; jsp.scrollTo(startX + touchStartX - touchPos.pageX, startY + touchStartY - touchPos.pageY); moved = moved || Math.abs(touchStartX - touchPos.pageX) > 5 || Math.abs(touchStartY - touchPos.pageY) > 5; // return true if there was no movement so rest of screen can scroll return dX == horizontalDragPosition && dY == verticalDragPosition; } ).bind( 'touchend.jsp', function (e) { moving = false; /*if(moved) { return false; }*/ } ).bind( 'click.jsp-touchclick', function (e) { if (moved) { moved = false; return false; } } ); } function destroy() { var currentY = contentPositionY(), currentX = contentPositionX(); elem.removeClass('jspScrollable').unbind('.jsp'); elem.replaceWith(originalElement.append(pane.children())); originalElement.scrollTop(currentY); originalElement.scrollLeft(currentX); // clear reinitialize timer if active if (reinitialiseInterval) { clearInterval(reinitialiseInterval); } } // Public API $.extend( jsp, { // Reinitialises the scroll pane (if it's internal dimensions have changed since the last time it // was initialised). The settings object which is passed in will override any settings from the // previous time it was initialised - if you don't pass any settings then the ones from the previous // initialisation will be used. reinitialise: function (s) { s = $.extend({}, settings, s); initialise(s); }, // Scrolls the specified element (a jQuery object, DOM node or jQuery selector string) into view so // that it can be seen within the viewport. If stickToTop is true then the element will appear at // the top of the viewport, if it is false then the viewport will scroll as little as possible to // show the element. You can also specify if you want animation to occur. If you don't provide this // argument then the animateScroll value from the settings object is used instead. scrollToElement: function (ele, stickToTop, animate) { scrollToElement(ele, stickToTop, animate); }, // Scrolls the pane so that the specified co-ordinates within the content are at the top left // of the viewport. animate is optional and if not passed then the value of animateScroll from // the settings object this jScrollPane was initialised with is used. scrollTo: function (destX, destY, animate) { scrollToX(destX, animate); scrollToY(destY, animate); }, // Scrolls the pane so that the specified co-ordinate within the content is at the left of the // viewport. animate is optional and if not passed then the value of animateScroll from the settings // object this jScrollPane was initialised with is used. scrollToX: function (destX, animate) { scrollToX(destX, animate); }, // Scrolls the pane so that the specified co-ordinate within the content is at the top of the // viewport. animate is optional and if not passed then the value of animateScroll from the settings // object this jScrollPane was initialised with is used. scrollToY: function (destY, animate) { scrollToY(destY, animate); }, // Scrolls the pane to the specified percentage of its maximum horizontal scroll position. animate // is optional and if not passed then the value of animateScroll from the settings object this // jScrollPane was initialised with is used. scrollToPercentX: function (destPercentX, animate) { scrollToX(destPercentX * (contentWidth - paneWidth), animate); }, // Scrolls the pane to the specified percentage of its maximum vertical scroll position. animate // is optional and if not passed then the value of animateScroll from the settings object this // jScrollPane was initialised with is used. scrollToPercentY: function (destPercentY, animate) { scrollToY(destPercentY * (contentHeight - paneHeight), animate); }, // Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then // the value of animateScroll from the settings object this jScrollPane was initialised with is used. scrollBy: function (deltaX, deltaY, animate) { jsp.scrollByX(deltaX, animate); jsp.scrollByY(deltaY, animate); }, // Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then // the value of animateScroll from the settings object this jScrollPane was initialised with is used. scrollByX: function (deltaX, animate) { var destX = contentPositionX() + Math[deltaX < 0 ? 'floor' : 'ceil'](deltaX), percentScrolled = destX / (contentWidth - paneWidth); positionDragX(percentScrolled * dragMaxX, animate); }, // Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then // the value of animateScroll from the settings object this jScrollPane was initialised with is used. scrollByY: function (deltaY, animate) { var destY = contentPositionY() + Math[deltaY < 0 ? 'floor' : 'ceil'](deltaY), percentScrolled = destY / (contentHeight - paneHeight); positionDragY(percentScrolled * dragMaxY, animate); }, // Positions the horizontal drag at the specified x position (and updates the viewport to reflect // this). animate is optional and if not passed then the value of animateScroll from the settings // object this jScrollPane was initialised with is used. positionDragX: function (x, animate) { positionDragX(x, animate); }, // Positions the vertical drag at the specified y position (and updates the viewport to reflect // this). animate is optional and if not passed then the value of animateScroll from the settings // object this jScrollPane was initialised with is used. positionDragY: function (y, animate) { positionDragY(y, animate); }, // This method is called when jScrollPane is trying to animate to a new position. You can override // it if you want to provide advanced animation functionality. It is passed the following arguments: // * ele - the element whose position is being animated // * prop - the property that is being animated // * value - the value it's being animated to // * stepCallback - a function that you must execute each time you update the value of the property // You can use the default implementation (below) as a starting point for your own implementation. animate: function (ele, prop, value, stepCallback) { var params = {}; params[prop] = value; ele.animate( params, { 'duration': settings.animateDuration, 'easing': settings.animateEase, 'queue': false, 'step': stepCallback } ); }, // Returns the current x position of the viewport with regards to the content pane. getContentPositionX: function () { return contentPositionX(); }, // Returns the current y position of the viewport with regards to the content pane. getContentPositionY: function () { return contentPositionY(); }, // Returns the width of the content within the scroll pane. getContentWidth: function () { return contentWidth; }, // Returns the height of the content within the scroll pane. getContentHeight: function () { return contentHeight; }, // Returns the horizontal position of the viewport within the pane content. getPercentScrolledX: function () { return contentPositionX() / (contentWidth - paneWidth); }, // Returns the vertical position of the viewport within the pane content. getPercentScrolledY: function () { return contentPositionY() / (contentHeight - paneHeight); }, // Returns whether or not this scrollpane has a horizontal scrollbar. getIsScrollableH: function () { return isScrollableH; }, // Returns whether or not this scrollpane has a vertical scrollbar. getIsScrollableV: function () { return isScrollableV; }, // Gets a reference to the content pane. It is important that you use this method if you want to // edit the content of your jScrollPane as if you access the element directly then you may have some // problems (as your original element has had additional elements for the scrollbars etc added into // it). getContentPane: function () { return pane; }, // Scrolls this jScrollPane down as far as it can currently scroll. If animate isn't passed then the // animateScroll value from settings is used instead. scrollToBottom: function (animate) { positionDragY(dragMaxY, animate); }, // Hijacks the links on the page which link to content inside the scrollpane. If you have changed // the content of your page (e.g. via AJAX) and want to make sure any new anchor links to the // contents of your scroll pane will work then call this function. hijackInternalLinks: $.noop, // Removes the jScrollPane and returns the page to the state it was in before jScrollPane was // initialised. destroy: function () { destroy(); } } ); initialise(s); } // Pluginifying code... settings = $.extend({}, $.fn.jScrollPane.defaults, settings); // Apply default speed $.each(['arrowButtonSpeed', 'trackClickSpeed', 'keyboardSpeed'], function () { settings[this] = settings[this] || settings.speed; }); return this.each( function () { var elem = $(this), jspApi = elem.data('jsp'); if (jspApi) { jspApi.reinitialise(settings); } else { $("script", elem).filter('[type="text/javascript"],:not([type])').remove(); jspApi = new JScrollPane(elem, settings); elem.data('jsp', jspApi); } } ); }; $.fn.jScrollPane.defaults = { showArrows: false, maintainPosition: true, stickToBottom: false, stickToRight: false, clickOnTrack: true, autoReinitialise: false, autoReinitialiseDelay: 500, verticalDragMinHeight: 0, verticalDragMaxHeight: 99999, horizontalDragMinWidth: 0, horizontalDragMaxWidth: 99999, contentWidth: undefined, animateScroll: true, animateDuration: 300, animateEase: 'linear', hijackInternalLinks: false, verticalGutter: 4, horizontalGutter: 4, mouseWheelSpeed: 3, arrowButtonSpeed: 0, arrowRepeatFreq: 50, arrowScrollOnHover: false, trackClickSpeed: 0, trackClickRepeatFreq: 70, verticalArrowPositions: 'split', horizontalArrowPositions: 'split', enableKeyboardNavigation: true, hideFocus: false, keyboardSpeed: 0, initialDelay: 300, // Delay before starting repeating speed: 30, // Default speed when others falsey scrollPagePercent: .8 // Percent of visible area scrolled when pageUp/Down or track area pressed }; })); // source --> https://esneux.mr.be/wp-content/plugins/team_awesome/front/js/ta.js?ver=a3db3f8ceb41c2e8645e66c599606b9f (function ($) { "use strict"; var ta_helper = { canvas_polygon: function (ctx, x, y, radius, sides, startAngle, anticlockwise) { if (sides < 3) { return; } var a = (Math.PI * 2) / sides; a = anticlockwise ? -a : a; ctx.save(); ctx.translate(x, y); ctx.rotate(startAngle); ctx.moveTo(radius, 0); for (var i = 1; i < sides; i++) { ctx.lineTo(radius * Math.cos(a * i), radius * Math.sin(a * i)); } ctx.closePath(); ctx.restore(); }, onResizeEnd: function (callback, time) { var id; time = time ? time : 10; $(window).on("resize", function () { clearTimeout(id); id = setTimeout(function () { if (typeof callback === "function") { callback.call(); } }, time); }); }, onScrollEnd: function (callback, time, relelem) { var id; time = time ? time : 50; $(document).on("scroll", relelem, function () { clearTimeout(id); id = setTimeout(function () { if (typeof callback === "function") { callback.call(); } }, time); }); }, isScrolledIntoView: function (elem, relelem) { if (!relelem) { relelem = window; } // Check elem on front page if ($(elem).length <= 0) { return false; } var docViewTop = relelem === window ? $(relelem).scrollTop() : $(relelem).offset().top; var docViewBottom = docViewTop + $(relelem).outerHeight(true); var elemTop = $(elem).offset().top; var elemBottom = elemTop + $(elem).outerHeight(true); return (docViewBottom >= elemTop && docViewTop <= elemBottom); }, isMobile: function() { return ( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) ? true : false; }, clickHandle: function(){ return this.isMobile() ? "touchstart" : "click"; } }; function team_awesome() { var instance = ""; var $instance = ""; var glob = { settings: {} }; this.init = function (settings) { glob.settings = settings; instance = "#" + glob.settings.id; $instance = $(instance); if (!ta_helper.isMobile()) { $(window).on("scroll", function () { /* background parallax */ $instance.filter(".ta-parallax").each(function () { if (ta_helper.isScrolledIntoView(this)) { var scrolledY = -1 * ($(window).scrollTop() - $(this).offset().top + $(this).height()); $(this).css('background-position', 'center ' + ((scrolledY * 0.2)) + 'px'); } }); }); } if (ta_helper.isMobile()) { $instance.addClass("ta-no-blur"); } categories.init(); memberBox.init(); if (glob.settings.slider == "enable") { slider.init(); } }; var categories = { $blur: "", maxblur: 100, easing: "easeOutQuint", /* blur easing */ speed: 500, /* should match css anim speed */ init: function () { this.$blur = $("#ta-blur-vert").children().get(0); this.filter(); this.bindControls(); }, swapOld: function(){ var parent = this; $instance.find('.team-awesome-container').removeClass("ta-anim-swap-new"); $instance.find('.team-awesome-container').addClass("ta-anim-swap-old"); // STOP BLUR if (ta_helper.isMobile()) { return; } // blur $instance.find('.team-awesome-container').css({ tablurvert: 0 }).stop().animate({ tablurvert: 1 }, { start: function () { $instance.find('.team-awesome-member-box').addClass("ta-svg-blur-vert"); parent.setBlur(0, 0); }, step: function (x) { var p = parent.maxblur - Math.round(parent.maxblur * x); parent.setBlur(0, p); }, complete: function () { $instance.find('.team-awesome-member-box').removeClass("ta-svg-blur-vert"); }, easing: parent.easing, duration: parent.speed }); }, swapNew: function(){ var parent = this; slider.runVideos(); $instance.find('.team-awesome-container').removeClass("ta-anim-swap-old"); $instance.find('.team-awesome-container').addClass("ta-anim-swap-new"); // STOP BLUR if (ta_helper.isMobile()) { return; } // blur $instance.find('.team-awesome-container').css({ tablurvert: 0 }).stop().animate({ tablurvert: 1 }, { start: function () { $instance.find('.team-awesome-member-box').addClass("ta-svg-blur-vert"); parent.setBlur(0, 0); }, step: function (x) { var p = parent.maxblur - Math.round(parent.maxblur * x); parent.setBlur(0, p); }, complete: function () { $instance.find('.team-awesome-member-box').removeClass("ta-svg-blur-vert"); $instance.find('.team-awesome-container').removeClass("ta-anim-swap-new"); }, easing: parent.easing, duration: parent.speed }); }, setBlur: function (x, y) { this.$blur.setAttribute("stdDeviation", x + "," + y); }, bindControls: function () { var parent = this; $instance.find(".team-awesome-menu li").on(ta_helper.clickHandle(), function (e) { e.preventDefault(); if ($(this).hasClass("active")) { return; } $(this).addClass("active"); $(this).siblings().removeClass("active"); var swap = function () { parent.swapOld(); setTimeout(function () { parent.filter(); if (slider.$slider) { slider.reset(); } parent.swapNew(); }, 500); }; // Check for opened popup if ($(instance).find(".ta-open").length > 0) { $(instance).find(".ta-open").removeClass("ta-open"); setTimeout(function () { slider.$slider.css({ overflow: "hidden" }); swap(); }, 350); } else { swap(); } }); }, filter: function () { // Filter members by category var active = $(instance).find(".team-awesome-menu .active").attr("data-cat"); if (!active) { active = 0; } var all = glob.settings.members; var filter = ""; if (active == 0) { filter = all; } else { filter = $(all).filter(function (index, obj) { var catarr = obj.cat.split("-"); return $.inArray(active, catarr) >= 0; }); } // Clear old $instance.find('.team-awesome-slide').remove(); $instance.find('.team-awesome-member-box').remove(); // Add New $(filter).each(function () { var html = this.html; $(html).appendTo($instance.find(".team-awesome-slider")); memberBox.dimensions(); memberBox.popDimensions(); }); } }; var memberBox = { mobileAvatarHover: false, init: function () { var parent = this; parent.dimensions(); parent.popDimensions(); parent.bindControls(); }, mediaQuery: function(){ memberBox.scrolls(); }, popDimensions: function () { var $box = $instance.find(".team-awesome-member-box"); $box.each(function(){ var $pop = $(this).find(".team-awesome-member-pop"); var $inner = $pop.find(".team-awesome-member-pop-inner"); $pop.css({ maxHeight: $pop.attr("data-maxheight"), width: $pop.attr("data-width"), height: $inner.outerHeight() + 20 }); $pop.css({ left: $(this).outerWidth() / 2 - $pop.outerWidth() / 2, top: $(this).outerHeight() / 2 - $pop.outerHeight() / 2 }); }); }, dimensions: function () { var $boxes = $(instance).find(".team-awesome-member-box"); $boxes.each(function () { var boxWidth = $(this).attr("data-width"); // Member box width $(this).css({ width: boxWidth }); }); }, scrolls: function () { $instance.find(".team-awesome-member-pop-scroll").jScrollPane({ verticalGutter: 0 }); }, emptyStats: function (el) { var $box = $(instance).find(".ta-open"); if (el) { $box = $(el); } setTimeout(function () { $box.find(".team-awesome-member-pop-percents-inner").stop().css({ width: 0 }); $box.find(".team-awesome-member-pop-percents-box-aftertitle").stop().text("0%"); }, 1000); $box.find(".team-awesome-member-pop-percents-inner").removeAttr("data-filled"); }, fillStats: function (delay, speed) { if (!delay) { delay = 0; } if (!speed) { speed = 2000; } setTimeout(function () { var $box = $instance.find(".ta-open"); var a = $box.find(".team-awesome-member-pop-stats"); var b = $box; if (ta_helper.isScrolledIntoView(a, b)) { // Fill stats bars $box.find(".team-awesome-member-pop-percents-inner:not([data-filled])").each(function (i) { var th = this; var fill = $(th).attr("data-fill"); $(th).attr("data-filled", 1); $(th).stop().delay(i * 100).animate({ width: fill }, { duration: speed, easing: "easeInOutExpo", step: function (x) { x = Math.round(x) + "%"; $(th).parents(".team-awesome-member-pop-percents-box").find(".team-awesome-member-pop-percents-box-aftertitle").text(x); } }); }); } }, delay); }, getRandomAnim: function () { // Random social hover animation var animationArray = new Array( "ta-anim-grow", "ta-anim-pulse", "ta-anim-wobble-hor", "ta-anim-wobble-ver", "ta-anim-wobble-br", "ta-anim-wobble-tr", "ta-anim-wobble-t", "ta-anim-wobble-b", "ta-anim-wobble-c", "ta-anim-buzz" ); var random = animationArray[Math.floor(Math.random() * animationArray.length)]; return random; }, cleanRandomAnim: function (el) { // Remove social hover animation var classes = "ta-anim-grow ta-anim-pulse ta-anim-wobble-hor ta-anim-wobble-ver ta-anim-wobble-br ta-anim-wobble-tr ta-anim-wobble-t ta-anim-wobble-b ta-anim-wobble-c ta-anim-buzz"; $(el).removeClass(classes); }, bindControls: function () { var parent = this; /* UNIVERSAL */ ta_helper.onScrollEnd(function () { parent.fillStats(); }, 100, instance + " .ta-open .team-awesome-member-pop-scroll"); ta_helper.onResizeEnd(function(){ memberBox.scrolls(); }, 100); /* /UNIVERSAL */ /* MOBILE BINDS */ if (ta_helper.isMobile()) { // a link fix $(document).on(ta_helper.clickHandle(), instance + " a", function (e) { e.stopPropagation(); return; }); // ta-hover $(document).on(ta_helper.clickHandle(), instance + " .team-awesome-member-avatar-circle, .team-awesome-member-avatar-box, .team-awesome-member-avatar-hex", function (e) { e.preventDefault(); if (parent.mobileAvatarHover === false) { $(this).addClass("ta-hover"); parent.mobileAvatarHover = true; } }); // ta-open $(document).on(ta_helper.clickHandle(), instance + " .team-awesome-member-circle-stamp, .team-awesome-member-box-stamp, .team-awesome-member-hex-stamp", function (e) { e.preventDefault(); if (parent.mobileAvatarHover === false) { return; } if (glob.settings.pop == "disable") { return; } if ($instance.find(".team-awesome-slide").is(":animated")) { return; } $instance.find(".team-awesome-member-box").removeClass("ta-open"); $(this).parents(".team-awesome-member-box").addClass("ta-open"); parent.fillStats(1000); // hide <> cslide slides if (slider.$slider) { slider.$slider.find(".team-awesome-slide").eq(slider.cslide).siblings().hide(); } // visible to stop cutting the popup $instance.find(".team-awesome-slider").css({ overflow: "visible" }); parent.scrolls(); }); // pop close $(document).on("tap", instance + " .team-awesome-member-pop", function (e) { e.preventDefault(); parent.mobileAvatarHover = false; parent.emptyStats(this); $(this).parents(".team-awesome-member-box").removeClass("ta-open"); $instance.find(".team-awesome-member-avatar-circle, .team-awesome-member-avatar-box, .team-awesome-member-avatar-hex").removeClass("ta-hover"); setTimeout(function () { $instance.find(".team-awesome-slider").css({ overflow: "hidden" }); }, 500); }); } /* /MOBILE BINDS */ /* NORMAL BINDS */ if (!ta_helper.isMobile()) { // ta-hover $(document).on("hover", instance + " .team-awesome-member-avatar-circle, .team-awesome-member-avatar-box, .team-awesome-member-avatar-hex", function () { $(this).addClass("ta-hover"); }); $(document).on("mouseleave", instance + " .team-awesome-member-avatar-circle, .team-awesome-member-avatar-box, .team-awesome-member-avatar-hex", function () { $(this).removeClass("ta-hover"); }); $(document).on("hover", instance + " .team-awesome-social-button-inner", function () { $(this).siblings().addClass("ta-nofocus"); $(this).removeClass("ta-nofocus").addClass("ta-focus"); var klass = glob.settings.socanim; if (klass == "random") { klass = parent.getRandomAnim(); } $(this).addClass(klass); }); $(document).on("mouseleave", instance + " .team-awesome-social-button-inner", function () { $(this).removeClass("ta-focus"); parent.cleanRandomAnim(this); }); // ta-open $(document).on(ta_helper.clickHandle(), instance + " .team-awesome-member-circle-stamp, .team-awesome-member-box-stamp, .team-awesome-member-hex-stamp", function (e) { e.preventDefault(); if (glob.settings.pop == "disable") { return; } if ($(instance).find(".team-awesome-slide").is(":animated")) { return; } $instance.find(".team-awesome-member-box").removeClass("ta-open"); $(this).parents(".team-awesome-member-box").addClass("ta-open"); parent.fillStats(1000); // hide <> cslide slides if (slider.$slider) { slider.$slider.find(".team-awesome-slide").eq(slider.cslide).siblings().hide(); } // visible to stop cutting the popup $instance.find(".team-awesome-slider").css({ overflow: "visible" }); parent.scrolls(); }); // pop close $(document).on(ta_helper.clickHandle(), instance + " .team-awesome-member-pop", function (e) { e.preventDefault(); parent.emptyStats(this); $(this).parents(".team-awesome-member-box").removeClass("ta-open"); setTimeout(function () { $instance.find(".team-awesome-slider").css({ overflow: "hidden" }); }, 500); }); }; /* /NORMAL BINDS */ } }; var slider = { $slider: "", perpage: 3, cslide: 0, total: "", $blur: "", maxblur: 100, easing: "easeOutQuint", /* blur easing */ speed: 1000, /* should match css anim speed */ init: function () { this.$slider = $(instance).find(".team-awesome-slider"); this.perpage = this.$slider.attr("data-perpage"); this.total = Math.ceil(this.$slider.find(".team-awesome-member-box").length / this.perpage); this.$blur = $("#ta-blur").children().get(0); this.runVideos(); this.mediaQuery(true); this.bindControls(); }, runVideos: function(){ // check compatability here if (ta_helper.isMobile()) { $instance.find(".team-awesome-member-hex-stamp-inner-video").hide(); $instance.find(".team-awesome-member-circle-stamp-inner-video").hide(); $instance.find(".team-awesome-member-box-stamp-inner-video").hide(); return; } // if video, hide image $instance.find(".team-awesome-member-circle-stamp-inner-video, .team-awesome-member-box-stamp-inner-video, .team-awesome-member-hex-stamp-inner-video").each(function(){ $(this).prev().hide(); }); // run box $instance.find(".team-awesome-member-box-stamp-inner-video").each(function(){ var canvas = $(this).find("canvas").get(0); var ctx = canvas.getContext('2d'); var video = $(this).find("video").get(0); var r = glob.settings.avatarb == "off" ? 159 : 150; var ar = $(video).width() / $(video).height(); ta_helper.canvas_polygon(ctx, 112.5, 112.5, r, 4, Math.PI / 4, true); var offset_x = -1 * $(video).width() / 2; ctx.imageSmoothingEnabled = true; $(video).on('canplaythrough', function () { this.play(); }); video.addEventListener('play', function () { var th = this; try { (function loop() { if (!th.paused && !th.ended) { ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.translate(offset_x, 0); ctx.save(); ctx.clip(); ctx.drawImage(th, 0, 0, canvas.width * ar, canvas.height); ctx.restore(); ctx.translate(-offset_x, 0); setTimeout(loop, 1000 / 30); // drawing at 30fps } })(); } catch (err) { loop(); } }); }); // run circles $instance.find(".team-awesome-member-circle-stamp-inner-video").each(function(){ var canvas = $(this).find("canvas").get(0); var ctx = canvas.getContext('2d'); var video = $(this).find("video").get(0); var r = glob.settings.avatarb == "off" ? 112.5 : 106.5; var ar = $(video).width() / $(video).height(); ctx.beginPath(); ctx.arc(112.5, 112.5, r, 0, Math.PI * 2, true); ctx.closePath(); var offset_x = -1 * $(video).width() / 2 ; ctx.imageSmoothingEnabled = true; $(video).on('canplaythrough', function () { this.play(); }); video.addEventListener('play', function () { var th = this; try { (function loop() { if (!th.paused && !th.ended) { ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.translate(offset_x, 0); ctx.save(); ctx.clip(); ctx.drawImage(th, 0, 0, canvas.width * ar, canvas.height); ctx.restore(); ctx.translate(-offset_x, 0); setTimeout(loop, 1000 / 30); // drawing at 30fps } })(); } catch (err) { loop(); } }); }); // run hexagons $instance.find(".team-awesome-member-hex-stamp-inner-video").each(function(){ var canvas = $(this).find("canvas").get(0); var ctx = canvas.getContext('2d'); var video = $(this).find("video").get(0); var r = glob.settings.avatarb == "off" ? 112 : 105; var ar = $(video).width() / $(video).height(); ta_helper.canvas_polygon(ctx, 112, 112, r, 6, Math.PI / 2, true); var offset_x = -1 * $(video).width() / 2 ; ctx.imageSmoothingEnabled = true; $(video).on('canplaythrough', function () { this.play(); }); video.addEventListener('play', function () { var th = this; try { (function loop() { if (!th.paused && !th.ended) { ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.translate(offset_x, 0); ctx.save(); ctx.clip(); ctx.drawImage(th, 0, 0, canvas.width * ar, canvas.height); ctx.restore(); ctx.translate(-offset_x, 0); setTimeout(loop, 1000 / 30); // drawing at 30fps } })(); } catch(err) { loop(); }; }); }); }, reset: function () { this.cslide = 0; this.total = Math.ceil(this.$slider.find(".team-awesome-member-box").length / this.perpage); this.dimensions(); this.clearPages(); this.createPages(); memberBox.mobileAvatarHover = false; }, setBlur: function (x, y) { this.$blur.setAttribute("stdDeviation", x + "," + y); }, dimensions: function () { this.$slider.css({ height: this.$slider.find(".team-awesome-member-box").outerHeight(true) }); }, clearPages: function(){ var parent = this; parent.$slider.find(".team-awesome-member-box").appendTo(parent.$slider); parent.$slider.find(".team-awesome-slide").remove(); }, createPages: function () { var parent = this; if (parent.total > 1) { var i = parent.total; while (i > 0) { var html = "
"; $(html).appendTo(parent.$slider); i--; } //var n = parent.$slider.find(".team-awesome-slide").length; var n = -1; parent.$slider.find(".team-awesome-member-box").each(function (i) { if (i % parent.perpage === 0) { n++; } $(this).appendTo(parent.$slider.find(".team-awesome-slide").eq(n)); }); } // enable/disable pagination if (this.total <= 1) { $instance.find(".team-awesome-slider-control").hide(); } else { $instance.find(".team-awesome-slider-control").show(); } }, mediaQuery: function (force) { var parent = this; var maxSize = parent.$slider.width(); var cur = parent.perpage; var limit = parent.$slider.attr("data-perpage"); parent.perpage = Math.floor(maxSize / $instance.find(".team-awesome-member-box").outerWidth(true)); if (parent.perpage > limit) { parent.perpage = limit; } if (parent.perpage <= 0) { parent.perpage = 1; } if (parent.perpage != cur) { parent.reset(); } if (force === true) { parent.reset(); } }, bindControls: function () { var parent = this; ta_helper.onResizeEnd(function(){ parent.mediaQuery(); }, 100); $(instance).find(".team-awesome-slider-control-right").on(ta_helper.clickHandle(), function(e) { e.preventDefault(); var doslide = function () { memberBox.mobileAvatarHover = false; var $old = parent.$slider.find(".team-awesome-slide").eq(parent.cslide); // clear old animation classes $old.removeClass("ta-slide-ctl ta-slide-rtc ta-slide-ctr ta-slide-ltc"); $old.addClass("ta-slide-ctl"); $old.show(); var nextslide = parent.cslide + 1; if (nextslide >= parent.total) { nextslide = 0; } var $new = parent.$slider.find(".team-awesome-slide").eq(nextslide); $new.removeClass("ta-slide-ctl ta-slide-rtc ta-slide-ctr ta-slide-ltc"); $new.show(); $new.addClass("ta-slide-rtc"); parent.cslide = nextslide; // STOP BLUR if (ta_helper.isMobile()) { return; } // simple blur parent.$slider.css({ tablur: 0 }).stop().animate({ tablur: 1 }, { start: function () { parent.$slider.addClass("ta-svg-blur"); parent.setBlur(0, 0); }, step: function (x) { var p = parent.maxblur - Math.round(parent.maxblur * x); parent.setBlur(p, 0); }, complete: function () { parent.$slider.removeClass("ta-svg-blur"); }, easing: parent.easing, duration: parent.speed }); }; // Check for opened popup if ($instance.find(".ta-open").length > 0) { $instance.find(".ta-open").removeClass("ta-open"); setTimeout(function () { parent.$slider.css({ overflow: "hidden" }); doslide(); }, 350); } else { doslide(); } }); $instance.find(".team-awesome-slider-control-left").on(ta_helper.clickHandle(), function (e) { e.preventDefault(); var doslide = function () { memberBox.mobileAvatarHover = false; var $old = parent.$slider.find(".team-awesome-slide").eq(parent.cslide); // clear old animatino classes $old.removeClass("ta-slide-ctl ta-slide-rtc ta-slide-ctr ta-slide-ltc"); $old.addClass("ta-slide-ctr"); $old.show(); var nextslide = parent.cslide - 1; if (nextslide < 0) { nextslide = parent.total - 1; } var $new = parent.$slider.find(".team-awesome-slide").eq(nextslide); $new.removeClass("ta-slide-ctl ta-slide-rtc ta-slide-ctr ta-slide-ltc"); $new.show(); $new.addClass("ta-slide-ltc"); parent.cslide = nextslide; // STOP BLUR if (ta_helper.isMobile()) { return; } // simple blur parent.$slider.css({ tablur: 0 }).stop().animate({ tablur: 1 }, { start: function () { parent.$slider.addClass("ta-svg-blur"); parent.setBlur(0, 0); }, step: function (x) { var p = parent.maxblur - Math.round(parent.maxblur * x); parent.setBlur(p, 0); }, complete: function () { parent.$slider.removeClass("ta-svg-blur"); }, easing: parent.easing, duration: parent.speed }); }; // Check for opened popup if ($instance.find(".ta-open").length > 0) { $instance.find(".ta-open").removeClass("ta-open"); setTimeout(function () { parent.$slider.css({ overflow: "hidden" }); doslide(); }, 350); } else { doslide(); } }); } }; } $(document).ready(function () { if (typeof window.team_awesome_instance !== "undefined") { $(window.team_awesome_instance).each(function () { new team_awesome().init(this); }); } }); })(jQuery); // source --> https://esneux.mr.be/wp-content/plugins/wp-retina-2x/js/picturefill.min.js?ver=3.0.2 /*! picturefill - v3.0.2 - 2016-02-12 * https://scottjehl.github.io/picturefill/ * Copyright (c) 2016 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT */ !function(a){var b=navigator.userAgent;a.HTMLPictureElement&&/ecko/.test(b)&&b.match(/rv\:(\d+)/)&&RegExp.$1<45&&addEventListener("resize",function(){var b,c=document.createElement("source"),d=function(a){var b,d,e=a.parentNode;"PICTURE"===e.nodeName.toUpperCase()?(b=c.cloneNode(),e.insertBefore(b,e.firstElementChild),setTimeout(function(){e.removeChild(b)})):(!a._pfLastSize||a.offsetWidth>a._pfLastSize)&&(a._pfLastSize=a.offsetWidth,d=a.sizes,a.sizes+=",100vw",setTimeout(function(){a.sizes=d}))},e=function(){var a,b=document.querySelectorAll("picture > img, img[srcset][sizes]");for(a=0;a2.7?h=c+1:(f=b-c,e=Math.pow(a-.6,1.5),g=f*e,d&&(g+=.1*e),h=a+g):h=c>1?Math.sqrt(a*b):a,h>c}function h(a){var b,c=s.getSet(a),d=!1;"pending"!==c&&(d=r,c&&(b=s.setRes(c),s.applySetCandidate(b,a))),a[s.ns].evaled=d}function i(a,b){return a.res-b.res}function j(a,b,c){var d;return!c&&b&&(c=a[s.ns].sets,c=c&&c[c.length-1]),d=k(b,c),d&&(b=s.makeUrl(b),a[s.ns].curSrc=b,a[s.ns].curCan=d,d.res||aa(d,d.set.sizes)),d}function k(a,b){var c,d,e;if(a&&b)for(e=s.parseSet(b),a=s.makeUrl(a),c=0;cc;c++)e=g[c],e[s.ns]=!0,f=e.getAttribute("srcset"),f&&b.push({srcset:f,media:e.getAttribute("media"),type:e.getAttribute("type"),sizes:e.getAttribute("sizes")})}function m(a,b){function c(b){var c,d=b.exec(a.substring(m));return d?(c=d[0],m+=c.length,c):void 0}function e(){var a,c,d,e,f,i,j,k,l,m=!1,o={};for(e=0;el?m=!0:c=l):X.test(j)&&"h"===i?((d||c)&&(m=!0),0===k?m=!0:d=k):m=!0;m||(o.url=g,a&&(o.w=a),c&&(o.d=c),d&&(o.h=d),d||c||a||(o.d=1),1===o.d&&(b.has1x=!0),o.set=b,n.push(o))}function f(){for(c(T),i="",j="in descriptor";;){if(k=a.charAt(m),"in descriptor"===j)if(d(k))i&&(h.push(i),i="",j="after descriptor");else{if(","===k)return m+=1,i&&h.push(i),void e();if("("===k)i+=k,j="in parens";else{if(""===k)return i&&h.push(i),void e();i+=k}}else if("in parens"===j)if(")"===k)i+=k,j="in descriptor";else{if(""===k)return h.push(i),void e();i+=k}else if("after descriptor"===j)if(d(k));else{if(""===k)return void e();j="in descriptor",m-=1}m+=1}}for(var g,h,i,j,k,l=a.length,m=0,n=[];;){if(c(U),m>=l)return n;g=c(V),h=[],","===g.slice(-1)?(g=g.replace(W,""),e()):f()}}function n(a){function b(a){function b(){f&&(g.push(f),f="")}function c(){g[0]&&(h.push(g),g=[])}for(var e,f="",g=[],h=[],i=0,j=0,k=!1;;){if(e=a.charAt(j),""===e)return b(),c(),h;if(k){if("*"===e&&"/"===a[j+1]){k=!1,j+=2,b();continue}j+=1}else{if(d(e)){if(a.charAt(j-1)&&d(a.charAt(j-1))||!f){j+=1;continue}if(0===i){b(),j+=1;continue}e=" "}else if("("===e)i+=1;else if(")"===e)i-=1;else{if(","===e){b(),c(),j+=1;continue}if("/"===e&&"*"===a.charAt(j+1)){k=!0,j+=2;continue}}f+=e,j+=1}}}function c(a){return k.test(a)&&parseFloat(a)>=0?!0:l.test(a)?!0:"0"===a||"-0"===a||"+0"===a?!0:!1}var e,f,g,h,i,j,k=/^(?:[+-]?[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?:ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmin|vmax|vw)$/i,l=/^calc\((?:[0-9a-z \.\+\-\*\/\(\)]+)\)$/i;for(f=b(a),g=f.length,e=0;g>e;e++)if(h=f[e],i=h[h.length-1],c(i)){if(j=i,h.pop(),0===h.length)return j;if(h=h.join(" "),s.matchesMedia(h))return j}return"100vw"}b.createElement("picture");var o,p,q,r,s={},t=!1,u=function(){},v=b.createElement("img"),w=v.getAttribute,x=v.setAttribute,y=v.removeAttribute,z=b.documentElement,A={},B={algorithm:""},C="data-pfsrc",D=C+"set",E=navigator.userAgent,F=/rident/.test(E)||/ecko/.test(E)&&E.match(/rv\:(\d+)/)&&RegExp.$1>35,G="currentSrc",H=/\s+\+?\d+(e\d+)?w/,I=/(\([^)]+\))?\s*(.+)/,J=a.picturefillCFG,K="position:absolute;left:0;visibility:hidden;display:block;padding:0;border:none;font-size:1em;width:1em;overflow:hidden;clip:rect(0px, 0px, 0px, 0px)",L="font-size:100%!important;",M=!0,N={},O={},P=a.devicePixelRatio,Q={px:1,"in":96},R=b.createElement("a"),S=!1,T=/^[ \t\n\r\u000c]+/,U=/^[, \t\n\r\u000c]+/,V=/^[^ \t\n\r\u000c]+/,W=/[,]+$/,X=/^\d+$/,Y=/^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,Z=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d||!1):a.attachEvent&&a.attachEvent("on"+b,c)},$=function(a){var b={};return function(c){return c in b||(b[c]=a(c)),b[c]}},_=function(){var a=/^([\d\.]+)(em|vw|px)$/,b=function(){for(var a=arguments,b=0,c=a[0];++b in a;)c=c.replace(a[b],a[++b]);return c},c=$(function(a){return"return "+b((a||"").toLowerCase(),/\band\b/g,"&&",/,/g,"||",/min-([a-z-\s]+):/g,"e.$1>=",/max-([a-z-\s]+):/g,"e.$1<=",/calc([^)]+)/g,"($1)",/(\d+[\.]*[\d]*)([a-z]+)/g,"($1 * e.$2)",/^(?!(e.[a-z]|[0-9\.&=|><\+\-\*\(\)\/])).*/gi,"")+";"});return function(b,d){var e;if(!(b in N))if(N[b]=!1,d&&(e=b.match(a)))N[b]=e[1]*Q[e[2]];else try{N[b]=new Function("e",c(b))(Q)}catch(f){}return N[b]}}(),aa=function(a,b){return a.w?(a.cWidth=s.calcListLength(b||"100vw"),a.res=a.w/a.cWidth):a.res=a.d,a},ba=function(a){if(t){var c,d,e,f=a||{};if(f.elements&&1===f.elements.nodeType&&("IMG"===f.elements.nodeName.toUpperCase()?f.elements=[f.elements]:(f.context=f.elements,f.elements=null)),c=f.elements||s.qsa(f.context||b,f.reevaluate||f.reselect?s.sel:s.selShort),e=c.length){for(s.setupRun(f),S=!0,d=0;e>d;d++)s.fillImg(c[d],f);s.teardownRun(f)}}};o=a.console&&console.warn?function(a){console.warn(a)}:u,G in v||(G="src"),A["image/jpeg"]=!0,A["image/gif"]=!0,A["image/png"]=!0,A["image/svg+xml"]=b.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1"),s.ns=("pf"+(new Date).getTime()).substr(0,9),s.supSrcset="srcset"in v,s.supSizes="sizes"in v,s.supPicture=!!a.HTMLPictureElement,s.supSrcset&&s.supPicture&&!s.supSizes&&!function(a){v.srcset="data:,a",a.src="data:,a",s.supSrcset=v.complete===a.complete,s.supPicture=s.supSrcset&&s.supPicture}(b.createElement("img")),s.supSrcset&&!s.supSizes?!function(){var a="data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==",c="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",d=b.createElement("img"),e=function(){var a=d.width;2===a&&(s.supSizes=!0),q=s.supSrcset&&!s.supSizes,t=!0,setTimeout(ba)};d.onload=e,d.onerror=e,d.setAttribute("sizes","9px"),d.srcset=c+" 1w,"+a+" 9w",d.src=c}():t=!0,s.selShort="picture>img,img[srcset]",s.sel=s.selShort,s.cfg=B,s.DPR=P||1,s.u=Q,s.types=A,s.setSize=u,s.makeUrl=$(function(a){return R.href=a,R.href}),s.qsa=function(a,b){return"querySelector"in a?a.querySelectorAll(b):[]},s.matchesMedia=function(){return a.matchMedia&&(matchMedia("(min-width: 0.1em)")||{}).matches?s.matchesMedia=function(a){return!a||matchMedia(a).matches}:s.matchesMedia=s.mMQ,s.matchesMedia.apply(this,arguments)},s.mMQ=function(a){return a?_(a):!0},s.calcLength=function(a){var b=_(a,!0)||!1;return 0>b&&(b=!1),b},s.supportsType=function(a){return a?A[a]:!0},s.parseSize=$(function(a){var b=(a||"").match(I);return{media:b&&b[1],length:b&&b[2]}}),s.parseSet=function(a){return a.cands||(a.cands=m(a.srcset,a)),a.cands},s.getEmValue=function(){var a;if(!p&&(a=b.body)){var c=b.createElement("div"),d=z.style.cssText,e=a.style.cssText;c.style.cssText=K,z.style.cssText=L,a.style.cssText=L,a.appendChild(c),p=c.offsetWidth,a.removeChild(c),p=parseFloat(p,10),z.style.cssText=d,a.style.cssText=e}return p||16},s.calcListLength=function(a){if(!(a in O)||B.uT){var b=s.calcLength(n(a));O[a]=b?b:Q.width}return O[a]},s.setRes=function(a){var b;if(a){b=s.parseSet(a);for(var c=0,d=b.length;d>c;c++)aa(b[c],a.sizes)}return b},s.setRes.res=aa,s.applySetCandidate=function(a,b){if(a.length){var c,d,e,f,h,k,l,m,n,o=b[s.ns],p=s.DPR;if(k=o.curSrc||b[G],l=o.curCan||j(b,k,a[0].set),l&&l.set===a[0].set&&(n=F&&!b.complete&&l.res-.1>p,n||(l.cached=!0,l.res>=p&&(h=l))),!h)for(a.sort(i),f=a.length,h=a[f-1],d=0;f>d;d++)if(c=a[d],c.res>=p){e=d-1,h=a[e]&&(n||k!==s.makeUrl(c.url))&&g(a[e].res,c.res,p,a[e].cached)?a[e]:c;break}h&&(m=s.makeUrl(h.url),o.curSrc=m,o.curCan=h,m!==k&&s.setSrc(b,h),s.setSize(b))}},s.setSrc=function(a,b){var c;a.src=b.url,"image/svg+xml"===b.set.type&&(c=a.style.width,a.style.width=a.offsetWidth+1+"px",a.offsetWidth+1&&(a.style.width=c))},s.getSet=function(a){var b,c,d,e=!1,f=a[s.ns].sets;for(b=0;bf?c=setTimeout(e,b-f):(c=null,a())};return function(){d=new Date,c||(c=setTimeout(e,b))}},h=z.clientHeight,i=function(){M=Math.max(a.innerWidth||0,z.clientWidth)!==Q.width||z.clientHeight!==h,h=z.clientHeight,M&&s.fillImgs()};Z(a,"resize",g(i,99)),Z(b,"readystatechange",e)}(),s.picturefill=ba,s.fillImgs=ba,s.teardownRun=u,ba._=s,a.picturefillCFG={pf:s,push:function(a){var b=a.shift();"function"==typeof s[b]?s[b].apply(s,a):(B[b]=a[0],S&&s.fillImgs({reselect:!0}))}};for(;J&&J.length;)a.picturefillCFG.push(J.shift());a.picturefill=ba,"object"==typeof module&&"object"==typeof module.exports?module.exports=ba:"function"==typeof define&&define.amd&&define("picturefill",function(){return ba}),s.supPicture||(A["image/webp"]=e("image/webp","data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA=="))}(window,document); // source --> https://esneux.mr.be/wp-content/uploads/js-cache-himmelen.js?ver=a3db3f8ceb41c2e8645e66c599606b9f (function($){ $(document).ready(function() { }); })(jQuery); /*2020-02-28 14:59*//* JS Generator Execution Time: 7.5101852416992E-5 seconds */;