-
Notifications
You must be signed in to change notification settings - Fork 51
/
jquery.adaptive-modal.min.js
1 lines (1 loc) · 8.37 KB
/
jquery.adaptive-modal.min.js
1
!function(e){function n(e){if(/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(e)){return true}else{return false}}function r(t,n,r){setTimeout(function(){if(typeof r[t].beforeAnimate=="function")r[t].beforeAnimate();if(r[t].remove){if(r[t].hide==true){e(r[t].selector).removeClass(r[t].remove).addClass(r[t].step).one("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd",function(){e(this).hide();if(typeof r[t].afterAnimate=="function")r[t].afterAnimate()})}else{e(r[t].selector).removeClass(r[t].remove).addClass(r[t].step).show().one("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd",function(){if(typeof r[t].afterAnimate=="function")r[t].afterAnimate()})}}else{if(r[t].hide==true){e(r[t].selector).addClass(r[t].step).one("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd",function(){e(this).hide();if(typeof r[t].afterAnimate=="function")r[t].afterAnimate()})}else{e(r[t].selector).addClass(r[t].step).show().one("animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd",function(){if(typeof r[t].afterAnimate=="function")r[t].afterAnimate()})}}},n)}var t={elementAnimateTime:100,customBgColor:"#333",remoteUrl:false,elementAnimateIn:"scaleShow",elementAnimateOut:"scaleHide",beforeAnimate:function(e,t){},afterAnimate:function(e,t){},type:"GET",async:true,complete:function(e,t){},cache:true,error:function(e,t,n){},global:true,headers:{},statusCode:{},success:function(e,t,n){},dataType:"html"};e.fn.getStyleObject=function(){var e=this.get(0);var t;var n={};if(window.getComputedStyle){var r=function(e,t){return t.toUpperCase()};t=window.getComputedStyle(e,null);for(var i=0,s=t.length;i<s;i++){var o=t[i];var u=o.replace(/\-([a-z])/g,r);var a=t.getPropertyValue(o);n[u]=a}return n}if(t=e.currentStyle){for(var o in t){n[o]=t[o]}return n}return this.css()};e.fn.adaptiveModal=function(i){return this.each(function(){var s=e.extend({},t,i),o=e(this);e.fn.openModal=function(){var t=e(this),n=t.data("am-custom-class")||"",i=t.data("am-custom-bgcolor")||t.css("backgroundColor")||s.customBgColor;h=t.outerHeight(),w=t.outerWidth(),posX=t.offset().left;posY=t.offset().top-e(window).scrollTop(),styles=t.getStyleObject(),remote="";if(t.hasClass("am-animating")){return false}if(typeof s.beforeAnimate=="function")s.beforeAnimate(t,"open");if(t.css("backgroundColor")=="rgba(0 ,0 ,0 ,0)")i=s.customBgColor;bgColor=i;t.addClass("am-animating");if(t.data("remote")==true||s.remoteUrl!=false){content="Loading..";remote="am-remote";var o=t.data("type")?t.data("type"):s.type;var u=t.attr("href")||s.remoteUrl;var a=t.data("datatype")?t.data("datatype"):s.dataType;e.ajax({type:o,url:u,async:s.async,complete:s.complete,cache:s.cache,error:s.error,global:s.global,headers:s.headers,statusCode:s.statusCode,success:function(n,i,o){if(typeof s.success=="function"){s.success(n,i,o)}else{e(".am-remote").html(n)}e(".am-back > .am-modal-content > *").each(function(){l.push({time:0,step:"am-expanded",selector:e(".am-back"),beforeAnimate:function(){e(".am-back").attr("style","").css({background:bgColor,minHeight:e(".am-back").height()})}},{time:s.elementAnimateTime,step:"animated "+s.elementAnimateIn,selector:this})});l.push({time:0,step:"",selector:e(".am-back"),beforeAnimate:function(){if(typeof s.afterAnimate=="function")s.afterAnimate(t,"open");t.removeClass("am-animating")}});var u=0;for(var a=0;a<l.length;a++){u=parseInt(l[a].time,10)+parseInt(u,10);r(a,u,l)}},dataType:a})}else{content=t.data("title")||e(t.attr("href")).html()}e("body").append("<div class='am-overlay'><div class='am-close-backdrop'></div><div class='am-modal "+n+"'><div class='am-wrapper'></div></div></div>");t.clone().removeData("toggle").removeData("title").addClass("am-front").css(styles).appendTo(".am-modal .am-wrapper");e(".am-modal .am-wrapper").append("<div class='am-back'><div class='am-modal-content "+remote+"'>"+content+"</div></div>");e(".am-modal").css({width:w,height:h,top:posY,left:posX});e("body").prepend("<div class='am-sample'></div>");e(".am-back").clone().addClass("am-expanded "+n).appendTo(".am-sample");e(".am-sample .am-back").wrap("<div class='am-modal am-expanded "+n+"'></div>");var f=e(".am-sample .am-back").outerHeight();e(".am-sample").remove();e(".am-back").css({width:w,height:h,backgroundColor:bgColor});e(".am-back").append("<a href='#' class='am-close'>×</a>");e(".am-back .am-close, .am-close-backdrop, .am-trigger-close").click(function(e){t.closeModal();return false});var l=[];l.push({time:500,step:"am-flipped",selector:e(".am-modal"),beforeAnimate:function(){t.css({visibility:"hidden"})}},{time:500,step:"am-expanded",selector:e(".am-modal"),beforeAnimate:function(){e(".am-modal").attr("style","")}},{time:0,step:"am-expanded",selector:e(".am-back"),beforeAnimate:function(){e(".am-back").attr("style","").css({background:bgColor,height:f,minHeight:f})}},{time:500,step:"",selector:e(".am-back"),beforeAnimate:function(){if(!e(".am-back .am-modal-content").hasClass("am-remote")){e(".am-back").css({height:"auto"});if(typeof s.afterAnimate=="function")s.afterAnimate(t,"open");t.removeClass("am-animating")}}});e(".am-back > .am-modal-content > *").each(function(){l.push({time:s.elementAnimateTime,step:"animated scaleShow",selector:this})});var c=0;for(var p=0;p<l.length;p++){c=parseInt(l[p].time,10)+parseInt(c,10);r(p,c,l)}e("body").addClass("am-modal-open")};e.fn.closeModal=function(){var t=e(this),n=t.data("am-custom-class")||"",i=[],o=t.outerHeight(),u=t.outerWidth(),a=t.offset().left;posY=t.offset().top-e(window).scrollTop();if(t.hasClass("am-animating")){return false}if(typeof s.beforeAnimate=="function")s.beforeAnimate(t,"close");t.addClass("am-animating");e(".am-back > .am-modal-content > *").each(function(){i.push({time:s.elementAnimateTime,step:s.elementAnimateOut,remove:s.elementAnimateIn,selector:this})});e("body").prepend("<div class='am-sample'></div>");e(".am-back").clone().addClass("am-expanded "+n).appendTo(".am-sample");e(".am-sample .am-back").wrap("<div class='am-modal am-expanded "+n+"'></div>");var f=e(".am-sample .am-back").outerHeight();e(".am-sample").remove();i.push({time:0,selector:e(".am-expanded"),step:"",beforeAnimate:function(){e(".am-expanded").css({height:f})}},{time:300,remove:"am-expanded",selector:e(".am-back"),beforeAnimate:function(){e(".am-back").css({width:u,height:o,top:posY,left:a,minHeight:0})}},{time:0,remove:"am-expanded",selector:e(".am-modal"),step:"",beforeAnimate:function(){e(".am-modal").css({width:u,height:o,top:posY,left:a})}},{time:200,remove:"am-flipped",step:"",selector:e(".am-modal")},{time:0,step:"",selector:e(".am-modal"),beforeAnimate:function(){t.css({visibility:"visible"})}},{time:500,remove:"am-modal-open",step:"",selector:e("body")},{time:500,step:"",selector:e(".am-overlay"),beforeAnimate:function(){e(".am-overlay").remove();if(typeof s.afterAnimate=="function")s.afterAnimate(t,"close");t.removeClass("am-animating")}});var l=0;for(var c=0;c<i.length;c++){l=parseInt(i[c].time,10)+parseInt(l,10);r(c,l,i);if(c-1==i.length){}}};if(o.attr("href").length>0&&o.attr("href")!="#"){if(!n(o.attr("href")))e(o.attr("href")).hide()}o.addClass("am-btn").click(function(){o.openModal();return false})})};e(document).ready(function(){e("[data-toggle='adaptive-modal']").adaptiveModal()})}(window.jQuery)