!function(t,n){"function"==typeof define&&define.amd?define(["jquery"],function(e){return n(t,e)}):"object"==typeof exports?n(t,require("jquery")):n(t,t.jQuery||t.Zepto)}(this,function(t,n){"use strict";function e(t){if(E&&"none"===t.css("animation-name")&&"none"===t.css("-webkit-animation-name")&&"none"===t.css("-moz-animation-name")&&"none"===t.css("-o-animation-name")&&"none"===t.css("-ms-animation-name"))return 0;var n,e,a,i,o=t.css("animation-duration")||t.css("-webkit-animation-duration")||t.css("-moz-animation-duration")||t.css("-o-animation-duration")||t.css("-ms-animation-duration")||"0s",s=t.css("animation-delay")||t.css("-webkit-animation-delay")||t.css("-moz-animation-delay")||t.css("-o-animation-delay")||t.css("-ms-animation-delay")||"0s",r=t.css("animation-iteration-count")||t.css("-webkit-animation-iteration-count")||t.css("-moz-animation-iteration-count")||t.css("-o-animation-iteration-count")||t.css("-ms-animation-iteration-count")||"1";for(o=o.split(", "),s=s.split(", "),r=r.split(", "),i=0,e=o.length,n=Number.NEGATIVE_INFINITY;in&&(n=a);return n}function a(){if(n(document.body).height()<=n(window).height())return 0;var t,e,a=document.createElement("div"),i=document.createElement("div");return a.style.visibility="hidden",a.style.width="100px",document.body.appendChild(a),t=a.offsetWidth,a.style.overflow="scroll",i.style.width="100%",a.appendChild(i),e=i.offsetWidth,a.parentNode.removeChild(a),t-e}function i(){if(!N){var t,e,i=n("html"),o=c("is-locked");i.hasClass(o)||(e=n(document.body),t=parseInt(e.css("padding-right"),10)+a(),e.css("padding-right",t+"px"),i.addClass(o))}}function o(){if(!N){var t,e,i=n("html"),o=c("is-locked");i.hasClass(o)&&(e=n(document.body),t=parseInt(e.css("padding-right"),10)-a(),e.css("padding-right",t+"px"),i.removeClass(o))}}function s(t,n,e,a){var i=c("is",n),o=[c("is",$.CLOSING),c("is",$.OPENING),c("is",$.CLOSED),c("is",$.OPENED)].join(" ");t.$bg.removeClass(o).addClass(i),t.$overlay.removeClass(o).addClass(i),t.$wrapper.removeClass(o).addClass(i),t.$modal.removeClass(o).addClass(i),t.state=n,!e&&t.$modal.trigger({type:n,reason:a},[{reason:a}])}function r(t,a,i){var o=0,s=function(t){t.target===this&&o++},r=function(t){t.target===this&&0===--o&&(n.each(["$bg","$overlay","$wrapper","$modal"],function(t,n){i[n].off(v+" "+C)}),a())};n.each(["$bg","$overlay","$wrapper","$modal"],function(t,n){i[n].on(v,s).on(C,r)}),t(),0===e(i.$bg)&&0===e(i.$overlay)&&0===e(i.$wrapper)&&0===e(i.$modal)&&(n.each(["$bg","$overlay","$wrapper","$modal"],function(t,n){i[n].off(v+" "+C)}),a())}function d(t){t.state!==$.CLOSED&&(n.each(["$bg","$overlay","$wrapper","$modal"],function(n,e){t[e].off(v+" "+C)}),t.$bg.removeClass(t.settings.modifier),t.$overlay.removeClass(t.settings.modifier).hide(),t.$wrapper.hide(),o(),s(t,$.CLOSED,!0))}function l(t){var n,e,a,i,o={};for(t=t.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,","),n=t.split(","),i=0,e=n.length;i").addClass(c("overlay")+" "+c("is",$.CLOSED)).hide(),i.append(o.$overlay)),o.$bg=n("."+c("bg")).addClass(c("is",$.CLOSED)),o.$modal=t.addClass(h+" "+c("is-initialized")+" "+o.settings.modifier+" "+c("is",$.CLOSED)).attr("tabindex","-1"),o.$wrapper=n("
").addClass(c("wrapper")+" "+o.settings.modifier+" "+c("is",$.CLOSED)).hide().append(o.$modal),i.append(o.$wrapper),o.$wrapper.on("click."+h,'[data-remodal-action="close"]',function(t){t.preventDefault(),o.close()}),o.$wrapper.on("click."+h,'[data-remodal-action="cancel"]',function(t){t.preventDefault(),o.$modal.trigger(y.CANCELLATION),o.settings.closeOnCancel&&o.close(y.CANCELLATION)}),o.$wrapper.on("click."+h,'[data-remodal-action="confirm"]',function(t){t.preventDefault(),o.$modal.trigger(y.CONFIRMATION),o.settings.closeOnConfirm&&o.close(y.CONFIRMATION)}),o.$wrapper.on("click."+h,function(t){var e=n(t.target);e.hasClass(c("wrapper"))&&o.settings.closeOnOutsideClick&&o.close()})}var u,f,g="remodal",h=t.REMODAL_GLOBALS&&t.REMODAL_GLOBALS.NAMESPACE||g,v=n.map(["animationstart","webkitAnimationStart","MSAnimationStart","oAnimationStart"],function(t){return t+"."+h}).join(" "),C=n.map(["animationend","webkitAnimationEnd","MSAnimationEnd","oAnimationEnd"],function(t){return t+"."+h}).join(" "),O=n.extend({hashTracking:!0,closeOnConfirm:!0,closeOnCancel:!0,closeOnEscape:!0,closeOnOutsideClick:!0,modifier:"",appendTo:null},t.REMODAL_GLOBALS&&t.REMODAL_GLOBALS.DEFAULTS),$={CLOSING:"closing",CLOSED:"closed",OPENING:"opening",OPENED:"opened"},y={CONFIRMATION:"confirmation",CANCELLATION:"cancellation"},E=function(){var t=document.createElement("div").style;return void 0!==t.animationName||void 0!==t.WebkitAnimationName||void 0!==t.MozAnimationName||void 0!==t.msAnimationName||void 0!==t.OAnimationName}(),N=/iPad|iPhone|iPod/.test(navigator.platform);p.prototype.open=function(){var t,e=this;e.state!==$.OPENING&&e.state!==$.CLOSING&&(t=e.$modal.attr("data-remodal-id"),t&&e.settings.hashTracking&&(f=n(window).scrollTop(),location.hash=t),u&&u!==e&&d(u),u=e,i(),e.$bg.addClass(e.settings.modifier),e.$overlay.addClass(e.settings.modifier).show(),e.$wrapper.show().scrollTop(0),e.$modal.focus(),r(function(){s(e,$.OPENING)},function(){s(e,$.OPENED)},e))},p.prototype.close=function(t){var e=this;e.state!==$.OPENING&&e.state!==$.CLOSING&&(e.settings.hashTracking&&e.$modal.attr("data-remodal-id")===location.hash.substr(1)&&(location.hash="",n(window).scrollTop(f)),r(function(){s(e,$.CLOSING,!1,t)},function(){e.$bg.removeClass(e.settings.modifier),e.$overlay.removeClass(e.settings.modifier).hide(),e.$wrapper.hide(),o(),s(e,$.CLOSED,!1,t)},e))},p.prototype.getState=function(){return this.state},p.prototype.destroy=function(){var t,e=n[g].lookup;d(this),this.$wrapper.remove(),delete e[this.index],t=n.grep(e,function(t){return!!t}).length,0===t&&(this.$overlay.remove(),this.$bg.removeClass(c("is",$.CLOSING)+" "+c("is",$.OPENING)+" "+c("is",$.CLOSED)+" "+c("is",$.OPENED)))},n[g]={lookup:[]},n.fn[g]=function(t){var e,a;return this.each(function(i,o){a=n(o),null==a.data(g)?(e=new p(a,t),a.data(g,e.index),e.settings.hashTracking&&a.attr("data-remodal-id")===location.hash.substr(1)&&e.open()):e=n[g].lookup[a.data(g)]}),e},n(document).ready(function(){n(document).on("click","[data-remodal-target]",function(t){t.preventDefault();var e=t.currentTarget,a=e.getAttribute("data-remodal-target"),i=n('[data-remodal-id="'+a+'"]');n[g].lookup[i.data(g)].open()}),n(document).find("."+h).each(function(t,e){var a=n(e),i=a.data("remodal-options");i?("string"==typeof i||i instanceof String)&&(i=l(i)):i={},a[g](i)}),n(document).on("keydown."+h,function(t){u&&u.settings.closeOnEscape&&u.state===$.OPENED&&27===t.keyCode&&u.close()}),n(window).on("hashchange."+h,m)})});