123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <<<<<<< 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) {
- $("<div>").addClass("arrow")
- .prepend( $("<span>").addClass("glyphicon glyphicon-chevron-left left") )
- .append( $("<span>").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 = $('<div>').css({
- 'position': 'absolute',
- 'width': '100%',
- 'top': maxHeight/2,
- 'font-size': '30px'
- })
- .appendTo('.gallery');
-
-
- $rightArrow = $('<a>').append('<span class="glyphicon glyphicon-chevron-right">')
- .addClass('pull-right')
- .appendTo($arrowContain);
-
- $leftArrow = $('<a>').append('<span class="glyphicon glyphicon-chevron-left">')
- .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);
|