HEAD
(function($) {
'use strict';
$.fn.gallery = function(options) {
var defaults = {
current: 0,
classes: "",
arrow: false
};
return this.each(function() {
var $gallery = $(this),
$galleryItems = $gallery.children();
options = $.extend(defaults, options);
$gallery.addClass("gallery").addClass(options.classes);
$galleryItems.addClass("gallery-item");
$galleryItems.eq(options.current).addClass("current");
$gallery.attr("tabindex", 0);
var maxHeight = $($galleryItems[0]).height();
for (var i = 1; i < $galleryItems.length; i++) {
if ($($galleryItems[i]).height() > maxHeight) maxHeight = $($galleryItems[i]).height();
}
$gallery.height(maxHeight + "px");
if (options.arrow) {
$("
").addClass("arrow")
.prepend( $("
").addClass("glyphicon glyphicon-chevron-left left") )
.append( $("").addClass("glyphicon glyphicon-chevron-right right") )
.prependTo($galleryItems);
}
$gallery.find(".left").on("click", function() {
var next;
var $currentItem = $(".current", $gallery);
next = $currentItem.index() - 1;
var prev;
if (next === $galleryItems.length - 1) {
next = 0;
}
$galleryItems.removeClass("current").eq(next).addClass("current")
});
$gallery.find(".right").on("click", function() {
var next;
var $currentItem = $(".current", $gallery);
next = $currentItem.index() + 1;
if (next === $galleryItems.length) {
next = 0;
}
$galleryItems.removeClass("current").eq(next).addClass("current")
});
$gallery.on("keyup", function(event) {
var $currentItem = $(".current", $gallery);
var next;
if (event.which === 39) {
next = $currentItem.index() + 1;
if (next === $galleryItems.length) {
next = 0;
$gallery.trigger("gallery-event");
}
} else if (event.which === 37) {
next = $currentItem.index() - 1;
if (next < 0) next = $galleryItems.length - 1;
}
$galleryItems.removeClass("current").eq(next).addClass("current");
});
$(window).on('resize', function() {
if (options.thumbs) $gallery.height( $('.current', $gallery).height() + $thumbs.innerHeight() );
else $gallery.height( $('.current', $gallery).height() );
});
});
};
=======
'use strict';
(function($){
$.fn.gallery =function(options) {
var defaults = {
current: 0,
classes: '',
};
var maxHeight,
$arrowContain,
$rightArrow,
$leftArrow;
function addArrow () {
$arrowContain = $('