A simple prefetching ajax modal plugin. Prefetches the target page DOM and displays it in a modal when clicking on the link.
Accepts a JSON response with a content attribute too.
Opens given content as string too.
Download the production version or the development version.
Integrate the basic styles from the stylesheet and add your own styling.
<a href="somepage.html" class="modal">Some page</a>
jump to a DOM element referenced by hash string
<a href="somepage.html#qunit-fixture" class="modal">Some page</a>
add a custom class to the modalview container
<a href="somepage.html" class="modal" data-modalclass="custom">Some page</a>
$('.modal').modalview();
or
$.modalview('some content');
// setting global default options
$.fn.modalview.options = {
selector: '#main',
closeText: 'close',
padding: 10,
width: 580,
onInit: function () {},
onOpen: function () {},
onClose: function () {}
};
// setting custom instance options
$('.modal').modalview({
selector: '#main',
closeText: 'close',
padding: 10,
width: 580,
onInit: function () {},
onOpen: function () {},
onClose: function () {}
});
- refactoring to automatically set the target width & padding (is this a good idea?)
- refactoring close button (html string?)
- making the plugin extendable globally and per instance (prototypal inheritance)
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.
Also, please don't edit files in the "dist" subdirectory as they are generated via grunt. You'll find source code in the "src" subdirectory!
Copyright (c) 2012 bleech
Licensed under the MIT, GPL licenses.