|
1 | | -//// jQuery.leanModal2.js v2.3.2 |
| 1 | +//// jQuery.leanModal2.js v2.3.3 |
2 | 2 | // MIT Licensed by eustasy https://eustasy.org |
3 | 3 | // Based on leanModal v1.1 by Ray Stone - http://finelysliced.com.au |
4 | 4 |
|
5 | 5 | // ANONFUNC Wrap in an anonymous function. |
6 | 6 | (function($){ |
7 | 7 |
|
8 | | - //// Close the Modal |
9 | | - // FUNCTION: Fade out the overlay and a passed identifier. |
10 | | - function leanModal_Close(modal_id) { |
11 | | - $('.js-leanmodal-overlay').fadeOut(300); |
12 | | - $(modal_id).fadeOut(200); |
13 | | - } |
14 | | - |
15 | 8 | //// Extend jQuery |
16 | 9 | // EXTENDFUNC |
17 | 10 | $.fn.extend({ |
|
21 | 14 | //// Default Options |
22 | 15 | // Set some Defaults. |
23 | 16 | var defaults = { |
24 | | - top: 100, |
25 | | - overlayOpacity: 0.5, |
| 17 | + top: '100px', |
| 18 | + overlayOpacity: 0.7, |
26 | 19 | closeButton: '.js-leanmodal-close', |
27 | 20 | disableCloseOnOverlayClick: false, |
28 | 21 | disableCloseOnEscape: false, |
| 22 | + fadeTime: 300, |
| 23 | + modalCenter: true, |
29 | 24 | }; |
30 | 25 | // Merge in any passed options. |
31 | 26 | options = $.extend(defaults, options); |
32 | 27 |
|
| 28 | + //// Close the Modal |
| 29 | + // FUNCTION: Fade out the overlay and a passed identifier. |
| 30 | + function leanModal_Close(modal_id) { |
| 31 | + $('.js-leanmodal-overlay').fadeOut(options.fadeTime); |
| 32 | + $(modal_id).fadeOut(options.fadeTime); |
| 33 | + } |
| 34 | + |
33 | 35 | //// There can be only one. |
34 | 36 | // Overlay. If there isn't an overlay, add one. |
35 | 37 | if ( $('.js-leanmodal-overlay').length == 0 ) { |
|
96 | 98 | // Actually it doesn't, but it is hard to globally position. |
97 | 99 | var modal_height = $(modal_id).innerHeight(); |
98 | 100 | var modal_width = $(modal_id).innerWidth(); |
99 | | - $(modal_id).css({ |
100 | | - 'display': 'block', |
101 | | - 'left': 50 + '%', |
102 | | - 'margin-left': - ( modal_width / 2 ) + 'px', |
103 | | - 'opacity': 0, |
104 | | - 'position': 'fixed', |
105 | | - 'top': options.top + 'px', |
106 | | - 'z-index': 11000, |
107 | | - }); |
| 101 | + if ( options.modalCenter ) { |
| 102 | + $(modal_id).css({ |
| 103 | + 'display': 'block', |
| 104 | + 'left': 50 + '%', |
| 105 | + 'margin-left': - ( modal_width / 2 ) + 'px', |
| 106 | + 'opacity': 0, |
| 107 | + 'position': 'fixed', |
| 108 | + 'top': options.top, |
| 109 | + 'z-index': 11000, |
| 110 | + }); |
| 111 | + } |
108 | 112 |
|
109 | 113 | //// Curtain Up |
110 | 114 | // Fade in the modal and overlay. |
111 | 115 | $('.js-leanmodal-overlay').css({ 'display': 'block', opacity: 0 }); |
112 | | - $('.js-leanmodal-overlay').fadeTo(300, options.overlayOpacity); |
113 | | - $(modal_id).fadeTo(200, 1); |
| 116 | + $('.js-leanmodal-overlay').fadeTo(options.fadeTime, options.overlayOpacity); |
| 117 | + $(modal_id).fadeIn(options.fadeTime); |
114 | 118 |
|
115 | 119 | //// Default Prevention |
116 | 120 | // Prevent whatever the default was (probably scrolling). |
|
0 commit comments