From 2ebd9730fba6f7986e52a28a3e5eb87cd0e9c15b Mon Sep 17 00:00:00 2001 From: dolce Date: Mon, 8 Aug 2016 20:57:57 -0300 Subject: [PATCH] Update v1.3.1 --- css/iziModal.css | 2 +- css/iziModal.min.css | 2 +- js/iziModal.js | 33 ++++++++++++++++++--------------- js/iziModal.min.js | 4 ++-- package.json | 2 +- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/css/iziModal.css b/css/iziModal.css index f444502..d5eb5f3 100644 --- a/css/iziModal.css +++ b/css/iziModal.css @@ -1,5 +1,5 @@ /* -* iziModal | v1.3.0 +* iziModal | v1.3.1 * http://izimodal.marcelodolce.com * by Marcelo Dolce. */ diff --git a/css/iziModal.min.css b/css/iziModal.min.css index ed3917e..e0c929e 100644 --- a/css/iziModal.min.css +++ b/css/iziModal.min.css @@ -1,5 +1,5 @@ /* -* iziModal | v1.3.0 +* iziModal | v1.3.1 * http://izimodal.marcelodolce.com * by Marcelo Dolce. */ diff --git a/js/iziModal.js b/js/iziModal.js index 2fcafda..50472d3 100644 --- a/js/iziModal.js +++ b/js/iziModal.js @@ -1,5 +1,5 @@ /* -* iziModal | v1.3.0 +* iziModal | v1.3.1 * http://izimodal.marcelodolce.com * by Marcelo Dolce. */ @@ -166,7 +166,9 @@ medida = "px"; wClear = String(wClear).split(",")[0]; - if(isNaN(parseInt(options.width))){ + + if(isNaN(options.width)){ + if( String(options.width).indexOf("%") != -1){ medida = "%"; } else { @@ -177,9 +179,10 @@ 'margin-left': -(wClear / 2) + medida, 'max-width': parseInt(wClear) + medida }); - that.mediaQueries = ''; - - that.width = wClear; + + that.width = that.$element.outerWidth(); + + that.mediaQueries = ''; $(document.body).append(that.mediaQueries); @@ -296,17 +299,16 @@ }); var href = null; - if(this.options.iframeURL !== null){ + try { + href = $(param.currentTarget).attr('href') !== "" ? $(param.currentTarget).attr('href') : null; + } catch(e) { + console.warn(e); + } + if( (this.options.iframeURL !== null) && (href === null || href === undefined)){ href = this.options.iframeURL; - } else { - try { - href = param.target.href; - if(href !== undefined){ - href = param.target.href; - } - } catch(e) { - console.warn(e); - } + } + if(href === null || href === undefined){ + alert("Failed to find iframe URL."); } this.$element.find('.'+PLUGIN_NAME+'-iframe').attr('src', href); } @@ -465,6 +467,7 @@ document.title = oldTitle + " - " + that.options.title; document.location.hash = that.id; document.title = oldTitle; + //history.pushState({}, that.options.title, "#"+that.id); } })(); diff --git a/js/iziModal.min.js b/js/iziModal.min.js index 14eff73..1ec3012 100644 --- a/js/iziModal.min.js +++ b/js/iziModal.min.js @@ -1,6 +1,6 @@ /* -* iziModal | v1.3.0 +* iziModal | v1.3.1 * http://izimodal.marcelodolce.com * by Marcelo Dolce. */ -(function(t){"use strict";function e(){var t,e=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}var i=t(window),n=t(document),o="iziModal",s={CLOSING:"closing",CLOSED:"closed",OPENING:"opening",OPENED:"opened",DESTROYED:"destroyed"},a=e(),r=!!/Mobi/.test(navigator.userAgent),l=0,d=function(t,e){this.init(t,e)};d.prototype={constructor:d,init:function(e,i){var n=this;this.$element=t(e),this.id=this.$element.attr("id"),this.content=this.$element.html(),this.state=s.CLOSED,this.options=i,this.width=0,this.timer=null,this.timerTimeout=null,this.progressBar=null,this.isPaused=!1,this.isFullscreen=!1,this.headerHeight=0,this.modalHeight=0,this.$overlay=t('
'),this.$navigate=t('
Use
'),this.group={name:this.$element.attr("data-"+o+"-group"),index:null,ids:[]},void 0!==this.$element.attr("data-"+o+"-title")&&(i.title=this.$element.attr("data-"+o+"-title")),void 0!==this.$element.attr("data-"+o+"-subtitle")&&(i.subtitle=this.$element.attr("data-"+o+"-subtitle")),void 0!==this.$element.attr("data-"+o+"-icon")&&(i.icon=this.$element.attr("data-"+o+"-icon")),this.options.loop===!0&&this.$element.attr("data-"+o+"-loop",!0),this.$header=t('

'+i.title+'

'+i.subtitle+'

"),i.fullscreen===!0&&(this.$header.append('"),this.$header.css("padding-right","76px")),i.timeoutProgressbar!==!0||isNaN(parseInt(i.timeout))||i.timeout===!1||0===i.timeout||this.$header.prepend('
'),i.iframe===!0?(this.$element.html('
'+this.content+"
"),null!==i.iframeHeight&&this.$element.find("."+o+"-iframe").css("height",i.iframeHeight)):this.$element.html('
'+this.content+"
"),""===i.subtitle&&this.$header.addClass(o+"-noSubtitle"),""===i.title&&""===i.subtitle||(null!==i.headerColor&&(this.$element.css("border-bottom","3px solid "+i.headerColor),this.$header.css("background",this.options.headerColor)),null!==i.icon&&(this.$header.prepend(''),this.$header.find("."+o+"-header-icon").css("color",i.iconColor)),this.$element.css("overflow","hidden").prepend(this.$header)),null===i.zindex||isNaN(parseInt(i.zindex))||(this.$element.css("z-index",i.zindex),this.$navigate.css("z-index",i.zindex-1),this.$overlay.css("z-index",i.zindex-2)),""!==i.radius&&this.$element.css("border-radius",i.radius),""!==i.padding&&this.$element.find("."+o+"-content").css("padding",i.padding),""!==i.theme&&this.$element.addClass(i.theme),this.$element.addClass(o),i.openFullscreen===!0&&(this.isFullscreen=!0,this.$element.addClass("isFullscreen")),"top"!==i.attached&&"top"!=this.$element.attr("data-"+o+"-attached")||this.$element.addClass("isAttachedTop"),"bottom"!==i.attached&&"bottom"!=this.$element.attr("data-"+o+"-attached")||this.$element.addClass("isAttachedBottom"),function(){t(document.body).find("style[rel="+n.id+"]").remove();var e=/%|px|em|cm/,s=String(i.width).split(e),a=String(i.width),r="px";s=String(s).split(",")[0],isNaN(parseInt(i.width))&&(r=-1!=String(i.width).indexOf("%")?"%":a.slice("-2")),n.$element.css({"margin-left":-(s/2)+r,"max-width":parseInt(s)+r}),n.mediaQueries='",n.width=s,t(document.body).append(n.mediaQueries),n.$element.css("margin-top",parseInt(-(n.$element.innerHeight()/2))+"px")}(),function(){if(void 0!==n.$element.attr("data-"+o+"-group")){var e=0;t.each(t("."+o+"[data-"+o+"-group="+n.group.name+"]"),function(i,o){n.group.ids.push(t(this).attr("id")),n.id==t(this).attr("id")&&(n.group.index=e),e++})}}()},toggle:function(){this.state==s.OPENED&&this.close(),this.state==s.CLOSED&&this.open()},open:function(e){function i(){d.$element.trigger(s.OPENED),d.state=s.OPENED,d.options.onOpened&&"function"==typeof d.options.onOpened&&d.options.onOpened(d)}function l(){d.$element.off("click","[data-"+o+"-close]").on("click","[data-"+o+"-close]",function(e){e.preventDefault();var i=t(e.currentTarget).attr("data-"+o+"-transitionOut");void 0!==i?d.close({transition:i}):d.close()}),d.$element.off("click","[data-"+o+"-fullscreen]").on("click","[data-"+o+"-fullscreen]",function(t){t.preventDefault(),d.isFullscreen===!0?(d.isFullscreen=!1,d.$element.removeClass("isFullscreen")):(d.isFullscreen=!0,d.$element.addClass("isFullscreen")),d.options.onFullscreen&&"function"==typeof d.options.onFullscreen&&d.options.onFullscreen(d),d.$element.trigger("fullscreen",d)}),d.$navigate.off("click","."+o+"-navigate-next").on("click","."+o+"-navigate-next",function(t){d.next(t)}),d.$element.off("click","[data-"+o+"-next]").on("click","[data-"+o+"-next]",function(t){d.next(t)}),d.$navigate.off("click","."+o+"-navigate-prev").on("click","."+o+"-navigate-prev",function(t){d.prev(t)}),d.$element.off("click","[data-"+o+"-prev]").on("click","[data-"+o+"-prev]",function(t){d.prev(t)})}var d=this;if(this.state==s.CLOSED){if(l(),this.$element.trigger(s.OPENING),this.state=s.OPENING,this.options.iframe===!0){this.$element.find("."+o+"-content").addClass(o+"-content-loader"),this.$element.find("."+o+"-iframe").on("load",function(){t(this).parent().removeClass(o+"-content-loader")});var h=null;if(null!==this.options.iframeURL)h=this.options.iframeURL;else try{h=e.target.href,void 0!==h&&(h=e.target.href)}catch(c){console.warn(c)}this.$element.find("."+o+"-iframe").attr("src",h)}(this.options.bodyOverflow||r)&&t(document.body).css("overflow","hidden"),d.options.onOpening&&"function"==typeof d.options.onOpening&&d.options.onOpening(this),function(){if(d.group.ids.length>1){d.$navigate.appendTo("body"),d.$navigate.addClass(d.options.transitionInOverlay),d.options.navigateCaption===!0&&d.$navigate.find("."+o+"-navigate-caption").show(),d.options.navigateArrows===!0||"closeToModal"===d.options.navigateArrows?(d.$navigate.find("."+o+"-navigate-prev").css("margin-left",-(d.width/2+84)),d.$navigate.find("."+o+"-navigate-next").css("margin-right",-(d.width/2+84))):(d.$navigate.find("."+o+"-navigate-prev").css("left",0),d.$navigate.find("."+o+"-navigate-next").css("right",0));var n;0===d.group.index&&(n=t("."+o+"[data-"+o+'-group="'+d.group.name+'"][data-'+o+"-loop]").length,0===n&&d.options.loop===!1&&d.$navigate.find("."+o+"-navigate-prev").hide()),d.group.index+1===d.group.ids.length&&(n=t("."+o+"[data-"+o+'-group="'+d.group.name+'"][data-'+o+"-loop]").length,0===n&&d.options.loop===!1&&d.$navigate.find("."+o+"-navigate-next").hide())}d.options.overlay===!0&&d.$overlay.appendTo("body"),d.options.transitionInOverlay&&d.$overlay.addClass(d.options.transitionInOverlay);var s=d.options.transitionIn;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionIn||(s=e.transition||e.transitionIn)),""!==s?(d.$element.addClass("transitionIn "+s).show(),d.$element.find("."+o+"-wrap").one(a,function(){d.$element.removeClass(s+" transitionIn"),d.$overlay.removeClass(d.options.transitionInOverlay),d.$navigate.removeClass(d.options.transitionInOverlay),i()})):(d.$element.show(),i()),d.options.pauseOnHover!==!0||d.options.pauseOnHover!==!0||d.options.timeout===!1||isNaN(parseInt(d.options.timeout))||d.options.timeout===!1||0===d.options.timeout||(d.$element.off("mouseenter").on("mouseenter",function(t){t.preventDefault(),d.isPaused=!0}),d.$element.off("mouseleave").on("mouseleave",function(t){t.preventDefault(),d.isPaused=!1}))}(),this.options.timeout===!1||isNaN(parseInt(this.options.timeout))||this.options.timeout===!1||0===this.options.timeout||(this.options.timeoutProgressbar===!0?(this.progressBar={hideEta:null,maxHideTime:null,currentTime:(new Date).getTime(),el:this.$element.find("."+o+"-progressbar > div"),updateProgress:function(){if(!d.isPaused){d.progressBar.currentTime=d.progressBar.currentTime+10;var t=(d.progressBar.hideEta-d.progressBar.currentTime)/d.progressBar.maxHideTime*100;d.progressBar.el.width(t+"%"),0>t&&d.close()}}},this.options.timeout>0&&(this.progressBar.maxHideTime=parseFloat(this.options.timeout),this.progressBar.hideEta=(new Date).getTime()+this.progressBar.maxHideTime,this.timerTimeout=setInterval(this.progressBar.updateProgress,10))):this.timerTimeout=setTimeout(function(){d.close()},d.options.timeout)),this.options.overlayClose&&!this.$element.hasClass(this.options.transitionOut)&&this.$overlay.click(function(){d.close()}),this.options.focusInput&&this.$element.find(":input:not(button):enabled:visible:first").focus(),function u(){d.recalculateLayout(),d.timer=setTimeout(u,300)}(),function(){if(d.options.history||r){var t=document.title;document.title=t+" - "+d.options.title,document.location.hash=d.id,document.title=t}}(),n.keydown(function(t){d.options.closeOnEscape&&27===t.keyCode&&d.close()})}},close:function(e){function i(){l.options.iframe===!0&&l.$element.find("."+o+"-iframe").attr("src",""),(l.options.bodyOverflow||r)&&t(document.body).css("overflow","initial"),t(document.body).removeClass(o+"-attached"),l.$element.trigger(s.CLOSED),l.state=s.CLOSED,l.options.onClosed&&"function"==typeof l.options.onClosed&&l.options.onClosed(l),l.options.restoreDefaultContent===!0&&l.$element.find("."+o+"-content").html(l.content)}var l=this;if(this.state==s.OPENED||this.state==s.OPENING){n.off("keydown"),this.state=s.CLOSING,this.$element.trigger(s.CLOSING),clearTimeout(this.timer),clearTimeout(this.timerTimeout),l.options.onClosing&&"function"==typeof l.options.onClosing&&l.options.onClosing(this);var d=this.options.transitionOut;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionOut||(d=e.transition||e.transitionOut)),""!==d?(this.$element.attr("class",o+" transitionOut "+d+" "+this.options.theme+" "+String(this.isFullscreen===!0?"isFullscreen":"")+" "+String("top"===this.options.attached?"isAttachedTop":"")+" "+String("bottom"===this.options.attached?"isAttachedBottom":"")),this.$overlay.attr("class",o+"-overlay "+this.options.transitionOutOverlay),this.$navigate.attr("class",o+"-navigate "+this.options.transitionOutOverlay),this.$element.one(a,function(){l.$element.hasClass(d)&&l.$element.removeClass(d+" transitionOut").hide(),l.$overlay.removeClass(l.options.transitionOutOverlay).remove(),l.$navigate.removeClass(l.options.transitionOutOverlay).remove(),i()})):(this.$element.hide(),this.$overlay.remove(),this.$navigate.remove(),i())}},next:function(e){var i=this,n="fadeInRight",s="fadeOutLeft",a=t("."+o+":visible"),r={};r.out=this,void 0!==e&&"object"!=typeof e?(e.preventDefault(),a=t(e.currentTarget),n=a.attr("data-"+o+"-transitionIn"),s=a.attr("data-"+o+"-transitionOut")):void 0!==e&&(void 0!==e.transitionIn&&(n=e.transitionIn),void 0!==e.transitionOut&&(s=e.transitionOut)),this.close({transition:s}),setTimeout(function(){var e=t("."+o+"[data-"+o+'-group="'+i.group.name+'"][data-'+o+"-loop]").length;(e>0||i.options.loop===!0)&&i.group.index+1===i.group.ids.length?(t("#"+i.group.ids[0]).iziModal("open",{transition:n}),r["in"]=t("#"+i.group.ids[0]).data().iziModal):i.group.index+10||i.options.loop===!0)&&0===i.group.index?(t("#"+i.group.ids[i.group.ids.length-1]).iziModal("open",{transition:n}),r["in"]=t("#"+i.group.ids[i.group.ids.length-1]).data().iziModal):i.group.index>0&&(t("#"+i.group.ids[i.group.index-1]).iziModal("open",{transition:n}),r["in"]=t("#"+i.group.ids[i.group.index-1]).data().iziModal)},200),t(document).trigger(o+"-group-change",r)},destroy:function(){var e=t.Event("destroy");this.$element.trigger(e),n.off("keydown"),clearTimeout(this.timer),clearTimeout(this.timerTimeout),this.options.iframe===!0&&this.$element.find("."+o+"-iframe").remove(),this.$element.html(this.$element.find("."+o+"-content").html()),n.find("style[rel="+this.id+"]").remove(),this.$element.off("click","[data-"+o+"-close]"),this.$element.off("click","[data-"+o+"-fullscreen]"),this.$element.off("."+o).removeData(o).attr("style",""),this.$overlay.remove(),this.$navigate.remove(),this.$element.trigger(s.DESTROYED),this.$element=null},getState:function(){return this.state},getGroup:function(){return this.group},setTitle:function(t){null!==this.options.title&&(this.$header.find("."+o+"-header-title").html(t),this.options.title=t)},setSubtitle:function(t){null!==this.options.subtitle&&(this.$header.find("."+o+"-header-subtitle").html(t),this.options.subtitle=t)},setIcon:function(t){null!==this.options.icon&&(this.$header.find("."+o+"-header-icon").attr("class",o+"-header-icon "+t),this.options.icon=t)},setHeaderColor:function(t){this.$element.css("border-bottom","3px solid "+t),this.$header.css("background",t),this.options.headerColor=t},setZindex:function(t){isNaN(parseInt(this.options.zindex))||(this.options.zindex=t,this.$element.css("z-index",t),this.$navigate.css("z-index",t-1),this.$overlay.css("z-index",t-2))},setTransitionIn:function(t){this.options.transitionIn=param.transition},setTransitionOut:function(t){this.options.transitionOut=param.transition},startLoading:function(){this.$element.find("."+o+"-loader").length||this.$element.append('
')},stopLoading:function(){var t=this;this.$element.find("."+o+"-loader").removeClass(this.options.transitionInOverlay).addClass(this.options.transitionOutOverlay),this.$element.find("."+o+"-loader").one(a,function(){t.$element.find("."+o+"-loader").removeClass(t.options.transitionOutOverlay).remove()})},recalculateLayout:function(){this.$element.find("."+o+"-header").length&&(this.headerHeight=parseInt(this.$element.find("."+o+"-header").innerHeight())+2,this.$element.css("overflow","hidden"));var e=i.height(),n=this.$element.outerHeight(),a=this.$element.find("."+o+"-content")[0].scrollHeight,r=parseInt(-((this.$element.innerHeight()+1)/2))+"px";if(n!==this.modalHeight&&(this.modalHeight=n,this.options.onResize&&"function"==typeof this.options.onResize&&this.options.onResize(this)),this.state==s.OPENED||this.state==s.OPENING)if(this.options.iframe===!0)ea+this.headerHeight&&this.isFullscreen!==!0&&(t(document.body).removeClass(o+"-attached"),this.$element.find("."+o+"-wrap").css({height:"auto"})),(a+this.headerHeight>e||this.$element.innerHeight()h+l?this.$element.addClass("hasScroll"):this.$element.removeClass("hasScroll")}this.$element.css("margin-top")!=r&&"0px"!=this.$element.css("margin-top")&&this.$element.css("margin-top",r)}},i.off("hashchange load").on("hashchange load",function(e){0===l?""!==document.location.hash?(t.each(t("."+o),function(e,i){var n=t(i).iziModal("getState");"opened"!=n&&"opening"!=n||"#"+t(i).attr("id")!==document.location.hash&&t(i).iziModal("close")}),setTimeout(function(){t(document.location.hash).iziModal("open")},200)):t.each(t("."+o),function(e,i){var n=t(i).iziModal("getState");"opened"!=n&&"opening"!=n||t(i).iziModal("close")}):l=0}),n.off("click","[data-"+o+"-open]").on("click","[data-"+o+"-open]",function(e){e.preventDefault();var i=t("."+o+":visible").attr("id"),n=t(e.currentTarget).attr("data-"+o+"-open"),s=t(e.currentTarget).attr("data-"+o+"-transitionIn"),a=t(e.currentTarget).attr("data-"+o+"-transitionOut");void 0!==a?t("#"+i).iziModal("close",{transition:a}):t("#"+i).iziModal("close"),setTimeout(function(){void 0!==s?t("#"+n).iziModal("open",{transition:s}):t("#"+n).iziModal("open")},200)}),n.off("keyup").on("keyup",function(e){var i=t("."+o+":visible").attr("id"),n=t("#"+i).iziModal("getGroup"),s=e||window.event,a=s.target||s.srcElement;void 0===i||void 0===n||s.ctrlKey||s.metaKey||s.altKey||"INPUT"===a.tagName.toUpperCase()||"TEXTAREA"==a.tagName.toUpperCase()||(37===s.keyCode?t("#"+i).iziModal("prev",s):39===s.keyCode&&t("#"+i).iziModal("next",s))}),t.fn[o]=function(e,i){var n=t(this),s=n.data(o),a=t.extend({},t.fn.iziModal.defaults,n.data(),"object"==typeof e&&e);if(s||e&&"object"!=typeof e){if("string"==typeof e&&"undefined"!=typeof s)return s[e].apply(s,[].concat(i))}else n.data(o,s=new d(this,a));return a.autoOpen&&(isNaN(parseInt(a.autoOpen))?a.autoOpen===!0&&s.open():setTimeout(function(){s.open()},a.autoOpen),l++),this},t.fn[o].defaults={title:"",subtitle:"",headerColor:"#88A0B9",theme:"",attached:"",icon:"",iconColor:"",width:600,padding:0,radius:3,zindex:999,iframe:!1,iframeHeight:400,iframeURL:null,focusInput:!0,group:"",loop:!1,navigateCaption:!0,navigateArrows:!0,history:!0,restoreDefaultContent:!1,autoOpen:0,bodyOverflow:!1,fullscreen:!1,openFullscreen:!1,closeOnEscape:!0,overlay:!0,overlayClose:!0,overlayColor:"rgba(0, 0, 0, 0.4)",timeout:!1,timeoutProgressbar:!1,pauseOnHover:!1,timeoutProgressbarColor:"rgba(255,255,255,0.5)",transitionIn:"comingIn",transitionOut:"comingOut",transitionInOverlay:"fadeIn",transitionOutOverlay:"fadeOut",onFullscreen:function(){},onResize:function(){},onOpening:function(){},onOpened:function(){},onClosing:function(){},onClosed:function(){}},t.fn[o].Constructor=d}).call(this,window.jQuery); \ No newline at end of file +(function(t){"use strict";function e(){var t,e=document.createElement("fakeelement"),i={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in i)if(void 0!==e.style[t])return i[t]}var i=t(window),n=t(document),o="iziModal",s={CLOSING:"closing",CLOSED:"closed",OPENING:"opening",OPENED:"opened",DESTROYED:"destroyed"},a=e(),r=!!/Mobi/.test(navigator.userAgent),l=0,d=function(t,e){this.init(t,e)};d.prototype={constructor:d,init:function(e,i){var n=this;this.$element=t(e),this.id=this.$element.attr("id"),this.content=this.$element.html(),this.state=s.CLOSED,this.options=i,this.width=0,this.timer=null,this.timerTimeout=null,this.progressBar=null,this.isPaused=!1,this.isFullscreen=!1,this.headerHeight=0,this.modalHeight=0,this.$overlay=t('
'),this.$navigate=t('
Use
'),this.group={name:this.$element.attr("data-"+o+"-group"),index:null,ids:[]},void 0!==this.$element.attr("data-"+o+"-title")&&(i.title=this.$element.attr("data-"+o+"-title")),void 0!==this.$element.attr("data-"+o+"-subtitle")&&(i.subtitle=this.$element.attr("data-"+o+"-subtitle")),void 0!==this.$element.attr("data-"+o+"-icon")&&(i.icon=this.$element.attr("data-"+o+"-icon")),this.options.loop===!0&&this.$element.attr("data-"+o+"-loop",!0),this.$header=t('

'+i.title+'

'+i.subtitle+'

"),i.fullscreen===!0&&(this.$header.append('"),this.$header.css("padding-right","76px")),i.timeoutProgressbar!==!0||isNaN(parseInt(i.timeout))||i.timeout===!1||0===i.timeout||this.$header.prepend('
'),i.iframe===!0?(this.$element.html('
'+this.content+"
"),null!==i.iframeHeight&&this.$element.find("."+o+"-iframe").css("height",i.iframeHeight)):this.$element.html('
'+this.content+"
"),""===i.subtitle&&this.$header.addClass(o+"-noSubtitle"),""===i.title&&""===i.subtitle||(null!==i.headerColor&&(this.$element.css("border-bottom","3px solid "+i.headerColor),this.$header.css("background",this.options.headerColor)),null!==i.icon&&(this.$header.prepend(''),this.$header.find("."+o+"-header-icon").css("color",i.iconColor)),this.$element.css("overflow","hidden").prepend(this.$header)),null===i.zindex||isNaN(parseInt(i.zindex))||(this.$element.css("z-index",i.zindex),this.$navigate.css("z-index",i.zindex-1),this.$overlay.css("z-index",i.zindex-2)),""!==i.radius&&this.$element.css("border-radius",i.radius),""!==i.padding&&this.$element.find("."+o+"-content").css("padding",i.padding),""!==i.theme&&this.$element.addClass(i.theme),this.$element.addClass(o),i.openFullscreen===!0&&(this.isFullscreen=!0,this.$element.addClass("isFullscreen")),"top"!==i.attached&&"top"!=this.$element.attr("data-"+o+"-attached")||this.$element.addClass("isAttachedTop"),"bottom"!==i.attached&&"bottom"!=this.$element.attr("data-"+o+"-attached")||this.$element.addClass("isAttachedBottom"),function(){t(document.body).find("style[rel="+n.id+"]").remove();var e=/%|px|em|cm/,s=String(i.width).split(e),a=String(i.width),r="px";s=String(s).split(",")[0],isNaN(i.width)&&(r=-1!=String(i.width).indexOf("%")?"%":a.slice("-2")),n.$element.css({"margin-left":-(s/2)+r,"max-width":parseInt(s)+r}),n.width=n.$element.outerWidth(),n.mediaQueries='",t(document.body).append(n.mediaQueries),n.$element.css("margin-top",parseInt(-(n.$element.innerHeight()/2))+"px")}(),function(){if(void 0!==n.$element.attr("data-"+o+"-group")){var e=0;t.each(t("."+o+"[data-"+o+"-group="+n.group.name+"]"),function(i,o){n.group.ids.push(t(this).attr("id")),n.id==t(this).attr("id")&&(n.group.index=e),e++})}}()},toggle:function(){this.state==s.OPENED&&this.close(),this.state==s.CLOSED&&this.open()},open:function(e){function i(){d.$element.trigger(s.OPENED),d.state=s.OPENED,d.options.onOpened&&"function"==typeof d.options.onOpened&&d.options.onOpened(d)}function l(){d.$element.off("click","[data-"+o+"-close]").on("click","[data-"+o+"-close]",function(e){e.preventDefault();var i=t(e.currentTarget).attr("data-"+o+"-transitionOut");void 0!==i?d.close({transition:i}):d.close()}),d.$element.off("click","[data-"+o+"-fullscreen]").on("click","[data-"+o+"-fullscreen]",function(t){t.preventDefault(),d.isFullscreen===!0?(d.isFullscreen=!1,d.$element.removeClass("isFullscreen")):(d.isFullscreen=!0,d.$element.addClass("isFullscreen")),d.options.onFullscreen&&"function"==typeof d.options.onFullscreen&&d.options.onFullscreen(d),d.$element.trigger("fullscreen",d)}),d.$navigate.off("click","."+o+"-navigate-next").on("click","."+o+"-navigate-next",function(t){d.next(t)}),d.$element.off("click","[data-"+o+"-next]").on("click","[data-"+o+"-next]",function(t){d.next(t)}),d.$navigate.off("click","."+o+"-navigate-prev").on("click","."+o+"-navigate-prev",function(t){d.prev(t)}),d.$element.off("click","[data-"+o+"-prev]").on("click","[data-"+o+"-prev]",function(t){d.prev(t)})}var d=this;if(this.state==s.CLOSED){if(l(),this.$element.trigger(s.OPENING),this.state=s.OPENING,this.options.iframe===!0){this.$element.find("."+o+"-content").addClass(o+"-content-loader"),this.$element.find("."+o+"-iframe").on("load",function(){t(this).parent().removeClass(o+"-content-loader")});var h=null;try{h=""!==t(e.currentTarget).attr("href")?t(e.currentTarget).attr("href"):null}catch(c){console.warn(c)}null===this.options.iframeURL||null!==h&&void 0!==h||(h=this.options.iframeURL),null!==h&&void 0!==h||alert("Failed to find iframe URL."),this.$element.find("."+o+"-iframe").attr("src",h)}(this.options.bodyOverflow||r)&&t(document.body).css("overflow","hidden"),d.options.onOpening&&"function"==typeof d.options.onOpening&&d.options.onOpening(this),function(){if(d.group.ids.length>1){d.$navigate.appendTo("body"),d.$navigate.addClass(d.options.transitionInOverlay),d.options.navigateCaption===!0&&d.$navigate.find("."+o+"-navigate-caption").show(),d.options.navigateArrows===!0||"closeToModal"===d.options.navigateArrows?(d.$navigate.find("."+o+"-navigate-prev").css("margin-left",-(d.width/2+84)),d.$navigate.find("."+o+"-navigate-next").css("margin-right",-(d.width/2+84))):(d.$navigate.find("."+o+"-navigate-prev").css("left",0),d.$navigate.find("."+o+"-navigate-next").css("right",0));var n;0===d.group.index&&(n=t("."+o+"[data-"+o+'-group="'+d.group.name+'"][data-'+o+"-loop]").length,0===n&&d.options.loop===!1&&d.$navigate.find("."+o+"-navigate-prev").hide()),d.group.index+1===d.group.ids.length&&(n=t("."+o+"[data-"+o+'-group="'+d.group.name+'"][data-'+o+"-loop]").length,0===n&&d.options.loop===!1&&d.$navigate.find("."+o+"-navigate-next").hide())}d.options.overlay===!0&&d.$overlay.appendTo("body"),d.options.transitionInOverlay&&d.$overlay.addClass(d.options.transitionInOverlay);var s=d.options.transitionIn;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionIn||(s=e.transition||e.transitionIn)),""!==s?(d.$element.addClass("transitionIn "+s).show(),d.$element.find("."+o+"-wrap").one(a,function(){d.$element.removeClass(s+" transitionIn"),d.$overlay.removeClass(d.options.transitionInOverlay),d.$navigate.removeClass(d.options.transitionInOverlay),i()})):(d.$element.show(),i()),d.options.pauseOnHover!==!0||d.options.pauseOnHover!==!0||d.options.timeout===!1||isNaN(parseInt(d.options.timeout))||d.options.timeout===!1||0===d.options.timeout||(d.$element.off("mouseenter").on("mouseenter",function(t){t.preventDefault(),d.isPaused=!0}),d.$element.off("mouseleave").on("mouseleave",function(t){t.preventDefault(),d.isPaused=!1}))}(),this.options.timeout===!1||isNaN(parseInt(this.options.timeout))||this.options.timeout===!1||0===this.options.timeout||(this.options.timeoutProgressbar===!0?(this.progressBar={hideEta:null,maxHideTime:null,currentTime:(new Date).getTime(),el:this.$element.find("."+o+"-progressbar > div"),updateProgress:function(){if(!d.isPaused){d.progressBar.currentTime=d.progressBar.currentTime+10;var t=(d.progressBar.hideEta-d.progressBar.currentTime)/d.progressBar.maxHideTime*100;d.progressBar.el.width(t+"%"),0>t&&d.close()}}},this.options.timeout>0&&(this.progressBar.maxHideTime=parseFloat(this.options.timeout),this.progressBar.hideEta=(new Date).getTime()+this.progressBar.maxHideTime,this.timerTimeout=setInterval(this.progressBar.updateProgress,10))):this.timerTimeout=setTimeout(function(){d.close()},d.options.timeout)),this.options.overlayClose&&!this.$element.hasClass(this.options.transitionOut)&&this.$overlay.click(function(){d.close()}),this.options.focusInput&&this.$element.find(":input:not(button):enabled:visible:first").focus(),function u(){d.recalculateLayout(),d.timer=setTimeout(u,300)}(),function(){if(d.options.history||r){var t=document.title;document.title=t+" - "+d.options.title,document.location.hash=d.id,document.title=t}}(),n.keydown(function(t){d.options.closeOnEscape&&27===t.keyCode&&d.close()})}},close:function(e){function i(){l.options.iframe===!0&&l.$element.find("."+o+"-iframe").attr("src",""),(l.options.bodyOverflow||r)&&t(document.body).css("overflow","initial"),t(document.body).removeClass(o+"-attached"),l.$element.trigger(s.CLOSED),l.state=s.CLOSED,l.options.onClosed&&"function"==typeof l.options.onClosed&&l.options.onClosed(l),l.options.restoreDefaultContent===!0&&l.$element.find("."+o+"-content").html(l.content)}var l=this;if(this.state==s.OPENED||this.state==s.OPENING){n.off("keydown"),this.state=s.CLOSING,this.$element.trigger(s.CLOSING),clearTimeout(this.timer),clearTimeout(this.timerTimeout),l.options.onClosing&&"function"==typeof l.options.onClosing&&l.options.onClosing(this);var d=this.options.transitionOut;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionOut||(d=e.transition||e.transitionOut)),""!==d?(this.$element.attr("class",o+" transitionOut "+d+" "+this.options.theme+" "+String(this.isFullscreen===!0?"isFullscreen":"")+" "+String("top"===this.options.attached?"isAttachedTop":"")+" "+String("bottom"===this.options.attached?"isAttachedBottom":"")),this.$overlay.attr("class",o+"-overlay "+this.options.transitionOutOverlay),this.$navigate.attr("class",o+"-navigate "+this.options.transitionOutOverlay),this.$element.one(a,function(){l.$element.hasClass(d)&&l.$element.removeClass(d+" transitionOut").hide(),l.$overlay.removeClass(l.options.transitionOutOverlay).remove(),l.$navigate.removeClass(l.options.transitionOutOverlay).remove(),i()})):(this.$element.hide(),this.$overlay.remove(),this.$navigate.remove(),i())}},next:function(e){var i=this,n="fadeInRight",s="fadeOutLeft",a=t("."+o+":visible"),r={};r.out=this,void 0!==e&&"object"!=typeof e?(e.preventDefault(),a=t(e.currentTarget),n=a.attr("data-"+o+"-transitionIn"),s=a.attr("data-"+o+"-transitionOut")):void 0!==e&&(void 0!==e.transitionIn&&(n=e.transitionIn),void 0!==e.transitionOut&&(s=e.transitionOut)),this.close({transition:s}),setTimeout(function(){var e=t("."+o+"[data-"+o+'-group="'+i.group.name+'"][data-'+o+"-loop]").length;(e>0||i.options.loop===!0)&&i.group.index+1===i.group.ids.length?(t("#"+i.group.ids[0]).iziModal("open",{transition:n}),r["in"]=t("#"+i.group.ids[0]).data().iziModal):i.group.index+10||i.options.loop===!0)&&0===i.group.index?(t("#"+i.group.ids[i.group.ids.length-1]).iziModal("open",{transition:n}),r["in"]=t("#"+i.group.ids[i.group.ids.length-1]).data().iziModal):i.group.index>0&&(t("#"+i.group.ids[i.group.index-1]).iziModal("open",{transition:n}),r["in"]=t("#"+i.group.ids[i.group.index-1]).data().iziModal)},200),t(document).trigger(o+"-group-change",r)},destroy:function(){var e=t.Event("destroy");this.$element.trigger(e),n.off("keydown"),clearTimeout(this.timer),clearTimeout(this.timerTimeout),this.options.iframe===!0&&this.$element.find("."+o+"-iframe").remove(),this.$element.html(this.$element.find("."+o+"-content").html()),n.find("style[rel="+this.id+"]").remove(),this.$element.off("click","[data-"+o+"-close]"),this.$element.off("click","[data-"+o+"-fullscreen]"),this.$element.off("."+o).removeData(o).attr("style",""),this.$overlay.remove(),this.$navigate.remove(),this.$element.trigger(s.DESTROYED),this.$element=null},getState:function(){return this.state},getGroup:function(){return this.group},setTitle:function(t){null!==this.options.title&&(this.$header.find("."+o+"-header-title").html(t),this.options.title=t)},setSubtitle:function(t){null!==this.options.subtitle&&(this.$header.find("."+o+"-header-subtitle").html(t),this.options.subtitle=t)},setIcon:function(t){null!==this.options.icon&&(this.$header.find("."+o+"-header-icon").attr("class",o+"-header-icon "+t),this.options.icon=t)},setHeaderColor:function(t){this.$element.css("border-bottom","3px solid "+t),this.$header.css("background",t),this.options.headerColor=t},setZindex:function(t){isNaN(parseInt(this.options.zindex))||(this.options.zindex=t,this.$element.css("z-index",t),this.$navigate.css("z-index",t-1),this.$overlay.css("z-index",t-2))},setTransitionIn:function(t){this.options.transitionIn=param.transition},setTransitionOut:function(t){this.options.transitionOut=param.transition},startLoading:function(){this.$element.find("."+o+"-loader").length||this.$element.append('
')},stopLoading:function(){var t=this;this.$element.find("."+o+"-loader").removeClass(this.options.transitionInOverlay).addClass(this.options.transitionOutOverlay),this.$element.find("."+o+"-loader").one(a,function(){t.$element.find("."+o+"-loader").removeClass(t.options.transitionOutOverlay).remove()})},recalculateLayout:function(){this.$element.find("."+o+"-header").length&&(this.headerHeight=parseInt(this.$element.find("."+o+"-header").innerHeight())+2,this.$element.css("overflow","hidden"));var e=i.height(),n=this.$element.outerHeight(),a=this.$element.find("."+o+"-content")[0].scrollHeight,r=parseInt(-((this.$element.innerHeight()+1)/2))+"px";if(n!==this.modalHeight&&(this.modalHeight=n,this.options.onResize&&"function"==typeof this.options.onResize&&this.options.onResize(this)),this.state==s.OPENED||this.state==s.OPENING)if(this.options.iframe===!0)ea+this.headerHeight&&this.isFullscreen!==!0&&(t(document.body).removeClass(o+"-attached"),this.$element.find("."+o+"-wrap").css({height:"auto"})),(a+this.headerHeight>e||this.$element.innerHeight()h+l?this.$element.addClass("hasScroll"):this.$element.removeClass("hasScroll")}this.$element.css("margin-top")!=r&&"0px"!=this.$element.css("margin-top")&&this.$element.css("margin-top",r)}},i.off("hashchange load").on("hashchange load",function(e){0===l?""!==document.location.hash?(t.each(t("."+o),function(e,i){var n=t(i).iziModal("getState");"opened"!=n&&"opening"!=n||"#"+t(i).attr("id")!==document.location.hash&&t(i).iziModal("close")}),setTimeout(function(){t(document.location.hash).iziModal("open")},200)):t.each(t("."+o),function(e,i){var n=t(i).iziModal("getState");"opened"!=n&&"opening"!=n||t(i).iziModal("close")}):l=0}),n.off("click","[data-"+o+"-open]").on("click","[data-"+o+"-open]",function(e){e.preventDefault();var i=t("."+o+":visible").attr("id"),n=t(e.currentTarget).attr("data-"+o+"-open"),s=t(e.currentTarget).attr("data-"+o+"-transitionIn"),a=t(e.currentTarget).attr("data-"+o+"-transitionOut");void 0!==a?t("#"+i).iziModal("close",{transition:a}):t("#"+i).iziModal("close"),setTimeout(function(){void 0!==s?t("#"+n).iziModal("open",{transition:s}):t("#"+n).iziModal("open")},200)}),n.off("keyup").on("keyup",function(e){var i=t("."+o+":visible").attr("id"),n=t("#"+i).iziModal("getGroup"),s=e||window.event,a=s.target||s.srcElement;void 0===i||void 0===n||s.ctrlKey||s.metaKey||s.altKey||"INPUT"===a.tagName.toUpperCase()||"TEXTAREA"==a.tagName.toUpperCase()||(37===s.keyCode?t("#"+i).iziModal("prev",s):39===s.keyCode&&t("#"+i).iziModal("next",s))}),t.fn[o]=function(e,i){var n=t(this),s=n.data(o),a=t.extend({},t.fn.iziModal.defaults,n.data(),"object"==typeof e&&e);if(s||e&&"object"!=typeof e){if("string"==typeof e&&"undefined"!=typeof s)return s[e].apply(s,[].concat(i))}else n.data(o,s=new d(this,a));return a.autoOpen&&(isNaN(parseInt(a.autoOpen))?a.autoOpen===!0&&s.open():setTimeout(function(){s.open()},a.autoOpen),l++),this},t.fn[o].defaults={title:"",subtitle:"",headerColor:"#88A0B9",theme:"",attached:"",icon:"",iconColor:"",width:600,padding:0,radius:3,zindex:999,iframe:!1,iframeHeight:400,iframeURL:null,focusInput:!0,group:"",loop:!1,navigateCaption:!0,navigateArrows:!0,history:!0,restoreDefaultContent:!1,autoOpen:0,bodyOverflow:!1,fullscreen:!1,openFullscreen:!1,closeOnEscape:!0,overlay:!0,overlayClose:!0,overlayColor:"rgba(0, 0, 0, 0.4)",timeout:!1,timeoutProgressbar:!1,pauseOnHover:!1,timeoutProgressbarColor:"rgba(255,255,255,0.5)",transitionIn:"comingIn",transitionOut:"comingOut",transitionInOverlay:"fadeIn",transitionOutOverlay:"fadeOut",onFullscreen:function(){},onResize:function(){},onOpening:function(){},onOpened:function(){},onClosing:function(){},onClosed:function(){}},t.fn[o].Constructor=d}).call(this,window.jQuery); \ No newline at end of file diff --git a/package.json b/package.json index 5fc1272..457d07f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "izimodal", - "version": "1.3.0", + "version": "1.3.1", "description": "Elegant, responsive, flexible and lightweight modal plugin with jQuery.", "readmeFilename": "README.md", "main": "index.js",