From 7f75b84f2b16db5787dbccde9b2849de8c455759 Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:06:39 +0000 Subject: [PATCH 01/10] Update jQuery.leanModal2.js --- jQuery.leanModal2.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/jQuery.leanModal2.js b/jQuery.leanModal2.js index 024bfc6..2c9c2c1 100644 --- a/jQuery.leanModal2.js +++ b/jQuery.leanModal2.js @@ -16,7 +16,6 @@ //// Default Options // Set some Defaults. var defaults = { - top: '15vh', overlayOpacity: 0.7, closeButton: '.js-leanmodal-close', disableCloseOnOverlayClick: false, @@ -28,20 +27,14 @@ options = $.extend(defaults, options) //// Close the Modal - // FUNCTION: Fade out the overlay and a passed identifier. + // FUNCTION: Fade out the overlay and a passed identifier while destroying the modal center aligner. function leanModal_Close(modal_id) { - $('.js-leanmodal-overlay').fadeOut(options.fadeTime) + $('#js-leanmodal-overlay').fadeOut(options.fadeTime) $(modal_id).fadeOut(options.fadeTime) - $('.js-leanmodal-overlay').unbind('click') + $('#js-leanmodal-overlay').unbind('click') $(document).off('keyup') - } - - //// There can be only one. - // Overlay. If there isn't an overlay, add one. - if ( $('.js-leanmodal-overlay').length == 0 ) { - var style = 'background: #000; display: none; height: 100%; left: 0; position: fixed; top: 0; width: 100%; z-index: 100;' - var overlay = $('
') - $('body').append(overlay) + $(modal_id).appendTo('body') + $('#js-leanmodal-overlay').remove() } //// Everything is Linked @@ -89,11 +82,19 @@ }) } + //// There can be only one. + // Overlay. If there isn't an overlay, add one. + if ( $('#js-leanmodal-overlay').length == 0 ) { + var style = 'background: #000; display: none; height: 100%; left: 0; position: fixed; top: 0; width: 100%; z-index: 100; align-items: center; justify-content: center;'; + var overlay = $('
') + $('body').append(overlay) + } + //// Envelope in Darkness // Close the modal when someone clicks on the overlay, // except when `disableCloseOnOverlayClick` is set to `true` if ( !options.disableCloseOnOverlayClick ) { - $('.js-leanmodal-overlay').click(function() { + $('#js-leanmodal-overlay').click(function() { leanModal_Close(modal_id) }) } @@ -106,21 +107,16 @@ if ( options.modalCenter ) { $(modal_id).css({ 'display': 'block', - //'left': 50 + '%', - //'margin-left': - ( modal_width / 2 ) + 'px', - 'margin-left': '50%', - 'transform': 'translateX(-50%)', 'opacity': 0, - 'position': 'fixed', - 'top': options.top, 'z-index': 11000, }) + $(modal_id).appendTo('#js-leanmodal-aligner') } //// Curtain Up // Fade in the modal and overlay. - $('.js-leanmodal-overlay').css({ 'display': 'block', opacity: 0 }) - $('.js-leanmodal-overlay').fadeTo(options.fadeTime, options.overlayOpacity) + $('#js-leanmodal-overlay').css({ 'display': 'flex', opacity: 0 }) + $('#js-leanmodal-overlay').fadeTo(options.fadeTime, options.overlayOpacity) $(modal_id).fadeTo(options.fadeTime, 1) //// Default Prevention From 4f08eb646fe0830f50298dba8309f9e8e2d3236f Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:08:03 +0000 Subject: [PATCH 02/10] Update jQuery.leanModal2.js --- jQuery.leanModal2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jQuery.leanModal2.js b/jQuery.leanModal2.js index 2c9c2c1..e0c6d4e 100644 --- a/jQuery.leanModal2.js +++ b/jQuery.leanModal2.js @@ -27,7 +27,7 @@ options = $.extend(defaults, options) //// Close the Modal - // FUNCTION: Fade out the overlay and a passed identifier while destroying the modal center aligner. + // FUNCTION: Fade out the overlay and a passed identifier. function leanModal_Close(modal_id) { $('#js-leanmodal-overlay').fadeOut(options.fadeTime) $(modal_id).fadeOut(options.fadeTime) @@ -110,7 +110,7 @@ 'opacity': 0, 'z-index': 11000, }) - $(modal_id).appendTo('#js-leanmodal-aligner') + $(modal_id).appendTo('#js-leanmodal-overlay') } //// Curtain Up From b90ac91e8e2e77e20424fa60876c1e9a27407a98 Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:09:49 +0000 Subject: [PATCH 03/10] Fix opacity --- jQuery.leanModal2.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jQuery.leanModal2.js b/jQuery.leanModal2.js index e0c6d4e..1d238c3 100644 --- a/jQuery.leanModal2.js +++ b/jQuery.leanModal2.js @@ -85,7 +85,11 @@ //// There can be only one. // Overlay. If there isn't an overlay, add one. if ( $('#js-leanmodal-overlay').length == 0 ) { - var style = 'background: #000; display: none; height: 100%; left: 0; position: fixed; top: 0; width: 100%; z-index: 100; align-items: center; justify-content: center;'; + var style = + 'background: rgba(0, 0, 0, ' + + options.overlayOpacity + + '); display: none; height: 100%; left: 0; position: fixed; top: 0; width: 100%; z-index: 100; ' + + 'align-items: center; justify-content: center;'; var overlay = $('
') $('body').append(overlay) } @@ -116,7 +120,7 @@ //// Curtain Up // Fade in the modal and overlay. $('#js-leanmodal-overlay').css({ 'display': 'flex', opacity: 0 }) - $('#js-leanmodal-overlay').fadeTo(options.fadeTime, options.overlayOpacity) + $('#js-leanmodal-overlay').fadeTo(options.fadeTime, 1) $(modal_id).fadeTo(options.fadeTime, 1) //// Default Prevention From 4524b1ffdc41f536929b97af3d1573db4789e2c3 Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:12:18 +0000 Subject: [PATCH 04/10] Update jQuery.leanModal2.js --- jQuery.leanModal2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jQuery.leanModal2.js b/jQuery.leanModal2.js index 1d238c3..e63ddef 100644 --- a/jQuery.leanModal2.js +++ b/jQuery.leanModal2.js @@ -100,6 +100,8 @@ if ( !options.disableCloseOnOverlayClick ) { $('#js-leanmodal-overlay').click(function() { leanModal_Close(modal_id) + }).children().click(function(e) { + e.stopPropagation() }) } From 85b30a4eb0dc88f985adde26e0f1179655c28e79 Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:13:32 +0000 Subject: [PATCH 05/10] Update jQuery.leanModal2.js --- jQuery.leanModal2.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jQuery.leanModal2.js b/jQuery.leanModal2.js index e63ddef..206c01f 100644 --- a/jQuery.leanModal2.js +++ b/jQuery.leanModal2.js @@ -99,9 +99,9 @@ // except when `disableCloseOnOverlayClick` is set to `true` if ( !options.disableCloseOnOverlayClick ) { $('#js-leanmodal-overlay').click(function() { - leanModal_Close(modal_id) - }).children().click(function(e) { - e.stopPropagation() + if ( e.target == this ) { + leanModal_Close(modal_id) + } }) } From c7bb50f284d80c56e554b3cd34bdda696d831ef1 Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:15:29 +0000 Subject: [PATCH 06/10] Update jQuery.leanModal2.js --- jQuery.leanModal2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jQuery.leanModal2.js b/jQuery.leanModal2.js index 206c01f..f31745c 100644 --- a/jQuery.leanModal2.js +++ b/jQuery.leanModal2.js @@ -98,7 +98,7 @@ // Close the modal when someone clicks on the overlay, // except when `disableCloseOnOverlayClick` is set to `true` if ( !options.disableCloseOnOverlayClick ) { - $('#js-leanmodal-overlay').click(function() { + $('#js-leanmodal-overlay').click(function(e) { if ( e.target == this ) { leanModal_Close(modal_id) } From 166efb1e86c00f55a8f7673c7d8849327ef212cc Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:18:34 +0000 Subject: [PATCH 07/10] Liniting --- jQuery.leanModal2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jQuery.leanModal2.js b/jQuery.leanModal2.js index f31745c..8d9e1ed 100644 --- a/jQuery.leanModal2.js +++ b/jQuery.leanModal2.js @@ -89,7 +89,7 @@ 'background: rgba(0, 0, 0, ' + options.overlayOpacity + '); display: none; height: 100%; left: 0; position: fixed; top: 0; width: 100%; z-index: 100; ' + - 'align-items: center; justify-content: center;'; + 'align-items: center; justify-content: center;' var overlay = $('
') $('body').append(overlay) } From 9eab0c6a6c2f3d4d97d5a902a5d2b2c738c8839f Mon Sep 17 00:00:00 2001 From: Lewis Goddard Date: Wed, 14 Feb 2018 23:20:16 +0000 Subject: [PATCH 08/10] Update index.html --- index.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/index.html b/index.html index 295ba80..dbedd3d 100644 --- a/index.html +++ b/index.html @@ -45,7 +45,6 @@

jQuery.leanModal2

Defaults