/*! * powerswitch.js by sucaiweb(.com) * under mit license * you can use powerswitch to switch anything */ (function(window, $, undefined) { var isanimation = typeof history.pushstate == "function"; // 涓€浜涙柟娉? $.powerswitch = function(elements, options) { $(elements).powerswitch(options); }; $.extend($.powerswitch, { getrelative: function(trigger, params) { trigger = $(trigger); // 娌℃湁鏁版嵁婧愶紝鍥炲甯﹀瀛? if (trigger.length == 0) return $(); // 鍏冪礌鏁扮粍 var arrtarget = [], ismoretoone = false; trigger.each(function(index, element) { var selector = $(this).attr(params.attribute) || ($(this).attr("href") || "").split("#")[1]; if (selector && arrtarget[selector] != true) { var target = $(); if (/^\w+$/.test(selector)) { target = $("#" + selector); // 濡傛灉灞炴€у€间綔涓篿d娌℃湁瀵瑰簲鍏冪礌锛屽氨浣滀负绫诲悕閫夋嫨鍣ㄤ娇鐢? if (target.length === 0) { target = $("." + selector); } // 濡傛灉绫诲悕閫夋嫨鍣ㄤ篃娌℃湁瀵瑰簲鐨勫厓绱狅紝浣滀负閫夋嫨鍣ㄤ娇鐢? if (target.length === 0) { target = $(selector); } } else { // 绾€夋嫨鍣? target = $(selector); } target.each(function(index, element) { arrtarget.push(element); }); // 璁剧疆鏍囧織閲忥紝閬垮厤閲嶅 arrtarget[selector] = true; } else if (arrtarget[selector] == true) { ismoretoone = true; } }); // 椤轰究鍒ゆ柇涓嬫槸鍚︽槸澶氬涓€鐨勫叧绯? trigger.data("ismoretoone", ismoretoone); return $(arrtarget); }, transition: function(target, duration, isreset) { var transform = "transform " + duration + "ms linear"; if (isanimation == false) return; // css3 transition璁剧疆 if (isreset == true) { target.css("webkittransition", "none").css("transition", "none") .data("hastransition", false); } else if (!target.data("hastransition")) { target.css({ webkittransition: "-webkit-" + transform, webkitbackfacevisibility: "hidden", transition: transform, backfacevisibility: "hidden" }).data("hastransition", true); } }, translate: function(target, key, value) { // 鍋忕щ鍊艰缃? var valuetransform = "translate"+ key +"("+ value +")"; isanimation? target.css("webkittransform", valuetransform).css("transform", valuetransform): target.css(key == "x"? { left: value }: { top: value }); }, animation: function(targethide, targetshow, params) { var container = null, that = this, noanimate = params.animation == "none"; // 鍔ㄧ敾鐩稿叧鐨勫嚑涓皬鏂规硶 var funtransform = function(target, key, value) { // 濡傛灉value鏄函鏁板€? if (parseint(value) === value) value += "px"; // ie10+绛夌幇浠f祻瑙堝櫒 if (isanimation) { // css3椹卞姩鍔ㄧ敾 that.transition(target, params.duration, noanimate); // 鍔ㄧ敾瑙﹀彂绛? that.translate(target, key, value); // console.log(value); } else { // ie6-ie9杩欎簺鑰佸急鐥呮畫 // left/top target[noanimate? "css": "animate"](key == "x"? { left: value }: { top: value }, params.duration); } }; // 鍥犱负鏄竾鑳藉垏鎹紝鏄剧劧鎯呭喌灏辨瘮杈冨鏉? // 鍙互鏄垪琛ㄥ厓绱犲姩鐢伙紝涔熷彲浠ユ槸瀹瑰櫒鍏冪礌鍔ㄧ敾 // 瀹瑰櫒鍏冪礌鍔ㄧ敾鍙堝垎涓轰袱绉嶏紝scroll鍜宼ransform(ie6-9 left/top浠f浛)锛岃嚜鍔ㄥ垽鏂? // 鍒楄〃鍏冪礌鍔ㄧ敾涔熸湁鍑犵锛宼ransform, fade, 鍜宻lide(toggle妯″紡涓嬩笓鐢? // 鏍规嵁鏄惁鏈塼arget杩欎釜鍙傛暟锛屽喅瀹氭槸瀹瑰櫒鍔ㄧ敾杩樻槸鍒楄〃鍔ㄧ敾 // 涓轰簡鏅鸿兘锛屽鍣ㄥ姩鐢绘牴鎹竴瀹氱殑鏈哄埗鑷姩鍒ゆ柇鍔ㄧ敾绫诲瀷锛岃繖鍦–arousel妯″紡涓嬪緢鏈夌敤 // 鏅鸿兘鍒ゆ柇鐨勬潯浠舵槸锛歱arams.animation == "auto" // 鍔ㄧ敾鐨勭粓鐐瑰€间笌鍔ㄧ敾绫诲瀷鐩稿叧 // 鍒楄〃鍏冪礌鍔ㄧ敾浣跨敤鐧惧垎姣旓紝鏄畾鍒舵棤闇€鍏冲績 // 瀹瑰櫒鍏冪礌鍔ㄧ敾鐨勬渶缁堜綅缃€氳繃"data-position"瀛樺偍璁块棶 if ((targetshow && targetshow.length) || (targethide && targethide.length)) { // 鍒楄〃鍔ㄧ敾 // 涓€鑸敤鍦ㄩ€夐」鍗★紝鎵嬮鐞存晥鏋? // 鏈変竴浜涢檺鍒惰鍒欙細 // 1. 濡傛灉鏄閫夋ā寮忥紝鍗充竴娆″彲浠ユ湁澶氫釜闈㈡澘灞曞紑锛堟墜椋庣惔鏁堟灉锛夛紝涓嶆敮鎸乼ransform绉诲姩鍔ㄧ敾 // 鍥犳锛屾鏃讹紝鏃犲姩鐢绘樉绀? if (params.toggle == true && params.animation == "translate") { params.animation = "none"; } switch (params.animation) { case "translate": { // 绉诲姩 // 姣旇緝鍓嶅悗绉诲姩鍏冪礌鐨勭储寮曞ぇ灏忕‘瀹氬墠鍚庝綅缃紝 // 鐢ㄦ潵鍐冲畾绉诲姩鐨勬柟鍚? var indexhide = targethide.data("index"), indexshow = targetshow.data("index"); var objdirection = { "vertical": "y", "horizontal": "x" }; if (indexhide != undefined && indexshow != undefined) { // 纭畾鍔ㄧ敾璧风偣鎴栫粓鐐逛綅缃槸姝g殑100%杩樻槸璐熺殑100% var hundred = 100, isnext = true; // 鍏卞瓨鍦ㄤ笁绉嶅垏鎹㈡儏鍐? // 1. 瀹氭椂 // 2. 鐐瑰嚮閫夐」鍗¤е鍙? // 3. 鐐瑰嚮鍓嶈繘鍚庨€€鎸夐挳瑙﹀彂 if (params.prevornext) { switch (params.prevornext.attr("data-type")) { case "prev": { isnext = false; break; } case "next": { isnext = true; break; } default: { // 杩欐槸鐐瑰嚮閫夐」鍗? // 鏍规嵁鍓嶅悗鐨勪綅缃‘瀹氭柟鍚? isnext = indexhide < indexshow; } } } hundred = (isnext * 2 - 1 ) * 100; // 娓呴櫎鍙兘鐨則ransition // 鍥犱负鍔ㄧ敾鐨勯渶瑕佸厓绱犺鏀逛竴涓嬭捣濮嬩綅缃? // 鐢变簬涔嬪墠css3 transition鐨勮缃紝杩欑浣嶇疆鍙樺寲浼氭湁鍔ㄧ敾鏁堟灉锛岃€屾垜浠渶瑕佺殑鏄灛闂寸щ鍔紙鐢ㄦ埛鐪嬩笉鍒扮殑閭g锛? that.transition(targetshow.show(), params.duration, true); // 瑕佹樉绀虹殑鍏冪礌涔惧潳澶ф尓绉诲埌鎴戜滑甯屾湜鐨勪綅缃? that.translate(targetshow, objdirection[params.direction], hundred + "%"); // 鍔ㄧ敾瑙﹀彂浜嗭紝涓€涓щ璧帮紝涓€涓щ鍏? settimeout(function() { funtransform(targethide, objdirection[params.direction], -1 * hundred + "%"); funtransform(targetshow, objdirection[params.direction], "0%"); }, 17); // 娓呴櫎瑙﹀彂婧? params.prevornext = null; } else { // 绱㈠紩缂哄け锛岀洿鎺ユ樉绀洪殣钘? targethide.hide(); targetshow.show(); } break; } case "slide": { // 鎵嬮鐞磗lideup/slidedown鏁堟灉 if (params.duration != "sync") { if (targethide) targethide.slideup(params.duration); if (targetshow) targetshow.slidedown(params.duration); } else { if (targethide) { targethide.slideup("normal", function() { if (targetshow) targetshow.slidedown(); }); } else if (targetshow) { targetshow.slidedown(); } } break; } case "fade": { // 娣″叆娣″嚭鏁堟灉 if (params.duration != "sync") { if (targethide) targethide.fadeout(params.duration); if (targetshow) targetshow.fadein(params.duration); } else { if (targethide) { targethide.fadeout("normal", function() { if (targetshow) targetshow.fadein(); }); } else if (targetshow) { targetshow.fadein(); } } break; } case "visibility": { // visibility闅愯棌涓庢樉绀? if (targethide) targethide.css("visibility", "hidden"); if (targetshow) targetshow.css("visibility", "visible"); break; } default: { // "auto", "none" 鎴栧叾浠栦贡涓冨叓绯熺被鍨嬬洿鎺isplay鏄鹃殣 if (targethide) targethide.hide(); if (targetshow) targetshow.show(); } } } else if (params.container && params.container.length) { var position = params.container.data("position"); container = params.container.get(0); // 瀹瑰櫒鍔ㄧ敾 // 鍚勭妯″紡閮藉彲鑳藉嚭鐜? // 浠ヤ笅涓哄悇绉嶅姩鐢荤被鍨嬬殑鏉′欢澶勭悊 if (params.direction == "vertical") { // 鏍规嵁瀹瑰櫒鏄惁瀛樺湪婊氬姩楂樺害 if (container.scrollheight - container.clientheight >= math.max(position.top, 1)) { // scroll妯″紡 params.animation == "auto"? params.container.animate({scrolltop: position.top}): params.container.scrolltop(position.top); } else { // transform妯″紡 funtransform(params.container, "y", -1 * position.top) } } else { // 姘村钩鏂瑰悜 if (container.scrollwidth - container.clientwidth >= math.max(position.left, 1)) { // scroll妯″紡 params.animation == "auto"? params.container.animate({"scrollleft": position.left}): params.container.scrollleft(position.left); } else { // transform妯″紡 funtransform(params.container, "x", -1 * position.left) } } } } }); $.fn.powerswitch = function(options) { // 榛樿鍙傛暟 var defaults = { direction: "horizontal", eventtype: "click", // 鍏朵粬鍙€夊弬鏁帮細hover classadd: "", // 濡傛灉娌℃湁鏍峰紡鍙樺寲锛岃浣跨敤浠绘剰绫诲悕浠f浛 classremove: "", classprefix: "", // eg. "prefix" 鈫?prefix_disabled, prefix_prev, prefix_play, prefix_pause, prefix_next attribute: "data-rel", animation: "auto", // 鍏朵粬鍙€夊€硷細"none|display", "visibility", "translate", "fade", "slide" duration: 250, // 鍔ㄧ敾鎸佺画鏃堕棿锛屽崟浣嶆绉? 濡傛灉浣跨敤"sync"鍒欒〃绀哄悓姝? container: null, autotime: 0, // 鑷姩鎾斁鏃堕棿 number: "auto", // 姣忔鍒囨崲鐨勬暟鐩? hoverdelay: 200, toggle: false, onswitch: $.noop }; // 鏈€缁堝弬鏁? var params = $.extend({}, defaults, options || {}); // 涓€浜涘叏灞€绫诲悕 $.each(["disabled", "prev", "play", "pause", "next"], function(index, key) { key = $.trim(key); var upperkey = key.slice(0, 1).touppercase() + key.slice(1), paramskey = "class" + upperkey, lastchar = params.classprefix.slice(-1); if (params[paramskey] === undefined) { if (params.classprefix) { // 鏍规嵁classprefix涓槸鍚﹀惈鍏抽敭瀛楃锛堜笅鍒掔嚎鎴栫煭妯嚎锛夊仛鍒ゆ柇 if (/\-/g.test(params.classprefix)) { params[paramskey] = lastchar == "-"? (params.classprefix + key): [params.classprefix, key].join("-"); } else if (/_/g.test(params.classprefix)) { params[paramskey] = lastchar == "_"? (params.classprefix + key): [params.classprefix, key].join("_"); } else { // 椹煎嘲-澶у皬鍐欑粍鍚? params[paramskey] = params.classprefix + upperkey; } } else { params[paramskey] = key; } } }); // 涓€浜涘叏灞€鍙橀噺 some global variables // 閫変腑鐨勮е鍙戦」 the selected item var indexselected = params.indexselected || -1, numswitch = parseint(params.number) || 1, // hover寤舵椂澶勭悊鐨勮鏃跺櫒 the timer for hover delay hovertimer = null, // 鑷姩鎾斁鐨勫畾鏃跺櫒 autoplaytimer = null, // 鍒囨崲涓讳綋鍏冪礌浠? elerelatives = $(), // 涓讳綋鍏冪礌鐨勯暱搴? lenrelatives = 0; // 鎹鎼炰釜鍙橀噺閫熷害鏇村揩~ var self = $(this); // 鏃犺е鍙戞簮锛屼袱绉嶅彲鑳芥€? // 1. 閫夋嫨鍣ㄦ寕鎺変簡 // 2. 鍗曠函鐨勮嚜鍔ㄦ挱鏀撅紝渚嬪婊氬姩鏂伴椈鍔熻兘 if (self.length == 0) { // 濡傛灉鏄儏鍐?锛岀洿鎺ュ洖瀹? if (params.container == null || params.autotime == 0) return self; } elerelatives = $.powerswitch.getrelative(self, params); if ((lenrelatives = elerelatives.length) == 0) return self; // 纭畾indexselected // 鍙湁褰撴湭璁惧畾锛屾垨鑰呬笉鏄痶oggle妯″紡鐨勬椂鍊? if (indexselected == -1 && params.toggle == false) { if (params.classadd) { // 閫氳繃娣诲姞绫诲悕纭畾 self.each(function(index, element) { if (indexselected != -1) return; if ($(element).hasclass(params.classadd)) indexselected = index; }); } else { // 閫氳繃鍏宠仈闈㈡澘鐨勬樉闅愮‘瀹? elerelatives.each(function(index, element) { if (indexselected != -1) return; if (params.animation == "visibility") { if ($(element).css("visibility") != "hidden") indexselected = index; } else if ($(element).css("display") != "none") { indexselected = index; } }); } } var ismoretoone = false, eleprev = $(), elenext = $(), eleprevornext = $(); var funstateprevnext = function(indexwill) { // 鍚庨€€鎸夐挳鐨勭姸鎬? if (indexwill <= 0) { eleprev.addclass(params.classdisabled).removeattr("title").attr("disabled", "disabled"); } else { eleprev.removeclass(params.classdisabled).attr("title", eleprev.data("title")).removeattr("disabled"); } // 鍓嶈繘鎸夐挳鐨勭姸鎬? // 瑙勫垯濡備笅锛? // (鎬绘潯鐩?- indexselected浣嶇疆鍊? / 姣忔鍒囨崲鐨勬潯鏁?鏄惁澶т簬 1 if ((lenrelatives - indexwill) / numswitch > 1) { elenext.removeclass(params.classdisabled).attr("title", elenext.data("title")).removeattr("disabled"); } else { elenext.addclass(params.classdisabled).removeattr("title").attr("disabled", "disabled"); } } // 鍒ゆ柇鏄惁鏄瀵逛竴鐨勫叧绯? if (self.eq(0).data("ismoretoone") == true) { ismoretoone = true; // 濡傛灉涓嶆槸鏃犻檺婊氬姩 if (params.classdisabled) { eleprev = self.eq(0), elenext = self.eq(1); eleprev.data("title", eleprev.attr("title")); elenext.data("title", elenext.attr("title")); // 鍒濆鎸夐挳鐨勭姸鎬? funstateprevnext(indexselected); // 婊氬姩浣嶇疆 if (indexselected <= 0 && params.container) { $(params.container).scrollleft(0).scrolltop(0); } } else if (params.container) { // 鏃犻檺婊氬姩 // 鍏嬮殕骞惰浇鍏? elerelatives.clone().insertafter(elerelatives.eq(lenrelatives - 1)); // 閲嶆柊纭畾鍏宠仈鍏冪礌浠? elerelatives = $.powerswitch.getrelative(self, params); // more 鈫?one涓嬩箣鍓嶇偣鍑荤殑鎸夐挳 // 鐢ㄦ潵纭畾鑷姩鎾斁(濡傛灉鏈?鐨勬柟鍚? // 榛樿鏄痭ext鏂瑰悜 eleprevornext = self.eq(1); } else { // 浼瀵?锛屽姩鐢诲彧鑳芥槸fade鎴栨櫘閫氭樉闅? eleprev = self.eq(0), elenext = self.eq(1); eleprevornext = elenext; } } // 鍒ゆ柇鏄惁1瀵瑰 var isonetomore = false; if (self.length == 1 && lenrelatives > 1) { isonetomore = true; } // 鍒囨崲鐨勬牳蹇冿紝鎵€鏈夌殑鍒囨崲閮借璧拌繖涓€姝? // 闈㈠悜鍒囨崲闈㈡澘鍏冪礌璁捐鐨勫垏鎹㈡柟娉? var funswitchable = function(indexwill) { // 鎬荤殑鍒囨崲椤圭洰鏁帮紝姣忔鍒囨崲鐨勯」鐩暟 var elewillrelative = elerelatives.slice(indexwill, indexwill + numswitch); var eleselected = null, elewillselect = null, elerelative = null; // 濡傛灉鏄痶oggle鍒囨崲 if (params.toggle == false) { // 鍦ㄥ瀵?妯″紡涓嬶紝鎴戜滑鍏冲績鐨勬槸瑙﹀彂鎸夐挳鐨勪复鐣岀姸鎬?锛坉isabled锛夌瓑 // 鑰屼笉鏄€変腑涓庝笉閫変腑鐨勬牱寮忓垏鎹㈢姸鎬? if (ismoretoone == true) { // 鍋忕щ鍏冪礌灏辨槸 elewillrelative if (params.container) { // 鑾峰彇鐩稿鐖跺厓绱犵殑鍋忕щ var position = elewillrelative.position(); // 瀹氫綅 params.container = $(params.container); // 浣嶇疆瀛樺偍锛堝姩鐢荤粓鐐逛綅缃級 params.container.data("position", position); // 瀹瑰櫒鍔ㄧ敾 $.powerswitch.animation(null, null, params); // 鎸夐挳鐘舵€? params.classdisabled && funstateprevnext(indexwill); } else { // 瀹瑰櫒鍔ㄧ敾 $.powerswitch.animation(elerelatives.eq(indexselected, indexselected + numswitch), elewillrelative, params); } // 鍥炶皟 params.onswitch.call(this, elewillrelative); } else if (isonetomore == true) { // 1瀵瑰妯″紡 // 涔熷瓨鍦ㄦ寜閽殑涓寸晫鐘舵€? // 鍙兘鏄剧ず锛屼笉鑳芥敹璧? // 瀵瑰簲鍏冪礌鐨勬樉闅愭帶鍒? $.powerswitch.animation(null, elewillrelative, params); // 鍥炶皟 params.onswitch.call(this, elewillrelative); } else { // 1 vs 1 鎴栬€?1 vs many鎯呭喌涓? // 鍏冲績鎸夐挳閫変腑涓庝笉閫変腑鐨勬牱瀛? // console.log([indexwill, indexselected].join()); elewillselect = self.eq(indexwill); if (indexselected >= 0) { eleselected = self.eq(indexselected); elerelative = elerelatives.eq(indexselected, indexselected + numswitch); } else { eleselected = $(); elerelative = $(); } // 瑙﹀彂鍏冪礌鐨勭被鍚嶇姸鎬佹敼鍙? elewillselect.addclass(params.classadd).removeclass(params.classremove); // 宸查€夊厓绱犵殑鏀瑰彉 if (indexselected !== indexwill) eleselected.addclass(params.classremove).removeclass(params.classadd); // 瀵瑰簲鍏冪礌鐨勬樉闅愭帶鍒? $.powerswitch.animation(elerelative, elewillrelative, params); // 鍥炶皟 params.onswitch.call(this, elewillrelative, eleselected, elerelative); } indexselected = indexwill; } else { // 濡傛灉澶氶€? // 濡傛灉鍙兘灞曞紑 // 鑳戒几鑳藉眻 if ((params.animation == "visibility" && elewillrelative.css("visibility") == "hidden") || (params.animation != "visibility" && elewillrelative.css("display") == "none")) { // 鏄剧ず $.powerswitch.animation(null, elewillrelative, params); display = true; } else { $.powerswitch.animation(elewillrelative, null, params); display = false; } // 鍥炶皟 params.onswitch.call(this, elewillrelative, display); } }; // 閬嶅巻 loop var anchorsplit = location.href.split("#")[1]; self.each(function(index, element) { // 瀛樺偍绱㈠紩 // 瀛樺偍title浠ュ強index $(element).data("index", index); if (ismoretoone == true) { $(element).bind("click", function() { var indexwill, elewill; if (params.classdisabled) { if ($(this).attr("disabled")) return false; if (index == 0) { indexwill = indexselected - numswitch; indexwill = math.max(0, indexwill); } else if (index == 1) { indexwill = indexselected + numswitch; indexwill = math.min(indexwill, lenrelatives - 1); } funswitchable.call(this, indexwill); } else if (params.container && lenrelatives > numswitch) { // 鏃犻檺婊氬姩 if (index == 0) { indexwill = indexselected - numswitch; if (indexwill < 0) { // 鐬棿鏃犳劅閲嶅畾浣? elewill = elerelatives.eq(indexselected + lenrelatives); $(params.container).data("position", elewill.position()); $.powerswitch.animation(null, null, $.extend({}, params, { animation: "none" })); indexwill = indexselected + lenrelatives - numswitch; } } else if (index == 1) { indexwill = indexselected + numswitch; if (indexwill > lenrelatives * 2 - numswitch) { // 鏈綅鏁伴噺涓嶅浜? elewill = elerelatives.eq(indexselected - lenrelatives); $(params.container).data("position", elewill.position()); $.powerswitch.animation(null, null, $.extend({}, params, { animation: "none" })); // 鏂扮殑绱㈠紩浣嶇疆 indexwill = indexselected - lenrelatives + numswitch; } } funswitchable.call(this, indexwill); eleprevornext = $(this); } else { index? funplaynext(this): funplayprev(this); eleprevornext = $(this); } return false; }); } else if (isonetomore == true) { $(element).bind("click", function() { var indexwill; if (params.number == "auto") { numswitch = lenrelatives; } if (!$(this).attr("disabled")) { if (indexselected == -1) { indexwill = 0; } else { indexwill = indexselected + numswitch; } funswitchable.call(this, indexwill); if (indexwill >= lenrelatives - 1) { $(this).addclass(params.classdisabled).attr("disabled", "disabled").removeattr("title"); } } return false; }); } else if (params.eventtype == "click") { $(element).bind("click", function() { // 璁剧疆鏍囧織閲忥紝鏍规嵁浣嶇疆鍒ゆ柇鏂瑰悜 params.prevornext = $(this); // 鐐瑰嚮浜嬩欢 click events funswitchable.call(this, index); return false; }); if (anchorsplit && element.href && anchorsplit == element.href.split("#")[1]) { $(element).trigger("click"); } } else if (/^hover|mouseover$/.test(params.eventtype)) { $(element).hover(function() { params.prevornext = $(this); // 榧犳爣缁忚繃 hover events cleartimeout(hovertimer); hovertimer = settimeout(function() { funswitchable.call(element, index); }, parseint(params.hoverdelay) || 0); }, function() { // 榧犳爣绉诲紑 cleartimeout(hovertimer); }); } }); elerelatives.each(function(index, element) { $(element).data("index", index); }); // 鑷姩鎾斁 var funplaynext = function(trigger) { var indexwill = indexselected + 1; if (indexwill >= lenrelatives) { indexwill = 0; } funswitchable.call(trigger || self.get(indexwill), indexwill); }, funplayprev = function(trigger) { var indexwill = indexselected - 1; if (indexwill < 0) { indexwill = lenrelatives -1; } funswitchable.call(trigger || self.get(indexwill), indexwill); }, funplayprevornext = function() { eleprevornext.trigger("click"); }, funautoplay = function() { cleartimeout(autoplaytimer); if (funautoplay.flagautoplay == true) { autoplaytimer = settimeout(function() { ismoretoone == false? funplaynext(): funplayprevornext(); funautoplay(); }, params.autotime); } }; // 鍗曞鍗曟ā寮忥紝鎴栬€呮棤闄愬垏鎹㈢殑澶氬涓€妯″紡鏀寔鑷姩鎾斁 if ((isonetomore == false && params.toggle == false && ismoretoone == false) || (ismoretoone == true && !params.classdisabled)) { // 鍒涘缓鍓嶈繘銆佸悗閫€銆佷互鍙婃殏鍋滄寜閽? if (params.container && ismoretoone == false) { var htmltempoperate = ''; self.length && $.each(["prev", "pause", "next"], function(index, key) { if (params.autotime == 0 && key == "pause") return; // 鑷姩鎾斁妯″紡鏃跺€欓渶瑕? htmltempoperate = htmltempoperate + ''; }); params.container.append(htmltempoperate).delegate("a", "click", function() { var type = $(this).attr("data-type"), classtype = params["class" + type.slice(0, 1).touppercase() + type.slice(1)], indexwill = indexselected; switch (type) { case "prev": { params.prevornext = $(this); funplayprev(); break } case "play": { funautoplay.flagautoplay = true; $(this).attr("data-type", "pause").removeclass(classtype).addclass(params.classpause); funautoplay(); break } case "pause": { funautoplay.flagautoplay = false; $(this).attr("data-type", "play").removeclass(classtype).addclass(params.classplay); funautoplay(); break } case "next": { params.prevornext = $(this); funplaynext(); break } } return false; }); } if (params.autotime) { // 瀹氭椂鎾斁鐩稿叧浜嬩欢缁戝畾 // 鑷畾涔夋寜閽鍣紝閫夐」鍗★紝浠ュ強鍒囨崲闈㈡澘榧犳爣缁忚繃鍋滄鑷姩鎾斁 // 濡傛灉瀹瑰櫒瀛樺湪锛屼笖鏄寘鍚叧绯? // 鍙缁戝畾瀹瑰櫒灏卞彲浠? var arrhoverplay = [self, elerelatives, params.container]; if (ismoretoone == true || (document.body.contains && params.container && params.container.get(0).contains(elerelatives.get(0)))) { arrhoverplay = [self, params.container]; } $.each(arrhoverplay, function(index, hovertarget) { if (hovertarget) hovertarget.hover(function(event) { if (event.pagex !== undefined || params.eventtype == "click") cleartimeout(autoplaytimer); }, function(event) { if (event.pagex !== undefined || params.eventtype == "click") funautoplay(); }); }); funautoplay.flagautoplay = true; funautoplay(); } } return self; }; })(window, jquery);/* 閰风珯浠g爜鏁寸悊 http://www.5icool.org */