1/* 2 * jquery.sldr 3 * 4 * A content slider featuring responsive slides, flexible slide widths, callbacks, 5 * and custom animation hooks. 6 * 7 * Version: 1.1 8 * Minimum requirements: Developed with jQuery 1.10.2, May work with older versions. 9 * 10 * The MIT License (MIT) 11 * 12 * Copyright (c) 2014 Devon Hirth 13 * 14 * Permission is hereby granted, free of charge, to any person obtaining a copy of 15 * this software and associated documentation files (the "Software"), to deal in 16 * the Software without restriction, including without limitation the rights to 17 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 18 * the Software, and to permit persons to whom the Software is furnished to do so, 19 * subject to the following conditions: 20 * 21 * The above copyright notice and this permission notice shall be included in all 22 * copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 26 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 27 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 28 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 * 31 */ 32 33( function( $ ) { 34 35var $win = $( window ); 36 37$.sldr = function( el , options ) { 38 39 var base = this; 40 base.$el = $( el ); 41 base.el = el; 42 base.$elwrp = $( el ).children(); 43 base.$el.data( "sldr" , base ); 44 45 /** 46 * Plugin Vars 47 */ 48 base.callback = new Array(); 49 base.sldrSlides = new Array(); 50 base.sldrLoadSlides = new Array(); 51 base.$sliderTimers = new Array(); 52 base.$resizeTimers = new Array(); 53 base.$delayTimers = new Array(); 54 55 base.wrp = base.$el.children(); 56 base.elmnts = base.wrp.children(); 57 base.elmntsHTML = base.wrp.html(); 58 59 base.benchcoordinate = {}; 60 base.prevcoordinate = {}; 61 base.cursorcoordinate = {}; 62 base.thiscoordinate = {}; 63 base.coordinatedifference = 0; 64 base.dragdifference = 0; 65 base.trackmouse = false; 66 base.pagescrollY = 0; 67 68 base.transformposition = 0; 69 70 /** 71 * Initializing function 72 * @return void 73 */ 74 base.init = function() { 75 76 base.config = $.extend( {} , $.sldr.defaultOptions , options ); 77 78 base.browser(); 79 80 var sldr = base.$el; 81 var wrp = base.$elwrp; 82 var elmnts = wrp.children(); 83 var elmntsHTML = wrp.html(); 84 var postLoad = false; 85 86 /** 87 * Build Slide Array 88 * @type {Number} 89 */ 90 if ( base.sldrSlides == '' ) { 91 92 base.callback = { 93 'sldr' : base.$el, 94 'prevFocalIndex' : '', 95 'prevSlideNum' : '', 96 'currentFocalIndex' : '', 97 'currentClass' : '', 98 'currentID' : '', 99 'currentFocalPoint' : '', 100 'currentSlideNum' : '', 101 'shiftWidth' : '', 102 'nextFocalIndex' : '', 103 'nextSlideNum' : '' 104 }; 105 106 for ( var i = 1; i < elmnts.length + 1; i++ ) { 107 108 var slide = elmnts.eq( i - 1 ); 109 var slideLoad = slide.find( '.sldr-load' ) 110 base.sldrSlides.push({ 111 'sld' : slide, 112 'slideNum' : i, 113 'id' : slide.attr( 'id' ), 114 'class_name' : slide.attr( 'class' ).split(' ')[0], 115 'html' : slide.html() 116 }); 117 118 if ( slideLoad.hasClass( 'sldr-load' ) ) { 119 postLoad = true; 120 base.sldrLoadSlides.push({ 121 'slideNum' : i, 122 'id' : slide.attr( 'id' ), 123 'class_name' : slide.attr( 'class' ).split(' ')[0], 124 'html' : slide.html() 125 }); 126 } 127 } 128 } 129 130 /** 131 * Do not finish initiating plugin if there is only one slide. 132 */ 133 if ( elmnts.length <= 1 ) { 134 elmnts.eq( 0 ).addClass( base.config.focalClass ); 135 base.sliderInit( { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 136 base.sliderLoaded( { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 137 } 138 139 /** 140 * Fill Gaps (if any) 141 */ 142 if ( elmnts.length > 1 ) base.fillGaps( elmntsHTML ); 143 144 /** 145 * sliderInit Callback 146 */ 147 base.sliderInit( { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 148 149 /** 150 * Center Slides 151 */ 152 base.focalChange( 1 ); 153 base.resizeElements(); 154 155 /** 156 * Activate Selectors 157 */ 158 if ( base.config.selectors != '' ) { 159 base.config.selectors.eq( 0 ).addClass( base.config.focalClass ); 160 base.config.selectors.click( function(e) { 161 var th = $( this ); 162 var change = base.focalChange( th.index() + 1 , 'selectors' ); 163 base.animate( change ); 164 th.siblings().removeClass( base.config.focalClass ); 165 th.addClass( base.config.focalClass ); 166 e.preventDefault(); 167 }); 168 169 if ( base.config.sldrAuto ) { 170 base.config.selectors.bind( 'mouseenter' , function() { 171 base.sliderPause(); 172 }); 173 base.config.selectors.bind( 'mouseleave' , function() { 174 base.sliderTimer(); 175 }); 176 } 177 } 178 179 if ( base.config.nextSlide != '' ) { 180 base.config.nextSlide.click( function(e) { 181 if ( base.config.selectors != '' ) { 182 base.config.selectors.removeClass( base.config.focalClass ); 183 base.config.selectors.eq( base.callback.nextSlideNum - 1 ).addClass( base.config.focalClass ); 184 } 185 var change = base.focalChange( base.callback.nextSlideNum , 'next' ); 186 base.animate( change ); 187 e.preventDefault(); 188 }); 189 190 if ( base.config.sldrAuto ) { 191 base.config.nextSlide.bind( 'mouseenter' , function() { 192 base.sliderPause(); 193 }); 194 base.config.nextSlide.bind( 'mouseleave' , function() { 195 base.sliderTimer(); 196 }); 197 } 198 } 199 200 if ( base.config.previousSlide != '' ) { 201 base.config.previousSlide.click( function(e) { 202 if ( base.config.selectors != '' ) { 203 base.config.selectors.removeClass( base.config.focalClass ); 204 base.config.selectors.eq( base.callback.prevSlideNum - 1 ).addClass( base.config.focalClass ); 205 } 206 var change = base.focalChange( base.callback.prevSlideNum , 'prev' ); 207 base.animate( change ); 208 e.preventDefault(); 209 }); 210 211 if ( base.config.sldrAuto ) { 212 base.config.previousSlide.bind( 'mouseenter' , function() { 213 base.sliderPause(); 214 }); 215 base.config.previousSlide.bind( 'mouseleave' , function() { 216 base.sliderTimer(); 217 }); 218 } 219 } 220 221 if ( base.config.swipeDragDesktop || base.isMobile() ) { 222 223 base.$elwrp.bind( 'mousemove touchmove' , base.coordinateevents ); 224 225 base.$elwrp.bind( 'mousedown touchstart' , function( event ) { 226 var xtf; 227 228 if ( base.pagescrollY !== window.pageYOffset ) return; 229 230 event.preventDefault(); 231 base.trackmouse = true; 232 base.$elwrp.removeClass( 'animate' ); 233 base.transformposition = parseInt( base.getTranslatePosition( base.$elwrp.css( base.config.cssPrefix + 'transform' ) , 4 ) ); 234 if ( event.originalEvent.touches !== undefined ) { 235 base.benchcoordinate = { x : event.originalEvent.touches[0].pageX , y : event.originalEvent.touches[0].pageY , trans : base.transformposition }; 236 } else { 237 base.benchcoordinate = { x : event.clientX , y : event.clientY , trans : base.transformposition }; 238 } 239 base.prevcoordinate = base.benchcoordinate; 240 base.coordinateevents( event ); 241 }); 242 243 base.$elwrp.bind( 'mouseup touchend' , function( event ) { 244 var change; 245 246 if ( base.pagescrollY !== window.pageYOffset ) return; 247 248 event.preventDefault(); 249 base.trackmouse = false;
250 base.coordinatedifference = base.benchcoordinate.x - base.cursorcoordinate.x; 251 if ( base.coordinatedifference > 0 && base.coordinatedifference > base.$el.width() / base.config.swipeDragCoefficient ) { 252 change = base.focalChange( base.callback.nextSlideNum , 'next' ); 253 } else if ( base.coordinatedifference < 0 && -(base.coordinatedifference) > base.$el.width() / base.config.swipeDragCoefficient ) { 254 change = base.focalChange( base.callback.prevSlideNum , 'prev' ); 255 } else if ( base.config.swipeDragSnapBack ) { 256 base.$elwrp.addClass( 'animate' ); 257 base.$elwrp.css( base.config.cssPrefix + 'transform' , 'translate3d( ' + base.benchcoordinate.trans + 'px , 0 , 0 )' ); 258 } 259 base.animate( change ); 260 }); 261 262 } 263 264 if ( elmnts.length > 1 ) base.sliderTimer(); 265 266 /** 267 * Activate Resize 268 */ 269 $win.bind( 'resize' , function( e ) { 270 base.$resizeTimers[base.config.sldrNumber] = setTimeout( function() { 271 base.sliderPause(); 272 base.resizeElements(); 273 if ( elmnts.length > 1 ) base.sliderTimer(); 274 } , base.config.resizeDelay ); 275 }); 276 277 base.resizeElements(); 278 279 var change = { 280 'currentFocalIndex' : base.$el.find( '.' + base.config.focalClass ).index(), 281 'currentFocalPoint' : base.findFocalPoint(), 282 'shiftWidth' : 0 283 }; 284 base.positionFocus( change ); 285 286 base.sliderLoaded( { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 287 288 }; 289 290 /** 291 * change the focus of the slider and animate it 292 * @return void 293 */ 294 base.animate = function( change ) { 295 try { 296 if ( base.config.animate != '' && base.config.animate ) { 297 base.config.animate( base.$el , change , { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 298 } else { 299 if ( !change ) return; 300 var curr, tf, easing; 301 base.$delayTimers[base.config.sliderNumber] = setTimeout( function() { 302 base.$elwrp.addClass( 'animate' ); 303 if ( base.config.animateJquery || base.config.isBrowser == 'MSIE 6' || base.config.isBrowser == 'MSIE 7' || base.config.isBrowser == 'MSIE 8' || base.config.isBrowser == 'MSIE 9' || base.config.animate != false ) { 304 easing = ( $.easing && $.easing.easeInOutQuint ) ? base.config.animateJqueryEasing : 'linear'; 305 base.$elwrp.animate({ 306 marginLeft : base.config.offset - change.currentFocalPoint 307 } , base.config.animateJqueryTiming , easing ); 308 } else { 309 curr = base.config.offset - change.currentFocalPoint; 310 base.$elwrp.css( base.config.cssPrefix + 'transform' , 'translate3d( ' + curr + 'px , 0 , 0 )' ); 311 } 312 base.slideComplete( { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 313 } , 100 ); // Tiny delay needed for slider to adjust 314 } 315 } catch ( err ) { console.log( err.message ); } 316 }; 317 318 /** 319 * change the focus of the slider without animating it 320 * @param {jquery selector object} the slide object 321 * @param {number} change [description] 322 * @return void 323 */ 324 base.positionFocus = function( change ) { 325 try { 326 if ( !change ) return; 327 var focus; 328 base.$elwrp.removeClass( 'animate' ); 329 if ( base.config.animateJquery || base.config.isBrowser == 'MSIE 6' || base.config.isBrowser == 'MSIE 7' || base.config.isBrowser == 'MSIE 8' || base.config.isBrowser == 'MSIE 9' || base.config.animate != false ) { 330 base.$elwrp.css( 'margin-left' , base.config.offset - change.currentFocalPoint ); 331 } else { 332 if ( base.$elwrp.css( base.config.cssPrefix + 'transform' ) == 'none' ) base.$elwrp.css( base.config.cssPrefix + 'transform' , 'translate3d( 0 , 0 , 0 )' ); 333 focus = base.config.offset - change.currentFocalPoint; 334 base.$elwrp.css( base.config.cssPrefix + 'transform' , 'translate3d(' + focus + 'px , 0 , 0 )' ); 335 } 336 base.$delayTimers[base.config.sliderNumber] = setTimeout( function() { 337 base.$elwrp.addClass( 'animate' ); 338 base.slideComplete( { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 339 } , base.config.resizeDelay + 1 ); // Tiny delay needed for slider to adjust 340 341 } catch ( err ) { console.log( err.message ); } 342 }; 343 344 345 /********************************************************** 346 ****************** Positioning Functions ***************** 347 **********************************************************/ 348 349 /** 350 * Function to move focal point of the slider to previous or next slide. 351 * @param {string} method ['prev' or 'previous' moves the slider backwards. Defaults to next.] 352 * @return {object} The callback of the slider including slide number, slide index, previous, next slides etc. 353 */ 354 base.focalChange = function( focalChangeNum , method ) { 355 try { 356 method = typeof method !== 'undefined' ? method : 'default'; 357 var elmnts = base.$elwrp.children(); 358 var focalElmnt = base.$elwrp.find( '> .' + base.config.focalClass ); 359 var focalIndex = focalElmnt.index(); 360 var nextFocalIndex, nextFocalPoint, prevFocalIndex, focalPoint, shiftSlide, shiftSlideClone, shiftSlideWidth, direction, slideClass; 361 362 base.slideStart( { 'slides' : base.sldrSlides , 'callback' : base.callback , 'config' : base.config } ); 363 364 /** 365 * Find the nearest index of the focal point we want. 366 * @type {integer} 367 */ 368 if ( !base.sldrSlides[ focalChangeNum - 1 ] ) return; 369 slideClass = base.sldrSlides[ focalChangeNum - 1 ].class_name; 370 slideClass = slideClass.split(' '); 371 slideClass = slideClass[ 0 ]; 372 373 if ( focalElmnt.hasClass( slideClass ) ) return false;
374 375 closerBehind = elmnts.eq( focalIndex ).prevAll( '.' + slideClass + ':first' ).index(); 376 closerInFront = elmnts.eq( focalIndex ).nextAll( '.' + slideClass + ':first' ).index(); 377 378 if ( 379 closerInFront != -1 380 && closerInFront - focalIndex < focalIndex - closerBehind 381 || closerInFront - focalIndex == focalIndex - closerBehind 382 && method != 'prev' 383 ) { 384 nextFocalIndex = closerInFront; 385 } else if ( closerBehind != -1 ) { 386 nextFocalIndex = closerBehind; 387 } else { 388 nextFocalIndex = $( '.' + slideClass ).index(); 389 } 390 391 nextFocalPoint = elmnts.eq( nextFocalIndex ); 392 elmnts.removeClass( base.config.focalClass ); 393 nextFocalPoint.addClass( base.config.focalClass ); 394 395 /** 396 * Find the range of elments in the slider to cut and paste, making it symmetrical. 397 * @type {Object} 398 */ 399 direction = ( nextFocalIndex > parseInt( ( elmnts.length - 1 ) / 2 ) ) ? 'next' : 'prev'; 400 sliceStart = ( direction == 'prev' ) ? parseInt( ( ( elmnts.length - nextFocalIndex + 1 ) / 2 ) + nextFocalIndex + 2 ) : 0; 401 sliceEnd = ( direction == 'prev' ) ? elmnts.length : parseInt( nextFocalIndex * 0.5 ) - 1; 402 elmntsSlice = elmnts.slice( sliceStart , sliceEnd ); 403 elmntsClone = elmntsSlice.clone(); 404 405 /** 406 * Find the width difference to shift the slider before animating. 407 * @type {Number} 408 */ 409 shiftSlideWidth = 0; 410 for ( var i = 0; i < elmntsSlice.length; i++ ) { 411 shiftSlideWidth = shiftSlideWidth + $( elmntsSlice[ i ] ).width(); 412 } 413 shiftSlideWidth = ( direction == 'prev' ) ? -( shiftSlideWidth ) : shiftSlideWidth; 414 415 /** 416 * Shift the slider so the transition will appear seamless 417 */ 418 base.$elwrp.removeClass( 'animate' ); 419 if ( base.config.animateJquery || base.config.isBrowser == 'MSIE 6' || base.config.isBrowser == 'MSIE 7' || base.config.isBrowser == 'MSIE 8' || base.config.isBrowser == 'MSIE 9' || base.config.animate != false ) { 420 // GET MARGIN PROPERTY 421 curr = parseFloat( base.$elwrp.css( 'margin-left' ) ); 422 base.$elwrp.css( 'margin-left' , curr + shiftSlideWidth + 'px' ); 423 } else { 424 // GET TRANSFORM PROPERTY 425 if ( base.$elwrp.css( base.config.cssPrefix + 'transform' ) == 'none' ) base.$elwrp.css( base.config.cssPrefix + 'transform' , 'translate3d( 0 , 0 , 0 )' ); 426 matrixIndex = ( base.config.isIE ) ? 12 : 4; 427 base.transformposition = parseInt( base.getTranslatePosition( base.$elwrp.css( base.config.cssPrefix + 'transform' ) , matrixIndex ) ); 428 curr = base.transformposition + shiftSlideWidth; 429 base.$elwrp.css( base.config.cssPrefix + 'transform' , 'translate3d( ' + curr + 'px , 0 , 0 )' ); 430 } 431 432 /** 433 * Remove/Append/Prepend Slides back to slider. 434 */ 435 elmnts.slice( sliceStart , sliceEnd ).remove(); 436 if ( direction == 'prev' || direction == 'previous' ) { 437 base.$elwrp.prepend( elmntsClone ); 438 } else { 439 base.$elwrp.append( elmntsClone ); 440 } 441 442 /** 443 * Update $.sldr.callback. 444 * @type {Object} 445 */ 446 focalPoint = base.findFocalPoint(); 447 currentFocalIndex = base.$elwrp.find( '> .' + base.config.focalClass ).index(); 448 nextFocalIndex = ( currentFocalIndex + 1 == elmnts.length ) ? 0 : currentFocalIndex + 1; 449 prevFocalIndex = ( currentFocalIndex - 1 == -1 ) ? elmnts.length - 1 : currentFocalIndex - 1; 450 nextSlideNum = ( focalChangeNum + 1 == base.sldrSlides.length + 1 ) ? 1 : focalChangeNum + 1; 451 prevSlideNum = ( focalChangeNum - 1 == 0 ) ? base.sldrSlides.length : focalChangeNum - 1; 452 453 base.callback.sldr = base.$el; 454 base.callback.prevFocalIndex = prevFocalIndex; 455 base.callback.prevSlideNum = prevSlideNum; 456 base.callback.currentFocalIndex = currentFocalIndex; 457 base.callback.currentClass = nextFocalPoint.attr( 'class' ); 458 base.callback.currentID = nextFocalPoint.attr( 'id' ); 459 base.callback.currentFocalPoint = focalPoint; 460 base.callback.currentSlideNum = focalChangeNum; 461 base.callback.shiftWidth = shiftSlideWidth; 462 base.callback.nextFocalIndex = nextFocalIndex; 463 base.callback.nextSlideNum = nextSlideNum; 464 465 if ( base.config.toggle.length > 0 ) { 466 base.config.toggle.removeClass( base.config.focalClass ); 467 base.config.toggle.eq( focalChangeNum - 1 ).addClass( base.config.focalClass ); 468 } 469 470 return base.callback; 471 472 } catch ( err ) { console.log( err.message ); } 473 }; 474 475 /** 476 * Recursive function to make slider fill the gaps of the stage 477 * @param {object} elmntsHTML The markup to fill gaps with 478 * @param {object} wrp the container to place the markup in 479 * @return {boolean} returns true when finished 480 */ 481 base.fillGaps = function( elmntsHTML ) { 482 try { 483 var sldrw = base.$el.width(); 484 var wrp = base.$elwrp; 485 var elmnt = wrp.children(); 486 var elmntw = base.findWidth( elmnt ); 487 var lastClass = base.sldrSlides[base.sldrSlides.length - 1].class_name; 488 if ( elmntw < sldrw * 5 ) { 489 wrp.find( '.' + lastClass ).after( elmntsHTML ); 490 base.fillGaps( elmntsHTML ); 491 } else { 492 wrp.css( 'width' , elmntw ); 493 return true; 494 } 495 } catch ( err ) { console.log( err.message ); } 496 }; 497 498 /** 499 * Find the width of a set of elements 500 * @return {float} the width of the entire set 501 */ 502 base.findWidth = function( elmnt ) { 503 try { 504 var wdth = 0; 505 elmnt.each( function( i ) { 506 wdth = wdth + $( elmnt[i] ).width(); 507 }); 508 return wdth; 509 } catch ( err ) { console.log( err.message ); } 510 }; 511 512 /**
513 * Find the focal point of the slider, by class name 'focalPoint' 514 * @return {integer} the x position of the focal point 515 */ 516 base.findFocalPoint = function() { 517 try { 518 var elmnts = base.$elwrp.children(); 519 var focalSlide = base.$el.find( '.'+base.config.focalClass ); 520 var focalSlideWidth = focalSlide.width() / 2; 521 var focalIndex = focalSlide.index(); 522 var focalPoint = focalSlideWidth; 523 for ( var i = 0; i < focalIndex; i++ ) { 524 focalPoint = focalPoint + elmnts.eq(i).width(); 525 } 526 return focalPoint; 527 } catch ( err ) { console.log( err.message ); } 528 }; 529 530 /** 531 * Functions to perform when the browser is resized 532 * @return void 533 */ 534 base.resizeElements = function() { 535 try { 536 var elmnts = base.$elwrp.children(); 537 var elmwdth = base.findWidth( elmnts ); 538 var wrpwdth = base.$elwrp.width(); 539 var samewdth = ( base.$el.css( 'width' ) == elmnts.css( 'width' ) ) ? true : false; 540 541 if ( base.config.sldrWidth == 'responsive' ) { 542 elmnts.css( 'width' , base.$el.width() ); 543 if ( elmwdth > wrpwdth ) base.$elwrp.css( 'width' , elmwdth ); 544 } else if ( base.config.sldrWidth != '' ) { 545 return; 546 } 547 548 if ( base.config.sldrCols !== 1 ) { 549 elmnts.css( 'width' , base.$el.width() / base.config.sldrCols ); 550 } 551 552 if ( samewdth ) return; 553 554 base.config.offset = base.$el.width() / 2; // UPDATE THE OFFSET, need to change this to work on the config offset 555 556 var change = { 557 'currentFocalIndex' : base.$el.find( '.' + base.config.focalClass ).index(), 558 'currentFocalPoint' : base.findFocalPoint(), 559 'shiftWidth' : 0 560 }; 561 base.positionFocus( change ); 562 } catch ( err ) { console.log( err.message ); } 563 }; 564 565 /** 566 * Updates the previous coordinates if there is movement on click drag or touch drag 567 * @return {[type]} [description] 568 */ 569 base.coordinateevents = function( event ) { 570 var curr; 571 base.pagescrollY = window.pageYOffset; 572 if ( !base.trackmouse ) return; 573 event = event || window.event; 574 if ( event.originalEvent.touches !== undefined ) { 575 base.cursorcoordinate = { x : event.originalEvent.touches[0].pageX , y : event.originalEvent.touches[0].pageY }; 576 } else { 577 base.cursorcoordinate = { x : event.clientX , y : event.clientY }; 578 } 579 base.thiscoordinate = base.cursorcoordinate; 580 if ( base.prevcoordinate != base.thiscoordinate ) { 581 matrixIndex = ( base.config.isIE ) ? 12 : 4; 582 base.transformposition = parseInt( base.getTranslatePosition( base.$elwrp.css( base.config.cssPrefix + 'transform' ) , matrixIndex ) ); 583 curr = base.transformposition - ( base.prevcoordinate.x - base.thiscoordinate.x ); 584 base.$elwrp.css( base.config.cssPrefix + 'transform' , 'translate3d( ' + curr + 'px , 0 , 0 )' ); 585 base.prevcoordinate = base.thiscoordinate; 586 } 587 }; 588 589 /** 590 * When the sldr is initiated, before the DOM is manipulated 591 * @param {object} args [the slides, callback, and config of the slider] 592 * @return void 593 */ 594 base.sliderInit = function( args ) { 595 if( base.config.sldrInit != '' ) { 596 base.config.sldrInit( args ); 597 } 598 }; 599 600 /** 601 * When individual slides are loaded 602 * @param {object} args [the slides, callback, and config of the slider] 603 * @return void 604 */ 605 base.slideLoaded = function( args ) { 606 if( base.config.sldLoaded != '' ) { 607 base.config.sldLoaded( args ); 608 } 609 }; 610 611 /** 612 * When the slider is loaded, after the DOM is manipulated 613 * @param {object} args [the slides, callback, and config of the slider] 614 * @return void 615 */ 616 base.sliderLoaded = function( args ) { 617 if( base.config.sldrLoaded != '' ) { 618 base.config.sldrLoaded( args ); 619 } 620 }; 621 622 /** 623 * Before the slides animate 624 * @param {object} args [the slides, callback, and config of the slider] 625 * @return void 626 */ 627 base.slideStart = function( args ) { 628 if( base.config.sldrStart != '' ) { 629 base.config.sldrStart( args ); 630 } 631 }; 632 633 /** 634 * When the slide has completed animating 635 * @param {object} args [the slides, callback, and config of the slider] 636 * @return void 637 */ 638 base.slideComplete = function( args ) { 639 if( base.config.sldrComplete != '' ) { 640 base.config.sldrComplete( args ); 641 } 642 }; 643 644 /** 645 * [sliderTimer description] 646 * @return void 647 */ 648 base.sliderTimer = function() { 649 if ( base.config.sldrAuto ) { 650 base.$sliderTimers[base.config.sldrNumber] = setTimeout( function() { 651 var change = base.focalChange( base.callback.nextSlideNum , 'next' ); 652 var animate = base.animate( change ); 653 base.sliderTimer( base.$el ); 654 if ( base.config.selectors != '' ) { 655 var selector = base.config.selectors.eq( base.callback.nextSlideNum - 2 ); 656 selector.siblings().removeClass( base.config.focalClass ); 657 selector.addClass( base.config.focalClass ); 658 } 659 660 } , base.config.sldrTime ) 661 } 662 }; 663 664 /** 665 * Pauses slider by clearing it's timer 666 * @return void 667 */ 668 base.sliderPause = function() { 669 if ( base.config.sldrAuto ) { 670 clearTimeout( base.$sliderTimers[base.config.sldrNumber] ); 671 } 672 }; 673 674 /** 675 * Check if number is even 676 * @param {number} num Number to check 677 * @return boolean 678 */ 679 base.evenNumber = function( num ) { 680 return ( num % 2 == 0 ) ? true : false;
681 }; 682 683 /** 684 * Disect and return the value of a desired property in 'matrix(0, 0, 0, 0, 0, 0)' string format 685 * @param {string} tf matrix string 686 * @param {number} matrixindex index of matrix desired 687 * @return {string} matrix value string 688 */ 689 base.getTranslatePosition = function( tf , matrixindex ) { 690 tf = tf.slice( 7 , -1 ); // remove 'matrix(' and ')' from string 691 tf = tf.split( ', ' ); // create array of matrix 692 return tf[ matrixindex ]; // return value of desired matrix 693 }; 694 695 /** 696 * Get Browser and Set URL Prefix 697 * @return null 698 */ 699 base.browser = function() { 700 if( navigator.userAgent.match('WebKit') != null ) { 701 base.config.isBrowser = 'Webkit'; 702 base.config.cssPrefix = '-webkit-'; 703 } else if( navigator.userAgent.match('Gecko') != null ) { 704 base.config.isBrowser = 'Gecko'; 705 } else if( navigator.userAgent.match('MSIE 6') != null ) { 706 base.config.isBrowser = 'MSIE 6'; 707 base.config.isIE = true; 708 } else if( navigator.userAgent.match('MSIE 7') != null ) { 709 base.config.isBrowser = 'MSIE 7'; 710 base.config.isIE = true; 711 } else if( navigator.userAgent.match('MSIE 8') != null ) { 712 base.config.isBrowser = 'MSIE 8'; 713 base.config.isIE = true; 714 } else if( navigator.userAgent.match('MSIE 9') != null ) { 715 base.config.isBrowser = 'MSIE 9'; 716 base.config.isIE = true; 717 base.config.cssPrefix = '-ms-'; 718 } else if( navigator.userAgent.match('MSIE 10') != null ) { 719 base.config.isBrowser = 'MSIE 10'; 720 base.config.isIE = true; 721 } 722 }; 723 724 /** 725 * [isMobile description] 726 * @return {Boolean} [description] 727 */ 728 base.isMobile = function() { 729 var check = false; 730 (function (a) { 731 if (/(android|ipad|playbook|silk|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; 732 })( navigator.userAgent || navigator.vendor || window.opera ); 733 return check; 734 }; 735 736 base.init(); 737 }; 738 739 /** 740 * [defaultOptions description] 741 * @type {Object} 742 */ 743 $.sldr.defaultOptions = { 744 focalClass : 'focalPoint', 745 offset : $( this ).width() / 2, 746 selectors : '', 747 toggle : '', 748 nextSlide : '', 749 hashChange : false, 750 previousSlide : '', 751 resizeDelay : 1, 752 sldrNumber : 0, 753 sldrStart : '', 754 sldrComplete : '', 755 sldrInit : '', 756 sldLoaded : '', 757 sldrLoaded : '', 758 sldrWidth : '', 759 sldrCols : 1, 760 animate : '', 761 animateJquery : false, 762 animateJqueryTiming : 750, 763 animateJqueryEasing : 'easeInOutQuint', 764 swipeDragDesktop : true, 765 swipeDragCoefficient : 3, 766 swipeDragSnapBack : true, 767 sldrAuto : false, 768 sldrTime : 8000, 769 isBrowser : navigator.userAgent, 770 isIE : false, 771 cssPrefix : '' 772 }; 773 774 /** 775 * [sldr description] 776 * @param {[type]} options [description] 777 * @return {[type]} [description] 778 */ 779 $.fn.sldr = function( options ) { 780 return this.each( function() { 781 ( new $.sldr( this , options ) ); 782 $.sldr.defaultOptions.sldrNumber++; 783 }); 784 }; 785 786})( 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.