/* * MultiSlider 2.1 - jQuery Plugin * jQuery required. * * Name jquery.multiSlider.js * Author Shigeki Hosomi * Copyright Shigeki Hosomi * Version 2.1 * Date 2012.3.28 * 2012.4.9 [SlideType] Fade - bugfix * 2012.4.10 options + Added: 'width'&'height' * 2012.10.10 options + Added: 'directionNav' 'startSlide' && reName: 'pointNav' * 2013.4.18 options + Added: CallBack function 'onStart'&'onChange' * 2013.5.15 options + Added: 'timer' 0 == TimerOff * 2013.6.5 options + Added: CallBack function 'onMouseOver'&'onMouseOut' * * Category jQuery plugin * * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * **/ ;(function($) { $.fn.multiSlider = function(options) { options = $.extend({ width: 0, // CanvasWidth (Number) height: 0, // CanvasHeight (Number) speed: 'normal', // 'slow' or 'normal' or 'fast' or Milliseconds. (String / Number) timer: 5000, // Milliseconds. (Number) or '0 == TimerOff' (Number) easing: 'swing', // 'easingType' (String) slideMode: 'col', // 'col' or 'row' or 'fade' (String) startSlide: 0, // Set starting Slide '0 index' (Number) directionNav: true, // true or false (Boolean) directionNavClass: 'multiSlider-DirectionNav', // 'Prev' & 'Next' Navigation ClassName (String) prevNavText: '< Prev', // 'Prev' Navigation innerHTML (String) nextNavText: 'Next >', // 'Next' Navigation innerHTML (String) pointNav: true, // true or false (Boolean) pointNavPosition: 'after', // 'after' or 'before' (String) pointNavClass: 'multiSlider-PointNav', // Current Position Navigation ClassName (String) pointNavIndex: null, // Current Position Navigation NumberTxt (Number) onStart: function(){}, // Start Slide (CallBack function) onChange: function(){}, // Change Slide (CallBack function) onMouseOver: function(){}, // MouseOver Event (CallBack function) onMouseOut: function(){} // MouseOut Event (CallBack function) }, options); return this.each(function() { var $el = $(this); var $elTarget = $(this).children(); var $elSize = { w: options.width == 0 ? ~~$elTarget.width() : options.width, h: options.height == 0 ? ~~$elTarget.height() : options.height }; var $elChild = $(this).children(); var total = $elChild.length; var cnt = 0; var num = options.startSlide < total ? options.startSlide : total-1; var prevnum = 0; var loopTimer = null; var isAnimate = false; var directionTpl = null; var pointNavTpl = null; var pointNavInnerTpl = ""; if(total>1) { setUp(); } function setUp() { $el.css({ width: $elSize.w, height: $elSize.h, position: 'relative' }).bind('mouseenter mouseleave', function(e) { if(e.type == 'mouseenter') { options.onMouseOver.call(this); clearTimer(); } else if(e.type == 'mouseleave') { options.onMouseOut.call(this); onSetTimer(); } }); switch(options.slideMode) { case 'col': setColMode(); break; case 'row': setRowMode(); break; case 'fade': setFadeMode(); break; default: setFadeMode(); break; } setTarget(); if(options.pointNav) { setPointNav(); } if(options.directionNav) { setDirectionNav(); } onSetTimer(); options.onStart.call(this); } function setTarget() { $elChild.each(function() { cnt++; }); } function setPointNav() { pointNavTpl = $("