diff --git a/examples/gallery.html b/examples/gallery.html new file mode 100644 index 0000000..33aabb4 --- /dev/null +++ b/examples/gallery.html @@ -0,0 +1,45 @@ + + + + + + Gallery + + + + + + +

+ This example shows how to use Shadowbox.open and start at a certain position in the gallery. +

+

+ Hong Kong + + + + + +

+ + + \ No newline at end of file diff --git a/source/adapters/jquery.js b/source/adapters/jquery.js index 8f25bd7..0122ba4 100644 --- a/source/adapters/jquery.js +++ b/source/adapters/jquery.js @@ -98,6 +98,11 @@ jQuery.fn.shadowbox = function(options) { var cls = this.className || ''; opts.width = parseInt((cls.match(/w:(\d+)/)||[])[1]) || opts.width; opts.height = parseInt((cls.match(/h:(\d+)/)||[])[1]) || opts.height; + // title + var title = el.attr('title'); + if (title) { + opts.title = title; + } Shadowbox.setup(el, opts); }); } diff --git a/source/core.js b/source/core.js index 1966793..5a671ed 100644 --- a/source/core.js +++ b/source/core.js @@ -444,20 +444,24 @@ S.init = function(options, callback) { * - A custom object similar to one produced by Shadowbox.makeObject * - An array of any of the above * + * If an array is given, the second parameter specifies the index of the first + * element, that should be displayed. + * * Note: When a single link object is given, Shadowbox will automatically search * for other cached link objects that have been set up in the same gallery and * display them all together. * * @param {mixed} obj + * @param {Integer} index (optional) * @public */ -S.open = function(obj) { +S.open = function(obj, index) { if (open) return; - + var gc = S.makeGallery(obj); S.gallery = gc[0]; - S.current = gc[1]; + S.current = index || gc[1]; obj = S.getCurrent();