diff --git a/bower.json b/bower.json index bebde8f..0808b93 100644 --- a/bower.json +++ b/bower.json @@ -1,9 +1,9 @@ { "name": "remodal", - "version": "0.1.0", + "version": "0.1.1", "homepage": "http://vodkabears.github.io/remodal/", "authors": [ - "Zeno Rocha " + "Ilya Makarov " ], "description": "Flat, responsive, lightweight, easy customizable modal window plugin with declarative state notation and hash tracking.", "main": [ "dist/jquery.remodal.js", "dist/jquery.remodal.min.js", "dist/jquery.remodal.css"], diff --git a/dist/jquery.remodal.css b/dist/jquery.remodal.css index 3cd9493..b81c8f9 100644 --- a/dist/jquery.remodal.css +++ b/dist/jquery.remodal.css @@ -1,6 +1,7 @@ -/*! Remodal - v0.1.0 - 2014-02-15 +/*! Remodal - v0.1.1 - 2014-02-23 * https://github.com/VodkaBears/remodal * Copyright (c) 2014 VodkaBears; */ + /* Fonts */ @import url(http://fonts.googleapis.com/css?family=Exo+2:700,400&subset=latin,cyrillic); @@ -20,11 +21,11 @@ html.remodal_lock, body.remodal_lock { } body.remodal_active .remodal-bg { - -webkit-filter: blur(5px); - -moz-filter: blur(5px); - -o-filter: blur(5px); - -ms-filter: blur(5px); - filter: blur(5px); + -webkit-filter: blur(3px); + -moz-filter: blur(3px); + -o-filter: blur(3px); + -ms-filter: blur(3px); + filter: blur(3px); } /* Background for effects(end) */ diff --git a/dist/jquery.remodal.js b/dist/jquery.remodal.js index efe60c4..84057aa 100644 --- a/dist/jquery.remodal.js +++ b/dist/jquery.remodal.js @@ -1,8 +1,7 @@ -/*! Remodal - v0.1.0 - 2014-02-15 +/*! Remodal - v0.1.1 - 2014-02-23 * https://github.com/VodkaBears/remodal * Copyright (c) 2014 VodkaBears; */ -; -(function ($) { +;(function ($) { "use strict"; /** @@ -29,17 +28,17 @@ * @return {Number} */ var getTransitionDuration = function ($elem) { - var duration = $elem.css('transitionDuration') || - $elem.css('webkitTransitionDuration') || - $elem.css('mozTransitionDuration') || - $elem.css('oTransitionDuration') || - $elem.css('msTransitionDuration') || + var duration = $elem.css('transition-duration') || + $elem.css('-webkit-transition-duration') || + $elem.css('-moz-transition-duration') || + $elem.css('-o-transition-duration') || + $elem.css('-ms-transition-duration') || 0; - var delay = $elem.css('transitionDelay') || - $elem.css('webkitTransitionDelay') || - $elem.css('mozTransitionDelay') || - $elem.css('oTransitionDelay') || - $elem.css('msTransitionDelay') || + var delay = $elem.css('transition-delay') || + $elem.css('-webkit-transition-delay') || + $elem.css('-moz-transition-delay') || + $elem.css('-o-transition-delay') || + $elem.css('-ms-transition-delay') || 0; return (parseFloat(duration) + parseFloat(delay)) * 1000; @@ -68,6 +67,22 @@ return widthNoScroll - widthWithScroll; }; + /** + * Lock screen + */ + var lockScreen = function () { + $("html, body").addClass(pluginName + "_lock"); + $(document.body).css("padding-right", "+=" + getScrollbarWidth()); + }; + + /** + * Unlock screen + */ + var unlockScreen = function () { + $("html, body").removeClass(pluginName + "_lock"); + $(document.body).css("padding-right", "-=" + getScrollbarWidth()); + }; + /** * Remodal constructor */ @@ -144,22 +159,6 @@ }.bind(this)); }; - /** - * Lock screen - */ - Remodal.prototype.lockScreen = function () { - $("html, body").addClass(pluginName + "_lock"); - this.body.css("padding-right", "+=" + getScrollbarWidth()); - }; - - /** - * Unlock screen - */ - Remodal.prototype.unlockScreen = function () { - $("html, body").removeClass(pluginName + "_lock"); - this.body.css("padding-right", "-=" + getScrollbarWidth()); - }; - /** * Open modal window */ @@ -183,7 +182,7 @@ } current = this; - this.lockScreen(); + lockScreen(); this.overlay.show(); setTimeout(function () { this.body.addClass(pluginName + "_active"); @@ -214,10 +213,11 @@ } this.body.removeClass(pluginName + "_active"); + console.log(this.td); setTimeout(function () { this.overlay.hide(); - this.unlockScreen(); + unlockScreen(); this.busy = false; this.modal.trigger("closed"); @@ -228,9 +228,9 @@ $["fn"][pluginName] = function (opts) { return this["each"](function (i, e) { var $e = $(e); - if (!$e.data(pluginName) || !$e.data(pluginName).open) { + if (!$e.data(pluginName)) { var instance = new Remodal($e, opts); - $e.data(pluginName, instance); + $e.data(pluginName, instance.index); } }); }; @@ -246,7 +246,7 @@ id = elem.getAttribute("data-" + pluginName + "-target"), $target = $("[data-" + pluginName + "-id=" + id + "]"); - $target.data(pluginName).open(); + instances[$target.data(pluginName)].open(); }); /** @@ -287,9 +287,9 @@ var $elem = $("[data-" + pluginName + "-id=" + id + "]"); if ($elem.length) { - var data = $elem.data(pluginName); - if (data && data.settings.hashTracking) { - data.open(); + var instance = instances[$elem.data(pluginName)]; + if (instance && instance.settings.hashTracking) { + instance.open(); } } @@ -297,4 +297,4 @@ }; $(window).bind("hashchange." + pluginName, hashHandler); hashHandler(null, false); -})(window["jQuery"]); \ No newline at end of file +})(window["jQuery"] || window["Zepto"]); \ No newline at end of file diff --git a/dist/jquery.remodal.min.js b/dist/jquery.remodal.min.js index 3ee6f6d..c3901ba 100644 --- a/dist/jquery.remodal.min.js +++ b/dist/jquery.remodal.min.js @@ -1,4 +1,4 @@ -/*! Remodal - v0.1.0 - 2014-02-15 +/*! Remodal - v0.1.1 - 2014-02-23 * https://github.com/VodkaBears/remodal * Copyright (c) 2014 VodkaBears; */ -!function(a){"use strict";function b(b,c){this.settings=a.extend({},e,c),this.modal=b,this.buildDOM(),this.addEventListeners(),this.index=f.push(this)-1,this.busy=!1}var c,d="remodal",e={hashTracking:!0},f=[],g=function(a){var b=a.css("transitionDuration")||a.css("webkitTransitionDuration")||a.css("mozTransitionDuration")||a.css("oTransitionDuration")||a.css("msTransitionDuration")||0,c=a.css("transitionDelay")||a.css("webkitTransitionDelay")||a.css("mozTransitionDelay")||a.css("oTransitionDelay")||a.css("msTransitionDelay")||0;return 1e3*(parseFloat(b)+parseFloat(c))},h=function(){var a=document.createElement("div");a.style.visibility="hidden",a.style.width="100px",document.body.appendChild(a);var b=a.offsetWidth;a.style.overflow="scroll";var c=document.createElement("div");c.style.width="100%",a.appendChild(c);var d=c.offsetWidth;return a.parentNode.removeChild(a),b-d};b.prototype.buildDOM=function(){this.body=a(document.body),this.bg=a("."+d+"-bg"),this.modalClose=a("").addClass(d+"-close"),this.overlay=a("
").addClass(d+"-overlay"),this.modal.hasClass(d)||this.modal.addClass(d),this.modal.css("visibility","visible"),this.modal.append(this.modalClose),this.overlay.append(this.modal),this.body.append(this.overlay),this.confirm=this.modal.find("."+d+"-confirm"),this.cancel=this.modal.find("."+d+"-cancel");var b=g(this.overlay),c=g(this.modal),e=g(this.bg);this.td=c>b?c:b,this.td=e>this.td?e:this.td},b.prototype.addEventListeners=function(){this.modalClose.bind("click."+d,function(a){a.preventDefault(),this.close()}.bind(this)),this.cancel.bind("click."+d,function(a){a.preventDefault(),this.modal.trigger("cancel"),this.close()}.bind(this)),this.confirm.bind("click."+d,function(a){a.preventDefault(),this.modal.trigger("confirm"),this.close()}.bind(this)),a(document).bind("keyup."+d,function(a){27===a.keyCode&&this.close()}.bind(this)),this.overlay.bind("click."+d,function(b){var c=a(b.target);c.hasClass(d+"-overlay")&&this.close()}.bind(this))},b.prototype.lockScreen=function(){a("html, body").addClass(d+"_lock"),this.body.css("padding-right","+="+h())},b.prototype.unlockScreen=function(){a("html, body").removeClass(d+"_lock"),this.body.css("padding-right","-="+h())},b.prototype.open=function(){if(!this.busy){this.busy=!0,this.modal.trigger("open");var a=this.modal.attr("data-"+d+"-id");a&&this.settings.hashTracking&&(location.hash=a),c&&c!==this&&(c.overlay.hide(),c.body.removeClass(d+"_active")),c=this,this.lockScreen(),this.overlay.show(),setTimeout(function(){this.body.addClass(d+"_active"),setTimeout(function(){this.busy=!1,this.modal.trigger("opened")}.bind(this),this.td+50)}.bind(this),25)}},b.prototype.close=function(){this.busy||(this.busy=!0,this.modal.trigger("close"),this.settings.hashTracking&&this.modal.attr("data-"+d+"-id")===location.hash.substr(1)&&(location.hash=""),this.body.removeClass(d+"_active"),setTimeout(function(){this.overlay.hide(),this.unlockScreen(),this.busy=!1,this.modal.trigger("closed")}.bind(this),this.td+50))},a&&(a.fn[d]=function(c){return this.each(function(e,f){var g=a(f);if(!g.data(d)||!g.data(d).open){var h=new b(g,c);g.data(d,h)}})}),a(document).on("click","[data-"+d+"-target]",function(b){b.preventDefault();var c=b.currentTarget,e=c.getAttribute("data-"+d+"-target"),f=a("[data-"+d+"-id="+e+"]");f.data(d).open()}),a(document).find("."+d).each(function(b,c){var e=a(c),f=e.data(d+"-options");f||(f={}),e[d](f)});var i=function(b,e){var f=location.hash.replace("#","");if("undefined"==typeof e&&(e=!0),f){var g=a("[data-"+d+"-id="+f+"]");if(g.length){var h=g.data(d);h&&h.settings.hashTracking&&h.open()}}else e&&c&&!c.busy&&c.settings.hashTracking&&c.close()};a(window).bind("hashchange."+d,i),i(null,!1)}(window.jQuery); \ No newline at end of file +!function(a){"use strict";function b(b,c){this.settings=a.extend({},e,c),this.modal=b,this.buildDOM(),this.addEventListeners(),this.index=f.push(this)-1,this.busy=!1}var c,d="remodal",e={hashTracking:!0},f=[],g=function(a){var b=a.css("transition-duration")||a.css("-webkit-transition-duration")||a.css("-moz-transition-duration")||a.css("-o-transition-duration")||a.css("-ms-transition-duration")||0,c=a.css("transition-delay")||a.css("-webkit-transition-delay")||a.css("-moz-transition-delay")||a.css("-o-transition-delay")||a.css("-ms-transition-delay")||0;return 1e3*(parseFloat(b)+parseFloat(c))},h=function(){var a=document.createElement("div");a.style.visibility="hidden",a.style.width="100px",document.body.appendChild(a);var b=a.offsetWidth;a.style.overflow="scroll";var c=document.createElement("div");c.style.width="100%",a.appendChild(c);var d=c.offsetWidth;return a.parentNode.removeChild(a),b-d},i=function(){a("html, body").addClass(d+"_lock"),a(document.body).css("padding-right","+="+h())},j=function(){a("html, body").removeClass(d+"_lock"),a(document.body).css("padding-right","-="+h())};b.prototype.buildDOM=function(){this.body=a(document.body),this.bg=a("."+d+"-bg"),this.modalClose=a("").addClass(d+"-close"),this.overlay=a("
").addClass(d+"-overlay"),this.modal.hasClass(d)||this.modal.addClass(d),this.modal.css("visibility","visible"),this.modal.append(this.modalClose),this.overlay.append(this.modal),this.body.append(this.overlay),this.confirm=this.modal.find("."+d+"-confirm"),this.cancel=this.modal.find("."+d+"-cancel");var b=g(this.overlay),c=g(this.modal),e=g(this.bg);this.td=c>b?c:b,this.td=e>this.td?e:this.td},b.prototype.addEventListeners=function(){this.modalClose.bind("click."+d,function(a){a.preventDefault(),this.close()}.bind(this)),this.cancel.bind("click."+d,function(a){a.preventDefault(),this.modal.trigger("cancel"),this.close()}.bind(this)),this.confirm.bind("click."+d,function(a){a.preventDefault(),this.modal.trigger("confirm"),this.close()}.bind(this)),a(document).bind("keyup."+d,function(a){27===a.keyCode&&this.close()}.bind(this)),this.overlay.bind("click."+d,function(b){var c=a(b.target);c.hasClass(d+"-overlay")&&this.close()}.bind(this))},b.prototype.open=function(){if(!this.busy){this.busy=!0,this.modal.trigger("open");var a=this.modal.attr("data-"+d+"-id");a&&this.settings.hashTracking&&(location.hash=a),c&&c!==this&&(c.overlay.hide(),c.body.removeClass(d+"_active")),c=this,i(),this.overlay.show(),setTimeout(function(){this.body.addClass(d+"_active"),setTimeout(function(){this.busy=!1,this.modal.trigger("opened")}.bind(this),this.td+50)}.bind(this),25)}},b.prototype.close=function(){this.busy||(this.busy=!0,this.modal.trigger("close"),this.settings.hashTracking&&this.modal.attr("data-"+d+"-id")===location.hash.substr(1)&&(location.hash=""),this.body.removeClass(d+"_active"),console.log(this.td),setTimeout(function(){this.overlay.hide(),j(),this.busy=!1,this.modal.trigger("closed")}.bind(this),this.td+50))},a&&(a.fn[d]=function(c){return this.each(function(e,f){var g=a(f);if(!g.data(d)){var h=new b(g,c);g.data(d,h.index)}})}),a(document).on("click","[data-"+d+"-target]",function(b){b.preventDefault();var c=b.currentTarget,e=c.getAttribute("data-"+d+"-target"),g=a("[data-"+d+"-id="+e+"]");f[g.data(d)].open()}),a(document).find("."+d).each(function(b,c){var e=a(c),f=e.data(d+"-options");f||(f={}),e[d](f)});var k=function(b,e){var g=location.hash.replace("#","");if("undefined"==typeof e&&(e=!0),g){var h=a("[data-"+d+"-id="+g+"]");if(h.length){var i=f[h.data(d)];i&&i.settings.hashTracking&&i.open()}}else e&&c&&!c.busy&&c.settings.hashTracking&&c.close()};a(window).bind("hashchange."+d,k),k(null,!1)}(window.jQuery||window.Zepto); \ No newline at end of file diff --git a/remodal.jquery.json b/remodal.jquery.json index bbc52df..b1d6169 100644 --- a/remodal.jquery.json +++ b/remodal.jquery.json @@ -13,7 +13,7 @@ "lightbox", "ui" ], - "version": "0.1.0", + "version": "0.1.1", "author": { "name": "Ilya Makarov", "email": "dfrost.00@gmail.com", diff --git a/src/jquery.remodal.css b/src/jquery.remodal.css index 017d69d..b81c8f9 100644 --- a/src/jquery.remodal.css +++ b/src/jquery.remodal.css @@ -1,6 +1,7 @@ -/*! Remodal - v0.1.0 - 2014-02-15 +/*! Remodal - v0.1.1 - 2014-02-23 * https://github.com/VodkaBears/remodal * Copyright (c) 2014 VodkaBears; */ + /* Fonts */ @import url(http://fonts.googleapis.com/css?family=Exo+2:700,400&subset=latin,cyrillic); diff --git a/src/jquery.remodal.js b/src/jquery.remodal.js index 190a6bd..84057aa 100644 --- a/src/jquery.remodal.js +++ b/src/jquery.remodal.js @@ -1,4 +1,4 @@ -/*! Remodal - v0.1.0 - 2014-02-15 +/*! Remodal - v0.1.1 - 2014-02-23 * https://github.com/VodkaBears/remodal * Copyright (c) 2014 VodkaBears; */ ;(function ($) {