Created
February 8, 2014 12:50
-
-
Save freakynit/8883273 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modal-box | |
========= | |
simple modal-box | |
Basic Usage: | |
------------ | |
MODAL.init(); | |
MODAL.show("Saving..."); | |
MODAL.hide(); | |
Methods available: | |
------------------ | |
MODAL.init(); | |
MODAL.show(); | |
MODAL.hide(); | |
MODAL.getOverlay(); - Returns modal element | |
MODAL.getOverlayContentElement(); - Returns content element inside modal element | |
MODAL.getOverlayContentTextElement(); - Returns text alement inside content element | |
MODAL.cancelTimeout(); - Cancels existing timeout, if any | |
Options available: | |
------------------ | |
1. | |
MODAL.init( | |
{ | |
'modalCss': { | |
/* CSS for modal box */ | |
}, | |
'modalContentCss':{ | |
/* CSS for modal box content block */ | |
}, | |
'modalContentTextCss':{ | |
/* CSS for text block inside content block */ | |
} | |
} | |
); | |
--- NOTE: all above arguments are optional | |
2. | |
MODAL.show( | |
<Message to show>, | |
<html of content box inside modal> | |
{ | |
'modalCss': {...} | |
'modalContentCss': {...} | |
'modalContentTextCss': {...} | |
'hideAfter': <Milliseconds to hide after its shown> | |
'afterShow': <called after overlay is shown> | |
'beforeShow': <called before overlay is shown, RETURN false to cancel modal show> | |
'afterHide': <called after overlay is hidden/removed> | |
'beforeHide': <called before overlay is hidden/removed, RETURN false to cancel modal hide/remove> | |
} | |
); | |
---NOTE: all above arguments are optional, also, | |
the css passed in show method overwrites that of init method | |
EXAMPLE: advanced: | |
------------------ | |
MODAL.init( | |
{ | |
'modalCss': { | |
'background-color': 'rgba(0, 0, 0, 0.8)', | |
'z-index': 999999, | |
'position': 'absolute', | |
'left': 0, | |
'top': 0, | |
'width': '100%', | |
'height': '100%', | |
'display': 'block', | |
'text-align':'center', | |
'padding-top':'150px' | |
}, | |
'modalContentCss':{ | |
'text-align':'center' | |
}, | |
'modalContentTextCss':{ | |
'color':'white' | |
} | |
} | |
); | |
MODAL.show( | |
"Saving...", | |
'<div id="overlay-content" style="background-color:yellow"></div>', | |
{ | |
'modalContentTextCss':{ | |
'color':'red' | |
}, | |
'modalContentCss':{ | |
'border':'3px solid green' | |
}, | |
'beforeShow':myBeforeShow | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment