10 lines
14 KiB
JavaScript
10 lines
14 KiB
JavaScript
|
/*
|
||
|
* custombox v3.0.0 - 2015-08-04
|
||
|
* Modal Window Effects with transitions CSS3.
|
||
|
* http://dixso.github.io/custombox/
|
||
|
* (c) 2015 Julio de la Calle - @dixso9
|
||
|
*
|
||
|
* Under MIT License - http://opensource.org/licenses/MIT
|
||
|
*/
|
||
|
|
||
|
!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Custombox=b()}(this,function(){"use strict";var a={target:null,cache:!1,escKey:!0,zIndex:9999,overlay:!0,overlayColor:"#000",overlayOpacity:.8,overlayClose:!0,overlaySpeed:300,overlayEffect:"auto",width:null,effect:"fadein",position:["center","center"],animation:null,speed:500,loading:!1,open:null,complete:null,close:null},b={oldIE:navigator.appVersion.indexOf("MSIE 8.")>-1||navigator.appVersion.indexOf("MSIE 9.")>-1,oldMobile:/(iPhone|iPad|iPod)\sOS\s6/.test(navigator.userAgent),overlay:{perspective:["letmein","makeway","slip"],together:["corner","slidetogether","scale","door","push","contentscale","simplegenie","slit","slip"]},modal:{position:["slide","flip","rotate"],animationend:["swell","rotatedown","flash"]}},c={set:function(c){if(this.cb&&this.cb.length||(this.cb=[],this.item=-1),this.item++,c&&"auto"===c.zIndex){for(var d=0,e=0,f=document.getElementsByTagName("*"),g=f.length;g>e;e+=1){var h=window.getComputedStyle(f[e]).getPropertyValue("z-index");h&&(h=+h,h>d&&(d=h))}c.zIndex=d}this.cb.push({settings:b.oldIE&&"undefined"!=typeof cbExtendObjects?cbExtendObjects({},a,c):Object.assign({},a,c)}),"auto"===this.cb[this.item].settings.overlayEffect&&(this.cb[this.item].settings.overlayEffect=this.cb[this.item].settings.effect)},get:function(){return this.cb[this.cb.length-1]||null},init:function(){document.documentElement.classList.add("custombox-open"),document.documentElement.classList.add("custombox-open-"+this.cb[this.item].settings.overlayEffect),b.overlay.perspective.indexOf(this.cb[this.item].settings.overlayEffect)>-1&&(this.cb[this.item].scroll=document.documentElement&&document.documentElement.scrollTop||document.body&&document.body.scrollTop||0,document.documentElement.classList.add("custombox-perspective"),window.scrollTo(0,0)),this.main||this.built("container"),this.cb[this.item].settings.loading&&this.cb[this.item].settings.loading.parent&&this.built("loading"),this.cb[this.item].settings.overlay?this.built("overlay").built("modal").open():this.built("modal").open(),this.binds()},zIndex:function(){for(var a=0,b=0,c=document.getElementsByTagName("*"),d=c.length;d>b;b+=1){var e=window.getComputedStyle(c[b]).getPropertyValue("z-index");e&&(e=+e,e>a&&(a=e))}return a},built:function(a){var c;switch("undefined"!=typeof this.item&&(c=this.cb[this.item]),a){case"container":for(this.main=document.createElement("div");document.body.firstChild;)this.main.appendChild(document.body.firstChild);document.body.appendChild(this.main);break;case"overlay":c.overlay||(c.overlay={}),c.overlay=document.createElement("div"),c.overlay.classList.add("custombox-overlay"),c.overlay.classList.add("custombox-overlay-"+c.settings.overlayEffect),c.overlay.style.zIndex=c.settings.zIndex+2,c.overlay.style.backgroundColor=c.settings.overlayColor,b.overlay.perspective.indexOf(c.settings.overlayEffect)>-1||b.overlay.together.indexOf(c.settings.overlayEffect)>-1?c.overlay.style.opacity=c.settings.overlayOpacity:c.overlay.classList.add("custombox-overlay-default"),c.overlay.style.transitionDuration=b.overlay.together.indexOf(c.settings.overlayEffect)>-1?c.settings.speed+"ms":c.settings.overlaySpeed+"ms",document.body.insertBefore(c.overlay,document.body.lastChild.nextSibling);break;case"modal":"push"===c.settings.overlayEffect&&(this.main.style.transitionDuration=c.settings.speed+"ms"),this.main.classList.add("custombox-container"),this.main.classList.add("custombox-container-"+c.settings.overlayEffect),c.wrapper=document.createElement("div"),c.wrapper.classList.add("custombox-modal-wrapper"),c.wrapper.classList.add("custombox-modal-wrapper-"+c.settings.effect),c.wrapper.style.zIndex=c.settings.zIndex+3,document.body.insertBefore(c.wrapper,document.body.lastChild.nextSibling),c.container=document.createElement("div"),c.container.classList.add("custombox-modal-container"),c.container.classList.add("custombox-modal-container-"+c.settings.effect),c.container.style.zIndex=c.settings.zIndex+4,b.modal.position.in
|