/*
-------------------------------------------------------
鍗曞睆鍐呴儴杞挱:
鍙В鍐充笂涓嬫粴灞忓悗瑙嗛鎾斁杩涘害銆佸崟灞忓唴閮ㄥ垏鎹㈤棶棰
鏈叆灞忓墠涓嶅惎鍔ㄥ睆鍐呰疆鎾紝鍑哄睆鍚庡仠姝㈠睆鍐呰疆鎾
--------------------------------------------------------
*/
(function ($) {
$.daliSlideDouble = function (obj, options) {
var speed = options.speed;
var duration = options.duration;
var dotname = options.dotname;
var direction = options.direction;
var aroname = options.aroname;
var dalitime;
var moving = false;
var aro = 'next';
var pnum = obj.find('ul:eq(0) li').length;
if (pnum > 1) {
//鍒涘缓dot锛屽鏋渉tml缁撴瀯宸茬粡鐩存帴杈撳嚭灏变笉鐢ㄤ簡
if (obj.find('.'+dotname).length==0){
var dot = '';
for (var i = 1; i <= pnum; i++) {
dot+='';
}
dot = '
' + dot + '
';
obj.append(dot);
}
//鍒涘缓绠ご
if (aroname != '') {
aroleft = aroname.split(',')[0];
aroright = aroname.split(',')[1];
obj.append('')
}
}
MoveFirst();
obj.find('em').click(function () {
var inidx = $(this).index();
aro = inidx > obj.find('em.on').index() ? 'next' : 'prev';
if (!$(this).hasClass('on') && !moving) {
MoveGo(inidx);
}
})
this.stop = function(){
if (dalitime) { clearTimeout(dalitime); }
}
this.begin = function(){
if (dalitime) { clearTimeout(dalitime); }
var inidx = obj.find('em.on').index();
MoveOver(inidx);
}
function MoveFirst(){
obj.find('em:eq(0)').addClass('on');
obj.find('ul:eq(0) li:eq(0)').css({ 'z-index': '1', 'left': 0 }).fadeIn();
obj.find('ul:eq(1) li:eq(0)').css({ 'z-index': '1', 'left': 0 }).fadeIn(function(){
MoveOver(0);
});
}
function MoveOver(inidx){
aro = 'next';
if (obj.find('ul:eq(0) li').length>1){
inidx++;
inidx == obj.find('ul:eq(0) li').length && (inidx = 0)
dalitime = setTimeout(function () { MoveGo(inidx) }, speed);
}
}
function MoveGo(inidx) {
moving = true;
if (dalitime) { clearTimeout(dalitime); }
var outidx = obj.find('em.on').index();
if (direction == 'fade') {
obj.find('li').css({ "z-index": "0" })
obj.find('ul:eq(0) li').eq(inidx).css({ "z-index": "1", "left": "0", "display": "none" }).fadeIn();
obj.find('ul:eq(1) li').eq(inidx).css({ "z-index": "1", "left": "0", "display": "none" }).fadeIn(duration, function () {
MoveOver(inidx);
obj.find('ul:eq(0) li').eq(outidx).hide();
obj.find('ul:eq(1) li').eq(outidx).hide();
moving = false;
});
}
else if (direction == 'left') {
var left = '100';
var moveto = '-=100';
if (aro == 'prev') {
left = '-100';
moveto = '+=100';
}
obj.find('ul:eq(0) li').eq(outidx).animate({ left: moveto + '%' }, duration, 'easeInOutExpo');
obj.find('ul:eq(1) li').eq(outidx).animate({ left: moveto + '%' }, duration, 'easeInOutExpo');
obj.find('ul:eq(0) li').eq(inidx).css({ 'left': left + '%' }).show().animate({ left: moveto + '%' }, duration, 'easeInOutExpo');
obj.find('ul:eq(1) li').eq(inidx).css({ 'left': left + '%' }).show().animate({ left: moveto + '%' }, duration, 'easeInOutExpo',function(){
MoveOver(inidx);
moving = false;
});
}
else if (direction == 'up') {
var top = '100';
var moveto = '-=100';
if (aro == 'prev') {
top = '-100';
moveto = '+=100';
}
obj.find('ul:eq(0) li').eq(outidx).animate({ top: moveto + '%' }, duration, 'easeInOutExpo');
obj.find('ul:eq(1) li').eq(outidx).animate({ top: moveto + '%' }, duration, 'easeInOutExpo');
obj.find('ul:eq(0) li').eq(inidx).css({ 'top': top + '%' }).show().animate({ top: moveto + '%' }, duration, 'easeInOutExpo');
obj.find('ul:eq(1) li').eq(inidx).css({ 'top': top + '%' }).show().animate({ top: moveto + '%' }, duration, 'easeInOutExpo',function(){
MoveOver(inidx);
moving = false;
});
}
obj.find('em').eq(outidx).removeClass("on");
obj.find('em').eq(inidx).addClass("on");
}
}
})(jQuery);