/*! jQuery Slideme 2 plugin @name jquery.slideme2.js @author Luigi Ferraresi (luigi.ferraresi@gmail.com) @version 2.21.36 @date 2014/12/16 @category jQuery Plugin @copyright (c)2014 Luigi Ferraresi (http://slideme.luigiferraresi.it) */ (function ($) { var version = '2.21.36'; var pluginName = 'slideme'; var Plugin, defaultOptions, __bind; var methods = [ 'init', 'animate', 'arrowClicked', 'arrowTaped', 'beforeScrollTo', 'checkArrows', 'clearFromClone', 'createArrows', 'createNumbers', 'createPagination', 'createThumbs', 'css3Supports', 'destroy', 'getBrowser', 'getInfinitePaginationIndex', 'getNativeTouchScrollNext', 'getNext', 'getNextById', 'getReadyForNewAnimation', 'getTotalSlides', 'inquire', 'jumpTo', 'jumpToId', 'onAnimationEnded', 'onOrientationchange', 'onResize', 'onSnapEnd', 'onSwipeEnd', 'onTouchend', 'onWindowScroll', 'play', 'playTo', 'playToId', 'redraw', 'removeAutoslide', 'resetAutoslide', 'restoreStartOrder', 'scrollTo', 'setAfter', 'setAutoslide', 'setBefore', 'setCurrent', 'setInfiniteSlides', 'setNext', 'setPaginationCurrent', 'setSibling', 'setStartOrder', 'setSwipe', 'setSwipeEnd', 'setSwipeMove', 'setSwipeStart', 'snapTo', 'stop', 'swipeSupport', 'swipeTo', 'update' ]; __bind = function (fn, me) { return function () { return fn.apply(me, arguments); }; }; // Plugin default options. defaultOptions = { arrows: false, autoslide: false, autoslideHoverStop: true, css3: true, current: 0, defaultWrapper: '.slideme', direction: 1, interval: 1000, itemsForSlide: 1, labels: { prev: '', next: '' }, loop: false, nativeTouchScroll: false, totalSlides: 0, onCreatedCallback: '', onEndCallback: '', onInquire: '', onStartCallback: '', pagination: '', ready: false, resizable: { width: '', height: '' }, thumbs: { width: 50, height: 40 }, transition: 'slide', speed: 500, swipe: true }; Plugin = (function (options) { function Plugin(options) { this.settings = $.extend({}, defaultOptions, options); for (var i = 0, n = methods.length; i < n; i++) { var method = methods[i]; this[method] = __bind(this[method], this); } }; $.extend(Plugin.prototype, { init: function (selector) { this.dom = {}; this.dom.slideme_container = $(selector).addClass('slideme_container'); this.dom.slideme = this.dom.slideme_container.find(this.settings.defaultWrapper); if (!this.dom.slideme.length) { console.error('Wrapper don\'t found'); return false; } if (this.settings.nativeTouchScroll) { this.settings.swipe = false; this.dom.slideme.addClass('slideme-touch').on('touchend', this.onTouchend); if (this.settings.autoslide) { this.dom.slideme.addClass('slideme-touch').on('touchstart', this.removeAutoslide); } $(window).on('resize.orientationchange', this.onOrientationchange); } else { this.dom.slideme.addClass('slideme-' + this.settings.transition); } if (this.settings.itemsForSlide > 1) { var slides = this.dom.slideme.children(); var k = this.settings.itemsForSlide; for (var i = 0, n = slides.length; i < n; i += k) { slides.slice(i, i + k).wrapAll("
  • "); } } this.browser = this.getBrowser(); this.counters = { current: 0, index: 0, next: 0, total: this.getTotalSlides() }; if (this.counters.total === 0) { this.dom.slideme_container.addClass('single'); } else if (this.counters.total < 1) { console.log('At last, one slide is needed!'); } if (this.settings.css3 && !this.css3Supports()) { this.settings.css3 = false; if (this.settings.transition === "zoom") { this.dom.slideme.removeClass('slideme-zoom').addClass('slideme-slide'); } console.log('Please, take notice that this browser don\'t supports css3 transition.'); } if (this.settings.arrows) { var event = this.settings.nativeTouchScroll ? this.arrowTaped : this.arrowClicked; var arrows = this.createArrows(event); this.dom.arrows = arrows; } if (this.settings.arrows && !this.settings.loop) { this.checkArrows(); } if (this.settings.pagination) { this.createPagination(); } if (this.settings.autoslide && this.settings.autoslideHoverStop && this.counters.total !== 0) { this.dom.slideme_container.on('mouseenter', this.removeAutoslide).on('mouseleave', this.resetAutoslide); } if (this.settings.resizable.width && this.settings.resizable.height) { this.resize = $(window).on('resize', this.onResize); this.onResize(); } if (this.settings.onCreatedCallback) { this.settings.onCreatedCallback({ 'instance': this.dom.slideme_container, 'index': this.counters.current }); } if (this.settings.swipe && this.swipeSupport()) { this.swipe = { 'startX': 0, 'startY': 0, 'endX': 0, 'endY': 0, 'deltaX': 0, 'deltaY': 0 }; this.setSwipe(); } this.setCurrent(); if (this.settings.loop && this.settings.nativeTouchScroll) { this.setStartOrder(); this.setInfiniteSlides(); } else if (!this.settings.nativeTouchScroll && this.counters.total !== 0) { this.setSibling(); } this.working = false; if (this.settings.autoslide && this.counters.total !== 0) { this.setAutoslide(); } }, animate: function (data) { if (this.counters.current !== this.counters.next) { this.working = true; this.animation = data.direction === 1 ? "nextClicked" : "prevClicked"; this.setNext(); if (this.settings.onStartCallback) { this.settings.onStartCallback({ 'instance': this.dom.slideme_container, 'index': this.counters.current, 'total': this.counters.total, 'next': this.counters.next }); } if (data.direction === 1) { this.dom.slideme.children().removeClass('before'); } else { this.dom.slideme.children().removeClass('after'); } this.redraw(this.dom.next); if (this.settings.css3) { this.dom.current.one('otransitionend webkitTransitionEnd transitionend', this.onAnimationEnded); this.dom.slideme.addClass(this.animation); } else { var currentAnimation = {}, nextAnimation = {}; switch (this.settings.transition) { case "fade": currentAnimation['opacity'] = 0; nextAnimation['opacity'] = 1; break; case "page": nextAnimation['left'] = '0%'; break; default: currentAnimation['left'] = -100 * data.direction + '%'; nextAnimation['left'] = 0; break; } this.dom.current.stop(true, false).animate(currentAnimation, this.speed); this.dom.next.stop(true, false).animate(nextAnimation, this.speed, this.onAnimationEnded); } } }, arrowClicked: function (e) { if (!this.working) { var direction = e.data.direction; this.counters.next = this.getNext(direction); this.animate({ 'direction': direction }); if (this.settings.swipe && this.swipeSupport() && this.settings.autoslide) { this.removeAutoslide(); } e.preventDefault(); } }, arrowTaped: function (e) { if (!this.working) { var direction = e.data.direction; var index; if (this.settings.loop) { this.counters.index = this.counters.index + direction; index = this.counters.current + direction; } else { index = this.getNext(direction); } if (this.settings.autoslide) { this.removeAutoslide(); } this.scrollTo(index); e.preventDefault(); } }, beforeScrollTo: function (e) { if (this.settings.loop) { var i = this.getInfinitePaginationIndex(); this.clearFromClone(i); this.restoreStartOrder(i); this.counters.index = e.data.index; } if (this.settings.autoslide) { this.removeAutoslide(); } this.scrollTo(e); }, checkArrows: function () { if (this.counters.current === this.counters.total) { this.dom.arrows.next.attr({ 'disabled': 'disabled' }); } else { this.dom.arrows.next.removeAttr('disabled'); } if (this.counters.current === 0) { this.dom.arrows.prev.attr({ 'disabled': 'disabled' }); } else { this.dom.arrows.prev.removeAttr('disabled'); } }, clearFromClone: function() { this.dom.slideme.children().removeClass('original').filter('.clone').remove(); var x = this.dom.current.position().left + this.dom.slideme.scrollLeft(); this.dom.slideme.scrollLeft(x); }, createArrows: function (event) { var arrows = {}; for (key in this.settings.labels) { var params = { 'direction': key === "next" ? 1 : -1, 'key': key }; var arrow = $('