Skip to content

Commit

Permalink
v2.6.0 - allowed thumbnails to display different images than their ma…
Browse files Browse the repository at this point in the history
…in target
  • Loading branch information
akalicki committed Mar 20, 2014
1 parent e216ea9 commit fd6c281
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ code and unneeded options.

[demo]: http://akalicki.github.io/jquery-simple-gallery/

**CURRENT VERSION: v2.5.1**
**CURRENT VERSION: v2.6.0**

## Get Started ##

Expand Down Expand Up @@ -88,6 +88,14 @@ anything, so long as the selector `$(source)` will isolate all `<img>` tags
to be displayed in the gallery. A gallery's source collection can be also be
dynamically changed after instantiation.

+ `thumbExt` (optional, *default = ""*) - a substring thumbnail extension to
remove from the source image urls before they are displayed. This option
allows the use of different thumbnail images from the one displayed for speed
optimization or page styling. A source image with `src` "pic1Thumb.jpg" will
display "pic1.jpg" in the main window if `thumbExt` is set to "Thumb". The
gallery only removes the last occurence of `thumbExt` from the source image
`src`.

+ `animate` (optional, *default = true*) - a boolean true/false value
representing whether to animate the slideshow. If false, the target display
will only change images when you click on a thumbnail image.
Expand Down
14 changes: 12 additions & 2 deletions simple-gallery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* simple-gallery.js - v2.5.1
* simple-gallery.js - v2.6.0
* Author: Alex Kalicki (https://github.com/akalicki)
*
* simple-gallery.js is a lightweight jQuery extension for quickly creating
Expand All @@ -15,6 +15,7 @@
// default widget options
options: {
source: "",
thumbExt: "",
animate: true,
startImg: 0,
waitTime: 5000,
Expand Down Expand Up @@ -120,7 +121,7 @@
this._trigger('imageload');

var selected = this.images.get(index);
var url = selected.src;
var url = this._removeLast(selected.src, this.options.thumbExt);
this.element.css("background-image", "url(" + url + ")");
this.images.removeClass(this.options.selectClass);
selected.className += this.options.selectClass;
Expand Down Expand Up @@ -198,6 +199,15 @@
self.cycle = window.setTimeout(function() {
self._loadNext();
}, self.options.waitTime);
},

// helper: remove last occurence of substring
_removeLast: function(str, substr) {
var lastPos = str.lastIndexOf(substr);
if (lastPos == -1)
return str;
return str.substring(0, lastPos) +
str.substring(lastPos + substr.length);
}

});
Expand Down
11 changes: 6 additions & 5 deletions simple-gallery.min.js

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

0 comments on commit fd6c281

Please sign in to comment.