1// JavaScript Document 2/* 3$("").mChange({ 4 auto : 1, //Whether to play automatically, 1 is automatic, 0 is manual 5arrow : 1, //whether to invert the arrow, 1 is to click on the left to scroll to the right, 0 is the opposite 6speed : 500, //effect speed, greater than 0.3 7time : 5000, //cycle time, greater than 1 8nav : null, //navigation 9nave : "click", //navigation event 10navs : 0, //navigation scroll 11prev : null, //previous 12next : null, //next 13cycle : 1, //whether to cycle 14mousestop : 0, //whether the mouse swipe to stop 15mousewheel : 0, //whether to enable the scroll wheel event 16count : null, //total 17index : null, //current 18fnCome: null, //function before callback 19fnBack: null //callback function 20}); 21*/ 22(function($) { 23 $.fn.mChange = function(options) { 24 var w1,np,ns,v; 25 var opts = $.extend({},$.fn.mChange.defaults,options); 26 //initialization 27 var c=$(this); 28 var f=c.parent(); 29 var n=$(opts.nav); 30 var i=0; 31 var sw=1; 32 c.hide(); 33 34 if(opts.navs){ 35 w1 = n.outerWidth()+(parseInt(n.css("margin-left"))?parseInt(n.css("margin-left")):0)+(parseInt(n.css("margin-right"))?parseInt(n.css("margin-right")):0); 36 np= $(opts.nav).parent(); 37 n.wrapAll("<div class='scroll' style='height:100%;'></div>"); 38 ns=np.find(".scroll"); 39 ns.width(n.length*w1); 40 np.stop().animate({scrollLeft:0},100); 41 } 42 43 function run(){ 44 if(sw){ 45 i++; 46 i=change(i); 47 } 48 } 49 50 $(opts.count).text(c.length); 51 52 function change(idx){ 53 if(c.length>1 || idx=="begin"){ 54 sw=0; 55 if(idx=="begin"){ 56 idx=0; 57 speed=0; 58 } 59 else{ 60 speed=opts.speed; 61 c.stop(true,true).fadeOut(speed); 62 } 63 64 n.removeClass("now"); 65 if(idx==c.length){idx=0;} 66 if(idx<0){idx=c.length-1;} 67 68 69 $(opts.index).text(idx+1); 70 71 c.eq(idx).stop().fadeIn(speed,function(){ 72 if(typeof(opts.fnBack)=="function"){ 73 opts.fnBack(idx);//Execute custom animation 2 74 } 75 sw=1; 76 }); 77 if(typeof(opts.fnCome)=="function"){ 78 opts.fnCome(idx);//Execute custom animation 1 79 } 80 81 n.eq(idx).addClass("now"); 82 if(opts.navs){autonav(idx);} 83 84 return idx; 85 } 86 } 87 change("begin"); 88 89 if(opts.auto==1){ 90 v=setInterval(run,opts.time); 91 } 92 93 if(opts.mousestop==1){ 94 c.hover( 95 function(){sw=0;}, 96 function(){sw=1;} 97 ); 98 } 99 100//Navigation overflow section sliding display 101 function autonav(idx){ 102 np.animate({scrollLeft:idx*w1}); 103 } 104 105 n.each(function(index, element) { 106 $(this).bind(opts.nave,function(){ 107 if(c.eq(index).length>0){ 108 change(index); 109 i=index; 110 if(opts.auto){ 111 clearInterval(v); 112 v=setInterval(run,opts.time); 113 } 114 } 115 }); 116 }); 117 118 $(opts.prev).click(function(){ 119 if(sw==1){ 120 if(opts.cycle==1 || (opts.cycle==0 && i>0)){ 121 i--; 122 i=change(i); 123 if(opts.auto==1){ 124 clearInterval(v); 125 v=setInterval(run,opts.time); 126 } 127 } 128 } 129 }); 130 $(opts.next).click(function(){ 131 if(sw==1){ 132 if(opts.cycle==1 || (opts.cycle==0 && i<c.length-1)){ 133 i++; 134 i=change(i); 135 if(opts.auto){ 136 clearInterval(v); 137 v=setInterval(run,opts.time); 138 } 139 } 140 } 141 }); 142 143 if(opts.mousewheel){ 144 f.mousewheel(function(event,delta,deltaX,deltaY){ 145 if(delta<0){ 146 if(sw==1){ 147 if(opts.cycle==1 || (opts.cycle==0 && i<c.length-1)){ 148 i++; 149 i=change(i); 150 if(opts.auto){ 151 clearInterval(v); 152 v=setInterval(run,opts.time); 153 } 154 } 155 } 156 } 157 else{ 158 if(sw==1){ 159 if(opts.cycle==1 || (opts.cycle==0 && i>0)){ 160 i--; 161 i=change(i); 162 if(opts.auto){ 163 clearInterval(v); 164 v=setInterval(run,opts.time); 165 } 166 } 167 } 168 } 169 event.stopPropagation(); 170 event.preventDefault(); 171 }); 172 } 173 174 }; 175 $.fn.mChange.defaults = { 176 auto : 1, 177 arrow : 1, 178 speed : 800, 179 time : 5000, 180 nav : null, 181 nave : "click", 182 navs : 0, 183 prev : null, 184 next : null, 185 cycle : 1, 186 mousestop : 0, 187 mousewheel : 0, 188 count : null, 189 index : null, 190 fnCome: null, 191 fnBack: null 192 } 193})(jQuery);
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.