Skip to content

Commit

Permalink
Added option for captions attribute (title or data-title)
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Jul 6, 2015
1 parent fe4d953 commit 90038f1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var lightbox = $('.gallery a').simpleLightbox(options);
| nav | true | bool | show arrow-navigation or not |
| navText | ['←','→'] | array | text or html for the navigation arrows |
| captions | true | bool | show captions if availabled or not |
| captionsData | title | string | get the caption from title or data-title attribute |
| close | true | bool | show the close button or not |
| closeText | 'X' | string | text or html for the close button |
| fileExt | 'png|jpg|jpeg|gif' | regexp | list of fileextensions the plugin works with |
Expand All @@ -29,9 +30,9 @@ var lightbox = $('.gallery a').simpleLightbox(options);
| loop | true | bool | enables looping through images |
| docClose | true | bool | closes the lightbox when clicking outside |
| swipeTolerance | 50 | int | how much pixel you have to swipe, until next or previous image |
| className: | 'simple-lightbox' | string | adds a class to the wrapper of the lightbox
| widthRatio: | 0.8 | float | Ratio of image width to screen width
| heightRatio: | 0.9 | float | Ratio of image height to screen height
| className: | 'simple-lightbox' | string | adds a class to the wrapper of the lightbox |
| widthRatio: | 0.8 | float | Ratio of image width to screen width |
| heightRatio: | 0.9 | float | Ratio of image height to screen height |

###Events
| Name | Description |
Expand Down Expand Up @@ -64,6 +65,7 @@ var gallery = $('.gallery a').simpleLightbox();
gallery.next(); // Next Image
```
### Changelog
**1.2.0 - Added option for captions attribute (title or data-title)**
**1.1.2 - Bugfix for looping images**
**1.1.1 - Bugfix for loading indicator and removed a log-event**
**1.1.0 - Added classname for lightbox wrapper and width/height ratio**
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simplelightbox",
"version": "1.1.0",
"version": "1.1.2",
"homepage": "http://andreknieriem.de/simple-lightbox",
"authors": [
"André Knieriem <[email protected]> (http://andreknieriem.de)"
Expand Down
6 changes: 3 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="container">
<h1 class="align-center">Simple Lightbox Demo Page</h1>
<div class="gallery">
<a href="images/image1.jpg" class="big"><img src="images/thumbs/thumb1.jpg" alt="" title="Beautiful Image"/></a>
<a href="images/image1.jpg" class="big"><img src="images/thumbs/thumb1.jpg" alt="" title="Beautiful Image" /></a>
<a href="images/image2.jpg"><img src="images/thumbs/thumb2.jpg" alt="" title=""/></a>
<a href="images/image3.jpg"><img src="images/thumbs/thumb3.jpg" alt="" title="Beautiful Image"/></a>
<a href="images/image4.jpg"><img src="images/thumbs/thumb4.jpg" alt="" title=""/></a>
Expand All @@ -36,8 +36,8 @@ <h1 class="align-center">Simple Lightbox Demo Page</h1>
<p>All images are free availabled on <a href="https://unsplash.com/" target="_blank">Unsplash</a></p>
<p>Documentation and download <a target="_blank" href="http://andreknieriem.de/simple-lightbox/">here</a></p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="../dist/simple-lightbox.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript" src="../dist/simple-lightbox.js"></script>
<script>
$(function(){
var gallery = $('.gallery a').simpleLightbox();
Expand Down
7 changes: 4 additions & 3 deletions dist/simple-lightbox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

/*
By André Knieriem, www.andreknieriem.de
By Andre Knieriem, www.andreknieriem.de
Available for use under the MIT License
*/

Expand All @@ -17,6 +17,7 @@ $.fn.simpleLightbox = function( options )
nav: true,
navText: ['&larr;','&rarr;'],
captions: true,
captionsData: 'title',
close: true,
closeText: 'X',
fileExt: 'png|jpg|jpeg|gif',
Expand Down Expand Up @@ -138,7 +139,7 @@ $.fn.simpleLightbox = function( options )
.fadeIn('fast');
opened = true;

var captionText = $(selector).eq(index).find('img').prop('title');
var captionText = (options.captionsData == 'title') ? $(selector).eq(index).find('img').prop('title') : $(selector).eq(index).find('img').data('title');
if(dir == 1 || dir == -1){
var css = { 'opacity': 1.0 };
if( canTransisions ) {
Expand All @@ -161,7 +162,7 @@ $.fn.simpleLightbox = function( options )
},
setCaption = function(captiontext){
if(captiontext != '' && options.captions){
caption.text(captiontext).hide().appendTo($('.sl-image')).fadeIn('fast');
caption.html(captiontext).hide().appendTo($('.sl-image')).fadeIn('fast');
}
},
slide = function(speed, pos){
Expand Down
4 changes: 2 additions & 2 deletions dist/simple-lightbox.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 90038f1

Please sign in to comment.