Skip to content

Commit aa4751d

Browse files
committed
Updated jQuery Image Gallery plugin.
1 parent af6658c commit aa4751d

File tree

2 files changed

+40
-21
lines changed

2 files changed

+40
-21
lines changed

jquery.fileupload-ui.css

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@
9090
white-space: nowrap;
9191
}
9292

93-
.gallery-dialog .ui-dialog-content {
94-
text-align: center;
95-
}
96-
9793
.gallery-dialog-loader {
9894
position: fixed;
9995
top: 50%;
@@ -102,14 +98,17 @@
10298
height: 32px;
10399
margin: -16px 0 0 -16px;
104100
background: url(loading.gif);
105-
z-index: 9999;
106101
}
107102

108103
/* IE 6: */
109104
*html .gallery-dialog-loader {
110105
position: absolute;
111106
}
112107

108+
.gallery-dialog .ui-dialog-content {
109+
text-align: center;
110+
}
111+
113112
.ui-state-disabled .ui-state-disabled {
114113
opacity: 1;
115114
filter: alpha(opacity=100);

jquery.image-gallery.js

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* jQuery Image Gallery Plugin 1.0
3-
* https://github.com/blueimp/jQuery-File-Upload
2+
* jQuery Image Gallery Plugin 1.1
3+
* https://github.com/blueimp/jQuery-Image-Gallery
44
*
55
* Copyright 2011, Sebastian Tschan
66
* https://blueimp.net
@@ -9,41 +9,48 @@
99
* http://creativecommons.org/licenses/MIT/
1010
*/
1111

12-
/*global jQuery, window, document */
12+
/*global jQuery, window, document, setTimeout, clearTimeout */
1313

1414
(function ($) {
1515
'use strict';
1616

1717
// The Image Gallery plugin makes use of jQuery's live method to attach
18-
// a click handler for all elements that match the selector of the given
18+
// a click handler to all elements that match the selector of the given
1919
// jQuery collection, now and in the future:
2020
//
21-
// $('a[rel^=gallery]').imagegallery();
21+
// $('a[rel=gallery]').imagegallery();
2222
//
2323
// The click handler opens the linked images in a jQuery UI dialog.
2424
// The options object given to the imagegallery method is passed to the
2525
// jQuery UI dialog initialization and allows to set any dialog options:
2626
//
27-
// $('a[rel^=gallery]').imagegallery({
27+
// $('a[rel=gallery]').imagegallery({
2828
// open: function (event, ui) {/* called on dialogopen */},
29-
// title: 'Image Gallery' // Sets the dialog title
29+
// title: 'Image Gallery', // Sets the dialog title
30+
// offsetWidth: 50, // Offset of image width to viewport width
31+
// offsetHeight: 50, // Offset of image height to viewport height
32+
// slideshow: 50000, // Shows the next image after 5000 ms
33+
// canvas: true, // Displays images as canvas element
34+
// namespace: 'myimagegallery' // event handler namespace
3035
// });
36+
//
37+
// offsetWidth, offsetHeight, canvas, slideshow and namespace are
38+
// imagegallery specific options, while open and title are jQuery UI
39+
// dialog options.
3140
//
3241
// The click event listeners can be removed by calling the imagegallery
3342
// method with "destroy" as first argument, using the same selector for
34-
// the jQuery collection:
43+
// the jQuery collection and the same namespace:
3544
//
36-
// $('a[rel^=gallery]').imagegallery('destroy', options);
45+
// $('a[rel=gallery]').imagegallery('destroy', {namespace: 'ns'});
3746
//
3847
// To directly open an image with gallery functionality, the imagegallery
3948
// method can be called with "open" as first argument:
4049
//
41-
// $('a[rel^=gallery]').imagegallery('open');
50+
// $('a:last').imagegallery('open', {selector: 'a[rel=gallery]'});
4251
//
4352
// The selector for related images can be overriden with the "selector"
4453
// option.
45-
// The namespace used for the click event listeners can be overriden
46-
// with the "namespace" option.
4754

4855
$.fn.imagegallery = function (options, opts) {
4956
opts = $.extend({
@@ -102,7 +109,9 @@
102109
// The loader is displayed until the image has loaded
103110
// and the dialog has been opened:
104111
loader = $('<div class="' + className + '-loader"></div>')
105-
.hide().appendTo('body').fadeIn();
112+
.hide()
113+
.appendTo($('.ui-widget-overlay:last')[0] || 'body')
114+
.fadeIn();
106115
options = $.extend({
107116
namespace: 'imagegallery',
108117
modal: true,
@@ -111,6 +120,8 @@
111120
height: 'auto',
112121
show: 'fade',
113122
hide: 'fade',
123+
offsetWidth: 100,
124+
offsetHeight: 100,
114125
title: link.title ||
115126
decodeURIComponent(link.href.split('/').pop()),
116127
dialogClass: className
@@ -178,15 +189,16 @@
178189
wheelHandler
179190
);
180191
},
192+
slideShow,
181193
scaledImage;
182194
if (e.type === 'error') {
183195
scaledImage = this;
184196
dialog.addClass('ui-state-error');
185197
} else {
186198
scaledImage = $.fn.imagegallery.scale(
187199
this,
188-
$(window).width() - 100,
189-
$(window).height() - 100,
200+
$(window).width() - options.offsetWidth,
201+
$(window).height() - options.offsetHeight,
190202
options.canvas
191203
);
192204
}
@@ -199,12 +211,19 @@
199211
', DOMMouseScroll.' + options.namespace,
200212
wheelHandler
201213
);
214+
if (options.slideshow) {
215+
slideShow = setTimeout(function () {
216+
dialog.click();
217+
}, options.slideshow);
218+
}
202219
dialog.bind({
203220
click: function (e) {
204-
dialog.unbind('click').fadeOut();
221+
clearTimeout(slideShow);
222+
dialog.unbind('click').dialog('widget').fadeOut();
205223
var newLink = (e.altKey && prevLink) || nextLink;
206224
if (newLink.href !== link.href) {
207225
options.callback = closeDialog;
226+
delete options.title;
208227
$.fn.imagegallery.open(newLink, options);
209228
} else {
210229
closeDialog();
@@ -217,6 +236,7 @@
217236
$('.ui-widget-overlay:last').click(closeDialog);
218237
},
219238
dialogclose: function () {
239+
clearTimeout(slideShow);
220240
$(this).remove();
221241
}
222242
}).css('cursor', 'pointer').append(

0 commit comments

Comments
 (0)