/*! lightgallery - v1.2.21 - 2016-06-28
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2016 Sachin N; Licensed Apache 2.0 */
(function($, window, document, undefined) {
'use strict';
var defaults = {
pager: false
};
var Pager = function(element) {
this.core = $(element).data('lightGallery');
this.$el = $(element);
this.core.s = $.extend({}, defaults, this.core.s);
if (this.core.s.pager && this.core.$items.length > 1) {
this.init();
}
return this;
};
Pager.prototype.init = function() {
var _this = this;
var pagerList = '';
var $pagerCont;
var $pagerOuter;
var timeout;
_this.core.$outer.find('.lg').append('
');
if (_this.core.s.dynamic) {
for (var i = 0; i < _this.core.s.dynamicEl.length; i++) {
pagerList += '';
}
} else {
_this.core.$items.each(function() {
if (!_this.core.s.exThumbImage) {
pagerList += '';
} else {
pagerList += '';
}
});
}
$pagerOuter = _this.core.$outer.find('.lg-pager-outer');
$pagerOuter.html(pagerList);
$pagerCont = _this.core.$outer.find('.lg-pager-cont');
$pagerCont.on('click.lg touchend.lg', function() {
var _$this = $(this);
_this.core.index = _$this.index();
_this.core.slide(_this.core.index, false, false);
});
$pagerOuter.on('mouseover.lg', function() {
clearTimeout(timeout);
$pagerOuter.addClass('lg-pager-hover');
});
$pagerOuter.on('mouseout.lg', function() {
timeout = setTimeout(function() {
$pagerOuter.removeClass('lg-pager-hover');
});
});
_this.core.$el.on('onBeforeSlide.lg.tm', function(e, prevIndex, index) {
$pagerCont.removeClass('lg-pager-active');
$pagerCont.eq(index).addClass('lg-pager-active');
});
};
Pager.prototype.destroy = function() {
};
$.fn.lightGallery.modules.pager = Pager;
})(jQuery, window, document);