jModal is a small jQuery plugin for customisable modal popups, released freely under the Apache license.
When run, a modal element is added to the page that pulls in content as instructed; its appearance is generated based on a set of predefined options and can be passed any user-defined custom CSS classes for additional theming (see examples below).
Install by referencing the js file:
<script src='scripts/jquery.jmodal.js'></script>
Then call the function and pass in the text you want to show:
$().modal({content:'Pass text in directly'});
OR use another element to store the HTML you want included:
$('#hiddenDivYum').modal(); // use the contents from the hidden div
// Values below represent default values (as of initial release)
$('#hiddenDivYum').modal(
{
///////////////////
// Core contents
target: this, // OPTIONAL - pull contents from element
content: '', // OPTIONAL - put contents in manually
// NOTE - content overrules target if they both have values.
///////////////////
// Appearance
width:400, // width of the popup
addonClasses: '', // any additional classes to add to the popup
borderRadius: '4px', // border radius for the popup
top: '15%', // distance from the top when it appears
///////////////////
//Behaviour
fadeTime: 400, // fade in/out time
addCloseButton: true, // Add a close button or not
closeOnOverlayClick: true, // close modal on click of the overlay
showOverlay: true, // show the overlay (required for click away)
});
Files required for installation: |
1 (jquery.jmodal.js) |
Total Size: |
~5kb minified, ~10kb raw |
Notable Requirements: |
jQuery |
Chapter 1 PETER BREAKS THROUGH
All children, except one, grow up. They soon know that they will grow
up, and the way Wendy knew was this. One day when she was two years old
she was playing in a garden, and she plucked another flower and ran with
it to her mother. I suppose she must have looked rather delightful, for
Mrs. Darling put her hand to her heart and cried, "Oh, why can't you
remain like this for ever!" This was all that passed between them on
the subject, but henceforth Wendy knew that she must grow up. You always
know after you are two. Two is the beginning of the end.
Of course they lived at 14 [their house number on their street], and
until Wendy came her mother was the chief one. She was a lovely lady,
with a romantic mind and such a sweet mocking mouth. Her romantic
mind was like the tiny boxes, one within the other, that come from the
puzzling East, however many you discover there is always one more; and
her sweet mocking mouth had one kiss on it that Wendy could never get,
though there it was, perfectly conspicuous in the right-hand corner.
The way Mr. Darling won her was this: the many gentlemen who had been
boys when she was a girl discovered simultaneously that they loved her,
and they all ran to her house to propose to her except Mr. Darling, who
took a cab and nipped in first, and so he got her. He got all of her,
except the innermost box and the kiss. He never knew about the box, and
in time he gave up trying for the kiss. Wendy thought Napoleon could
have got it, but I can picture him trying, and then going off in a
passion, slamming the door.
Mr. Darling used to boast to Wendy that her mother not only loved him
but respected him. He was one of those deep ones who know about stocks
and shares. Of course no one really knows, but he quite seemed to know,
and he often said stocks were up and shares were down in a way that
would have made any woman respect him.
etc...