diff --git a/README.md b/README.md
index 16a61a2..021a7d8 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,9 @@ Style with ``#fullsized_fullscreen``
**loop** (optional, defaults to false) - don't hide prev/next button on first/last image, so images are looped
+**caption** (optional, defaults to false) - display a caption above the image. Caption dan be set using ``data-caption`` on the fullsizable and will fall back to the ``title`` of the thumbnail.
+Styled with ``#fullsized_caption``
+
## Styling
The packaged ``fullsizable.css`` stylesheet provides only the bare bones to make fullsizable work. Everything
diff --git a/css/jquery-fullsizable.css b/css/jquery-fullsizable.css
index 9ebf03f..a4147c1 100644
--- a/css/jquery-fullsizable.css
+++ b/css/jquery-fullsizable.css
@@ -17,3 +17,7 @@
display: block;
margin: 0 auto;
}
+#fullsized_caption{
+ color: #ffffff;
+ text-align: center;
+}
diff --git a/examples/simple_with_caption.html b/examples/simple_with_caption.html
new file mode 100644
index 0000000..858230c
--- /dev/null
+++ b/examples/simple_with_caption.html
@@ -0,0 +1,80 @@
+
+
+
+
+
diff --git a/js/jquery-fullsizable.coffee b/js/jquery-fullsizable.coffee
index 3a00d40..b3ccbf8 100644
--- a/js/jquery-fullsizable.coffee
+++ b/js/jquery-fullsizable.coffee
@@ -17,6 +17,7 @@ Options:
**preload** (optional, defaults to true) - lookup selector on initialization, set only to false in combination with ``reloadOnOpen: true`` or ``fullsizable:reload`` event.
**reloadOnOpen** (optional, defaults to false) - lookup selector every time the viewer opens.
**loop** (optional, defaults to false) - don't hide prev/next button on first/last image, so images are looped
+ **caption** (optional, defaults to false) - display a caption above the image. Caption dan be set using ``data-caption`` on the fullsizable and will fall back to the ``title`` of the thumbnail.
###
$ = jQuery
@@ -25,6 +26,7 @@ container_id = '#jquery-fullsizable'
image_holder_id = '#fullsized_image_holder'
spinner_class = 'fullsized_spinner'
$image_holder = $('
')
+$caption_holder = $('')
images = []
current_image = 0
@@ -69,6 +71,7 @@ showImage = (image, direction = 1, shouldHideChrome = false) ->
current_image = image.index
$(image_holder_id).hide()
$(image_holder_id).html(image)
+ $caption_holder.text(image.caption) if image.caption && options.caption
# show/hide navigation when hitting range limits
if options.navigation
@@ -136,12 +139,14 @@ makeFullsizable = ->
$(options.selector).each ->
image = new Image
- image.buffer_src = $(this).attr('href')
+ $this = $(this)
+ image.buffer_src = $this.attr('href')
image.index = images.length
+ image.caption = $this.data('caption') || $this.children('img:first').attr('title') if options.caption
images.push image
if options.openOnClick
- $(this).click (e) ->
+ $this.click (e) ->
e.preventDefault()
makeFullsizable() if options.reloadOnOpen
openViewer(image, this)
@@ -172,6 +177,9 @@ prepareCurtain = ->
e.stopPropagation()
toggleFullscreen()
+ if options.caption
+ $image_holder.prepend($caption_holder )
+
switch options.clickBehaviour
when 'close' then $(document).on 'click', container_id, closeViewer
when 'next' then $(document).on 'click', container_id, -> nextImage(true)
@@ -225,6 +233,7 @@ $.fn.fullsizable = (opts) ->
preload: true
reloadOnOpen: false
loop: false
+ caption : false
, opts || {}
prepareCurtain()
diff --git a/js/jquery-fullsizable.js b/js/jquery-fullsizable.js
index f45f5dc..b0510f0 100644
--- a/js/jquery-fullsizable.js
+++ b/js/jquery-fullsizable.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.8.0
+// Generated by CoffeeScript 1.10.0
/*
jQuery fullsizable plugin v2.1.0
@@ -19,10 +19,11 @@ Options:
**preload** (optional, defaults to true) - lookup selector on initialization, set only to false in combination with ``reloadOnOpen: true`` or ``fullsizable:reload`` event.
**reloadOnOpen** (optional, defaults to false) - lookup selector every time the viewer opens.
**loop** (optional, defaults to false) - don't hide prev/next button on first/last image, so images are looped
+ **caption** (optional, defaults to false) - display a caption above the image. Caption dan be set using ``data-caption`` on the fullsizable and will fall back to the ``title`` of the thumbnail.
*/
(function() {
- var $, $image_holder, bindCurtainEvents, closeFullscreen, closeViewer, container_id, current_image, hasFullscreenSupport, hideChrome, image_holder_id, images, keyPressed, makeFullsizable, mouseMovement, mouseStart, nextImage, openViewer, options, preloadImage, prepareCurtain, prevImage, resizeImage, showChrome, showImage, spinner_class, stored_scroll_position, toggleFullscreen, unbindCurtainEvents;
+ var $, $caption_holder, $image_holder, bindCurtainEvents, closeFullscreen, closeViewer, container_id, current_image, hasFullscreenSupport, hideChrome, image_holder_id, images, keyPressed, makeFullsizable, mouseMovement, mouseStart, nextImage, openViewer, options, preloadImage, prepareCurtain, prevImage, resizeImage, showChrome, showImage, spinner_class, stored_scroll_position, toggleFullscreen, unbindCurtainEvents;
$ = jQuery;
@@ -34,6 +35,8 @@ Options:
$image_holder = $('