1/** 2 * osSlider é³å è½®ææä»¶ v1.0 3 * objs ä¼ é对象 4 */ 5function osSlider(objs) { 6 var that = this; //thatè·å¾thisçä½ç¨å åé¢é½æ¯that 鲿¢å¹²æ° 7 that.objs = objs; //å°ä¼ 鿥ç对象èµäºthis 8 that.pNode = $(that.objs.pNode); //pNodeè½®æå®¹å¨å¯¹è±¡ 9 that.cNodes = that.pNode.find(that.objs.cNode); //cNodesè½®æåèç¹å¯¹è±¡éå 10 that.cNodeNums = that.cNodes.length; //é¢åè½®æä½çæ»æ° 11 that.nowNodeKey = 0; //åå§ç¬¬ä¸æ¬¡é»è®¤æ¾ç¤ºèç¹ä¸ºç¬¬ä¸ä¸ª 12 that.width = that.cNodes.find('img').width();//å¾å°å®¹å¨ç宽度 13 that.height = that.cNodes.find('img').height();//å¾å°å®¹å¨çé«åº¦ 14 that.moveFlag = true;//æ·»å æ¯å¦å¯ä»¥è¿è¡ä¸ä¸ä¸ªè½®æç¶æ 15 that.isPause = false;//æ¯å¦æåç¶æ 16 that.speedNum = 0;//èªå¨è½®æçè®¡æ° 17 if (!that.objs.speed) {//æ·»å é»è®¤æ¶é´ 18 that.objs.speed = 3000; 19 } 20 if (!that.objs.autoPlay) {//æ·»å é»è®¤èªå¨ææ¾ 21 that.objs.autoPlay = true; 22 } 23 that.init = function() {//è½®æçåå§å 24 that.pNode.addClass('osSlider-main'); 25 that.pNode.css({//è½®æå®¹å¨ç大尿§å¶ å¯ç¨bfcæ¨¡å¼ 26 'width':that.width, 27 'height':that.height, 28 'overflow':'hidden', 29 'position':'relative' 30 }); 31 //å建ä¸ä¸æ¡åæ¢æé® 32 var $toggleBtn = $('<ul class="slider-btn"><li class="slider-btn-prev">prev</li><li class="slider-btn-next">next</li></ul>'); 33 $toggleBtn.appendTo(that.pNode); 34 //ä¸ºåæ¢æé®ç»å®äºä»¶ 35 $(that.pNode).find('.slider-btn-prev').bind('click',function(){ 36 that.toggleMove('prev'); 37 }); 38 $(that.pNode).find('.slider-btn-next').bind('click',function(){ 39 that.toggleMove('next'); 40 }); 41 //为é«äº®å¯¼èªå建èç¹ 42 var $navParent = $('<ul class="slider-nav"></ul>'); 43 $navParent.appendTo(that.pNode); 44 that.cNodes.each(function(index, el) {//éç¨éåï¼æ·»å ååé¡ºåº 45 if (index==0) {//让第ä¸ä¸ªæ¾ç¤ºå¨åé¢ åæ¶ä¸ºæ¯ä¸ªè½®æä½å建对åºnavç¹ 46 var indexNum = 20; 47 $navParent.append('<li class="active">'+(index+1)+'</li>'); 48 } else { 49 var indexNum = index; 50 $navParent.append('<li>'+(index+1)+'</li>'); 51 } 52 $(this).css({//为æ¯ä¸ä¸ªè½®æä½æ·»å æ ·å¼åé¡ºåº 53 'width':that.width + 'px', 54 'height':that.height + 'px', 55 'overflow':'hidden', 56 'position':'absolute', 57 'top':'0px', 58 'left':'0px', 59 'z-index':indexNum 60 }); 61 }); 62 //为é«äº®å¯¼èªèç¹ç»å®äºä»¶ 63 $(that.pNode).find('.slider-nav li').each(function(index, el) { 64 $(this).bind('click',function(){ 65 that.toggleMove(false,index); 66 }); 67 }); 68 //夿æ¯å¦èªå¨ææ¾ 69 if (that.objs.autoPlay) { 70 that.moveTime(); 71 } 72 } 73 /** 74 * åæ¢è½®æå è½®æå¯¼èªçé«äº® 75 * @param {Number} tid 76 */ 77 that.sliderNavToggle = function(tid,nid) { 78 //è¿éæ¯å ä¸èªå·±ç龿¥ä¿¡è¾¾ 79 //$("#sliderhref").attr("href",$(".slider-main").find("li").eq(tid).attr("rel")); 80 81 $('.slider-nav li').each(function(index, el) { 82 if (index==tid||index==nid) { 83 $(this).toggleClass('active'); 84 } 85 }); 86 } 87 /** 88 * åæ¢æææä»¤å½æ° é¿å BUG 89 * @param {String} command 'prev'|'next' 90 * @param {Number} tid ä¸ä¸ä¸ªè¦åæ¢çtid 91 * commandä¸tidå¯ä»¥ç¼ºçä¸ä¸ªï¼å½æ°èªå¨å¤æ 92 */ 93 that.toggleMove = function(command,tid) { 94 if (that.moveFlag) { 95 if (!command) { 96 if (that.nowNodeKey==tid) { 97 return; 98 } else if ((that.nowNodeKey==0&&tid==that.cNodeNums-1)||tid<that.nowNodeKey) { 99 command = 'prev'; 100 } else { 101 command = 'next'; 102 } 103 } 104 if (!tid) { 105 if(tid==0) { 106 } else if (command=='prev') { 107 tid = that.nowNodeKey-1; 108 if (that.nowNodeKey==0) { 109 tid = that.cNodeNums-1; 110 } 111 } else { 112 tid = that.nowNodeKey+1; 113 if (that.nowNodeKey==that.cNodeNums-1) { 114 tid = 0; 115 } 116 } 117 } 118 /** 119 * éæºå½æ° 120 */ 121 function random(min,max) { 122 return Math.floor(Math.random()*(max+1)-min); 123 } 124 that.moveSwitch(random(0,6),command,tid); 125 } 126 } 127 /** 128 * æ ¹æ®åé ç忢æä»¤æ§è¡ææ 129 * @param {Number} mid å¨ç»æä»¤ 130 * @param {String} command 'prev'|'next' 131 * @param {Number} tid ä¸ä¸ä¸ªè¦åæ¢çtid 132 */ 133 that.moveSwitch = function(mid,command,tid) { 134 nid = that.nowNodeKey; 135 that.moveFlag = false;
136 that.speedNum = 0; 137 that.sliderNavToggle(nid,tid); 138 switch (mid) { 139 case 0: 140 that.gridTop(tid,0); 141 break; 142 case 1: 143 that.gridTop(tid,1); 144 break; 145 case 2: 146 that.gridTop(tid,2); 147 break; 148 case 3: 149 that.gridLeft(tid,0); 150 break; 151 case 4: 152 that.gridLeft(tid,1); 153 break; 154 case 5: 155 that.gridLeft(tid,2); 156 break; 157 case 6: 158 that.cellToggle(tid); 159 break; 160 default: 161 that.gridTop(tid); 162 break; 163 } 164 } 165 /** 166 * æ æ ¼ä¸ä¸åæ¢ 167 */ 168 that.gridTop = function(tid,showNum) { 169 that.cNodes[tid].style.zIndex = 19;//让ä¸ä¸ªèç¹åå¤å¥½ 170 var $backHTML = that.cNodes[that.nowNodeKey].innerHTML;//å¤ä»½å½åèç¹çå 容 171 that.cNodes[that.nowNodeKey].innerHTML = '';//æ¸ ç©ºèç¹ï¼æ¹ä¾¿ä½¿ç¨ 172 for (var i = 0; i < 12; i++) {//å©ç¨å¾ªç¯ åå»ºåºæ æ ¼èç¹ 173 var $cvNode = $('<div class="cvNode"></div>'); 174 $(that.cNodes[that.nowNodeKey]).append($cvNode); 175 $cvNode.html($backHTML); 176 $cvNode.css({//为æ¯ä¸ªæ æ ¼èç¹æ·»å cssæ ·å¼ 177 'position':'absolute', 178 'width':that.width/12+'px', 179 'height':that.height+'px', 180 'zIndex':20, 181 'overflow':'hidden', 182 'left':that.width/12*i+'px', 183 'top':'0' 184 }); 185 $cvNode.find('*').first().css({ 186 'display':'block', 187 'margin-left':that.width/-12*i+'px' 188 }); 189 } 190 191 //åé å¯¹åºææ 192 switch (showNum) { 193 default: 194 case 0: 195 //æ·»å å¨ç»è¿æ¸¡ææ å¼ çèçª 196 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 197 if (index%2==0) { 198 var topNums = that.height; 199 } else { 200 var topNums = that.height*-1; 201 } 202 $(this).animate({ 203 top:topNums + 'px' 204 },1500); 205 }); 206 setTimeout(function(){//å¨ç»ç»æåå¼å§æ¢å¤åæç¶æ 207 that.moveFlag = true; 208 that.cNodes[tid].style.zIndex = 20; 209 that.cNodes[that.nowNodeKey].style.zIndex = that.nowNodeKey; 210 $(that.cNodes[that.nowNodeKey]).html($backHTML);//æ¸ é¤å¨ç»äº§ççå¤ä½å 容 211 that.nowNodeKey = tid;//å¾å°æ°çå½åèç¹key 212 },1500); 213 break; 214 case 1: 215 //å ¼å®¹å°ä¸é¢ 216 case 2: 217 if (showNum==1) { 218 //æ·»å å¨ç»è¿æ¸¡ææ ä¸é 219 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 220 var sp = 80*index; 221 $(this).animate({ 222 top: $(this).height() + 'px' 223 },500+sp); 224 }); 225 } else { 226 //æ·»å å¨ç»è¿æ¸¡ææ ä¸å 227 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 228 var sp = 80*index; 229 $(this).animate({ 230 top: $(this).height()*-1 + 'px' 231 },500+sp); 232 }); 233 } 234 setTimeout(function(){//å¨ç»ç»æåå¼å§æ¢å¤åæç¶æ 235 that.moveFlag = true; 236 that.cNodes[tid].style.zIndex = 20; 237 that.cNodes[that.nowNodeKey].style.zIndex = that.nowNodeKey; 238 $(that.cNodes[that.nowNodeKey]).html($backHTML);//æ¸ é¤å¨ç»äº§ççå¤ä½å 容 239 that.nowNodeKey = tid;//å¾å°æ°çå½åèç¹key 240 },1380); 241 break; 242 } 243 } 244 245 /** 246 * æ æ ¼å·¦å³å¼ çèçªåæ¢ 247 */ 248 that.gridLeft = function(tid,showNum) { 249 that.cNodes[tid].style.zIndex = 19;//让ä¸ä¸ªèç¹åå¤å¥½ 250 var $backHTML = that.cNodes[that.nowNodeKey].innerHTML;//å¤ä»½å½åèç¹çå 容 251 that.cNodes[that.nowNodeKey].innerHTML = '';
251//æ¸ ç©ºèç¹ï¼æ¹ä¾¿ä½¿ç¨ 252 for (var i = 0;i<12;i++) {//å©ç¨å¾ªç¯ åå»ºåºæ æ ¼èç¹ 253 var $cvNode = $('<div class="cvNode"></div>'); 254 $(that.cNodes[that.nowNodeKey]).append($cvNode); 255 $cvNode.html($backHTML); 256 $cvNode.css({//为æ¯ä¸ªæ æ ¼èç¹æ·»å cssæ ·å¼ 257 'position':'absolute', 258 'width':that.width+'px', 259 'height':that.height/12+'px', 260 'zIndex':20, 261 'overflow':'hidden', 262 'left':'0', 263 'top':that.height/12*i+'px', 264 }); 265 $cvNode.find('*').first().css({ 266 'display':'block', 267 'margin-top':that.height/-12*i+'px' 268 }); 269 } 270 switch (showNum) { 271 default: 272 case 0: 273 //æ·»å å¨ç»è¿æ¸¡ææ å¼ çèçª 274 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 275 if (index%2==0) { 276 var leftNums = that.width; 277 } else { 278 var leftNums = that.width*-1; 279 } 280 $(this).animate({ 281 'left':leftNums + 'px' 282 },1500); 283 }); 284 break; 285 case 1: 286 case 2: 287 if (showNum==1) { 288 //æ·»å å¨ç»è¿æ¸¡ææ åå·¦ 289 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 290 var sp = 80*index; 291 $(this).animate({ 292 'left':that.width*-1 + 'px' 293 },620+sp); 294 }); 295 } else { 296 //æ·»å å¨ç»è¿æ¸¡ææ åå³ 297 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 298 var sp = 80*index; 299 $(this).animate({ 300 'left':that.width + 'px' 301 },620+sp); 302 }); 303 } 304 break; 305 } 306 setTimeout(function(){//å¨ç»ç»æåå¼å§æ¢å¤åæç¶æ 307 that.moveFlag = true; 308 that.cNodes[tid].style.zIndex = 20; 309 that.cNodes[that.nowNodeKey].style.zIndex = that.nowNodeKey; 310 $(that.cNodes[that.nowNodeKey]).html($backHTML);//æ¸ é¤å¨ç»äº§ççå¤ä½å 容 311 that.nowNodeKey = tid;//å¾å°æ°çå½åèç¹key 312 },1500); 313 } 314 315 //æ ¼ååæ¢ææ 316 that.cellToggle = function(tid) { 317 that.cNodes[tid].style.zIndex = 19;//让ä¸ä¸ªèç¹åå¤å¥½ 318 var $backHTML = that.cNodes[that.nowNodeKey].innerHTML;//å¤ä»½å½åèç¹çå 容 319 that.cNodes[that.nowNodeKey].innerHTML = '';//æ¸ ç©ºèç¹ï¼æ¹ä¾¿ä½¿ç¨ 320 for (var i = 0;i<20;i++) {//å©ç¨å¾ªç¯ åå»ºåºæ æ ¼èç¹ 321 if (i<5) {//è¡æ°å¤æ 322 var rows = 0; 323 } else if (i<10) { 324 var rows = 1; 325 } else if (i<15) { 326 var rows = 2; 327 } else { 328 var rows = 3; 329 } 330 var $cvNode = $('<div class="cvNode"></div>'); 331 $(that.cNodes[that.nowNodeKey]).append($cvNode); 332 $cvNode.html($backHTML); 333 $cvNode.css({//为æ¯ä¸ªæ æ ¼èç¹æ·»å cssæ ·å¼ 334 'position':'absolute', 335 'width':that.width/5+'px', 336 'height':that.height/4+'px', 337 'zIndex':20, 338 'overflow':'hidden', 339 'left':that.width/5*(i%5)+'px', 340 'top':that.height/4*rows+'px', 341 }); 342 $cvNode.find('*').first().css({ 343 'display':'block', 344 'margin-left':that.width/-5*(i%5)+'px', 345 'margin-top':that.height/-4*rows+'px', 346 }); 347 } 348 //æ·»å å¨ç»è¿æ¸¡ææ 349 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 350 if (index%2==0) { 351 $(this).find('*').first().animate({ 352 "margin-left": $(this).width() + 'px' 353 }, 500); 354 } 355 }); 356 setTimeout(function(){ 357 $(that.cNodes[that.nowNodeKey]).find('.cvNode').each(function(index,el){ 358 if (index%1==0) { 359 $(this).find('*').first().animate({ 360 "margin-left": $(this).width() + 'px' 361 }, 500); 362 } 363 }); 364 },600); 365 setTimeout(function(){//å¨ç»ç»æåå¼å§æ¢å¤åæç¶æ 366 that.moveFlag = true; 367 that.cNodes[tid].style.zIndex = 20; 368 that.cNodes[that.nowNodeKey].style.zIndex = that.nowNodeKey; 369 $(that.cNodes[that.nowNodeKey]).html($backHTML);//æ¸ é¤å¨ç»äº§ççå¤ä½å 容 370 that.nowNodeKey = tid;//å¾å°æ°çå½åèç¹key 371 },1100); 372 } 373 374 //èªå¨ææ¾æ§å¶æ¹æ³ 375 that.moveTime = function() { 376 setTimeout(function(){ 377 if (that.moveFlag) { 378 that.speedNum++; 379 if (that.speedNum>=that.objs.speed/100) { 380 that.speedNum = 0; 381 that.toggleMove('next'); 382 } 383 } 384 if (!that.isPause) { 385 setTimeout(arguments.callee,100); 386 } 387 },100); 388 } 389 that.init(); 390}
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.