<<<<<<< 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 = $('
').css({ 'position': 'absolute', 'width': '100%', 'top': maxHeight/2, 'font-size': '30px' }) .appendTo('.gallery'); $rightArrow = $('').append('') .addClass('pull-right') .appendTo($arrowContain); $leftArrow = $('').append('') .attr({'href': '#'}) .css({'left': 300+'px'}) .appendTo($arrowContain); } return this.each(function(){ var $gallery = $(this), $galleryItems = $gallery.children(); var $currentItem = $('.current', $gallery), next; options = $.extend(defaults, options) $gallery.addClass('gallery').addClass(options.classes); $galleryItems.addClass('gallery-item'); $galleryItems.eq(options.current).addClass('current'); $gallery.attr('tabindex', 0); maxHeight = $galleryItems.height(); $gallery.height(maxHeight + 'px'); addArrow(); $rightArrow.on('click',function(){ var $currentItem = $('.current', $gallery); next= $currentItem.index() + 1; if (next === $galleryItems.length) next = 0; $galleryItems.removeClass('current') .eq(next) .addClass('current'); }); $leftArrow.on('click',function(){ var $currentItem = $('.current', $gallery); next= $currentItem.index() - 1; if (next < 0) next = $galleryItems.length - 1; $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; $galleryItems.removeClass('current') .eq(next) .addClass('current'); } else if (event.which === 37) { next = $currentItem.index() - 1; if (next < 0) next = $galleryItems.length - 1; $galleryItems.removeClass('current') .eq(next) .addClass('current'); } }); }); }; >>>>>>> 81998a7b2320275c76c2f6d969964b0e73055986 })(jQuery);