| 1 |
const $ = jQuery; |
| 2 |
let elLPOverlay = null; |
| 3 |
const lpModalOverlay = { |
| 4 |
elLPOverlay: null, |
| 5 |
elMainContent: null, |
| 6 |
elTitle: null, |
| 7 |
elBtnYes: null, |
| 8 |
elBtnNo: null, |
| 9 |
elFooter: null, |
| 10 |
elCalledModal: null, |
| 11 |
callBackYes: null, |
| 12 |
instance: null, |
| 13 |
init() { |
| 14 |
if ( this.instance ) { |
| 15 |
return true; |
| 16 |
} |
| 17 |
|
| 18 |
this.elLPOverlay = $( '.lp-overlay' ); |
| 19 |
|
| 20 |
if ( ! this.elLPOverlay.length ) { |
| 21 |
return false; |
| 22 |
} |
| 23 |
elLPOverlay = this.elLPOverlay; |
| 24 |
|
| 25 |
this.elMainContent = elLPOverlay.find( '.main-content' ); |
| 26 |
this.elTitle = elLPOverlay.find( '.modal-title' ); |
| 27 |
this.elBtnYes = elLPOverlay.find( '.btn-yes' ); |
| 28 |
this.elBtnNo = elLPOverlay.find( '.btn-no' ); |
| 29 |
this.elFooter = elLPOverlay.find( '.lp-modal-footer' ); |
| 30 |
|
| 31 |
$( document ).on( 'click', '.close, .btn-no', function() { |
| 32 |
elLPOverlay.hide(); |
| 33 |
} ); |
| 34 |
|
| 35 |
$( document ).on( 'click', '.btn-yes', function( e ) { |
| 36 |
e.preventDefault(); |
| 37 |
e.stopPropagation(); |
| 38 |
|
| 39 |
if ( 'function' === typeof lpModalOverlay.callBackYes ) { |
| 40 |
lpModalOverlay.callBackYes( e ); |
| 41 |
} |
| 42 |
} ); |
| 43 |
|
| 44 |
this.instance = this; |
| 45 |
|
| 46 |
return true; |
| 47 |
}, |
| 48 |
setElCalledModal( elCalledModal ) { |
| 49 |
this.elCalledModal = elCalledModal; |
| 50 |
}, |
| 51 |
setContentModal( content, event ) { |
| 52 |
this.elMainContent.html( content ); |
| 53 |
if ( 'function' === typeof event ) { |
| 54 |
event(); |
| 55 |
} |
| 56 |
}, |
| 57 |
setTitleModal( content ) { |
| 58 |
this.elTitle.html( content ); |
| 59 |
}, |
| 60 |
}; |
| 61 |
|
| 62 |
export default lpModalOverlay; |
| 63 |
|