ImageViewer is a jQuery plugin for customizing image presentation. Web developer may easily embed it into the website, add header and/or footer bars to show additional content such as image title or navigation controls as well as use other options, such as fullscreen displaying, etc.
The plugin is invoked by calling the imageviewer()
method on a
jQuery object that represents an <div>
element:
<script type="text/javascript"> $(function() { $('div#viewer').imageviewer( 'options', {'size': {'w':width, 'h':height}, ...} ); $('div#viewer').imageviewer( 'show', path_to_image, '', '' ); }); </script>
If there is more than one element in the jQuery object, the plugin will be enabled for all elements in the set.
There are three functions available in the ImageViewer plugin:
1. "OPTIONS"
function is used to initialize ImageViewer object as well as modify its options later.
$('div#viewer').imageviewer('options', See available options);
2. "SHOW"
is used to display image in ImageViewer object.
$('div#viewer').imageviewer('show', path_to_image, URL, target);
path_to_image
– path to image which should be displayed.URL
– If this parameter is not empty, then mouse click on the image will open the specified URL.target
– Specifies where to open the URL.
3. "HIDE"
function is used to delete ImageViewer object.
$('div#viewer').imageviewer('hide');
The plugin is configurable through the use of options which are passed to the "OPTIONS"
method.
The available options are:
Option | Description |
---|---|
mode |
If set to $('div#viewer').imageviewer('options', {'mode':'popup'});
|
size |
Set the size of ImageViewer object. If not specified ImageViewer object size depends on the showing image size. default:auto example: $('div#viewer').imageviewer('options', {'size': {'w':400, 'h':300}});
|
fade_dur |
0 example: $('div#viewer').imageviewer('options', {'fade_dur':1500});
|
header |
Any html code which will be embedded into the header bar. $('div#viewer').imageviewer('options', {'header':html_code, 'h_height':30});
|
h_height |
Set the height of the header bar (in pixels). $('div#viewer').imageviewer('options', {'header':html_code, 'h_height':30});
|
h_show |
Set it to $('div#viewer').imageviewer('options', {'h_show':'show', 'h_show_dur':1000});
|
h_show_dur |
This option determines how long it will take to show/hide the header bar (in milliseconds). 0 example: $('div#viewer').imageviewer('options', {'h_show':'show', 'h_show_dur':1000});
|
footer |
Any html code which will be embedded into the footer bar. $('div#viewer').imageviewer('options', {'footer':html_code, 'f_height':60});
|
f_height |
Set the height of the footer bar (in pixels). $('div#viewer').imageviewer('options', {'footer':html_code, 'f_height':60});
|
f_show |
Set it to $('div#viewer').imageviewer('options', {'f_show':'show', 'f_show_dur':1000});
|
f_show_dur |
This option determines how long it will take to show/hide the footer bar (in milliseconds). 0 example: $('div#viewer').imageviewer('options', {'f_show':'show', 'f_show_dur':1000});
|
There are only five css classes distributed with the plugin:
ivDisableColor
ivImageBgColor
ivFloatBgColor
ivLoadingBgColor
ivLoadingImage
You only need to include imageviewer.css
style sheet file in your page header.
There is also loading.gif
file which is ised in ivLoadingImage
class, so it should be placed in the same directory as the style sheet.