-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvenbox.min.js
12 lines (12 loc) · 14.8 KB
/
venbox.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*
* VenoBox - jQuery Plugin
* version: 1.9.3
* @requires jQuery >= 1.7.0
*
* Examples at http://veno.es/venobox/
* License: MIT License
* License URI: https://github.com/nicolafranchini/VenoBox/blob/master/LICENSE
* Copyright 2013-2021 Nicola Franchini - @nicolafranchini
*
*/
!function(e){"use strict";var s,a,i,t,o,c,r,l,d,n,v,u,b,h,k,p,g,m,f,x,w,y,_,C,z,B,P,M,E,O,D,N,U,V,I,j,A,R,X,Y,W,q,$,T,H,Q,S,Z,F='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24"><path d="M12 0c-6.627 0-12 5.372-12 12 0 5.084 3.163 9.426 7.627 11.174-.105-.949-.2-2.405.042-3.441.218-.937 1.407-5.965 1.407-5.965s-.359-.719-.359-1.782c0-1.668.967-2.914 2.171-2.914 1.023 0 1.518.769 1.518 1.69 0 1.029-.655 2.568-.994 3.995-.283 1.194.599 2.169 1.777 2.169 2.133 0 3.772-2.249 3.772-5.495 0-2.873-2.064-4.882-5.012-4.882-3.414 0-5.418 2.561-5.418 5.207 0 1.031.397 2.138.893 2.738.098.119.112.224.083.345l-.333 1.36c-.053.22-.174.267-.402.161-1.499-.698-2.436-2.889-2.436-4.649 0-3.785 2.75-7.262 7.929-7.262 4.163 0 7.398 2.967 7.398 6.931 0 4.136-2.607 7.464-6.227 7.464-1.216 0-2.359-.631-2.75-1.378l-.748 2.853c-.271 1.043-1.002 2.35-1.492 3.146 1.124.347 2.317.535 3.554.535 6.627 0 12-5.373 12-12 0-6.628-5.373-12-12-12z" fill-rule="evenodd" clip-rule="evenodd"/></svg>',G='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24"><path d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm3 8h-1.35c-.538 0-.65.221-.65.778v1.222h2l-.209 2h-1.791v7h-3v-7h-2v-2h2v-2.308c0-1.769.931-2.692 3.029-2.692h1.971v3z"/></svg>',J='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24"><path d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6.066 9.645c.183 4.04-2.83 8.544-8.164 8.544-1.622 0-3.131-.476-4.402-1.291 1.524.18 3.045-.244 4.252-1.189-1.256-.023-2.317-.854-2.684-1.995.451.086.895.061 1.298-.049-1.381-.278-2.335-1.522-2.304-2.853.388.215.83.344 1.301.359-1.279-.855-1.641-2.544-.889-3.835 1.416 1.738 3.533 2.881 5.92 3.001-.419-1.796.944-3.527 2.799-3.527.825 0 1.572.349 2.096.907.654-.128 1.27-.368 1.824-.697-.215.671-.67 1.233-1.263 1.589.581-.07 1.135-.224 1.649-.453-.384.578-.87 1.084-1.433 1.489z"/></svg>',K='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24"><path d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-2 16h-2v-6h2v6zm-1-6.891c-.607 0-1.1-.496-1.1-1.109 0-.612.492-1.109 1.1-1.109s1.1.497 1.1 1.109c0 .613-.493 1.109-1.1 1.109zm8 6.891h-1.998v-2.861c0-1.881-2.002-1.722-2.002 0v2.861h-2v-6h2v1.093c.872-1.616 4-1.736 4 1.548v3.359z"/></svg>',L='<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24"><path d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm2 9h-4v-1h4v1zm0-3v1h-4v-1h4zm-2 13l-6-6h4v-3h4v3h4l-6 6z"/></svg>';e.fn.extend({venobox:function(ee){var se=this,ae=e.extend({arrowsColor:"#B6B6B6",noArrows:!1,autoplay:!1,bgcolor:"#fff",border:"0",closeBackground:"transparent",closeColor:"#d2d2d2",framewidth:"",frameheight:"",gallItems:!1,infinigall:!1,htmlClose:"×",htmlNext:"<span>Next</span>",htmlPrev:"<span>Prev</span>",numeratio:!1,numerationBackground:"#161617",numerationColor:"#d2d2d2",numerationPosition:"top",overlayClose:!0,overlayColor:"rgba(23,23,23,0.85)",spinner:"double-bounce",spinColor:"#d2d2d2",titleattr:"title",titleBackground:"#161617",titleColor:"#d2d2d2",titlePosition:"top",share:[],cb_pre_open:function(){return!0},cb_post_open:function(){},cb_pre_close:function(){return!0},cb_post_close:function(){},cb_post_resize:function(){},cb_after_nav:function(){},cb_content_loaded:function(){},cb_init:function(){}},ee);return ae.cb_init(se),this.each(function(){if((U=e(this)).data("venobox"))return!0;function ee(){z=U.data("gall"),w=U.data("numeratio"),k=U.data("gallItems"),p=U.data("infinigall"),Q=U.data("share"),x=U.data("noArrows"),o.html(""),"iframe"!==U.data("vbtype")&&"inline"!==U.data("vbtype")&&"ajax"!==U.data("vbtype")&&(S={pinterest:'<a target="_blank" href="https://pinterest.com/pin/create/button/?url='+U.prop("href")+"&media="+U.prop("href")+"&description="+C+'">'+F+"</a>",facebook:'<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u='+U.prop("href")+'">'+G+"</a>",twitter:'<a target="_blank" href="https://twitter.com/intent/tweet?text='+C+"&url="+U.prop("href")+'">'+J+"</a>",linkedin:'<a target="_blank" href="https://www.linkedin.com/sharing/share-offsite/?url='+U.prop("href")+'">'+K+"</a>",download:'<a target="_blank" href="'+U.prop("href")+'">'+L+"</a>"},e.each(Q,function(e,s){o.append(S[s])})),(g=k||e('.vbox-item[data-gall="'+z+'"]')).length<2&&(p=!1,w=!1),B=g.eq(g.index(U)+1),P=g.eq(g.index(U)-1),B.length||!0!==p||(B=g.eq(0)),g.length>=1?(V=g.index(U)+1,t.html(V+" / "+g.length)):V=1,!0===w?t.show():t.hide(),""!==C?c.show():c.hide(),B.length||!0===p?(e(".vbox-next").css("display","block"),M=!0):(e(".vbox-next").css("display","none"),M=!1),g.index(U)>0||!0===p?(e(".vbox-prev").css("display","block"),E=!0):(e(".vbox-prev").css("display","none"),E=!1),1==x&&(e(".vbox-prev, .vbox-next ").css("display","none"),E=!1),!0!==E&&!0!==M||(n.on(ne.DOWN,re),n.on(ne.MOVE,le),n.on(ne.UP,de))}function ie(e){return!(e.length<1)&&(!m&&(m=!0,y=e.data("overlay")||e.data("overlaycolor"),b=e.data("framewidth"),h=e.data("frameheight"),r=e.data("border"),a=e.data("bgcolor"),v=e.data("href")||e.attr("href"),s=e.data("autoplay"),C=e.data("titleattr")&&e.attr(e.data("titleattr"))||"",e===P&&n.addClass("vbox-animated").addClass("swipe-right"),e===B&&n.addClass("vbox-animated").addClass("swipe-left"),D.show(),void n.animate({opacity:0},500,function(){_.css("background",y),n.removeClass("vbox-animated").removeClass("swipe-left").removeClass("swipe-right").css({"margin-left":0,"margin-right":0}),"iframe"==e.data("vbtype")?ke():"inline"==e.data("vbtype")?ge():"ajax"==e.data("vbtype")?he():"video"==e.data("vbtype")?pe(s):(n.html('<img src="'+v+'">'),me()),U=e,ee(),m=!1,ae.cb_after_nav(U,V,B,P)})))}function te(e){27===e.keyCode&&oe(),37==e.keyCode&&!0===E&&ie(P),39==e.keyCode&&!0===M&&ie(B)}function oe(){if(!1===ae.cb_pre_close(U,V,B,P))return!1;e("body").off("keydown",te).removeClass("vbox-open"),U.focus(),_.animate({opacity:0},500,function(){_.remove(),m=!1,ae.cb_post_close()})}se.VBclose=function(){oe()},U.addClass("vbox-item"),U.data("framewidth",ae.framewidth),U.data("frameheight",ae.frameheight),U.data("border",ae.border),U.data("bgcolor",ae.bgcolor),U.data("numeratio",ae.numeratio),U.data("gallItems",ae.gallItems),U.data("infinigall",ae.infinigall),U.data("noArrows",ae.noArrows),U.data("overlaycolor",ae.overlayColor),U.data("titleattr",ae.titleattr),U.data("share",ae.share),U.data("venobox",!0),U.on("click",function(k){if(k.preventDefault(),U=e(this),!1===ae.cb_pre_open(U))return!1;switch(U.blur(),se.VBnext=function(){ie(B)},se.VBprev=function(){ie(P)},y=U.data("overlay")||U.data("overlaycolor"),b=U.data("framewidth"),h=U.data("frameheight"),s=U.data("autoplay")||ae.autoplay,r=U.data("border"),a=U.data("bgcolor"),M=!1,E=!1,m=!1,v=U.data("href")||U.attr("href"),u=U.data("css")||"",C=U.attr(U.data("titleattr"))||"",Q=U.data("share"),O='<div class="vbox-preloader">',ae.spinner){case"rotating-plane":O+='<div class="sk-rotating-plane"></div>';break;case"double-bounce":O+='<div class="sk-double-bounce"><div class="sk-child sk-double-bounce1"></div><div class="sk-child sk-double-bounce2"></div></div>';break;case"wave":O+='<div class="sk-wave"><div class="sk-rect sk-rect1"></div><div class="sk-rect sk-rect2"></div><div class="sk-rect sk-rect3"></div><div class="sk-rect sk-rect4"></div><div class="sk-rect sk-rect5"></div></div>';break;case"wandering-cubes":O+='<div class="sk-wandering-cubes"><div class="sk-cube sk-cube1"></div><div class="sk-cube sk-cube2"></div></div>';break;case"spinner-pulse":O+='<div class="sk-spinner sk-spinner-pulse"></div>';break;case"chasing-dots":O+='<div class="sk-chasing-dots"><div class="sk-child sk-dot1"></div><div class="sk-child sk-dot2"></div></div>';break;case"three-bounce":O+='<div class="sk-three-bounce"><div class="sk-child sk-bounce1"></div><div class="sk-child sk-bounce2"></div><div class="sk-child sk-bounce3"></div></div>';break;case"circle":O+='<div class="sk-circle"><div class="sk-circle1 sk-child"></div><div class="sk-circle2 sk-child"></div><div class="sk-circle3 sk-child"></div><div class="sk-circle4 sk-child"></div><div class="sk-circle5 sk-child"></div><div class="sk-circle6 sk-child"></div><div class="sk-circle7 sk-child"></div><div class="sk-circle8 sk-child"></div><div class="sk-circle9 sk-child"></div><div class="sk-circle10 sk-child"></div><div class="sk-circle11 sk-child"></div><div class="sk-circle12 sk-child"></div></div>';break;case"cube-grid":O+='<div class="sk-cube-grid"><div class="sk-cube sk-cube1"></div><div class="sk-cube sk-cube2"></div><div class="sk-cube sk-cube3"></div><div class="sk-cube sk-cube4"></div><div class="sk-cube sk-cube5"></div><div class="sk-cube sk-cube6"></div><div class="sk-cube sk-cube7"></div><div class="sk-cube sk-cube8"></div><div class="sk-cube sk-cube9"></div></div>';break;case"fading-circle":O+='<div class="sk-fading-circle"><div class="sk-circle1 sk-circle"></div><div class="sk-circle2 sk-circle"></div><div class="sk-circle3 sk-circle"></div><div class="sk-circle4 sk-circle"></div><div class="sk-circle5 sk-circle"></div><div class="sk-circle6 sk-circle"></div><div class="sk-circle7 sk-circle"></div><div class="sk-circle8 sk-circle"></div><div class="sk-circle9 sk-circle"></div><div class="sk-circle10 sk-circle"></div><div class="sk-circle11 sk-circle"></div><div class="sk-circle12 sk-circle"></div></div>';break;case"folding-cube":O+='<div class="sk-folding-cube"><div class="sk-cube1 sk-cube"></div><div class="sk-cube2 sk-cube"></div><div class="sk-cube4 sk-cube"></div><div class="sk-cube3 sk-cube"></div></div>'}return O+="</div>",N='<a class="vbox-next">'+ae.htmlNext+'</a><a class="vbox-prev">'+ae.htmlPrev+"</a>",j='<div class="vbox-title"></div><div class="vbox-left"><div class="vbox-num">0/0</div></div><div class="vbox-close">'+ae.htmlClose+"</div>",'<div class="vbox-share"></div>',l='<div class="vbox-overlay '+u+'" style="background:'+y+'">'+O+'<div class="vbox-container"><div class="vbox-content"></div></div>'+j+N+'<div class="vbox-share"></div></div>',e("body").append(l).addClass("vbox-open"),e(".vbox-preloader div:not(.sk-circle) .sk-child, .vbox-preloader .sk-rotating-plane, .vbox-preloader .sk-rect, .vbox-preloader div:not(.sk-folding-cube) .sk-cube, .vbox-preloader .sk-spinner-pulse").css("background-color",ae.spinColor),_=e(".vbox-overlay"),d=e(".vbox-container"),n=e(".vbox-content"),i=e(".vbox-left"),t=e(".vbox-num"),o=e(".vbox-share"),c=e(".vbox-title"),(D=e(".vbox-preloader")).show(),Z="top"==ae.titlePosition?"bottom":"top",o.css(Z,"-1px"),o.css({color:ae.titleColor,fill:ae.titleColor,"background-color":ae.titleBackground}),c.css(ae.titlePosition,"-1px"),c.css({color:ae.titleColor,"background-color":ae.titleBackground}),e(".vbox-close").css({color:ae.closeColor,"background-color":ae.closeBackground}),i.css(ae.numerationPosition,"-1px"),i.css({color:ae.numerationColor,"background-color":ae.numerationBackground}),e(".vbox-next span, .vbox-prev span").css({"border-top-color":ae.arrowsColor,"border-right-color":ae.arrowsColor}),n.html(""),n.css("opacity","0"),_.css("opacity","0"),ee(),_.animate({opacity:1},250,function(){"iframe"==U.data("vbtype")?ke():"inline"==U.data("vbtype")?ge():"ajax"==U.data("vbtype")?he():"video"==U.data("vbtype")?pe(s):(n.html('<img src="'+v+'">'),me()),ae.cb_post_open(U,V,B,P)}),e("body").keydown(te),e(".vbox-prev").on("click",function(){ie(P)}),e(".vbox-next").on("click",function(){ie(B)}),!1});var ce=".vbox-overlay";function re(e){n.addClass("vbox-animated"),R=Y=e.pageY,X=W=e.pageX,I=!0}function le(e){if(!0===I){W=e.pageX,Y=e.pageY,$=W-X,T=Y-R;var s=Math.abs($);s>Math.abs(T)&&s<=100&&(e.preventDefault(),n.css("margin-left",$))}}function de(e){if(!0===I){I=!1;var s=U,a=!1;(q=W-X)<0&&!0===M&&(s=B,a=!0),q>0&&!0===E&&(s=P,a=!0),Math.abs(q)>=H&&!0===a?ie(s):n.css({"margin-left":0,"margin-right":0})}}ae.overlayClose||(ce=".vbox-close"),e("body").on("click touchstart",ce,function(s){(e(s.target).is(".vbox-overlay")||e(s.target).is(".vbox-content")||e(s.target).is(".vbox-close")||e(s.target).is(".vbox-preloader")||e(s.target).is(".vbox-container"))&&oe()}),X=0,W=0,q=0,H=50,I=!1;var ne={DOWN:"touchmousedown",UP:"touchmouseup",MOVE:"touchmousemove"},ve=function(s){var a;switch(s.type){case"mousedown":a=ne.DOWN;break;case"mouseup":case"mouseout":a=ne.UP;break;case"mousemove":a=ne.MOVE;break;default:return}var i=be(a,s,s.pageX,s.pageY);e(s.target).trigger(i)},ue=function(s){var a;switch(s.type){case"touchstart":a=ne.DOWN;break;case"touchend":a=ne.UP;break;case"touchmove":a=ne.MOVE;break;default:return}var i,t=s.originalEvent.touches[0];i=a==ne.UP?be(a,s,null,null):be(a,s,t.pageX,t.pageY),e(s.target).trigger(i)},be=function(s,a,i,t){return e.Event(s,{pageX:i,pageY:t,originalEvent:a})};function he(){e.ajax({url:v,cache:!1}).done(function(e){n.html('<div class="vbox-inline">'+e+"</div>"),me()}).fail(function(){n.html('<div class="vbox-inline"><p>Error retrieving contents, please retry</div>'),fe()})}function ke(){n.html('<iframe class="venoframe" src="'+v+'"></iframe>'),fe()}function pe(e){var s,a=function(e){var s;e.match(/(http:|https:|)\/\/(player.|www.)?(vimeo\.com|youtu(be\.com|\.be|be\.googleapis\.com))\/(video\/|embed\/|watch\?v=|v\/)?([A-Za-z0-9._%-]*)(\&\S+)?/),RegExp.$3.indexOf("youtu")>-1?s="youtube":RegExp.$3.indexOf("vimeo")>-1&&(s="vimeo");return{type:s,id:RegExp.$6}}(v),i=(e?"?rel=0&autoplay=1":"?rel=0")+function(e){var s="",a=decodeURIComponent(e).split("?");if(void 0!==a[1]){var i,t,o=a[1].split("&");for(t=0;t<o.length;t++)i=o[t].split("="),s=s+"&"+i[0]+"="+i[1]}return encodeURI(s)}(v);"vimeo"==a.type?s="https://player.vimeo.com/video/":"youtube"==a.type&&(s="https://www.youtube.com/embed/"),n.html('<iframe class="venoframe vbvid" webkitallowfullscreen mozallowfullscreen allowfullscreen allow="autoplay" frameborder="0" src="'+s+a.id+i+'"></iframe>'),fe()}function ge(){n.html('<div class="vbox-inline">'+e(v).html()+"</div>"),fe()}function me(){(A=n.find("img")).length?A.each(function(){e(this).one("load",function(){fe()})}):fe()}function fe(){c.html(C),n.find(">:first-child").addClass("vbox-figlio").css({width:b,height:h,padding:r,background:a}),e("img.vbox-figlio").on("dragstart",function(e){e.preventDefault()}),d.scrollTop(0),xe(),n.animate({opacity:"1"},"slow",function(){D.hide()}),ae.cb_content_loaded(U,V,B,P)}function xe(){var s=n.outerHeight(),a=e(window).height();f=s+60<a?(a-s)/2:"30px",n.css("margin-top",f),n.css("margin-bottom",f),ae.cb_post_resize()}"ontouchstart"in window?(e(document).on("touchstart",ue),e(document).on("touchmove",ue),e(document).on("touchend",ue)):(e(document).on("mousedown",ve),e(document).on("mouseup",ve),e(document).on("mouseout",ve),e(document).on("mousemove",ve)),e(window).resize(function(){e(".vbox-content").length&&setTimeout(xe(),800)})})}})}(jQuery);