diff --git a/bower.json b/bower.json index 833a3b2..25943c3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "owl.carousel2.thumbs", - "version": "0.1.3", + "version": "0.1.4", "homepage": "https://github.com/gijsroge/OwlCarousel2-Thumbs", "authors": [ { "name" : "Gijs Rogé", diff --git a/dist/owl.carousel2.thumbs.js b/dist/owl.carousel2.thumbs.js index 3950f90..f19ed08 100644 --- a/dist/owl.carousel2.thumbs.js +++ b/dist/owl.carousel2.thumbs.js @@ -1,8 +1,8 @@ -/*! owl.carousel2.thumbs - v0.1.2 | (c) 2015 @gijsroge | MIT license | https://github.com/gijsroge/OwlCarousel2-Thumbs */ +/*! owl.carousel2.thumbs - v0.1.4 | (c) 2015 @gijsroge | MIT license | https://github.com/gijsroge/OwlCarousel2-Thumbs */ /** * Thumbs Plugin * @version 2.0.0 - * @author Gijs Rogé + * @author Gijs Rogé * @license The MIT License (MIT) */ (function ($, window, document, undefined) { @@ -62,7 +62,7 @@ */ this._handlers = { 'prepared.owl.carousel': $.proxy(function (e) { - if (e.namespace && this.owl.options.thumbs && !this.owl.options.thumbImage && !this.owl.options.thumbPrerendered && !this.owl.options.thumbImage) { + if (e.namespace && this.owl.options.thumbs && !this.owl.options.thumbImage && !this.owl.options.thumbsPrerendered && !this.owl.options.thumbImage) { if ($(e.content).find('[data-thumb]').attr('data-thumb') !== undefined) { this._thumbcontent.push($(e.content).find('[data-thumb]').attr('data-thumb')); } @@ -105,7 +105,8 @@ thumbs: true, thumbImage: false, thumbContainerClass: 'owl-thumbs', - thumbItemClass: 'owl-thumb-item' + thumbItemClass: 'owl-thumb-item', + moveThumbsInside: false }; @@ -118,7 +119,7 @@ //set default options var options = this.owl.options; - if (options.thumbPrerendered) { + if (options.thumbsPrerendered) { this._thumbcontent._thumbcontainer = $('.' + options.thumbContainerClass); } @@ -131,7 +132,7 @@ // get index of clicked thumbnail var index = $(e.target).parent().is(this._thumbcontent._thumbcontainer) ? $(e.target).index() : $(e.target).parent().index(); - if (options.thumbPrerendered) { + if (options.thumbsPrerendered) { // slide to slide :) $('[data-slider-id=' + this._identifier + ']').trigger('to.owl.carousel', index); } else { @@ -156,7 +157,10 @@ if (!options.thumbsPrerendered) { this._thumbcontent._thumbcontainer = $('
').addClass(options.thumbContainerClass).appendTo(this.$element); } else { - this._thumbcontent._thumbcontainer = $('.' + options.thumbContainerClass + '').appendTo(this.$element); + this._thumbcontent._thumbcontainer = $('.' + options.thumbContainerClass + ''); + if(options.moveThumbsInside){ + this._thumbcontent._thumbcontainer.appendTo(this.$element); + } } //create thumb items @@ -189,7 +193,7 @@ var options = this.owl.options; // set relative thumbnail container - var thumbContainer = options.thumbPrerendered ? $('.' + options.thumbContainerClass + '[data-slider-id="' + this._identifier + '"]') : this._thumbcontent._thumbcontainer; + var thumbContainer = options.thumbsPrerendered ? $('.' + options.thumbContainerClass + '[data-slider-id="' + this._identifier + '"]') : this._thumbcontent._thumbcontainer; thumbContainer.children().filter('.active').removeClass('active'); thumbContainer.children().eq(this.owl_currentitem).addClass('active'); }; diff --git a/dist/owl.carousel2.thumbs.min.js b/dist/owl.carousel2.thumbs.min.js index 527bcc3..005f67e 100644 --- a/dist/owl.carousel2.thumbs.min.js +++ b/dist/owl.carousel2.thumbs.min.js @@ -1,2 +1,2 @@ -/*! owl.carousel2.thumbs - v0.1.2 | (c) 2015 @gijsroge | MIT license | https://github.com/gijsroge/OwlCarousel2-Thumbs */ -!function(a,b,c,d){"use strict";var e=function(b){this.owl=b,this._thumbcontent=[],this._identifier=0,this.owl_currentitem=this.owl.options.startPosition,this.$element=this.owl.$element,this._handlers={"prepared.owl.carousel":a.proxy(function(b){if(!b.namespace||!this.owl.options.thumbs||this.owl.options.thumbImage||this.owl.options.thumbPrerendered||this.owl.options.thumbImage){if(b.namespace&&this.owl.options.thumbs&&this.owl.options.thumbImage){var c=a(b.content).find("img");this._thumbcontent.push(c)}}else a(b.content).find("[data-thumb]").attr("data-thumb")!==d&&this._thumbcontent.push(a(b.content).find("[data-thumb]").attr("data-thumb"))},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this.owl.options.thumbs&&(this.render(),this.listen(),this._identifier=this.owl.$element.data("slider-id"),this.setActive())},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"===a.property.name&&this.owl.options.thumbs&&(this._identifier=this.owl.$element.data("slider-id"),this.setActive())},this)},this.owl.options=a.extend(e.Defaults,this.owl.options),this.owl.$element.on(this._handlers)};e.Defaults={thumbs:!0,thumbImage:!1,thumbContainerClass:"owl-thumbs",thumbItemClass:"owl-thumb-item"},e.prototype.listen=function(){var b=this.owl.options;b.thumbPrerendered&&(this._thumbcontent._thumbcontainer=a("."+b.thumbContainerClass)),a(this._thumbcontent._thumbcontainer).on("click",this._thumbcontent._thumbcontainer.children(),a.proxy(function(c){this._identifier=a(c.target).closest("."+b.thumbContainerClass).data("slider-id");var d=a(c.target).parent().is(this._thumbcontent._thumbcontainer)?a(c.target).index():a(c.target).parent().index();b.thumbPrerendered?a("[data-slider-id="+this._identifier+"]").trigger("to.owl.carousel",d):this.owl.to(d,b.dotsSpeed),c.preventDefault()},this))},e.prototype.render=function(){var b=this.owl.options;b.thumbsPrerendered?this._thumbcontent._thumbcontainer=a("."+b.thumbContainerClass).appendTo(this.$element):this._thumbcontent._thumbcontainer=a("
").addClass(b.thumbContainerClass).appendTo(this.$element);var c;if(b.thumbImage)for(c=0;c');else for(c=0;c"+this._thumbcontent[c]+"")},e.prototype.setActive=function(){this.owl_currentitem=this.owl._current-this.owl._clones.length/2,this.owl_currentitem===this.owl._items.length&&(this.owl_currentitem=0);var b=this.owl.options,c=b.thumbPrerendered?a("."+b.thumbContainerClass+'[data-slider-id="'+this._identifier+'"]'):this._thumbcontent._thumbcontainer;c.children().filter(".active").removeClass("active"),c.children().eq(this.owl_currentitem).addClass("active")},e.prototype.destroy=function(){var a,b;for(a in this._handlers)this.owl.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Thumbs=e}(window.Zepto||window.jQuery,window,document); \ No newline at end of file +/*! owl.carousel2.thumbs - v0.1.4 | (c) 2015 @gijsroge | MIT license | https://github.com/gijsroge/OwlCarousel2-Thumbs */ +!function(a,b,c,d){"use strict";var e=function(b){this.owl=b,this._thumbcontent=[],this._identifier=0,this.owl_currentitem=this.owl.options.startPosition,this.$element=this.owl.$element,this._handlers={"prepared.owl.carousel":a.proxy(function(b){if(!b.namespace||!this.owl.options.thumbs||this.owl.options.thumbImage||this.owl.options.thumbsPrerendered||this.owl.options.thumbImage){if(b.namespace&&this.owl.options.thumbs&&this.owl.options.thumbImage){var c=a(b.content).find("img");this._thumbcontent.push(c)}}else a(b.content).find("[data-thumb]").attr("data-thumb")!==d&&this._thumbcontent.push(a(b.content).find("[data-thumb]").attr("data-thumb"))},this),"initialized.owl.carousel":a.proxy(function(a){a.namespace&&this.owl.options.thumbs&&(this.render(),this.listen(),this._identifier=this.owl.$element.data("slider-id"),this.setActive())},this),"changed.owl.carousel":a.proxy(function(a){a.namespace&&"position"===a.property.name&&this.owl.options.thumbs&&(this._identifier=this.owl.$element.data("slider-id"),this.setActive())},this)},this.owl.options=a.extend(e.Defaults,this.owl.options),this.owl.$element.on(this._handlers)};e.Defaults={thumbs:!0,thumbImage:!1,thumbContainerClass:"owl-thumbs",thumbItemClass:"owl-thumb-item",moveThumbsInside:!1},e.prototype.listen=function(){var b=this.owl.options;b.thumbsPrerendered&&(this._thumbcontent._thumbcontainer=a("."+b.thumbContainerClass)),a(this._thumbcontent._thumbcontainer).on("click",this._thumbcontent._thumbcontainer.children(),a.proxy(function(c){this._identifier=a(c.target).closest("."+b.thumbContainerClass).data("slider-id");var d=a(c.target).parent().is(this._thumbcontent._thumbcontainer)?a(c.target).index():a(c.target).parent().index();b.thumbsPrerendered?a("[data-slider-id="+this._identifier+"]").trigger("to.owl.carousel",d):this.owl.to(d,b.dotsSpeed),c.preventDefault()},this))},e.prototype.render=function(){var b=this.owl.options;b.thumbsPrerendered?(this._thumbcontent._thumbcontainer=a("."+b.thumbContainerClass),b.moveThumbsInside&&this._thumbcontent._thumbcontainer.appendTo(this.$element)):this._thumbcontent._thumbcontainer=a("
").addClass(b.thumbContainerClass).appendTo(this.$element);var c;if(b.thumbImage)for(c=0;c');else for(c=0;c"+this._thumbcontent[c]+"")},e.prototype.setActive=function(){this.owl_currentitem=this.owl._current-this.owl._clones.length/2,this.owl_currentitem===this.owl._items.length&&(this.owl_currentitem=0);var b=this.owl.options,c=b.thumbsPrerendered?a("."+b.thumbContainerClass+'[data-slider-id="'+this._identifier+'"]'):this._thumbcontent._thumbcontainer;c.children().filter(".active").removeClass("active"),c.children().eq(this.owl_currentitem).addClass("active")},e.prototype.destroy=function(){var a,b;for(a in this._handlers)this.owl.$element.off(a,this._handlers[a]);for(b in Object.getOwnPropertyNames(this))"function"!=typeof this[b]&&(this[b]=null)},a.fn.owlCarousel.Constructor.Plugins.Thumbs=e}(window.Zepto||window.jQuery,window,document); \ No newline at end of file diff --git a/package.json b/package.json index 7e49c0e..aabfaba 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "owl.carousel2.thumbs", "title": "Owl Carousel 2 Thumbnails", "description": "Enables thumbnail support for Owl Carousel 2.0", - "version": "0.1.3", + "version": "0.1.4", "main": "dist/owl.carousel2.thumbs.min.js", "homepage": "https://github.com/gijsroge/OwlCarousel2-Thumbs", "author": {