Skip to content

Commit

Permalink
Added support to use different elements than links as gallery items.
Browse files Browse the repository at this point in the history
  • Loading branch information
blueimp committed Feb 11, 2012
1 parent da0eab5 commit d267199
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -59,6 +59,16 @@ Initialize the Image Gallery widget by adding the following **data-attributes**

No additional JavaScript snippets are required. Note that you can also add links to the container element at a later stage.

It is also possible to use different elements than links for the gallery functionality, by storing the url to the images as **data-href** attribute and setting **data-selector** on the gallery container:

```html
<div id="gallery" data-toggle="modal-gallery" data-target="#modal-gallery" data-selector="div.gallery-item">
<div class="gallery-item" data-href="banana.jpg" title="Banana">Banana</div>
<div class="gallery-item" data-href="apple.jpg" title="Apple">Apple</div>
<div class="gallery-item" data-href="orange.jpg" title="Orange">Orange</div>
</div>
```

## API

### Options
Expand Down
6 changes: 3 additions & 3 deletions bootstrap-image-gallery.js
@@ -1,5 +1,5 @@
/*
* Bootstrap Image Gallery 2.0.1
* Bootstrap Image Gallery 2.1
* https://github.com/blueimp/Bootstrap-Image-Gallery
*
* Copyright 2011, Sebastian Tschan
Expand Down Expand Up @@ -48,7 +48,7 @@
'a[data-target=' + options.target + ']',
index = 0;
$(options.delegate).find(selector).each(function (i, node) {
var url = node.href;
var url = node.href || $(node).data('href');
// Check the the previously added url, to account for
// thumbnail and name linking twice to the same image:
if ($this.urls[$this.urls.length - 1] !== url) {
Expand Down Expand Up @@ -311,7 +311,7 @@
link = $(e.target).closest(options.selector);
if (link.length && modal.length) {
e.preventDefault();
options.href = link.prop('href');
options.href = link.prop('href') || link.data('href');
options.delegate = link[0] !== this ? this : document;
if (data) {
$.extend(data.options, options);
Expand Down
2 changes: 1 addition & 1 deletion bootstrap-image-gallery.min.js

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

0 comments on commit d267199

Please sign in to comment.