Skip to content

Commit

Permalink
Feature: Adding support to multiple galleries.
Browse files Browse the repository at this point in the history
This change provides:

    Flexibility to select the element with a another selector different of the id. Providing you support to multiples galleries.
    Adding galleryItem option to choose another item type
    All elements added to gallery, now inherit the onclick event
  • Loading branch information
Igor Lino committed May 31, 2015
1 parent e52c02c commit 52fa17f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/jquery.ez-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (typeof Object.create !== 'function') {
var EZP = {
init: function (options, elem) {
var self = this;
var $galleries;

self.elem = elem;
self.$elem = $(elem);
Expand Down Expand Up @@ -54,15 +55,16 @@ if (typeof Object.create !== 'function') {


//Create the image swap from the gallery
$('#' + self.options.gallery + ' a').click(function (e) {
$galleries = $(self.options.gallery ? ('#' + self.options.gallery) : self.options.gallerySelector);
$galleries.on('click.zoom', self.options.galleryItem, function(e) {

//Set a class on the currently active gallery image
if (self.options.galleryActiveClass) {
$('#' + self.options.gallery + ' a').removeClass(self.options.galleryActiveClass);
$(self.options.galleryItem, $galleries).removeClass(self.options.galleryActiveClass);
$(this).addClass(self.options.galleryActiveClass);
}
//stop any link on the a tag from working
e.preventDefault();
if (this.tagName === 'A') e.preventDefault();

//call the swap image function
if ($(this).data("zoom-image")) {
Expand All @@ -72,7 +74,7 @@ if (typeof Object.create !== 'function') {
self.zoomImagePre = $(this).data("image");
}
self.swaptheimage($(this).data("image"), self.zoomImagePre);
return false;
if (this.tagName === 'A') return false;
});
},
refresh: function (length) {
Expand Down Expand Up @@ -1830,6 +1832,8 @@ if (typeof Object.create !== 'function') {
enabled: true,
gallery: false,
galleryActiveClass: "zoomGalleryActive",
gallerySelector: false,
galleryItem: 'a',
imageCrossfade: false,
lensBorderColour: "#000",
lensBorderSize: 1,
Expand Down

0 comments on commit 52fa17f

Please sign in to comment.