1/*! 2 * @author: INFORMARC 3 * @created: 2013/08/08 4 * @modified: 2013/08/19 5 */ 6(function( $, window, document, undefined ) { 7 var namespace = 'slider'; 8 9 $[ namespace ] = function( elem, options ) { 10 this.settings = $.extend({ 11 imgCount: 3, 12 panelCount: 9, 13 duration: 300, 14 easing: 'swing', 15 autoPlay: true, 16 autoPlayTimer: 4000, 17 callback: function() {} 18 }, options ); 19 20 // vfLbV 21 this.$slideWrapper = $( elem ); 22 this.$keyvisual = this.$slideWrapper.parent(); 23 this.$ul = this.$slideWrapper.find( '#slideList' ); 24 this.$li = this.$ul.find( 'li' ); 25 this.$nav = this.$keyvisual.find( '#slideNav' ).find( 'img' ); 26 this.$checkElem = this.$keyvisual.find( '#check' ); 27 28 // óÔÛ¶ 29 this.slideQueue = []; 30 this.isAnimate = false; 31 this.autoPlayPause = true; 32 this.currentIndex = 1; 33 this.basePos = 0; 34 this.panelWidth = 0; 35 this.panelHeight = 0; 36 this.panelWidthHalf = 0; 37 this.slideWidth = 0; 38 }; 39 40 $[ namespace ].prototype = { 41 init: function() { 42 this.setSize(); 43 this.eventBind(); 44 45 // ©®Ä¶ªLøÈç 46 if ( this.settings.autoPlay ) { 47 this.setTimer(); 48 this.autoPlayPause = false; 49 } 50 51 this.settings.callback(); 52 }, 53 getPos: function() { 54 return parseInt( this.$ul.css( 'marginLeft' ) ); 55 }, 56 getFirst: function() { 57 return $( '> li:first-child', this.$ul ); 58 }, 59 getLast: function() { 60 return $( '> li:last-child', this.$ul ); 61 }, 62 // X|VuÎFTCYÝè 63 setSize: function() { 64 // ¡&³æ¾ 65 this.panelHeight = this.$checkElem.height(); 66 this.panelWidth = this.$checkElem.width(); 67 this.panelWidthHalf = this.panelWidth / 2; 68 this.slideWidth = this.panelWidth * this.settings.panelCount; 69 70 // ¡&³Ýè 71 this.$keyvisual.css( 'height', this.panelHeight + 27 ); 72 this.$slideWrapper.css({ 73 'width': this.slideWidth, 74 'height': this.panelHeight 75 }); 76 this.$ul.css({ 77 'marginLeft': '-' + ( this.panelWidth * this.settings.imgCount + this.panelWidthHalf ) + 'px', 78 'width': this.slideWidth, 79 'height': this.panelHeight 80 }); 81 this.$li.css( 'width', this.panelWidth ); 82 83 // îÊuðæ¾ 84 this.basePos = this.getPos(); 85 }, 86 // irQ[VCxgZbg 87 eventBind: function() { 88 var self = this, 89 resizeQueue; 90 91 // ºÌirQ[V 92 this.$nav.on( 'click.slide', function() { 93 var next = Number( this.getAttribute('data-show') ); 94 95 if ( self.currentIndex !== next && !self.isAnimate ) { 96 self.slide( next ); 97 98 // irQ[VNbNÅ©®Ä¶I¹ 99 self.settings.autoPlay = false; 100 } 101 }); 102 103 // X|VuÎFTCYÝè 104 $( window ).on( 'resize.slide', function() { 105 clearTimeout( resizeQueue ); 106 resizeQueue = setTimeout(function() { 107 self.setSize(); 108 }, 100 ); 109 }); 110 111 // ^b`foCXÌætbNØèÖ¦ 112 if ( 'ontouchstart' in window ) { 113 var touchStartX = 0, 114 pageX = 0, 115 flickReady = false, 116 flickPause = false, 117 nextIndex = 0; 118 119 this.$keyvisual.on({ 120 'touchstart.slide': function( e ) { 121 flickReady = false;
122 flickPause = false; 123 touchStartX = e.originalEvent.changedTouches[0].pageX; 124 }, 125 'touchmove.slide': function( e ) { 126 pageX = e.originalEvent.changedTouches[0].pageX; 127 128 e.preventDefault(); 129 e.stopPropagation(); 130 131 if ( flickReady && !flickPause ) { 132 // ÌæªÅålð´¦Ä¢½ç1Úð\¦ 133 if ( nextIndex > self.settings.imgCount ) { 134 nextIndex = 1; 135 136 // ÌæªÅálȺÈç3Úð\¦ 137 } else if ( nextIndex < 1 ) { 138 nextIndex = self.settings.imgCount; 139 } 140 141 self.slide( nextIndex ); 142 flickPause = true; 143 144 // tbNãÍ©®Ä¶I¹ 145 self.settings.autoPlay = false; 146 147 // ^b`JnÊu©ç10ÈãÚ®Èç 148 } else if ( Math.abs( pageX - touchStartX ) > 10 ) { 149 flickReady = true; 150 151 // ¶ûüÌtbN 152 if ( touchStartX - pageX < 0 ) { 153 nextIndex = self.currentIndex - 1; 154 155 // EûüÌtbN 156 } else { 157 nextIndex = self.currentIndex + 1; 158 } 159 } 160 } 161 }); 162 } 163 }, 164 // Ìæð»è 165 updateIndex: function() { 166 var self = this; 167 168 this.$li.removeClass( 'center' ); 169 this.$ul.find( 'li' ).eq(3).addClass( 'center' ); 170 }, 171 // ¶EXCh 172 slide: function( nextIndex ) { 173 var self = this, 174 op = {}; 175 176 // XCh®¹ÜÅtOI 177 self.isAnimate = true; 178 179 // XChü«»Ê 180 // ÌæÖ 181 if ( this.currentIndex < nextIndex ) { 182 // 1ÚÌæð\¦ 183 if ( this.currentIndex === 1 ) { 184 op.moveCount = 1; 185 186 // ª3ÚÈç¶ñè 187 if ( nextIndex === 3 ) { 188 op.margin = this.basePos + this.panelWidth; 189 op.prop = 'prependTo'; 190 191 // ª2ÚÈçEñè 192 } else if ( nextIndex === 2 ) { 193 op.margin = this.basePos - this.panelWidth; 194 op.prop = 'appendTo'; 195 } 196 197 // 2ÚÌæð\¦ 198 } else { 199 op.moveCount = nextIndex - this.currentIndex; 200 op.margin = self.basePos - ( self.panelWidth * op.moveCount ); 201 op.prop = 'appendTo'; 202 } 203 204 } else { 205 op.moveCount = 1; 206 207 // 3ÚÌæð\¦ 208 if ( this.currentIndex === 3 ) { 209 // ª1ÚÈçEñè 210 if ( nextIndex === 1 ) { 211 op.margin = this.basePos - this.panelWidth; 212 op.prop = 'appendTo'; 213 214 // ª2ÚÈç¶ñè 215 } else if ( nextIndex === 2 ) { 216 op.margin = this.basePos + this.panelWidth; 217 op.prop = 'prependTo'; 218 } 219 220 // 2ÚÌæð\¦ 221 } else if ( this.currentIndex === 2 ) { 222 // ª1ÚÈç¶ñè 223 if ( nextIndex === 1 ) { 224 op.margin = this.basePos + this.panelWidth;
225 op.prop = 'prependTo'; 226 227 // ª3ÚÈçEñè 228 } else if ( nextIndex === 3 ) { 229 op.margin = this.basePos - this.panelWidth; 230 op.prop = 'appendTo'; 231 } 232 } 233 } 234 235 // Aj[V 236 self.$ul.animate({ 237 marginLeft: op.margin 238 }, self.settings.duration, self.settings.easing, function() { 239 for ( var i = -1; ++i < op.moveCount; ) { 240 var elem;; 241 242 if ( op.prop === 'appendTo' ) { 243 elem = self.getFirst(); 244 } else { 245 elem = self.getLast(); 246 } 247 248 elem[ op.prop ]( self.$ul ); 249 } 250 251 self.$ul.css({ 252 'marginLeft': '-' + ( self.panelWidth * self.settings.imgCount + self.panelWidthHalf ) + 'px', 253 'width': self.slideWidth 254 }); 255 256 // vpeBXV 257 self.currentIndex = nextIndex; 258 self.isAnimate = false; 259 260 // Jg\¦XV 261 self.$nav.each(function( i ) { 262 if ( i + 1 === nextIndex ) { 263 this.src = this.src.replace( '_off.png', '_on.png' ); 264 } else { 265 this.src = this.src.replace( '_on.png', '_off.png' ); 266 } 267 }); 268 269 // Z^[XV 270 self.updateIndex(); 271 }); 272 }, 273 // ©®Ä¶ 274 setTimer: function() { 275 var self = this, 276 nextIndex = 1; 277 278 // }EXI[o[Í©®Ä¶â~ 279 this.$slideWrapper.on({ 280 'mouseover.autoPlayFlag': function() { 281 self.autoPlayPause = true; 282 }, 283 'mouseout.autoPlayFlag': function() { 284 self.autoPlayPause = false; 285 } 286 }); 287 288 (function autoPlay() { 289 // ©®Ä¶I¹ 290 if ( !self.settings.autoPlay || nextIndex > self.settings.imgCount ) { 291 return; 292 } 293 294 // tOªIt̾¯©®Ä¶ 295 if ( !self.autoPlayPause ) { 296 nextIndex++; 297 298 if ( nextIndex <= self.settings.imgCount ) { 299 self.slide( nextIndex ); 300 } 301 } 302 303 // ³¼ÖÄA 304 setTimeout( autoPlay, self.settings.autoPlayTimer ); 305 })(); 306 } 307 }; 308 309 $.fn[ namespace ] = function( options ) { 310 return this.each(function() { 311 var o = new $[ namespace ]( this, options ); 312 o.init(); 313 }); 314 }; 315})( jQuery, this, this.document );
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.