diff --git a/bower.json b/bower.json index bb2b7c9..2b65cc2 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "remodal", - "version": "0.6.3", + "version": "0.6.4", "homepage": "http://vodkabears.github.io/remodal/", "authors": [ "Ilya Makarov " diff --git a/dist/jquery.remodal.css b/dist/jquery.remodal.css index d36c184..11a7c87 100644 --- a/dist/jquery.remodal.css +++ b/dist/jquery.remodal.css @@ -1,12 +1,12 @@ /* - * Remodal - v0.6.3 + * Remodal - v0.6.4 * Flat, responsive, lightweight, easy customizable modal window plugin with declarative state notation and hash tracking. * http://vodkabears.github.io/remodal/ * * Made by Ilya Makarov * Under MIT License */ -@import url(http://fonts.googleapis.com/css?family=Exo+2:700,400&subset=latin,cyrillic); +@import url(//fonts.googleapis.com/css?family=Exo+2:700,400&subset=latin,cyrillic); /* ========================================================================== Remodal necessary styles @@ -280,7 +280,7 @@ body.remodal-is-active .remodal { /* Media queries ========================================================================== */ -@media only screen and (min-width: 40.063em) /* min-width 641px */ { +@media only screen and (min-width: 641px) { .remodal { max-width: 700px; min-height: 0; diff --git a/dist/jquery.remodal.js b/dist/jquery.remodal.js index 58f9c8f..28278bf 100644 --- a/dist/jquery.remodal.js +++ b/dist/jquery.remodal.js @@ -1,12 +1,23 @@ /* - * Remodal - v0.6.3 + * Remodal - v0.6.4 * Flat, responsive, lightweight, easy customizable modal window plugin with declarative state notation and hash tracking. * http://vodkabears.github.io/remodal/ * * Made by Ilya Makarov * Under MIT License */ -!(function($) { +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + define(['jquery'], function($) { + return factory(root, $); + }); + } else if (typeof exports === 'object') { + factory(root, require('jquery')); + } else { + factory(root, root.jQuery || root.Zepto); + } +})(this, function(global, $) { + 'use strict'; /** @@ -21,7 +32,7 @@ * @private * @type {String} */ - var namespace = window.remodalGlobals && window.remodalGlobals.namespace || pluginName; + var namespace = global.remodalGlobals && global.remodalGlobals.namespace || pluginName; /** * Default settings @@ -34,7 +45,7 @@ closeOnCancel: true, closeOnEscape: true, closeOnAnyClick: true - }, window.remodalGlobals && window.remodalGlobals.defaults); + }, global.remodalGlobals && global.remodalGlobals.defaults); /** * Current modal @@ -247,8 +258,7 @@ tdOverlay = getTransitionDuration(remodal.$overlay); tdModal = getTransitionDuration(remodal.$modal); tdBg = getTransitionDuration(remodal.$bg); - remodal.td = tdModal > tdOverlay ? tdModal : tdOverlay; - remodal.td = tdBg > remodal.td ? tdBg : remodal.td; + remodal.td = Math.max(tdOverlay, tdModal, tdBg); // Add the close button event listener remodal.$wrapper.on('click.' + namespace, '.' + namespace + '-close', function(e) { @@ -341,6 +351,7 @@ setTimeout(function() { remodal.$body.addClass(namespace + '-is-active'); + remodal.$wrapper.scrollTop(0); setTimeout(function() { remodal.busy = false; @@ -369,9 +380,10 @@ reason: reason }); - if (remodal.settings.hashTracking && - remodal.$modal.attr('data-' + pluginName + '-id') === location.hash.substr(1)) { - + if ( + remodal.settings.hashTracking && + remodal.$modal.attr('data-' + pluginName + '-id') === location.hash.substr(1) + ) { location.hash = ''; $(window).scrollTop(scrollTop); } @@ -417,9 +429,10 @@ instance = new Remodal($elem, opts); $elem.data(pluginName, instance.index); - if (instance.settings.hashTracking && - $elem.attr('data-' + pluginName + '-id') === location.hash.substr(1)) { - + if ( + instance.settings.hashTracking && + $elem.attr('data-' + pluginName + '-id') === location.hash.substr(1) + ) { instance.open(); } } else { @@ -506,4 +519,4 @@ $(window).bind('hashchange.' + namespace, hashHandler); -})(window.jQuery || window.Zepto); +}); diff --git a/dist/jquery.remodal.min.js b/dist/jquery.remodal.min.js index 2d89c79..cd03c70 100644 --- a/dist/jquery.remodal.min.js +++ b/dist/jquery.remodal.min.js @@ -1,9 +1,9 @@ /* - * Remodal - v0.6.3 + * Remodal - v0.6.4 * Flat, responsive, lightweight, easy customizable modal window plugin with declarative state notation and hash tracking. * http://vodkabears.github.io/remodal/ * * Made by Ilya Makarov * Under MIT License */ -!function(a){"use strict";function b(a){var b,c,d,e,f=a.css("transition-duration")||a.css("-webkit-transition-duration")||a.css("-moz-transition-duration")||a.css("-o-transition-duration")||a.css("-ms-transition-duration")||"0s",g=a.css("transition-delay")||a.css("-webkit-transition-delay")||a.css("-moz-transition-delay")||a.css("-o-transition-delay")||a.css("-ms-transition-delay")||"0s";for(f=f.split(", "),g=g.split(", "),e=0,c=f.length,b=Number.NEGATIVE_INFINITY;c>e;e++)d=parseFloat(f[e])+parseFloat(g[e]),d>b&&(b=d);return 1e3*d}function c(){if(a(document.body).height()<=a(window).height())return 0;var b,c,d=document.createElement("div"),e=document.createElement("div");return d.style.visibility="hidden",d.style.width="100px",document.body.appendChild(d),b=d.offsetWidth,d.style.overflow="scroll",e.style.width="100%",d.appendChild(e),c=e.offsetWidth,d.parentNode.removeChild(d),b-c}function d(){var b,d,e=a("html"),f=l+"-is-locked";e.hasClass(f)||(d=a(document.body),b=parseInt(d.css("padding-right"),10)+c(),d.css("padding-right",b+"px"),e.addClass(f))}function e(){var b,d,e=a("html"),f=l+"-is-locked";e.hasClass(f)&&(d=a(document.body),b=parseInt(d.css("padding-right"),10)-c(),d.css("padding-right",b+"px"),e.removeClass(f))}function f(a){var b,c,d,e,f={};for(a=a.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,","),b=a.split(","),e=0,c=b.length;c>e;e++)b[e]=b[e].split(":"),d=b[e][1],("string"==typeof d||d instanceof String)&&(d="true"===d||("false"===d?!1:d)),("string"==typeof d||d instanceof String)&&(d=isNaN(d)?d:+d),f[b[e][0]]=d;return f}function g(c,d){var e,f,g,h=this;h.settings=a.extend({},m,d),h.$body=a(document.body),h.$overlay=a("."+l+"-overlay"),h.$overlay.length||(h.$overlay=a("
").addClass(l+"-overlay"),h.$body.append(h.$overlay)),h.$bg=a("."+l+"-bg"),h.$closeButton=a('').addClass(l+"-close"),h.$wrapper=a("
").addClass(l+"-wrapper"),h.$modal=c,h.$modal.addClass(l),h.$modal.css("visibility","visible"),h.$modal.append(h.$closeButton),h.$wrapper.append(h.$modal),h.$body.append(h.$wrapper),h.$confirmButton=h.$modal.find("."+l+"-confirm"),h.$cancelButton=h.$modal.find("."+l+"-cancel"),e=b(h.$overlay),f=b(h.$modal),g=b(h.$bg),h.td=f>e?f:e,h.td=g>h.td?g:h.td,h.$wrapper.on("click."+l,"."+l+"-close",function(a){a.preventDefault(),h.close()}),h.$wrapper.on("click."+l,"."+l+"-cancel",function(a){a.preventDefault(),h.$modal.trigger("cancel"),h.settings.closeOnCancel&&h.close("cancellation")}),h.$wrapper.on("click."+l,"."+l+"-confirm",function(a){a.preventDefault(),h.$modal.trigger("confirm"),h.settings.closeOnConfirm&&h.close("confirmation")}),a(document).on("keyup."+l,function(a){27===a.keyCode&&h.settings.closeOnEscape&&h.close()}),h.$wrapper.on("click."+l,function(b){var c=a(b.target);c.hasClass(l+"-wrapper")&&h.settings.closeOnAnyClick&&h.close()}),h.index=a[k].lookup.push(h)-1,h.busy=!1}function h(b,c){var d,e,f=location.hash.replace("#","");if("undefined"==typeof c&&(c=!0),f){try{e=a("[data-"+k+"-id="+f.replace(new RegExp("/","g"),"\\/")+"]")}catch(g){}e&&e.length&&(d=a[k].lookup[e.data(k)],d&&d.settings.hashTracking&&d.open())}else c&&i&&!i.busy&&i.settings.hashTracking&&i.close()}var i,j,k="remodal",l=window.remodalGlobals&&window.remodalGlobals.namespace||k,m=a.extend({hashTracking:!0,closeOnConfirm:!0,closeOnCancel:!0,closeOnEscape:!0,closeOnAnyClick:!0},window.remodalGlobals&&window.remodalGlobals.defaults);g.prototype.open=function(){if(!this.busy){var b,c=this;c.busy=!0,c.$modal.trigger("open"),b=c.$modal.attr("data-"+k+"-id"),b&&c.settings.hashTracking&&(j=a(window).scrollTop(),location.hash=b),i&&i!==c&&(i.$overlay.hide(),i.$wrapper.hide(),i.$body.removeClass(l+"-is-active")),i=c,d(),c.$overlay.show(),c.$wrapper.show(),setTimeout(function(){c.$body.addClass(l+"-is-active"),setTimeout(function(){c.busy=!1,c.$modal.trigger("opened")},c.td+50)},25)}},g.prototype.close=function(b){if(!this.busy){var c=this;c.busy=!0,c.$modal.trigger({type:"close",reason:b}),c.settings.hashTracking&&c.$modal.attr("data-"+k+"-id")===location.hash.substr(1)&&(location.hash="",a(window).scrollTop(j)),c.$body.removeClass(l+"-is-active"),setTimeout(function(){c.$overlay.hide(),c.$wrapper.hide(),e(),c.busy=!1,c.$modal.trigger({type:"closed",reason:b})},c.td+50)}},a[k]={lookup:[]},a.fn[k]=function(b){var c,d;return this.each(function(e,f){d=a(f),null==d.data(k)?(c=new g(d,b),d.data(k,c.index),c.settings.hashTracking&&d.attr("data-"+k+"-id")===location.hash.substr(1)&&c.open()):c=a[k].lookup[d.data(k)]}),c},a(document).ready(function(){a(document).on("click","[data-"+k+"-target]",function(b){b.preventDefault();var c=b.currentTarget,d=c.getAttribute("data-"+k+"-target"),e=a("[data-"+k+"-id="+d+"]");a[k].lookup[e.data(k)].open()}),a(document).find("."+l).each(function(b,c){var d=a(c),e=d.data(k+"-options");e?("string"==typeof e||e instanceof String)&&(e=f(e)):e={},d[k](e)})}),a(window).bind("hashchange."+l,h)}(window.jQuery||window.Zepto); \ No newline at end of file +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(c){return b(a,c)}):"object"==typeof exports?b(a,require("jquery")):b(a,a.jQuery||a.Zepto)}(this,function(a,b){"use strict";function c(a){var b,c,d,e,f=a.css("transition-duration")||a.css("-webkit-transition-duration")||a.css("-moz-transition-duration")||a.css("-o-transition-duration")||a.css("-ms-transition-duration")||"0s",g=a.css("transition-delay")||a.css("-webkit-transition-delay")||a.css("-moz-transition-delay")||a.css("-o-transition-delay")||a.css("-ms-transition-delay")||"0s";for(f=f.split(", "),g=g.split(", "),e=0,c=f.length,b=Number.NEGATIVE_INFINITY;c>e;e++)d=parseFloat(f[e])+parseFloat(g[e]),d>b&&(b=d);return 1e3*d}function d(){if(b(document.body).height()<=b(window).height())return 0;var a,c,d=document.createElement("div"),e=document.createElement("div");return d.style.visibility="hidden",d.style.width="100px",document.body.appendChild(d),a=d.offsetWidth,d.style.overflow="scroll",e.style.width="100%",d.appendChild(e),c=e.offsetWidth,d.parentNode.removeChild(d),a-c}function e(){var a,c,e=b("html"),f=m+"-is-locked";e.hasClass(f)||(c=b(document.body),a=parseInt(c.css("padding-right"),10)+d(),c.css("padding-right",a+"px"),e.addClass(f))}function f(){var a,c,e=b("html"),f=m+"-is-locked";e.hasClass(f)&&(c=b(document.body),a=parseInt(c.css("padding-right"),10)-d(),c.css("padding-right",a+"px"),e.removeClass(f))}function g(a){var b,c,d,e,f={};for(a=a.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,","),b=a.split(","),e=0,c=b.length;c>e;e++)b[e]=b[e].split(":"),d=b[e][1],("string"==typeof d||d instanceof String)&&(d="true"===d||("false"===d?!1:d)),("string"==typeof d||d instanceof String)&&(d=isNaN(d)?d:+d),f[b[e][0]]=d;return f}function h(a,d){var e,f,g,h=this;h.settings=b.extend({},n,d),h.$body=b(document.body),h.$overlay=b("."+m+"-overlay"),h.$overlay.length||(h.$overlay=b("
").addClass(m+"-overlay"),h.$body.append(h.$overlay)),h.$bg=b("."+m+"-bg"),h.$closeButton=b('').addClass(m+"-close"),h.$wrapper=b("
").addClass(m+"-wrapper"),h.$modal=a,h.$modal.addClass(m),h.$modal.css("visibility","visible"),h.$modal.append(h.$closeButton),h.$wrapper.append(h.$modal),h.$body.append(h.$wrapper),h.$confirmButton=h.$modal.find("."+m+"-confirm"),h.$cancelButton=h.$modal.find("."+m+"-cancel"),e=c(h.$overlay),f=c(h.$modal),g=c(h.$bg),h.td=Math.max(e,f,g),h.$wrapper.on("click."+m,"."+m+"-close",function(a){a.preventDefault(),h.close()}),h.$wrapper.on("click."+m,"."+m+"-cancel",function(a){a.preventDefault(),h.$modal.trigger("cancel"),h.settings.closeOnCancel&&h.close("cancellation")}),h.$wrapper.on("click."+m,"."+m+"-confirm",function(a){a.preventDefault(),h.$modal.trigger("confirm"),h.settings.closeOnConfirm&&h.close("confirmation")}),b(document).on("keyup."+m,function(a){27===a.keyCode&&h.settings.closeOnEscape&&h.close()}),h.$wrapper.on("click."+m,function(a){var c=b(a.target);c.hasClass(m+"-wrapper")&&h.settings.closeOnAnyClick&&h.close()}),h.index=b[l].lookup.push(h)-1,h.busy=!1}function i(a,c){var d,e,f=location.hash.replace("#","");if("undefined"==typeof c&&(c=!0),f){try{e=b("[data-"+l+"-id="+f.replace(new RegExp("/","g"),"\\/")+"]")}catch(g){}e&&e.length&&(d=b[l].lookup[e.data(l)],d&&d.settings.hashTracking&&d.open())}else c&&j&&!j.busy&&j.settings.hashTracking&&j.close()}var j,k,l="remodal",m=a.remodalGlobals&&a.remodalGlobals.namespace||l,n=b.extend({hashTracking:!0,closeOnConfirm:!0,closeOnCancel:!0,closeOnEscape:!0,closeOnAnyClick:!0},a.remodalGlobals&&a.remodalGlobals.defaults);h.prototype.open=function(){if(!this.busy){var a,c=this;c.busy=!0,c.$modal.trigger("open"),a=c.$modal.attr("data-"+l+"-id"),a&&c.settings.hashTracking&&(k=b(window).scrollTop(),location.hash=a),j&&j!==c&&(j.$overlay.hide(),j.$wrapper.hide(),j.$body.removeClass(m+"-is-active")),j=c,e(),c.$overlay.show(),c.$wrapper.show(),setTimeout(function(){c.$body.addClass(m+"-is-active"),c.$wrapper.scrollTop(0),setTimeout(function(){c.busy=!1,c.$modal.trigger("opened")},c.td+50)},25)}},h.prototype.close=function(a){if(!this.busy){var c=this;c.busy=!0,c.$modal.trigger({type:"close",reason:a}),c.settings.hashTracking&&c.$modal.attr("data-"+l+"-id")===location.hash.substr(1)&&(location.hash="",b(window).scrollTop(k)),c.$body.removeClass(m+"-is-active"),setTimeout(function(){c.$overlay.hide(),c.$wrapper.hide(),f(),c.busy=!1,c.$modal.trigger({type:"closed",reason:a})},c.td+50)}},b[l]={lookup:[]},b.fn[l]=function(a){var c,d;return this.each(function(e,f){d=b(f),null==d.data(l)?(c=new h(d,a),d.data(l,c.index),c.settings.hashTracking&&d.attr("data-"+l+"-id")===location.hash.substr(1)&&c.open()):c=b[l].lookup[d.data(l)]}),c},b(document).ready(function(){b(document).on("click","[data-"+l+"-target]",function(a){a.preventDefault();var c=a.currentTarget,d=c.getAttribute("data-"+l+"-target"),e=b("[data-"+l+"-id="+d+"]");b[l].lookup[e.data(l)].open()}),b(document).find("."+m).each(function(a,c){var d=b(c),e=d.data(l+"-options");e?("string"==typeof e||e instanceof String)&&(e=g(e)):e={},d[l](e)})}),b(window).bind("hashchange."+m,i)}); \ No newline at end of file diff --git a/package.json b/package.json index b259156..eec0c05 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "remodal", - "version": "0.6.3", + "version": "0.6.4", "description": "Flat, responsive, lightweight, easy customizable modal window plugin with declarative state notation and hash tracking.", "keywords": [ "jquery-plugin",