1/* SuperSlide1.2 -- Copyright ©2012 大è¯ä¸»å¸ 2 */ 3(function($){ 4 $.fn.slide=function(options){ 5 $.fn.slide.deflunt={ 6 effect : "fade", //ææ || fadeï¼æ¸æ¾ï¼ || topï¼ä¸æ»å¨ï¼|| leftï¼å·¦æ»å¨ï¼|| topLoopï¼ä¸å¾ªç¯æ»å¨ï¼|| leftLoopï¼å·¦å¾ªç¯æ»å¨ï¼|| topMarqueeï¼ä¸æ ç¼å¾ªç¯æ»å¨ï¼|| leftMarqueeï¼å·¦æ ç¼å¾ªç¯æ»å¨ï¼ 7 autoPlay:false, //èªå¨è¿è¡ 8 delayTime : 500, //æææç»æ¶é´ 9 interTime : 2500,//èªå¨è¿è¡é´éãå½effect为æ ç¼æ»å¨çæ¶åï¼ç¸å½äºè¿è¡é度ã 10 defaultIndex : 0,//é»è®¤çå½åä½ç½®ç´¢å¼ã0æ¯ç¬¬ä¸ä¸ª 11 titCell:".hd li",//导èªå ç´ 12 mainCell:".bd",//å 容å ç´ çç¶å±å¯¹è±¡ 13 trigger: "mouseover",//è§¦åæ¹å¼ || mouseoverï¼é¼ æ ç§»è¿è§¦åï¼|| clickï¼é¼ æ ç¹å»è§¦åï¼ 14 scroll:1,//æ¯æ¬¡æ»å¨ä¸ªæ°ã 15 vis:1,//visibleï¼å¯è§èå´ä¸ªæ°ï¼å½å 容个æ°å°äºå¯è§ä¸ªæ°çæ¶åï¼ä¸æ§è¡ææã 16 titOnClassName:"on",//å½åä½ç½®èªå¨å¢å çclassåç§° 17 autoPage:false,//ç³»ç»èªå¨å页ï¼å½ä¸ºtrueæ¶ï¼titCellå为导èªå ç´ ç¶å±å¯¹è±¡ï¼åæ¶ç³»ç»ä¼å¨titCelléé¢èªå¨æå ¥å页liå ç´ (1.2çæ¬æ°å¢) 18 prevCell:".prev",//åä¸ä¸ªæé®å ç´ ã 19 nextCell:".next",//åä¸ä¸ªæé®å ç´ ã 20 showType:"img"//æ¾ç¤ºæ¹å¼ || img: å¾çå½¢å¼ï¼ || bg: èæ¯å½¢å¼ 21 }; 22 23 return this.each(function() { 24 var opts = $.extend({},$.fn.slide.deflunt,options); 25 var index=opts.defaultIndex; 26 var prevBtn = $(opts.prevCell, $(this)); 27 var nextBtn = $(opts.nextCell, $(this)); 28 var navObj = $(opts.titCell, $(this));//导èªåå ç´ ç»å 29 var navObjSize = navObj.size(); 30 var conBox = $(opts.mainCell, $(this));//å 容å ç´ ç¶å±å¯¹è±¡ 31 var conBoxSize=conBox.children().size(); 32 var slideH=0; 33 var slideW=0; 34 var selfW=0; 35 var selfH=0; 36 var autoPlay = opts.autoPlay; 37 var inter=null;//setIntervalåç§° 38 var oldIndex = index; 39 40 if(conBoxSize<opts.vis) return; //å½å 容个æ°å°äºå¯è§ä¸ªæ°ï¼ä¸æ§è¡ææã 41 42 //å¤çå页 43 if( navObjSize==0 )navObjSize=conBoxSize; 44 if( opts.autoPage ){ 45 var tempS = conBoxSize-opts.vis; 46 navObjSize=1+parseInt(tempS%opts.scroll!=0?(tempS/opts.scroll+1):(tempS/opts.scroll)); 47 navObj.html(""); 48 for( var i=0; i<navObjSize; i++ ){ navObj.append("<li>"+(i+1)+"</li>") } 49 var navObj = $("li", navObj);//é置导èªåå ç´ å¯¹è±¡ 50 } 51 52 conBox.children().each(function(){ //åæå¤§å¼ 53 if(opts.showType=='bg'){ 54 $(this).find('a').css('background-image', 'url('+$(this).find('img').attr('src')+')'); 55 $(this).find('img').remove(); 56 } 57 if( $(this).width()>selfW ){ selfW=$(this).width(); slideW=$(this).outerWidth(true); } 58 if( $(this).height()>selfH ){ selfH=$(this).height(); slideH=$(this).outerHeight(true); } 59 }); 60 61 switch(opts.effect) 62 { 63 case "top": conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:'+opts.vis*slideH+'px"></div>').css( { "position":"relative","padding":"0","margin":"0"}).children().css( {"height":selfH} ); break; 64 case "left": conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:'+opts.vis*slideW+'px"></div>').css( { "width":conBoxSize*slideW,"position":"relative","overflow":"hidden","padding":"0","margin":"0"}).children().css( {"float":"left","width":selfW} ); break; 65 case "leftLoop": 66 case "leftMarquee": 67 conBox.children().clone().appendTo(conBox).clone().prependTo(conBox); 68 conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; width:'+opts.vis*slideW+'px"></div>').css( { "width":conBoxSize*slideW*3,"position":"relative","overflow":"hidden","padding":"0","margin":"0","left":-conBoxSize*slideW}).children().css( {"float":"left","width":selfW} ); break; 69 case "topLoop": 70 case "topMarquee": 71 conBox.children().clone().appendTo(conBox).clone().prependTo(conBox); 72 conBox.wrap('<div class="tempWrap" style="overflow:hidden; position:relative; height:'+opts.vis*slideH+'px"></div>').css( { "height":conBoxSize*slideH*3,"position":"relative","padding":"0","margin":"0","top":-conBoxSize*slideH}).children().css( {"height":selfH} ); break; 73 } 74 //-----------导èªå± ä¸---------- 75 if(opts.vis==1){ 76 var settitCellPos=function(){ 77 var navBox=navObj.parent().parent(), 78 objW=conBox.parent().parent().width(), 79 objH=conBox.parent().parent().height(), 80 navBoxLeft=(objW-navBox.width())/2; 81 82 slideW=objW; 83 slideH=objH; 84 85 navBox.css('left', navBoxLeft+'px'); 86 conBox.css('width', objW*(conBox.find('li').size())+'px').parent().css('width', objW+'px').find('div, li, img').css('width', objW+'px'); 87 } 88 jQuery(window).resize(function(){settitCellPos();}); 89 settitCellPos(); 90 } 91 //-----------导èªå± ä¸---------- 92 93 //ææå½æ° 94 var doPlay=function(){ 95 96 switch(opts.effect) 97 {
98 case "fade": case "top": case "left": if ( index >= navObjSize) { index = 0; } else if( index < 0) { index = navObjSize-1; } break; 99 case "leftMarquee":case "topMarquee": if ( index>= 2) { index=1; } else if( index<0) { index = 0; } break; 100 case "leftLoop": case "topLoop": 101 var tempNum = index - oldIndex; 102 if( navObjSize>2 && tempNum==-(navObjSize-1) ) tempNum=1; 103 if( navObjSize>2 && tempNum==(navObjSize-1) ) tempNum=-1; 104 var scrollNum = Math.abs( tempNum*opts.scroll ); 105 if ( index >= navObjSize) { index = 0; } else if( index < 0) { index = navObjSize-1; } 106 break; 107 } 108 switch (opts.effect) 109 { 110 case "fade":conBox.children().stop(true,true).eq(index).fadeIn(opts.delayTime).siblings().hide();break; 111 case "top":conBox.stop(true,true).animate({"top":-index*opts.scroll*slideH},opts.delayTime);break; 112 case "left":conBox.stop(true,true).animate({"left":-index*opts.scroll*slideW},opts.delayTime);break; 113 case "leftLoop": 114 if(tempNum<0 ){ 115 conBox.stop(true,true).animate({"left":-(conBoxSize-scrollNum )*slideW},opts.delayTime,function(){ 116 for(var i=0;i<scrollNum;i++){ conBox.children().last().prependTo(conBox); } 117 conBox.css("left",-conBoxSize*slideW); 118 }); 119 } 120 else{ 121 conBox.stop(true,true).animate({"left":-( conBoxSize + scrollNum)*slideW},opts.delayTime,function(){ 122 for(var i=0;i<scrollNum;i++){ conBox.children().first().appendTo(conBox); } 123 conBox.css("left",-conBoxSize*slideW); 124 }); 125 }break;// leftLoop end 126 127 case "topLoop": 128 if(tempNum<0 ){ 129 conBox.stop(true,true).animate({"top":-(conBoxSize-scrollNum )*slideH},opts.delayTime,function(){ 130 for(var i=0;i<scrollNum;i++){ conBox.children().last().prependTo(conBox); } 131 conBox.css("top",-conBoxSize*slideH); 132 }); 133 } 134 else{ 135 conBox.stop(true,true).animate({"top":-( conBoxSize + scrollNum)*slideH},opts.delayTime,function(){ 136 for(var i=0;i<scrollNum;i++){ conBox.children().first().appendTo(conBox); } 137 conBox.css("top",-conBoxSize*slideH); 138 }); 139 }break;//topLoop end 140 141 case "leftMarquee": 142 var tempLeft = conBox.css("left").replace("px",""); 143 144 if(index==0 ){ 145 conBox.animate({"left":++tempLeft},0,function(){ 146 if( conBox.css("left").replace("px","")>= 0){ for(var i=0;i<conBoxSize;i++){ conBox.children().last().prependTo(conBox); }conBox.css("left",-conBoxSize*slideW);} 147 }); 148 } 149 else{ 150 conBox.animate({"left":--tempLeft},0,function(){ 151 if( conBox.css("left").replace("px","")<= -conBoxSize*slideW*2){ for(var i=0;i<conBoxSize;i++){ conBox.children().first().appendTo(conBox); }conBox.css("left",-conBoxSize*slideW);} 152 }); 153 }break;// leftMarquee end 154 155 case "topMarquee": 156 var tempTop = conBox.css("top").replace("px",""); 157 if(index==0 ){ 158 conBox.animate({"top":++tempTop},0,function(){ 159 if( conBox.css("top").replace("px","") >= 0){ for(var i=0;i<conBoxSize;i++){ conBox.children().last().prependTo(conBox); }conBox.css("top",-conBoxSize*slideH);} 160 }); 161 } 162 else{ 163 conBox.animate({"top":--tempTop},0,function(){ 164 if( conBox.css("top").replace("px","")<= -conBoxSize*slideH*2){ for(var i=0;i<conBoxSize;i++){ conBox.children().first().appendTo(conBox); }conBox.css("top",-conBoxSize*slideH);} 165 }); 166 }break;// topMarquee end 167 168 169 }//switch end 170 navObj.removeClass(opts.titOnClassName).eq(index).addClass(opts.titOnClassName); 171 oldIndex=index; 172 }; 173 //åå§åæ§è¡ 174 doPlay(); 175 176 //èªå¨ææ¾ 177 if (autoPlay) { 178 if( opts.effect=="leftMarquee" || opts.effect=="topMarquee" ){ 179 index++; inter = setInterval(doPlay, opts.interTime); 180 conBox.hover(function(){if(autoPlay){clearInterval(inter); }},function(){if(autoPlay){clearInterval(inter);inter = setInterval(doPlay, opts.interTime);}}); 181 }else{ 182 inter=setInterval(function(){index++; doPlay() }, opts.interTime); 183 $(this).hover(function(){if(autoPlay){clearInterval(inter); }},function(){if(autoPlay){clearInterval(inter); inter=setInterval(function(){index++; doPlay() }, opts.interTime); }}); 184 } 185 } 186 187 //é¼ æ äºä»¶ 188 var mst; 189 if(opts.trigger=="mouseover"){ 190 navObj.hover(function(){ clearTimeout(mst); index=navObj.index(this); mst = window.setTimeout(doPlay,200); }, function(){ if(!mst)clearTimeout(mst); }); 191 }else{ navObj.click(function(){index=navObj.index(this); doPlay(); }) } 192 nextBtn.click(function(){ index++; doPlay(); }); 193 prevBtn.click(function(){ index--; doPlay(); }); 194 195 });//each End 196 197 };//slide End 198 199 200})(jQuery); 201
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.