Browse files

Issue #11 - Multiple images, one div

* Added data-image attribute. When clicked item has it it is used for the image URL. On close it reverts to the original HTML.
  • Loading branch information...
1 parent 48c7744 commit 01aa0fcf4a45e413dcb13eec28c69f6136838adb Jason Butz committed Nov 1, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 bootstrap-lightbox.js
View
17 bootstrap-lightbox.js
@@ -317,14 +317,31 @@ $(function ()
var $this = $(this), href;
var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')); //strip for ie7
var option = $target.data('lightbox') ? 'toggle' : $.extend({}, $target.data(), $this.data());
+ var img = $this.attr('data-image') || undefined;
e.preventDefault();
+ if(img)
+ {
+ var originalContent = $target.find('.lightbox-content').html();
+ $target.find('.lightbox-content').empty().html('<img src="'+img+'" border="0" alt="" />');
+ }
+ else
+ {
+ var originalContent = undefined;
+ }
+
+
+
$target
.lightbox(option)
.one('hide', function ()
{
$this.focus();
+ if( originalContent )
+ {
+ $target.find('.lightbox-content').empty().html( originalContent );
+ }
});
});
});

0 comments on commit 01aa0fc

Please sign in to comment.