This time I will share jQuery Plugin and tutorial about Lightweight Multifunctional Popup Window Plugin – jQuery popup.js, hope it will help you in programming stack.
A lightweight (~2.15kb minified and gzipped) yet customizable and powerful jQuery popup plugin created for images, AJAX contents, HTML elements, Youtube videos, image galleries and much more.
More features:
- Custom content types.
- Error handling.
- Callback functions.
- Content loader.
- Custom animations.
- Cross-browser.
How to use it:
1. Include jQuery library and the jQuery popup.js plugin’s files as usual.
1 |
< link href = "popup.css" rel = "stylesheet" > |
3 |
< script src = "jquery.popup.js" ></ script > |
2. Display your images, websites, inline elements or AJAX contents in the popup window.
1 |
< a href = "1.jpg" class = "basic" >Image</ a > |
3 |
< a href = "ajax.html" class = "basic" >AJAX</ a > |
4 |
< a href = "#inline" class = "basic" >Inline</ a > |
5 |
< div id = "inline" style = "display:none" > |
6 |
< p >< em >This</ em > is some < strong >content</ strong >.</ p > |
3. You can also specify the content to display using JavaScript as follows:
2 |
content: 'any content or function here' |
4. Create a custom content type. In this example, we’re going to display a Youtube video in the popup.
03 |
youtube: function (content, callback){ |
04 |
content = '<iframe width="420" height="315" src="' +content+ '" frameborder="0" allowfullscreen></iframe>' ; |
06 |
callback.call( this , content); |
5. Customize the content loader.
2 |
preloaderContent: '<img src="preloader.gif" class="preloader">' |
6. All possible options with default values.
03 |
backClass : 'popup_back' , |
05 |
containerClass : 'popup_cont' , |
06 |
closeContent : '<div class="popup_close">×</div>' , |
07 |
markup : '<div class="popup"><div class="popup_content"/></div>' , |
08 |
contentClass : 'popup_content' , |
09 |
preloaderContent : '<p class="preloader">Loading</p>' , |
10 |
activeClass : 'popup_active' , |
13 |
popupPlaceholderClass : 'popup_placeholder' , |
14 |
keepInlineChanges : true , |
7. Callback functions.
03 |
beforeOpen : function (type){}, |
04 |
afterOpen : function (){}, |
05 |
beforeClose : function (){}, |
06 |
afterClose : function (){}, |
08 |
show : function ($popup, $back){ |
17 |
.animate({opacity : 1}, plugin.o.speed, function (){ |
19 |
plugin.o.afterOpen.call(plugin); |
23 |
replaced : function ($popup, $back){ |
28 |
.o.afterOpen.call( this ); |
31 |
hide : function ($popup, $back){ |
33 |
if ( $popup !== undefined ){ |
36 |
$popup.animate({opacity : 0}, this .o.speed); |