日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
JS異步編程三:Jscex無(wú)創(chuàng)痕切入jQUI

很多人可能會(huì)有個(gè)疑問(wèn),Jscex和其他類庫(kù)共同使用或者語(yǔ)法混用時(shí),會(huì)不會(huì)出現(xiàn)沖突或者異常?那么我們就來(lái)做個(gè)嘗試吧!

創(chuàng)新互聯(lián)自2013年創(chuàng)立以來(lái),是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都做網(wǎng)站、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元云和做網(wǎng)站,已為上家服務(wù),為云和各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18982081108

我們使用tab插件:

 
 
 
  1. $(function () {
  2. $("#tabs").tabs({ event: "mouseover" });
  3. }); 

后來(lái),官網(wǎng)幫這個(gè)tab插件擴(kuò)展了一個(gè)自動(dòng)切換的功能,只需要這樣寫(xiě)就行:

 
 
 
  1. $(function () 
  2. {var t = $("#tabs").tabs();
  3. t.tabs("rotate", 3000, false);
  4. });

擴(kuò)展的代碼如下:

 
 
 
  1. $.extend($.ui.tabs.prototype, {
  2.             rotation: null,
  3.             rotate: function (ms, continuing) {
  4.                 var self = this,
  5. o = this.options;
  6.                 var rotate = self._rotate || (self._rotate = function (e) {
  7.                     clearTimeout(self.rotation);
  8.                     self.rotation = setTimeout(function () {
  9.                         var t = o.selected;
  10.                         self.select(++t < self.anchors.length ? t : 0);
  11.                     }, ms);
  12.                     if (e) {
  13.                         e.stopPropagation();
  14.                     }
  15.                 });
  16.                 var stop = self._unrotate || (self._unrotate = !continuing
  17. ? function (e) {
  18.     if (e.clientX) { // in case of a true click
  19.         self.rotate(null);
  20.     }
  21. }
  22. : function (e) {
  23.     t = o.selected;
  24.     rotate();
  25. });
  26.                 // start rotation
  27.                 if (ms) {
  28.                     this.element.bind("tabsshow", rotate);
  29.                     this.anchors.bind(o.event + ".tabs", stop);
  30.                     rotate();
  31.                     // stop rotation
  32.                 } else {
  33.                     clearTimeout(self.rotation);
  34.                     this.element.unbind("tabsshow", rotate);
  35.                     this.anchors.unbind(o.event + ".tabs", stop);
  36.                     delete this._rotate;
  37.                     delete this._unrotate;
  38.                 }
  39.                 return this;
  40.             }
  41.         });

依然是那么費(fèi)解的代碼!在官方?jīng)]有擴(kuò)展之前,我們可以用Jscex介樣子實(shí)現(xiàn):

 
 
 
  1. var swicthAsync = eval(Jscex.compile("async", function () {
  2.             var tabCount = $("#tabs ul li").length;
  3.             while (true) {
  4.                 for (var i = 0; i < tabCount; i++) {
  5.                     $await(Jscex.Async.sleep(2000));
  6.                     $('#tabs').tabs({ selected: i });
  7.                 }
  8.             }
  9.         }));
  10.         $(function () {
  11.             $("#tabs").tabs();
  12.             swicthAsync().start();
  13.         });

可以看得出來(lái),這樣的話Jscex沒(méi)有對(duì)JqueryUI做任何介入,Jscex只是外部控制的一層殼。這樣無(wú)法對(duì)測(cè)試出Jscex是否能與沖突或者異常,那么,我們就來(lái)用Jscex重寫(xiě)官方的擴(kuò)展方法吧!

 
 
 
  1. $.extend($.ui.tabs.prototype, {
  2.             rotation: null,
  3.             rotate: function (ms, continuing) {
  4.                 var self = this,
  5. o = this.options;
  6.                 var swicthAsync = eval(Jscex.compile("async", function () {
  7.                     while (true) {
  8.                         for (var i = 0; i < self.anchors.length; i++) {
  9.                             $await(Jscex.Async.sleep(ms));
  10.                             self.select(i);
  11.                         }
  12.                     }
  13.                 }));
  14.                 swicthAsync().start();
  15.                 return this;
  16.             }
  17.         });

但是continuing參數(shù)暫時(shí)沒(méi)有起作用,該參數(shù)是決定用戶在選中后是否繼續(xù)循環(huán)下去,這個(gè)就留個(gè)大家自己去完善吧~~~~

新的Jscex 庫(kù),請(qǐng)上https://github.com/JeffreyZhao/jscex或者h(yuǎn)ttp://www.sndacode.com/projects/jscex/wiki下載。


當(dāng)前名稱:JS異步編程三:Jscex無(wú)創(chuàng)痕切入jQUI
鏈接地址:http://m.5511xx.com/article/cdeedjo.html