From aeac0fc65e7599a64e26ecba927f3064679a2237 Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Fri, 23 Jan 2015 15:31:47 +0200 Subject: [PATCH 01/10] Minify the JavaScript --- jquery.leanModal.min.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 jquery.leanModal.min.js diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js new file mode 100644 index 0000000..a8e65c9 --- /dev/null +++ b/jquery.leanModal.min.js @@ -0,0 +1 @@ +(function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null,closeOnBlur:true}var overlay=$("
").css({'position':'fixed','z-index':'100','top':'0px','left':'0px','height':'100%','width':'100%','background':'#000','display':'none'});$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");if(o.closeOnBlur||!o.closeButton){overlay.click(function(){close_modal(modal_id);});}$(o.closeButton).click(function(){close_modal(modal_id);});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth();overlay.css({'display':'block',opacity:0});overlay.fadeTo(200,o.overlay);$(modal_id).css({'display':'block','position':'fixed','opacity':0,'z-index':11000,'left':50+'%','margin-left':-(modal_width/2)+"px",'top':o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault();});});function close_modal(modal_id){overlay.fadeOut(200);$(modal_id).css({'display':'none'});}}});})(jQuery); \ No newline at end of file From 19e953a6fe87b2b1c0dd1cce5c9c153973d78d12 Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Fri, 23 Jan 2015 15:34:08 +0200 Subject: [PATCH 02/10] Add closeOnBlur option and fix overlay so no external CSS is required --- jquery.leanModal.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/jquery.leanModal.js b/jquery.leanModal.js index facf07e..560f015 100644 --- a/jquery.leanModal.js +++ b/jquery.leanModal.js @@ -7,10 +7,20 @@ var defaults = { top: 100, overlay: 0.5, - closeButton: null + closeButton: null, + closeOnBlur: true } - var overlay = $("
"); + var overlay = $("
").css({ + 'position': 'fixed', + 'z-index': '100', + 'top': '0px', + 'left': '0px', + 'height': '100%', + 'width': '100%', + 'background': '#000', + 'display': 'none' + }); $("body").append(overlay); @@ -24,9 +34,13 @@ var modal_id = $(this).attr("href"); - $("#lean_overlay").click(function() { - close_modal(modal_id); - }); + // If there is no close button, we discard the "closeOnblur" setting, + // or otherwise it will be impossible to close the overlay. + if (o.closeOnBlur || !o.closeButton) { + overlay.click(function() { + close_modal(modal_id); + }); + } $(o.closeButton).click(function() { close_modal(modal_id); @@ -35,9 +49,9 @@ var modal_height = $(modal_id).outerHeight(); var modal_width = $(modal_id).outerWidth(); - $('#lean_overlay').css({ 'display' : 'block', opacity : 0 }); + overlay.css({ 'display' : 'block', opacity : 0 }); - $('#lean_overlay').fadeTo(200,o.overlay); + overlay.fadeTo(200,o.overlay); $(modal_id).css({ @@ -61,7 +75,7 @@ function close_modal(modal_id){ - $("#lean_overlay").fadeOut(200); + overlay.fadeOut(200); $(modal_id).css({ 'display' : 'none' }); From 5dafb8a69dcd61a5063f2f860791b45a284f719f Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Fri, 23 Jan 2015 18:32:27 +0200 Subject: [PATCH 03/10] Change dialog position from "fixed" to "absolute" If the dialog is larger than the browser window, it's impossible to scroll to the bottom of it if its positioning is "fixed". --- jquery.leanModal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.leanModal.js b/jquery.leanModal.js index 560f015..eed2db5 100644 --- a/jquery.leanModal.js +++ b/jquery.leanModal.js @@ -56,7 +56,7 @@ $(modal_id).css({ 'display' : 'block', - 'position' : 'fixed', + 'position' : 'absolute', 'opacity' : 0, 'z-index': 11000, 'left' : 50 + '%', From bdeb803df48b6c45517687d83a3df4b0efeead8f Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Fri, 23 Jan 2015 18:33:23 +0200 Subject: [PATCH 04/10] Minify --- jquery.leanModal.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js index a8e65c9..4020c4b 100644 --- a/jquery.leanModal.min.js +++ b/jquery.leanModal.min.js @@ -1 +1 @@ -(function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null,closeOnBlur:true}var overlay=$("
").css({'position':'fixed','z-index':'100','top':'0px','left':'0px','height':'100%','width':'100%','background':'#000','display':'none'});$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");if(o.closeOnBlur||!o.closeButton){overlay.click(function(){close_modal(modal_id);});}$(o.closeButton).click(function(){close_modal(modal_id);});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth();overlay.css({'display':'block',opacity:0});overlay.fadeTo(200,o.overlay);$(modal_id).css({'display':'block','position':'fixed','opacity':0,'z-index':11000,'left':50+'%','margin-left':-(modal_width/2)+"px",'top':o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault();});});function close_modal(modal_id){overlay.fadeOut(200);$(modal_id).css({'display':'none'});}}});})(jQuery); \ No newline at end of file +(function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null,closeOnBlur:true}var overlay=$("
").css({'position':'fixed','z-index':'100','top':'0px','left':'0px','height':'100%','width':'100%','background':'#000','display':'none'});$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");if(o.closeOnBlur||!o.closeButton){overlay.click(function(){close_modal(modal_id);});}$(o.closeButton).click(function(){close_modal(modal_id);});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth();overlay.css({'display':'block',opacity:0});overlay.fadeTo(200,o.overlay);$(modal_id).css({'display':'block','position':'absolute','opacity':0,'z-index':11000,'left':50+'%','margin-left':-(modal_width/2)+"px",'top':o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault();});});function close_modal(modal_id){overlay.fadeOut(200);$(modal_id).css({'display':'none'});}}});})(jQuery); \ No newline at end of file From 6119a1bf6b8cea934013bb525b9c1e99cec69acf Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Sat, 24 Jan 2015 14:32:41 +0200 Subject: [PATCH 05/10] Minify (fixed) --- jquery.leanModal.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js index 4020c4b..b58bf72 100644 --- a/jquery.leanModal.min.js +++ b/jquery.leanModal.min.js @@ -1 +1 @@ -(function($){$.fn.extend({leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null,closeOnBlur:true}var overlay=$("
").css({'position':'fixed','z-index':'100','top':'0px','left':'0px','height':'100%','width':'100%','background':'#000','display':'none'});$("body").append(overlay);options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click(function(e){var modal_id=$(this).attr("href");if(o.closeOnBlur||!o.closeButton){overlay.click(function(){close_modal(modal_id);});}$(o.closeButton).click(function(){close_modal(modal_id);});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth();overlay.css({'display':'block',opacity:0});overlay.fadeTo(200,o.overlay);$(modal_id).css({'display':'block','position':'absolute','opacity':0,'z-index':11000,'left':50+'%','margin-left':-(modal_width/2)+"px",'top':o.top+"px"});$(modal_id).fadeTo(200,1);e.preventDefault();});});function close_modal(modal_id){overlay.fadeOut(200);$(modal_id).css({'display':'none'});}}});})(jQuery); \ No newline at end of file +!function(t){t.fn.extend({leanModal:function(o){function e(o){i.fadeOut(200),t(o).css({display:"none"})}var n={top:100,overlay:.5,closeButton:null,closeOnBlur:!0},i=t("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:"#000",display:"none"});return t("body").append(i),o=t.extend(n,o),this.each(function(){var n=o;t(this).click(function(o){var l=t(this).attr("href");(n.closeOnBlur||!n.closeButton)&&i.click(function(){e(l)}),t(n.closeButton).click(function(){e(l)});var c=(t(l).outerHeight(),t(l).outerWidth());i.css({display:"block",opacity:0}),i.fadeTo(200,n.overlay),t(l).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:"50%","margin-left":-(c/2)+"px",top:n.top+"px"}),t(l).fadeTo(200,1),o.preventDefault()})})}})}(jQuery); \ No newline at end of file From e4174484dee1755b68f3500a52478d874ea1ac26 Mon Sep 17 00:00:00 2001 From: Samael803 Date: Wed, 4 Feb 2015 16:45:53 +0200 Subject: [PATCH 06/10] change top offset unit type from 'PX' to user define. --- jquery.leanModal.js | 2 +- jquery.leanModal.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.leanModal.js b/jquery.leanModal.js index eed2db5..74ea524 100644 --- a/jquery.leanModal.js +++ b/jquery.leanModal.js @@ -61,7 +61,7 @@ 'z-index': 11000, 'left' : 50 + '%', 'margin-left' : -(modal_width/2) + "px", - 'top' : o.top + "px" + 'top' : o.top }); diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js index b58bf72..6f0edc4 100644 --- a/jquery.leanModal.min.js +++ b/jquery.leanModal.min.js @@ -1 +1 @@ -!function(t){t.fn.extend({leanModal:function(o){function e(o){i.fadeOut(200),t(o).css({display:"none"})}var n={top:100,overlay:.5,closeButton:null,closeOnBlur:!0},i=t("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:"#000",display:"none"});return t("body").append(i),o=t.extend(n,o),this.each(function(){var n=o;t(this).click(function(o){var l=t(this).attr("href");(n.closeOnBlur||!n.closeButton)&&i.click(function(){e(l)}),t(n.closeButton).click(function(){e(l)});var c=(t(l).outerHeight(),t(l).outerWidth());i.css({display:"block",opacity:0}),i.fadeTo(200,n.overlay),t(l).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:"50%","margin-left":-(c/2)+"px",top:n.top+"px"}),t(l).fadeTo(200,1),o.preventDefault()})})}})}(jQuery); \ No newline at end of file +!function(t){t.fn.extend({leanModal:function(o){function e(o){i.fadeOut(200),t(o).css({display:"none"})}var n={top:100,overlay:.5,closeButton:null,closeOnBlur:!0},i=t("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:"#000",display:"none"});return t("body").append(i),o=t.extend(n,o),this.each(function(){var n=o;t(this).click(function(o){var l=t(this).attr("href");(n.closeOnBlur||!n.closeButton)&&i.click(function(){e(l)}),t(n.closeButton).click(function(){e(l)});var c=(t(l).outerHeight(),t(l).outerWidth());i.css({display:"block",opacity:0}),i.fadeTo(200,n.overlay),t(l).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:"50%","margin-left":-(c/2)+"px",top:n.top}),t(l).fadeTo(200,1),o.preventDefault()})})}})}(jQuery); \ No newline at end of file From 054897129a69a73faf76c82c23ff43f3775cd620 Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Thu, 5 Feb 2015 00:26:21 +0200 Subject: [PATCH 07/10] Minify --- jquery.leanModal.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js index 6f0edc4..b58bf72 100644 --- a/jquery.leanModal.min.js +++ b/jquery.leanModal.min.js @@ -1 +1 @@ -!function(t){t.fn.extend({leanModal:function(o){function e(o){i.fadeOut(200),t(o).css({display:"none"})}var n={top:100,overlay:.5,closeButton:null,closeOnBlur:!0},i=t("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:"#000",display:"none"});return t("body").append(i),o=t.extend(n,o),this.each(function(){var n=o;t(this).click(function(o){var l=t(this).attr("href");(n.closeOnBlur||!n.closeButton)&&i.click(function(){e(l)}),t(n.closeButton).click(function(){e(l)});var c=(t(l).outerHeight(),t(l).outerWidth());i.css({display:"block",opacity:0}),i.fadeTo(200,n.overlay),t(l).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:"50%","margin-left":-(c/2)+"px",top:n.top}),t(l).fadeTo(200,1),o.preventDefault()})})}})}(jQuery); \ No newline at end of file +!function(t){t.fn.extend({leanModal:function(o){function e(o){i.fadeOut(200),t(o).css({display:"none"})}var n={top:100,overlay:.5,closeButton:null,closeOnBlur:!0},i=t("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:"#000",display:"none"});return t("body").append(i),o=t.extend(n,o),this.each(function(){var n=o;t(this).click(function(o){var l=t(this).attr("href");(n.closeOnBlur||!n.closeButton)&&i.click(function(){e(l)}),t(n.closeButton).click(function(){e(l)});var c=(t(l).outerHeight(),t(l).outerWidth());i.css({display:"block",opacity:0}),i.fadeTo(200,n.overlay),t(l).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:"50%","margin-left":-(c/2)+"px",top:n.top+"px"}),t(l).fadeTo(200,1),o.preventDefault()})})}})}(jQuery); \ No newline at end of file From c3c67d2fc9ba695821b050099fa65278d696f4fa Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Thu, 5 Feb 2015 00:43:13 +0200 Subject: [PATCH 08/10] Add overlay color property --- jquery.leanModal.js | 88 ++++++++++++++++++++--------------------- jquery.leanModal.min.js | 2 +- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/jquery.leanModal.js b/jquery.leanModal.js index 74ea524..9ae5030 100644 --- a/jquery.leanModal.js +++ b/jquery.leanModal.js @@ -1,51 +1,60 @@ (function($){ - - $.fn.extend({ - + + $.fn.extend({ + leanModal: function(options) { - + var defaults = { top: 100, overlay: 0.5, closeButton: null, - closeOnBlur: true + closeOnBlur: true, + overlayColor: '#000' } - - var overlay = $("
").css({ - 'position': 'fixed', - 'z-index': '100', - 'top': '0px', - 'left': '0px', - 'height': '100%', - 'width': '100%', - 'background': '#000', - 'display': 'none' - }); - - $("body").append(overlay); - + options = $.extend(defaults, options); - + return this.each(function() { - + + function close_modal(modal_id){ + + overlay.fadeOut(200); + + $(modal_id).css({ 'display' : 'none' }); + + } + var o = options; - + + var overlay = $("
").css({ + 'position': 'fixed', + 'z-index': '100', + 'top': '0px', + 'left': '0px', + 'height': '100%', + 'width': '100%', + 'background': o.overlayColor, + 'display': 'none' + }); + + $("body").append(overlay); + $(this).click(function(e) { - + var modal_id = $(this).attr("href"); // If there is no close button, we discard the "closeOnblur" setting, // or otherwise it will be impossible to close the overlay. if (o.closeOnBlur || !o.closeButton) { - overlay.click(function() { - close_modal(modal_id); + overlay.click(function() { + close_modal(modal_id); }); } - - $(o.closeButton).click(function() { - close_modal(modal_id); + + $(o.closeButton).click(function() { + close_modal(modal_id); }); - + var modal_height = $(modal_id).outerHeight(); var modal_width = $(modal_id).outerWidth(); @@ -53,8 +62,8 @@ overlay.fadeTo(200,o.overlay); - $(modal_id).css({ - + $(modal_id).css({ + 'display' : 'block', 'position' : 'absolute', 'opacity' : 0, @@ -62,26 +71,17 @@ 'left' : 50 + '%', 'margin-left' : -(modal_width/2) + "px", 'top' : o.top - + }); $(modal_id).fadeTo(200,1); e.preventDefault(); - - }); - - }); - - function close_modal(modal_id){ - overlay.fadeOut(200); + }); - $(modal_id).css({ 'display' : 'none' }); - - } - + }); } }); - + })(jQuery); \ No newline at end of file diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js index b58bf72..13536e9 100644 --- a/jquery.leanModal.min.js +++ b/jquery.leanModal.min.js @@ -1 +1 @@ -!function(t){t.fn.extend({leanModal:function(o){function e(o){i.fadeOut(200),t(o).css({display:"none"})}var n={top:100,overlay:.5,closeButton:null,closeOnBlur:!0},i=t("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:"#000",display:"none"});return t("body").append(i),o=t.extend(n,o),this.each(function(){var n=o;t(this).click(function(o){var l=t(this).attr("href");(n.closeOnBlur||!n.closeButton)&&i.click(function(){e(l)}),t(n.closeButton).click(function(){e(l)});var c=(t(l).outerHeight(),t(l).outerWidth());i.css({display:"block",opacity:0}),i.fadeTo(200,n.overlay),t(l).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:"50%","margin-left":-(c/2)+"px",top:n.top+"px"}),t(l).fadeTo(200,1),o.preventDefault()})})}})}(jQuery); \ No newline at end of file +!(function(e){e.fn.extend({leanModal:function(t){var n={top:100,overlay:.5,closeButton:null,closeOnBlur:true,overlayColor:"#000"};t=e.extend(n,t);return this.each(function(){function n(t){i.fadeOut(200);e(t).css({display:"none"})}var r=t;var i=e("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:r.overlayColor,display:"none"});e("body").append(i);e(this).click(function(t){var s=e(this).attr("href");if(r.closeOnBlur||!r.closeButton){i.click(function(){n(s)})}e(r.closeButton).click(function(){n(s)});var u=e(s).outerHeight();var a=e(s).outerWidth();i.css({display:"block",opacity:0});i.fadeTo(200,r.overlay);e(s).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:50+"%","margin-left":-(a/2)+"px",top:r.top});e(s).fadeTo(200,1);t.preventDefault()})})}})})(jQuery); \ No newline at end of file From 84b8756fdcdde76f3285ac527ebad7a7422a72de Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Sun, 8 Feb 2015 20:17:25 +0200 Subject: [PATCH 09/10] Use jQuery show/hide instead of manually overriding CSS display --- jquery.leanModal.js | 101 +++++++++++++++++----------------------- jquery.leanModal.min.js | 2 +- 2 files changed, 44 insertions(+), 59 deletions(-) diff --git a/jquery.leanModal.js b/jquery.leanModal.js index 9ae5030..1b799a6 100644 --- a/jquery.leanModal.js +++ b/jquery.leanModal.js @@ -1,9 +1,6 @@ (function($){ - $.fn.extend({ - leanModal: function(options) { - var defaults = { top: 100, overlay: 0.5, @@ -11,77 +8,65 @@ closeOnBlur: true, overlayColor: '#000' } - options = $.extend(defaults, options); return this.each(function() { - function close_modal(modal_id){ - - overlay.fadeOut(200); - - $(modal_id).css({ 'display' : 'none' }); - + function closeModal(modalId){ + $overlay.fadeOut(200); + $(modalId).hide(); } var o = options; - var overlay = $("
").css({ - 'position': 'fixed', - 'z-index': '100', - 'top': '0px', - 'left': '0px', - 'height': '100%', - 'width': '100%', - 'background': o.overlayColor, - 'display': 'none' - }); - - $("body").append(overlay); + var $overlay = + $('
') + .css({ + 'position': 'fixed', + 'z-index': '100', + 'top': '0px', + 'left': '0px', + 'height': '100%', + 'width': '100%', + 'background': o.overlayColor, + 'display': 'none'}) + .appendTo($('body')); $(this).click(function(e) { - - var modal_id = $(this).attr("href"); - - // If there is no close button, we discard the "closeOnblur" setting, - // or otherwise it will be impossible to close the overlay. - if (o.closeOnBlur || !o.closeButton) { - overlay.click(function() { - close_modal(modal_id); + var modalId = $(this).attr('href'); + + // If there is no close button, we discard the "closeOnblur" setting, + // or otherwise it will be impossible to close the overlay. + if (o.closeOnBlur || !o.closeButton) { + $overlay.click(function() { + closeModal(modalId); + }); + } + $(o.closeButton).click(function() { + closeModal(modalId); }); - } - $(o.closeButton).click(function() { - close_modal(modal_id); - }); - - var modal_height = $(modal_id).outerHeight(); - var modal_width = $(modal_id).outerWidth(); - - overlay.css({ 'display' : 'block', opacity : 0 }); - - overlay.fadeTo(200,o.overlay); - - $(modal_id).css({ - - 'display' : 'block', - 'position' : 'absolute', - 'opacity' : 0, - 'z-index': 11000, - 'left' : 50 + '%', - 'margin-left' : -(modal_width/2) + "px", - 'top' : o.top - - }); - - $(modal_id).fadeTo(200,1); + $overlay + .css({ opacity: 0 }) + .show() + .fadeTo(200, o.overlay); + + var $modalId = $(modalId); + $modalId.css({ + 'display' : 'block', + 'position' : 'absolute', + 'opacity' : 0, + 'z-index': 11000, + 'left' : 50 + '%', + 'margin-left' : -($modalId.outerWidth() / 2) + 'px', + 'top' : o.top + }); - e.preventDefault(); + $(modalId).fadeTo(200, 1); + e.preventDefault(); }); - }); } }); - })(jQuery); \ No newline at end of file diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js index 13536e9..44f5097 100644 --- a/jquery.leanModal.min.js +++ b/jquery.leanModal.min.js @@ -1 +1 @@ -!(function(e){e.fn.extend({leanModal:function(t){var n={top:100,overlay:.5,closeButton:null,closeOnBlur:true,overlayColor:"#000"};t=e.extend(n,t);return this.each(function(){function n(t){i.fadeOut(200);e(t).css({display:"none"})}var r=t;var i=e("
").css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:r.overlayColor,display:"none"});e("body").append(i);e(this).click(function(t){var s=e(this).attr("href");if(r.closeOnBlur||!r.closeButton){i.click(function(){n(s)})}e(r.closeButton).click(function(){n(s)});var u=e(s).outerHeight();var a=e(s).outerWidth();i.css({display:"block",opacity:0});i.fadeTo(200,r.overlay);e(s).css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:50+"%","margin-left":-(a/2)+"px",top:r.top});e(s).fadeTo(200,1);t.preventDefault()})})}})})(jQuery); \ No newline at end of file +!(function(e){e.fn.extend({leanModal:function(t){var n={top:100,overlay:.5,closeButton:null,closeOnBlur:true,overlayColor:"#000"};t=e.extend(n,t);return this.each(function(){function n(t){i.fadeOut(200);e(t).hide()}var r=t;var i=e('
').css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:r.overlayColor,display:"none"}).appendTo(e("body"));e(this).click(function(t){var s=e(this).attr("href");if(r.closeOnBlur||!r.closeButton){i.click(function(){n(s)})}e(r.closeButton).click(function(){n(s)});i.css({opacity:0}).show().fadeTo(200,r.overlay);var u=e(s);u.css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:50+"%","margin-left":-(u.outerWidth()/2)+"px",top:r.top});e(s).fadeTo(200,1);t.preventDefault()})})}})})(jQuery); \ No newline at end of file From ddf7d5e982d800da991c1167964b7ba0a9ee6fcc Mon Sep 17 00:00:00 2001 From: Daniel Gorbatov Date: Thu, 2 Apr 2015 14:21:37 +0300 Subject: [PATCH 10/10] Change positioning from 'absolute' to 'fixed' We want the modal element to be immediately visible when shown so the user does not need to scroll and look for it. --- jquery.leanModal.js | 2 +- jquery.leanModal.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.leanModal.js b/jquery.leanModal.js index 1b799a6..cb3130f 100644 --- a/jquery.leanModal.js +++ b/jquery.leanModal.js @@ -54,7 +54,7 @@ var $modalId = $(modalId); $modalId.css({ 'display' : 'block', - 'position' : 'absolute', + 'position' : 'fixed', 'opacity' : 0, 'z-index': 11000, 'left' : 50 + '%', diff --git a/jquery.leanModal.min.js b/jquery.leanModal.min.js index 44f5097..f9b225a 100644 --- a/jquery.leanModal.min.js +++ b/jquery.leanModal.min.js @@ -1 +1 @@ -!(function(e){e.fn.extend({leanModal:function(t){var n={top:100,overlay:.5,closeButton:null,closeOnBlur:true,overlayColor:"#000"};t=e.extend(n,t);return this.each(function(){function n(t){i.fadeOut(200);e(t).hide()}var r=t;var i=e('
').css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:r.overlayColor,display:"none"}).appendTo(e("body"));e(this).click(function(t){var s=e(this).attr("href");if(r.closeOnBlur||!r.closeButton){i.click(function(){n(s)})}e(r.closeButton).click(function(){n(s)});i.css({opacity:0}).show().fadeTo(200,r.overlay);var u=e(s);u.css({display:"block",position:"absolute",opacity:0,"z-index":11e3,left:50+"%","margin-left":-(u.outerWidth()/2)+"px",top:r.top});e(s).fadeTo(200,1);t.preventDefault()})})}})})(jQuery); \ No newline at end of file +!function(a){a.fn.extend({leanModal:function(b){var c={top:100,overlay:.5,closeButton:null,closeOnBlur:!0,overlayColor:"#000"};return b=a.extend(c,b),this.each(function(){function c(b){e.fadeOut(200),a(b).hide()}var d=b,e=a('
').css({position:"fixed","z-index":"100",top:"0px",left:"0px",height:"100%",width:"100%",background:d.overlayColor,display:"none"}).appendTo(a("body"));a(this).click(function(b){var f=a(this).attr("href");(d.closeOnBlur||!d.closeButton)&&e.click(function(){c(f)}),a(d.closeButton).click(function(){c(f)}),e.css({opacity:0}).show().fadeTo(200,d.overlay);var g=a(f);g.css({display:"block",position:"fixed",opacity:0,"z-index":11e3,left:"50%","margin-left":-(g.outerWidth()/2)+"px",top:d.top}),a(f).fadeTo(200,1),b.preventDefault()})})}})}(jQuery); \ No newline at end of file