mirror of
https://github.com/cchuster/connerchu.com
synced 2024-11-16 23:03:26 +00:00
2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
|
/*! Swipebox v1.4.4 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */
|
||
|
"use strict";!function(window,document,$,undefined){$.swipebox=function(elem,options){var ui,defaults={useCSS:!0,useCssLoadingAnimation:!0,useSVG:!0,initialIndexOnArray:0,removeTopBarOnMobile:!1,removeBottomBarOnMobile:!0,hideCloseButtonOnMobile:!1,hideBarsDelay:5e3,videoMaxWidth:1140,vimeoColor:"cccccc",beforeOpen:null,afterOpen:null,afterClose:null,afterMedia:null,nextSlide:null,prevSlide:null,loopAtEnd:!1,autoplayVideos:!1,queryStringData:{},toggleClassOnLoad:"",closeFadeOutTime:500,selector:null},plugin=this,elements=[],$elem,selector=elem.selector,isMobile=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i),isTouch=null!==isMobile||void 0!==document.createTouch||"ontouchstart"in window||"onmsgesturechange"in window||navigator.msMaxTouchPoints,supportSVG=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,winWidth=window.innerWidth?window.innerWidth:$(window).width(),winHeight=window.innerHeight?window.innerHeight:$(window).height(),currentX=0,html='<div id="swipebox-overlay">\t\t\t\t\t<div id="swipebox-container">\t\t\t\t\t\t<div id="swipebox-slider"></div>\t\t\t\t\t\t<div id="swipebox-top-bar">\t\t\t\t\t\t\t<div id="swipebox-title"></div>\t\t\t\t\t\t</div>\t\t\t\t\t\t<div id="swipebox-bottom-bar">\t\t\t\t\t\t\t<div id="swipebox-arrows">\t\t\t\t\t\t\t\t<a id="swipebox-prev"></a>\t\t\t\t\t\t\t\t<a id="swipebox-next"></a>\t\t\t\t\t\t\t\t<div id="swipebox-description"></div>\t\t\t\t\t\t\t</div>\t\t\t\t\t\t</div>\t\t\t\t\t\t<a id="swipebox-close"></a>\t\t\t\t\t</div>\t\t\t</div>';plugin.settings={},$.swipebox.close=function(){ui.closeSlide()},$.swipebox.extend=function(){return ui},plugin.init=function(){plugin.settings=$.extend({},defaults,options),$.isArray(elem)?(elements=elem,ui.target=$(window),ui.init(plugin.settings.initialIndexOnArray)):$(elem).on("click",plugin.settings.selector,(function(event){if("slide current"===event.target.parentNode.className)return!1;var index,relType,relVal;ui.destroy(),$elem=null===plugin.settings.selector?$(elem):$(elem).find(plugin.settings.selector),elements=[],relVal||(relType="data-rel",relVal=$(this).attr(relType)),relVal||(relType="rel",relVal=$(this).attr(relType)),relVal&&""!==relVal&&"nofollow"!==relVal&&($elem=$elem.filter("["+relType+'="'+relVal+'"]')),$elem.each((function(){var title=null,description=null,href=null;$(this).attr("title")&&(title=$(this).attr("title")),$(this).data("description")&&(description=$(this).data("description")),$(this).attr("href")&&(href=$(this).attr("href")),elements.push({href:href,title:title,description:description})})),index=$elem.index($(this)),event.preventDefault(),event.stopPropagation(),ui.target=$(event.target),ui.init(index)}))},plugin.refresh=function(){$.isArray(elem)||(ui.destroy(),$elem=$(selector),ui.actions())},ui={init:function(index){plugin.settings.beforeOpen&&plugin.settings.beforeOpen(),this.target.trigger("swipebox-start"),$.swipebox.isOpen=!0,this.build(),this.openSlide(index),this.openMedia(index),this.preloadMedia(index+1),this.preloadMedia(index-1),plugin.settings.afterOpen&&plugin.settings.afterOpen(index)},build:function(){var $this=this,bg;$("body").append(html),supportSVG&&!0===plugin.settings.useSVG&&$("#swipebox-overlay").addClass("useSvg"),this.doCssLoadingAnimation()&&$("#swipebox-overlay").addClass("useCssLoadingAnimation"),isMobile&&(plugin.settings.removeBottomBarOnMobile&&$("#swipebox-bottom-bar").remove(),plugin.settings.removeTopBarOnMobile&&$("#swipebox-top-bar").remove()),$.each(elements,(function(){$("#swipebox-slider").append('<div class="slide"></div>')})),this.setDim(),this.actions(),isTouch&&this.gesture(),this.keyboard(),this.animBars(),this.resize()},setDim:function(){var width,height,sliderCss={};"onorientationchange"in window?window.addEventListener("orientationchange",(function(){0===window.orientation?(width=winWidth,height=winHeight):90!==window.orientation&&-90!==window.orientation||(width=winHeight,height=winWidth)}),!1):(width=window.innerWidth?window.in
|