modalist 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE +21 -0
- data/README.md +302 -0
- data/app/helpers/modalist/modal_helper.rb +29 -0
- data/app/helpers/modalist/render_helper.rb +9 -0
- data/app/views/layouts/modalist.html.erb +19 -0
- data/app/views/modalist/_close.html.erb +4 -0
- data/app/views/modalist/_modal.html.erb +2 -0
- data/lib/modalist/ajax.rb +9 -0
- data/lib/modalist/engine.rb +6 -0
- data/lib/modalist/railtie.rb +13 -0
- data/lib/modalist/version.rb +5 -0
- data/lib/modalist.rb +10 -0
- data/vendor/javascripts/iziModal.js +1440 -0
- data/vendor/javascripts/iziModal.min.js +6 -0
- data/vendor/javascripts/modalist.js +111 -0
- data/vendor/stylesheets/iziModal.css +1097 -0
- data/vendor/stylesheets/iziModal.min.css +6 -0
- data/vendor/stylesheets/modalist.sass +86 -0
- metadata +119 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
/*
|
2
|
+
* iziModal | v1.5.1
|
3
|
+
* http://izimodal.marcelodolce.com
|
4
|
+
* by Marcelo Dolce.
|
5
|
+
*/
|
6
|
+
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=function(e,i){return void 0===i&&(i="undefined"!=typeof window?require("jquery"):require("jquery")(e)),t(i),i}:t(jQuery)}(function(t){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]}function i(t){return 9===t?navigator.appVersion.indexOf("MSIE 9.")!==-1:(userAgent=navigator.userAgent,userAgent.indexOf("MSIE ")>-1||userAgent.indexOf("Trident/")>-1)}function n(t){var e=/%|px|em|cm|vh|vw/;return parseInt(String(t).split(e)[0])}var o=t(window),s=t(document),a="iziModal",r={CLOSING:"closing",CLOSED:"closed",OPENING:"opening",OPENED:"opened",DESTROYED:"destroyed"},l=e(),d=!!/Mobi/.test(navigator.userAgent);window.$iziModal={},window.$iziModal.autoOpen=0,window.$iziModal.history=!1;var h=function(t,e){this.init(t,e)};return h.prototype={constructor:h,init:function(e,i){var n=this;this.$element=t(e),void 0!==this.$element[0].id&&""!==this.$element[0].id?this.id=this.$element[0].id:(this.id=a+Math.floor(1e7*Math.random()+1),this.$element.attr("id",this.id)),this.classes=void 0!==this.$element.attr("class")?this.$element.attr("class"):"",this.content=this.$element.html(),this.state=r.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('<div class="'+a+'-overlay" style="background-color:'+i.overlayColor+'"></div>'),this.$navigate=t('<div class="'+a+'-navigate"><div class="'+a+'-navigate-caption">Use</div><button class="'+a+'-navigate-prev"></button><button class="'+a+'-navigate-next"></button></div>'),this.group={name:this.$element.attr("data-"+a+"-group"),index:null,ids:[]},this.$element.attr("aria-hidden","true"),this.$element.attr("aria-labelledby",this.id),this.$element.attr("role","dialog"),this.$element.hasClass("iziModal")||this.$element.addClass("iziModal"),void 0===this.group.name&&""!==i.group&&(this.group.name=i.group,this.$element.attr("data-"+a+"-group",i.group)),this.options.loop===!0&&this.$element.attr("data-"+a+"-loop",!0),t.each(this.options,function(t,e){var o=n.$element.attr("data-"+a+"-"+t);try{"undefined"!=typeof o&&(""===o||"true"==o?i[t]=!0:"false"==o?i[t]=!1:"function"==typeof e?i[t]=new Function(o):i[t]=o)}catch(s){}}),i.appendTo!==!1&&this.$element.appendTo(i.appendTo),i.iframe===!0?(this.$element.html('<div class="'+a+'-wrap"><div class="'+a+'-content"><iframe class="'+a+'-iframe"></iframe>'+this.content+"</div></div>"),null!==i.iframeHeight&&this.$element.find("."+a+"-iframe").css("height",i.iframeHeight)):this.$element.html('<div class="'+a+'-wrap"><div class="'+a+'-content">'+this.content+"</div></div>"),null!==this.options.background&&this.$element.css("background",this.options.background),this.$wrap=this.$element.find("."+a+"-wrap"),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("."+a+"-content").css("padding",i.padding),""!==i.theme&&("light"===i.theme?this.$element.addClass(a+"-light"):this.$element.addClass(i.theme)),i.rtl===!0&&this.$element.addClass(a+"-rtl"),i.openFullscreen===!0&&(this.isFullscreen=!0,this.$element.addClass("isFullscreen")),this.createHeader(),this.recalcWidth(),this.recalcVerticalPos(),!n.options.afterRender||"function"!=typeof n.options.afterRender&&"object"!=typeof n.options.afterRender||n.options.afterRender(n)},createHeader:function(){this.$header=t('<div class="'+a+'-header"><h2 class="'+a+'-header-title">'+this.options.title+'</h2><p class="'+a+'-header-subtitle">'+this.options.subtitle+'</p><div class="'+a+'-header-buttons"></div></div>'),this.options.closeButton===!0&&this.$header.find("."+a+"-header-buttons").append('<a href="javascript:void(0)" class="'+a+"-button "+a+'-button-close" data-'+a+"-close></a>"),this.options.fullscreen===!0&&this.$header.find("."+a+"-header-buttons").append('<a href="javascript:void(0)" class="'+a+"-button "+a+'-button-fullscreen" data-'+a+"-fullscreen></a>"),this.options.timeoutProgressbar!==!0||isNaN(parseInt(this.options.timeout))||this.options.timeout===!1||0===this.options.timeout||this.$header.prepend('<div class="'+a+'-progressbar"><div style="background-color:'+this.options.timeoutProgressbarColor+'"></div></div>'),""===this.options.subtitle&&this.$header.addClass(a+"-noSubtitle"),""!==this.options.title&&(null!==this.options.headerColor&&(this.options.borderBottom===!0&&this.$element.css("border-bottom","3px solid "+this.options.headerColor),this.$header.css("background",this.options.headerColor)),null===this.options.icon&&null===this.options.iconText||(this.$header.prepend('<i class="'+a+'-header-icon"></i>'),null!==this.options.icon&&this.$header.find("."+a+"-header-icon").addClass(this.options.icon).css("color",this.options.iconColor),null!==this.options.iconText&&this.$header.find("."+a+"-header-icon").html(this.options.iconText)),this.$element.css("overflow","hidden").prepend(this.$header))},setGroup:function(e){var i=this,n=this.group.name||e;if(this.group.ids=[],void 0!==e&&e!==this.group.name&&(n=e,this.group.name=n,this.$element.attr("data-"+a+"-group",n)),void 0!==n&&""!==n){var o=0;t.each(t("."+a+"[data-"+a+"-group="+n+"]"),function(e,n){i.group.ids.push(t(this)[0].id),i.id==t(this)[0].id&&(i.group.index=o),o++})}},toggle:function(){this.state==r.OPENED&&this.close(),this.state==r.CLOSED&&this.open()},open:function(e){function i(){o.state=r.OPENED,o.$element.trigger(r.OPENED),!o.options.onOpened||"function"!=typeof o.options.onOpened&&"object"!=typeof o.options.onOpened||o.options.onOpened(o)}function n(){o.$element.off("click","[data-"+a+"-close]").on("click","[data-"+a+"-close]",function(e){e.preventDefault();var i=t(e.currentTarget).attr("data-"+a+"-transitionOut");void 0!==i?o.close({transition:i}):o.close()}),o.$element.off("click","[data-"+a+"-fullscreen]").on("click","[data-"+a+"-fullscreen]",function(t){t.preventDefault(),o.isFullscreen===!0?(o.isFullscreen=!1,o.$element.removeClass("isFullscreen")):(o.isFullscreen=!0,o.$element.addClass("isFullscreen")),o.options.onFullscreen&&"function"==typeof o.options.onFullscreen&&o.options.onFullscreen(o),o.$element.trigger("fullscreen",o)}),o.$navigate.off("click","."+a+"-navigate-next").on("click","."+a+"-navigate-next",function(t){o.next(t)}),o.$element.off("click","[data-"+a+"-next]").on("click","[data-"+a+"-next]",function(t){o.next(t)}),o.$navigate.off("click","."+a+"-navigate-prev").on("click","."+a+"-navigate-prev",function(t){o.prev(t)}),o.$element.off("click","[data-"+a+"-prev]").on("click","[data-"+a+"-prev]",function(t){o.prev(t)})}var o=this;if(t.each(t("."+a),function(e,i){if(void 0!==t(i).data().iziModal){var n=t(i).iziModal("getState");"opened"!=n&&"opening"!=n||t(i).iziModal("close")}}),function(){if(o.options.history){var t=document.title;document.title=t+" - "+o.options.title,document.location.hash=o.id,document.title=t,window.$iziModal.history=!0}else window.$iziModal.history=!1}(),this.state==r.CLOSED){if(n(),this.setGroup(),this.state=r.OPENING,this.$element.trigger(r.OPENING),this.$element.attr("aria-hidden","false"),this.options.iframe===!0){this.$element.find("."+a+"-content").addClass(a+"-content-loader"),this.$element.find("."+a+"-iframe").on("load",function(){t(this).parent().removeClass(a+"-content-loader")});var h=null;try{h=""!==t(e.currentTarget).attr("href")?t(e.currentTarget).attr("href"):null}catch(c){}if(null===this.options.iframeURL||null!==h&&void 0!==h||(h=this.options.iframeURL),null===h||void 0===h)throw new Error("Failed to find iframe URL");this.$element.find("."+a+"-iframe").attr("src",h)}(this.options.bodyOverflow||d)&&(t("html").addClass(a+"-isOverflow"),d&&t("body").css("overflow","hidden")),this.options.onOpening&&"function"==typeof this.options.onOpening&&this.options.onOpening(this),function(){if(o.group.ids.length>1){o.$navigate.appendTo("body"),o.$navigate.addClass("fadeIn"),o.options.navigateCaption===!0&&o.$navigate.find("."+a+"-navigate-caption").show();var n=o.$element.outerWidth();o.options.navigateArrows!==!1?"closeScreenEdge"===o.options.navigateArrows?(o.$navigate.find("."+a+"-navigate-prev").css("left",0).show(),o.$navigate.find("."+a+"-navigate-next").css("right",0).show()):(o.$navigate.find("."+a+"-navigate-prev").css("margin-left",-(n/2+84)).show(),o.$navigate.find("."+a+"-navigate-next").css("margin-right",-(n/2+84)).show()):(o.$navigate.find("."+a+"-navigate-prev").hide(),o.$navigate.find("."+a+"-navigate-next").hide());var s;0===o.group.index&&(s=t("."+a+"[data-"+a+'-group="'+o.group.name+'"][data-'+a+"-loop]").length,0===s&&o.options.loop===!1&&o.$navigate.find("."+a+"-navigate-prev").hide()),o.group.index+1===o.group.ids.length&&(s=t("."+a+"[data-"+a+'-group="'+o.group.name+'"][data-'+a+"-loop]").length,0===s&&o.options.loop===!1&&o.$navigate.find("."+a+"-navigate-next").hide())}o.options.overlay===!0&&(o.options.appendToOverlay===!1?o.$overlay.appendTo("body"):o.$overlay.appendTo(o.options.appendToOverlay)),o.options.transitionInOverlay&&o.$overlay.addClass(o.options.transitionInOverlay);var r=o.options.transitionIn;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionIn||(r=e.transition||e.transitionIn)),""!==r&&void 0!==l?(o.$element.addClass("transitionIn "+r).show(),o.$wrap.one(l,function(){o.$element.removeClass(r+" transitionIn"),o.$overlay.removeClass(o.options.transitionInOverlay),o.$navigate.removeClass("fadeIn"),i()})):(o.$element.show(),i()),o.options.pauseOnHover!==!0||o.options.pauseOnHover!==!0||o.options.timeout===!1||isNaN(parseInt(o.options.timeout))||o.options.timeout===!1||0===o.options.timeout||(o.$element.off("mouseenter").on("mouseenter",function(t){t.preventDefault(),o.isPaused=!0}),o.$element.off("mouseleave").on("mouseleave",function(t){t.preventDefault(),o.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("."+a+"-progressbar > div"),updateProgress:function(){if(!o.isPaused){o.progressBar.currentTime=o.progressBar.currentTime+10;var t=(o.progressBar.hideEta-o.progressBar.currentTime)/o.progressBar.maxHideTime*100;o.progressBar.el.width(t+"%"),t<0&&o.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(){o.close()},o.options.timeout)),this.options.overlayClose&&!this.$element.hasClass(this.options.transitionOut)&&this.$overlay.click(function(){o.close()}),this.options.focusInput&&this.$element.find(":input:not(button):enabled:visible:first").focus(),function u(){o.recalcLayout(),o.timer=setTimeout(u,300)}(),s.on("keydown."+a,function(t){o.options.closeOnEscape&&27===t.keyCode&&o.close()})}},close:function(e){function i(){n.state=r.CLOSED,n.$element.trigger(r.CLOSED),n.options.iframe===!0&&n.$element.find("."+a+"-iframe").attr("src",""),(n.options.bodyOverflow||d)&&(t("html").removeClass(a+"-isOverflow"),d&&t("body").css("overflow","auto")),n.options.onClosed&&"function"==typeof n.options.onClosed&&n.options.onClosed(n),n.options.restoreDefaultContent===!0&&n.$element.find("."+a+"-content").html(n.content),0===t("."+a+":visible").length&&t("html").removeClass(a+"-isAttached")}var n=this;if(this.state==r.OPENED||this.state==r.OPENING){s.off("keydown."+a),this.state=r.CLOSING,this.$element.trigger(r.CLOSING),this.$element.attr("aria-hidden","true"),clearTimeout(this.timer),clearTimeout(this.timerTimeout),n.options.onClosing&&"function"==typeof n.options.onClosing&&n.options.onClosing(this);var o=this.options.transitionOut;"object"==typeof e&&(void 0===e.transition&&void 0===e.transitionOut||(o=e.transition||e.transitionOut)),o===!1||""===o||void 0===l?(this.$element.hide(),this.$overlay.remove(),this.$navigate.remove(),i()):(this.$element.attr("class",[this.classes,a,o,"light"==this.options.theme?a+"-light":this.options.theme,this.isFullscreen===!0?"isFullscreen":"",this.options.rtl?a+"-rtl":""].join(" ")),this.$overlay.attr("class",a+"-overlay "+this.options.transitionOutOverlay),n.options.navigateArrows!==!1&&this.$navigate.attr("class",a+"-navigate fadeOut"),this.$element.one(l,function(){n.$element.hasClass(o)&&n.$element.removeClass(o+" transitionOut").hide(),n.$overlay.removeClass(n.options.transitionOutOverlay).remove(),n.$navigate.removeClass("fadeOut").remove(),i()}))}},next:function(e){var i=this,n="fadeInRight",o="fadeOutLeft",s=t("."+a+":visible"),r={};r.out=this,void 0!==e&&"object"!=typeof e?(e.preventDefault(),s=t(e.currentTarget),n=s.attr("data-"+a+"-transitionIn"),o=s.attr("data-"+a+"-transitionOut")):void 0!==e&&(void 0!==e.transitionIn&&(n=e.transitionIn),void 0!==e.transitionOut&&(o=e.transitionOut)),this.close({transition:o}),setTimeout(function(){for(var e=t("."+a+"[data-"+a+'-group="'+i.group.name+'"][data-'+a+"-loop]").length,o=i.group.index+1;o<=i.group.ids.length;o++){try{r["in"]=t("#"+i.group.ids[o]).data().iziModal}catch(s){}if("undefined"!=typeof r["in"]){t("#"+i.group.ids[o]).iziModal("open",{transition:n});break}if(o==i.group.ids.length&&e>0||i.options.loop===!0)for(var l=0;l<=i.group.ids.length;l++)if(r["in"]=t("#"+i.group.ids[l]).data().iziModal,"undefined"!=typeof r["in"]){t("#"+i.group.ids[l]).iziModal("open",{transition:n});break}}},200),t(document).trigger(a+"-group-change",r)},prev:function(e){var i=this,n="fadeInLeft",o="fadeOutRight",s=t("."+a+":visible"),r={};r.out=this,void 0!==e&&"object"!=typeof e?(e.preventDefault(),s=t(e.currentTarget),n=s.attr("data-"+a+"-transitionIn"),o=s.attr("data-"+a+"-transitionOut")):void 0!==e&&(void 0!==e.transitionIn&&(n=e.transitionIn),void 0!==e.transitionOut&&(o=e.transitionOut)),this.close({transition:o}),setTimeout(function(){for(var e=t("."+a+"[data-"+a+'-group="'+i.group.name+'"][data-'+a+"-loop]").length,o=i.group.index;o>=0;o--){try{r["in"]=t("#"+i.group.ids[o-1]).data().iziModal}catch(s){}if("undefined"!=typeof r["in"]){t("#"+i.group.ids[o-1]).iziModal("open",{transition:n});break}if(0===o&&e>0||i.options.loop===!0)for(var l=i.group.ids.length-1;l>=0;l--)if(r["in"]=t("#"+i.group.ids[l]).data().iziModal,"undefined"!=typeof r["in"]){t("#"+i.group.ids[l]).iziModal("open",{transition:n});break}}},200),t(document).trigger(a+"-group-change",r)},destroy:function(){var e=t.Event("destroy");this.$element.trigger(e),s.off("keydown."+a),clearTimeout(this.timer),clearTimeout(this.timerTimeout),this.options.iframe===!0&&this.$element.find("."+a+"-iframe").remove(),this.$element.html(this.$element.find("."+a+"-content").html()),this.$element.off("click","[data-"+a+"-close]"),this.$element.off("click","[data-"+a+"-fullscreen]"),this.$element.off("."+a).removeData(a).attr("style",""),this.$overlay.remove(),this.$navigate.remove(),this.$element.trigger(r.DESTROYED),this.$element=null},getState:function(){return this.state},getGroup:function(){return this.group},setWidth:function(t){this.options.width=t,this.recalcWidth();var e=this.$element.outerWidth();this.options.navigateArrows!==!0&&"closeToModal"!=this.options.navigateArrows||(this.$navigate.find("."+a+"-navigate-prev").css("margin-left",-(e/2+84)).show(),this.$navigate.find("."+a+"-navigate-next").css("margin-right",-(e/2+84)).show())},setTop:function(t){this.options.top=t,this.recalcVerticalPos(!1)},setBottom:function(t){this.options.bottom=t,this.recalcVerticalPos(!1)},setHeader:function(t){t?this.$element.find("."+a+"-header").show():(this.headerHeight=0,this.$element.find("."+a+"-header").hide())},setTitle:function(t){this.options.title=t,0===this.headerHeight&&this.createHeader(),0===this.$header.find("."+a+"-header-title").length&&this.$header.append('<h2 class="'+a+'-header-title"></h2>'),this.$header.find("."+a+"-header-title").html(t)},setSubtitle:function(t){""===t?(this.$header.find("."+a+"-header-subtitle").remove(),this.$header.addClass(a+"-noSubtitle")):(0===this.$header.find("."+a+"-header-subtitle").length&&this.$header.append('<p class="'+a+'-header-subtitle"></p>'),this.$header.removeClass(a+"-noSubtitle")),this.$header.find("."+a+"-header-subtitle").html(t),this.options.subtitle=t},setIcon:function(t){0===this.$header.find("."+a+"-header-icon").length&&this.$header.prepend('<i class="'+a+'-header-icon"></i>'),this.$header.find("."+a+"-header-icon").attr("class",a+"-header-icon "+t),this.options.icon=t},setIconText:function(t){this.$header.find("."+a+"-header-icon").html(t),this.options.iconText=t},setHeaderColor:function(t){this.options.borderBottom===!0&&this.$element.css("border-bottom","3px solid "+t),this.$header.css("background",t),this.options.headerColor=t},setBackground:function(t){t===!1?(this.options.background=null,this.$element.css("background","")):(this.$element.css("background",t),this.options.background=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))},setFullscreen:function(t){t?(this.isFullscreen=!0,this.$element.addClass("isFullscreen")):(this.isFullscreen=!1,this.$element.removeClass("isFullscreen"))},setContent:function(t){if("object"==typeof t){var e=t["default"]||!1;e===!0&&(this.content=t.content),t=t.content}this.options.iframe===!1&&this.$element.find("."+a+"-content").html(t)},setTransitionIn:function(t){this.options.transitionIn=t},setTransitionOut:function(t){this.options.transitionOut=t},resetContent:function(){this.$element.find("."+a+"-content").html(this.content)},startLoading:function(){this.$element.find("."+a+"-loader").length||this.$element.append('<div class="'+a+'-loader fadeIn"></div>'),this.$element.find("."+a+"-loader").css({top:this.headerHeight,borderRadius:this.options.radius})},stopLoading:function(){var t=this.$element.find("."+a+"-loader");t.length||(this.$element.prepend('<div class="'+a+'-loader fadeIn"></div>'),t=this.$element.find("."+a+"-loader").css("border-radius",this.options.radius)),t.removeClass("fadeIn").addClass("fadeOut"),setTimeout(function(){t.remove()},600)},recalcWidth:function(){var t=this;if(this.$element.css("max-width",this.options.width),i()){var e=t.options.width;e.toString().split("%").length>1&&(e=t.$element.outerWidth()),t.$element.css({left:"50%",marginLeft:-(e/2)})}},recalcVerticalPos:function(t){null!==this.options.top&&this.options.top!==!1?(this.$element.css("margin-top",this.options.top),0===this.options.top&&this.$element.css({borderTopRightRadius:0,borderTopLeftRadius:0})):t===!1&&this.$element.css({marginTop:"",borderRadius:this.options.radius}),null!==this.options.bottom&&this.options.bottom!==!1?(this.$element.css("margin-bottom",this.options.bottom),0===this.options.bottom&&this.$element.css({borderBottomRightRadius:0,borderBottomLeftRadius:0})):t===!1&&this.$element.css({marginBottom:"",borderRadius:this.options.radius})},recalcLayout:function(){var e=this,s=o.height(),l=this.$element.outerHeight(),d=this.$element.outerWidth(),h=this.$element.find("."+a+"-content")[0].scrollHeight,c=h+this.headerHeight,u=this.$element.innerHeight()-this.headerHeight,p=(parseInt(-((this.$element.innerHeight()+1)/2))+"px",this.$wrap.scrollTop()),f=0;i()&&(d>=o.width()||this.isFullscreen===!0?this.$element.css({left:"0",marginLeft:""}):this.$element.css({left:"50%",marginLeft:-(d/2)})),this.options.borderBottom===!0&&""!==this.options.title&&(f=3),this.$element.find("."+a+"-header").length&&this.$element.find("."+a+"-header").is(":visible")?(this.headerHeight=parseInt(this.$element.find("."+a+"-header").innerHeight()),this.$element.css("overflow","hidden")):(this.headerHeight=0,this.$element.css("overflow","")),this.$element.find("."+a+"-loader").length&&this.$element.find("."+a+"-loader").css("top",this.headerHeight),l!==this.modalHeight&&(this.modalHeight=l,this.options.onResize&&"function"==typeof this.options.onResize&&this.options.onResize(this)),this.state!=r.OPENED&&this.state!=r.OPENING||(this.options.iframe===!0&&(s<this.options.iframeHeight+this.headerHeight+f||this.isFullscreen===!0?this.$element.find("."+a+"-iframe").css("height",s-(this.headerHeight+f)):this.$element.find("."+a+"-iframe").css("height",this.options.iframeHeight)),l==s?this.$element.addClass("isAttached"):this.$element.removeClass("isAttached"),this.isFullscreen===!1&&this.$element.width()>=o.width()?this.$element.find("."+a+"-button-fullscreen").hide():this.$element.find("."+a+"-button-fullscreen").show(),this.recalcButtons(),this.isFullscreen===!1&&(s=s-(n(this.options.top)||0)-(n(this.options.bottom)||0)),c>s?(this.options.top>0&&null===this.options.bottom&&h<o.height()&&this.$element.addClass("isAttachedBottom"),this.options.bottom>0&&null===this.options.top&&h<o.height()&&this.$element.addClass("isAttachedTop"),t("html").addClass(a+"-isAttached"),this.$element.css("height",s)):(this.$element.css("height",h+(this.headerHeight+f)),this.$element.removeClass("isAttachedTop isAttachedBottom"),t("html").removeClass(a+"-isAttached")),function(){h>u&&c>s?(e.$element.addClass("hasScroll"),e.$wrap.css("height",l-(e.headerHeight+f))):(e.$element.removeClass("hasScroll"),e.$wrap.css("height","auto"))}(),function(){u+p<h-30?e.$element.addClass("hasShadow"):e.$element.removeClass("hasShadow")}())},recalcButtons:function(){var t=this.$header.find("."+a+"-header-buttons").innerWidth()+10;this.options.rtl===!0?this.$header.css("padding-left",t):this.$header.css("padding-right",t)}},o.off("load."+a).on("load."+a,function(e){var i=document.location.hash;if(0===window.$iziModal.autoOpen&&!t("."+a).is(":visible"))try{var n=t(i).data();"undefined"!=typeof n&&n.iziModal.options.autoOpen!==!1&&t(i).iziModal("open")}catch(o){}}),o.off("hashchange."+a).on("hashchange."+a,function(e){var i=document.location.hash,n=t(i).data();if(""!==i)try{"undefined"!=typeof n&&"opening"!==t(i).iziModal("getState")&&setTimeout(function(){t(i).iziModal("open")},200)}catch(o){}else window.$iziModal.history&&t.each(t("."+a),function(e,i){if(void 0!==t(i).data().iziModal){var n=t(i).iziModal("getState");"opened"!=n&&"opening"!=n||t(i).iziModal("close")}})}),s.off("click","[data-"+a+"-open]").on("click","[data-"+a+"-open]",function(e){e.preventDefault();var i=t("."+a+":visible"),n=t(e.currentTarget).attr("data-"+a+"-open"),o=t(e.currentTarget).attr("data-"+a+"-transitionIn"),s=t(e.currentTarget).attr("data-"+a+"-transitionOut");void 0!==s?i.iziModal("close",{transition:s}):i.iziModal("close"),setTimeout(function(){void 0!==o?t(n).iziModal("open",{transition:o}):t(n).iziModal("open")},200)}),s.off("keyup."+a).on("keyup."+a,function(e){if(t("."+a+":visible").length){var i=t("."+a+":visible")[0].id,n=t("#"+i).iziModal("getGroup"),o=e||window.event,s=o.target||o.srcElement;void 0===i||void 0===n.name||o.ctrlKey||o.metaKey||o.altKey||"INPUT"===s.tagName.toUpperCase()||"TEXTAREA"==s.tagName.toUpperCase()||(37===o.keyCode?t("#"+i).iziModal("prev",o):39===o.keyCode&&t("#"+i).iziModal("next",o))}}),t.fn[a]=function(e,i){if(!t(this).length&&"object"==typeof e){var n={$el:document.createElement("div"),id:this.selector.split("#"),"class":this.selector.split(".")};if(n.id.length>1){try{n.$el=document.createElement(id[0])}catch(o){}n.$el.id=this.selector.split("#")[1].trim()}else if(n["class"].length>1){try{n.$el=document.createElement(n["class"][0])}catch(o){}for(var s=1;s<n["class"].length;s++)n.$el.classList.add(n["class"][s].trim())}document.body.appendChild(n.$el),this.push(t(this.selector))}for(var r=this,l=0;l<r.length;l++){var d=t(r[l]),c=d.data(a),u=t.extend({},t.fn[a].defaults,d.data(),"object"==typeof e&&e);if(c||e&&"object"!=typeof e){if("string"==typeof e&&"undefined"!=typeof c)return c[e].apply(c,[].concat(i))}else d.data(a,c=new h(d,u));u.autoOpen&&(isNaN(parseInt(u.autoOpen))?u.autoOpen===!0&&c.open():setTimeout(function(){c.open()},u.autoOpen),window.$iziModal.autoOpen++)}return this},t.fn[a].defaults={title:"",subtitle:"",headerColor:"#88A0B9",background:null,theme:"",icon:null,iconText:null,iconColor:"",rtl:!1,width:600,top:null,bottom:null,borderBottom:!0,padding:0,radius:3,zindex:999,iframe:!1,iframeHeight:400,iframeURL:null,focusInput:!0,group:"",loop:!1,navigateCaption:!0,navigateArrows:!0,history:!1,restoreDefaultContent:!1,autoOpen:0,bodyOverflow:!1,fullscreen:!1,openFullscreen:!1,closeOnEscape:!0,closeButton:!0,appendTo:"body",appendToOverlay:"body",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(){},afterRender:function(){}},t.fn[a].Constructor=h,t.fn.iz
|
@@ -0,0 +1,111 @@
|
|
1
|
+
(function($) {
|
2
|
+
var Modalist = new function(options) {
|
3
|
+
|
4
|
+
var defaults = {
|
5
|
+
iziModal: {}
|
6
|
+
};
|
7
|
+
options = $.extend( defaults, options );
|
8
|
+
|
9
|
+
this.modal = $('#modalist');
|
10
|
+
this.iziModal = $(Modalist.modal).iziModal(options.iziModal);
|
11
|
+
|
12
|
+
$('.modalist--trigger').unbind('click');
|
13
|
+
$('.modalist--trigger').click(function(event) {
|
14
|
+
|
15
|
+
event.preventDefault();
|
16
|
+
|
17
|
+
var event = jQuery.Event('modalist:click'),
|
18
|
+
url = $(this).data('modalist-url') || $(this).attr('href'),
|
19
|
+
form = $(this).data('modalist-form') || false,
|
20
|
+
fullScreen = $(this).data('modalist-full-screen');
|
21
|
+
|
22
|
+
event.target = $(this);
|
23
|
+
event.data = { url: url };
|
24
|
+
$(document).trigger(event);
|
25
|
+
|
26
|
+
Modalist.reset();
|
27
|
+
Modalist.fullScreen(fullScreen);
|
28
|
+
Modalist.load( url, form );
|
29
|
+
|
30
|
+
});
|
31
|
+
|
32
|
+
this.open = function(options) {
|
33
|
+
|
34
|
+
var defaults = {
|
35
|
+
url: null,
|
36
|
+
form: false,
|
37
|
+
fullScreen: false
|
38
|
+
};
|
39
|
+
options = $.extend( defaults, options );
|
40
|
+
|
41
|
+
Modalist.reset();
|
42
|
+
Modalist.fullScreen(options.fullScreen);
|
43
|
+
Modalist.load( options.url, options.form );
|
44
|
+
|
45
|
+
};
|
46
|
+
|
47
|
+
this.close = function() {
|
48
|
+
$(Modalist.modal).iziModal('close');
|
49
|
+
};
|
50
|
+
|
51
|
+
this.reset = function() {
|
52
|
+
$(Modalist.modal).iziModal('setTransitionIn', 'comingIn');
|
53
|
+
$(Modalist.modal).iziModal('setTransitionOut', 'comingOut');
|
54
|
+
$(Modalist.modal).data('full-screen', false);
|
55
|
+
$(Modalist.modal).iziModal('setTop', 'auto');
|
56
|
+
$(Modalist.modal).iziModal('setBottom', 'auto');
|
57
|
+
};
|
58
|
+
|
59
|
+
this.fullScreen = function(fullScreen) {
|
60
|
+
if ( fullScreen == 'true' || ( fullScreen == 'mobile' && $(window).width() <= 800 ) ) {
|
61
|
+
$(Modalist.modal).iziModal('setTransitionIn', 'fadeInRight');
|
62
|
+
$(Modalist.modal).iziModal('setTransitionOut', 'fadeOutRight');
|
63
|
+
$(Modalist.modal).data('full-screen', true);
|
64
|
+
};
|
65
|
+
};
|
66
|
+
|
67
|
+
this.load = function( url, options ) {
|
68
|
+
|
69
|
+
var defaults = {
|
70
|
+
form: false
|
71
|
+
};
|
72
|
+
options = $.extend( defaults, options );
|
73
|
+
|
74
|
+
$(document).trigger('modalist:request-start');
|
75
|
+
|
76
|
+
if (options.form) {
|
77
|
+
$.ajax({
|
78
|
+
url: $(options.form).attr('action'),
|
79
|
+
type: 'GET',
|
80
|
+
data : $(options.form).serialize(),
|
81
|
+
success: function(data) {
|
82
|
+
$(document).trigger('modalist:request-end');
|
83
|
+
Modalist.data(data);
|
84
|
+
}
|
85
|
+
});
|
86
|
+
} else {
|
87
|
+
$.get( url, function(data) {
|
88
|
+
$(document).trigger('modalist:request-end');
|
89
|
+
Modalist.data(data);
|
90
|
+
});
|
91
|
+
};
|
92
|
+
|
93
|
+
};
|
94
|
+
|
95
|
+
this.data = function(data) {
|
96
|
+
|
97
|
+
$(document).trigger('modalist:before-render');
|
98
|
+
$(Modalist.modal).find('.iziModal-content').html(data);
|
99
|
+
$(document).trigger('modal:render');
|
100
|
+
|
101
|
+
$(Modalist.modal).iziModal('open');
|
102
|
+
if ( $(Modalist.modal).height() + 60 > $(window).height() ) {
|
103
|
+
$(Modalist.modal).iziModal('setTop', 30);
|
104
|
+
$(Modalist.modal).iziModal('setBottom', 30);
|
105
|
+
};
|
106
|
+
$(document).trigger('modalist:load');
|
107
|
+
|
108
|
+
};
|
109
|
+
|
110
|
+
};
|
111
|
+
})(jQuery);
|