Skip to content

Commit

Permalink
Added option to move thumbs inside owl carousel html
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsroge committed Jun 27, 2015
1 parent 4c8f3e7 commit 1cb3b1a
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/owl.carousel2.thumbs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Thumbs Plugin
* @version 2.0.0
* @author Gijs Rogé
* @author Gijs Rogé
* @license The MIT License (MIT)
*/
(function ($, window, document, undefined) {
Expand Down Expand Up @@ -61,7 +61,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'));
}
Expand Down Expand Up @@ -104,7 +104,8 @@
thumbs: true,
thumbImage: false,
thumbContainerClass: 'owl-thumbs',
thumbItemClass: 'owl-thumb-item'
thumbItemClass: 'owl-thumb-item',
moveThumbsInside: false
};


Expand All @@ -117,7 +118,7 @@
//set default options
var options = this.owl.options;

if (options.thumbPrerendered) {
if (options.thumbsPrerendered) {
this._thumbcontent._thumbcontainer = $('.' + options.thumbContainerClass);
}

Expand All @@ -130,7 +131,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 {
Expand All @@ -155,7 +156,10 @@
if (!options.thumbsPrerendered) {
this._thumbcontent._thumbcontainer = $('<div>').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
Expand Down Expand Up @@ -188,7 +192,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');
};
Expand Down

0 comments on commit 1cb3b1a

Please sign in to comment.