1/*! LayerSlider 5.1.4 2* layerslider.webshopworks.com 3* Copyright 2015 WebshopWorks */ 4 5function lsShowNotice(lsobj,issue,ver){ 6 7 var el; 8 9 if( typeof lsobj == 'string' ){ 10 el = jQuery('#'+lsobj); 11 }else if( typeof lsobj == 'object' ){ 12 el = lsobj; 13 } 14 15 var errorTitle, errorText; 16 17 switch(issue){ 18 case 'jquery': 19 errorTitle = 'multiple jQuery issue'; 20 errorText = 'It looks like that another module or your theme loads an extra copy of the jQuery library causing problems for LayerSlider to show your sliders.</strong>'; 21 break; 22 case 'oldjquery': 23 errorTitle = 'old jQuery issue'; 24 errorText = 'It looks like you are using an old version ('+ver+') of the jQuery library. LayerSlider requires at least version 1.7.0 or newer. Please update jQuery to 1.10.x or higher.</a>'; 25 break; 26 } 27 28 el.addClass('ls-error'); 29 el.append('<p class="ls-exclam">!</p>'); 30 el.append('<p class="ls-error-title">LayerSlider: '+errorTitle+'</p>'); 31 el.append('<p class="ls-error-text">'+errorText+'</p>'); 32} 33 34(function($) { 35 window.lsjq = $; 36 $.fn.layerSlider = function( options ){ 37 38 // IMPROVEMENT v4.1.0 Checking jQuery version 39 // IMPROVEMENT v4.1.3 Changed required version from 1.7.2 to 1.7.0 40 41 var reqVer = '1.7.0'; 42 var curVer = $.fn.jquery; 43 var el = $(this); 44 45 var checkVersions = function(v1,v2){ 46 47 var v1parts = v1.split('.'); 48 var v2parts = v2.split('.'); 49 50 for (var i = 0; i < v1parts.length; ++i) { 51 52 if (v2parts.length == i) { 53 return false; 54 } 55 56 if(parseInt(v1parts[i]) == parseInt(v2parts[i])){ 57 continue; 58 }else if (parseInt(v1parts[i]) > parseInt(v2parts[i])){ 59 return false; 60 }else{ 61 return true; 62 } 63 } 64 65 if (v1parts.length != v2parts.length) { 66 return true; 67 } 68 69 return true; 70 }; 71 72 if( !checkVersions('1.8.0',curVer) ){ 73 el.addClass('ls-norotate'); 74 } 75 76 // Initializing if jQuery version is greater than 1.7.0 77 78 if( !checkVersions(reqVer,curVer) ){ 79 lsShowNotice( el, 'oldjquery', curVer ); 80 }else{ 81 82 if( (typeof(options)).match('object|undefined') ){ 83 return this.each(function(i){ 84 new layerSlider(this, options); 85 }); 86 }else{ 87 if( options == 'data' ){ 88 var lsData = $(this).data('LayerSlider').g; 89 if( lsData ){ 90 return lsData; 91 } 92 }else{ 93 return this.each(function(i){ 94 95 // Control functions: prev, next, start, stop & change 96 97 var lsData = $(this).data('LayerSlider'); 98 if( lsData ){ 99 if( !lsData.g.isAnimating && !lsData.g.isLoading ){ 100 if( typeof options == 'number' ){ 101 if( options > 0 && options < lsData.g.layersNum + 1 && options != lsData.g.curLayerIndex ){ 102 lsData.change(options); 103 } 104 }else{ 105 switch(options){ 106 case 'prev': 107 lsData.o.cbPrev(lsData.g); 108 lsData.prev('clicked'); 109 break; 110 case 'next': 111 lsData.o.cbNext(lsData.g); 112 lsData.next('clicked'); 113 break; 114 case 'start': 115 if( !lsData.g.autoSlideshow ){ 116 lsData.o.cbStart(lsData.g); 117 lsData.g.originalAutoSlideshow = true; 118 lsData.start(); 119 } 120 break; 121 } 122 } 123 } 124 if( options == 'debug' ){ 125 lsData.d.show(); 126 } 127 if( ( lsData.g.autoSlideshow || ( !lsData.g.autoSlideshow && lsData.g.originalAutoSlideshow ) ) && options == 'stop' ){ 128 lsData.o.cbStop(lsData.g); 129 lsData.g.originalAutoSlideshow = false; 130 lsData.g.curLayer.find('iframe[src*="www.youtu"], iframe[src*="player.vimeo"]').each(function(){ 131 132 // Clearing videoTimeouts 133 134 clearTimeout( $(this).data( 'videoTimer') ); 135 }); 136 137 lsData.stop(); 138 } 139 if( options == 'forceStop'){ 140 lsData.forcestop(); 141 } 142 } 143 }); 144 } 145 } 146 } 147 }; 148 149 // LayerSlider methods 150 151 var layerSlider = function(el, options) { 152 153 var ls = this; 154 ls.$el = $(el).addClass('ls-container'); 155 ls.$el.data('LayerSlider', ls); 156 157 ls.load = function(){ 158 159 // Setting options (user settings) and global (not modificable) parameters 160 161 ls.o = $.extend({},layerSlider.options, options); 162 ls.g = $.extend({},layerSlider.global); 163 ls.lt = $.extend({},layerSlider.layerTransitions ); 164 ls.st = $.extend({},layerSlider.slideTransitions ); 165 166 ls.g.enableCSS3 = $(el).hasClass('ls-norotate') ? false : true; 167 168 if( ls.g.ie78 ){ 169 ls.o.lazyLoad = false;
170 } 171 172 // WP parameters 173 174 if( ls.o.autoPauseSlideshow === 'enabled' ){ 175 ls.o.autoPauseSlideshow = true; 176 } 177 if( ls.o.autoPauseSlideshow === 'disabled' ){ 178 ls.o.autoPauseSlideshow = false; 179 } 180 181 // If layerslider.transitions.js is loaded... 182 183 if( typeof layerSliderTransitions !== 'undefined' ){ 184 ls.t = $.extend({},layerSliderTransitions); 185 } 186 187 // If custom transitions are loaded... 188 189 if( typeof layerSliderCustomTransitions !== 'undefined' ){ 190 ls.ct = $.extend({},layerSliderCustomTransitions); 191 } 192 193 // NEW IMPROVEMENT v3.6 forbid to call the init code more than once on the same element 194 195 if( !ls.g.initialized ){ 196 197 ls.g.initialized = true; 198 199 // Added debug mode v3.5 200 201 ls.debug(); 202 203 if( $('html').find('meta[content*="WordPress"]').length ){ 204 ls.g.wpVersion = $('html').find('meta[content*="WordPress"]').attr('content').split('WordPress')[1]; 205 } 206 207 if( $('html').find('script[src*="layerslider"]').length ){ 208 if( $('html').find('script[src*="layerslider"]').attr('src').indexOf('?') != -1 ){ 209 ls.g.lswpVersion = $('html').find('script[src*="layerslider"]').attr('src').split('?')[1].split('=')[1]; 210 } 211 } 212 213 // Debug mode controls 214 215 ls.d.aT('LayerSlider controls'); 216 ls.d.aU('<a href="#">prev</a> | <a href="#">next</a> | <a href="#">start</a> | <a href="#">stop</a> | <a href="#">force stop</a>'); 217 ls.d.history.find('a').each(function(){ 218 $(this).click(function(e){ 219 e.preventDefault(); 220 $(el).layerSlider($(this).text()); 221 }); 222 }); 223 224 ls.d.aT('LayerSlider version information'); 225 ls.d.aU('JS version: <strong>' + ls.g.version + '</strong>'); 226 if(ls.g.lswpVersion){ 227 ls.d.aL('WP version: <strong>' + ls.g.lswpVersion + '</strong>'); 228 } 229 if(ls.g.wpVersion){ 230 ls.d.aL('WordPress version: <strong>' + ls.g.wpVersion + '</strong>'); 231 } 232 233 ls.d.aL('jQuery version: <strong>' + $().jquery + '</strong>'); 234 235 if( $(el).attr('id') ){ 236 237 ls.d.aT('LayerSlider container'); 238 ls.d.aU('#'+$(el).attr('id')); 239 } 240 241 // NEW LOAD METHOD v3.5 242 // FIXED v4.0 If the selected skin is already loaded, calling the ls.init() function immediately 243 244 if( !ls.o.skin || ls.o.skin == '' || !ls.o.skinsPath || ls.o.skinsPath == '' ){ 245 246 ls.d.aT('Loading without skin. Possibilities: mistyped skin and / or skinsPath.'); 247 248 ls.init(); 249 }else{ 250 251 ls.d.aT('Trying to load with skin: '+ls.o.skin, true); 252 253 // Applying skin 254 255 $(el).addClass('ls-'+ls.o.skin); 256 var skinStyle = ls.o.skinsPath+ls.o.skin+'/skin.css'; 257 258 cssContainer = $('head'); 259 260 if( !$('head').length ){ 261 cssContainer = $('body'); 262 } 263 264 if( $('link[href="'+skinStyle+'"]').length ){ 265 266 ls.d.aU('Skin "'+ls.o.skin+'" is already loaded.'); 267 268 curSkin = $('link[href="'+skinStyle+'"]'); 269 270 if( !ls.g.loaded ){ 271 272 ls.g.loaded = true; 273 274 // IMPROVEMENT v4.5.0 Added delay because of caching bugs 275 276 ls.g.t1 = setTimeout(function(){ 277 ls.init(); 278 },150); 279 } 280 281 }else{ 282 var curSkin = $('<link rel="stylesheet" href="'+skinStyle+'" type="text/css" />').appendTo( cssContainer ); 283 } 284 285 // curSkin.load(); function for most of the browsers. 286 287 curSkin.load(function(){ 288 289 if( !ls.g.loaded ){ 290 291 ls.d.aU('curSkin.load(); fired'); 292 293 ls.g.loaded = true; 294 295 // IMPROVEMENT v4.5.0 Added delay because of caching bugs 296 297 ls.g.t2 = setTimeout(function(){ 298 ls.init(); 299 },150); 300 } 301 }); 302 303 // $(window).load(); function for older webkit ( < v536 ). 304 305 $(window).load(function(){ 306 307 if( !ls.g.loaded ){ 308 309 ls.d.aU('$(window).load(); fired'); 310 311 ls.g.loaded = true; 312 313 // IMPROVEMENT v4.5.0 Added delay because of caching bugs 314 315 ls.g.t3 = setTimeout(function(){ 316 ls.init(); 317 },150); 318 } 319 }); 320 321 // Fallback: if $(window).load();Â not fired in 2 secs after $(document).ready(), 322 // curSkin.load(); not fired at all or the name of the skin and / or the skinsPath 323 // mistyped, we must call the init function manually. 324 325 ls.g.t4 = setTimeout( function(){ 326 327 if( !ls.g.loaded ){ 328 329 ls.d.aT('Fallback mode: Neither curSkin.load(); or $(window).load(); were fired'); 330 331 ls.g.loaded = true; 332 ls.init(); 333 } 334 }, 1000); 335 } 336 } 337 }; 338 339 ls.init = function(){ 340 341 // IMPROVEMENT v4.0.1 Trying to add special ID to <body> or <html> (required to overwrite WordPresss global styles) 342 343 if( !$('html').attr('id') ){ 344 $('html').attr('id','ls-global'); 345 }else if( !$('body').attr('id') ){ 346 $('body').attr('id','ls-global'); 347 } 348 349 // NEW FEATURE v1.7 making the slider responsive 350 351 ls.g.sliderWidth = function(){ 352 return $(el).width(); 353 } 354 355 ls.g.sliderHeight = function(){ 356 return $(el).height(); 357 } 358 359 // Compatibility mode v5.0.0 360 // .ls-layer -> .ls-slide 361 // .ls-s -> .ls-l 362 363 $(el).find('.ls-layer').removeClass('ls-layer').addClass('ls-slide'); 364 $(el).find('.ls-slide > *[class*="ls-s"]').each(function(){ 365 var oldDistanceNum = $(this).attr('class').split('ls-s')[1].split(' ')[0]; 366 $(this).removeClass('ls-s'+oldDistanceNum).addClass('ls-l'+oldDistanceNum); 367 }); 368 369 370 if( ls.o.firstLayer ){ 371 ls.o.firstSlide = ls.o.firstLayer; 372 } 373 if( ls.o.animateFirstLayer === false ){ 374 ls.o.animateFirstSlide = false;
375 } 376 377 // REPLACED FEATURE v2.0 If there is only ONE layer, instead of duplicating it, turning off slideshow and loops, hiding all controls, etc. 378 379 if( $(el).find('.ls-slide').length == 1 ){ 380 ls.o.autoStart = false; 381 ls.o.navPrevNext = false; 382 ls.o.navStartStop = false; 383 ls.o.navButtons = false; 384 ls.o.loops = 0; 385 ls.o.forceLoopNum = false; 386 ls.o.autoPauseSlideshow = true; 387 ls.o.firstSlide = 1; 388 ls.o.thumbnailNavigation = 'disabled'; 389 } 390 391 // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing 392 // NEW FEATURE v3.5 responsiveUnder 393 394 if( ls.o.width ){ 395 ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = '' + ls.o.width; 396 }else{ 397 ls.g.sliderOriginalWidthRU = ls.g.sliderOriginalWidth = $(el)[0].style.width; 398 } 399 400 if( ls.o.height ){ 401 ls.g.sliderOriginalHeight = '' + ls.o.height; 402 }else{ 403 ls.g.sliderOriginalHeight = $(el)[0].style.height; 404 } 405 406 if( ls.g.sliderOriginalWidth.indexOf('%') == -1 && ls.g.sliderOriginalWidth.indexOf('px') == -1 ){ 407 ls.g.sliderOriginalWidth += 'px'; 408 } 409 410 if( ls.g.sliderOriginalHeight.indexOf('%') == -1 && ls.g.sliderOriginalHeight.indexOf('px') == -1 ){ 411 ls.g.sliderOriginalHeight += 'px'; 412 } 413 414 if( ls.o.responsive && ls.g.sliderOriginalWidth.indexOf('px') != -1 && ls.g.sliderOriginalHeight.indexOf('px') != -1 ){ 415 ls.g.responsiveMode = true; 416 }else{ 417 ls.g.responsiveMode = false; 418 } 419 420 // IMPROVEMENT v3.0 preventing WordPress to wrap your sublayers in <code> or <p> elements 421 422 $(el).find('*[class*="ls-l"], *[class*="ls-bg"]').each(function(){ 423 if( !$(this).parent().hasClass('ls-slide') ){ 424 $(this).insertBefore( $(this).parent() ); 425 } 426 }); 427 428 $(el).find('.ls-slide').each(function(){ 429 $(this).children(':not([class*="ls-"])').each(function(){ 430 $(this).remove(); 431 }); 432 433 var hd = $('<div>').addClass('ls-gpuhack'); 434 if( $(this).find('.ls-bg').length ){ 435 hd.insertAfter( $(this).find('.ls-bg').eq('0') ); 436 }else{ 437 hd.prependTo( $(this) ); 438 } 439 }); 440 441 $(el).find('.ls-slide, *[class*="ls-l"]').each(function(){ 442 443 if( $(this).data('ls') || $(this).attr('rel') || $(this).attr('style') ){ 444 if( $(this).data('ls') ){ 445 var params = $(this).data('ls').toLowerCase().split(';'); 446 }else if( $(this).attr('rel') && $(this).attr('rel').indexOf(':') != -1 && $(this).attr('rel').indexOf(';') != -1 ){ 447 var params = $(this).attr('rel').toLowerCase().split(';'); 448 }else{ 449 var params = $(this).attr('style').toLowerCase().split(';'); 450 } 451 for(x=0;x<params.length;x++){ 452 param = params[x].split(':'); 453 454 if( param[0].indexOf('easing') != -1 ){ 455 param[1] = ls.ieEasing( param[1] ); 456 } 457 458 var p2 = ''; 459 if( param[2] ){ 460 p2 = ':'+$.trim(param[2]); 461 } 462 463 if( param[0] != ' ' && param[0] != '' ){ 464 $(this).data( $.trim(param[0]), $.trim(param[1]) + p2 ); 465 } 466 } 467 } 468 469 // NEW FEATURE v1.7 and v3.0 making the slider responsive - we have to use style.left instead of jQuery's .css('left') function! 470 471 var sl = $(this); 472 473 sl.data( 'originalLeft', sl[0].style.left ); 474 sl.data( 'originalTop', sl[0].style.top ); 475 476 if( $(this).is('a') && $(this).children().length > 0 ){ 477 sl = $(this).children(); 478 } 479 480 var _w = sl.width(); 481 var _h = sl.height(); 482 483 if( sl[0].style.width && sl[0].style.width.indexOf('%') != -1 ){ 484 _w = sl[0].style.width; 485 } 486 if( sl[0].style.height && sl[0].style.height.indexOf('%') != -1 ){ 487 _h = sl[0].style.height; 488 } 489 490 sl.data( 'originalWidth', _w ); 491 sl.data( 'originalHeight', _h ); 492 493 sl.data( 'originalPaddingLeft', sl.css('padding-left') ); 494 sl.data( 'originalPaddingRight', sl.css('padding-right') ); 495 sl.data( 'originalPaddingTop', sl.css('padding-top') ); 496 sl.data( 'originalPaddingBottom', sl.css('padding-bottom') ); 497 498 // iOS fade bug when GPU acceleration is enabled #1 499 500 var _o = typeof parseFloat( sl.css('opacity') ) == 'number' ? Math.round( parseFloat( sl.css('opacity') ) * 100 ) / 100 : 1; 501 $(this).data( 'originalOpacity', _o ); 502 503 if( sl.css('border-left-width').indexOf('px') == -1 ){ 504 sl.data( 'originalBorderLeft', sl[0].style.borderLeftWidth ); 505 }else{ 506 sl.data( 'originalBorderLeft', sl.css('border-left-width') ); 507 } 508 if( sl.css('border-right-width').indexOf('px') == -1 ){ 509 sl.data( 'originalBorderRight', sl[0].style.borderRightWidth ); 510 }else{ 511 sl.data( 'originalBorderRight', sl.css('border-right-width') ); 512 } 513 if( sl.css('border-top-width').indexOf('px') == -1 ){ 514 sl.data( 'originalBorderTop', sl[0].style.borderTopWidth ); 515 }else{ 516 sl.data( 'originalBorderTop', sl.css('border-top-width') ); 517 } 518 if( sl.css('border-bottom-width').indexOf('px') == -1 ){ 519 sl.data( 'originalBorderBottom', sl[0].style.borderBottomWidth ); 520 }else{ 521 sl.data( 'originalBorderBottom', sl.css('border-bottom-width') ); 522 } 523 524 sl.data( 'originalFontSize', sl.css('font-size') ); 525 sl.data( 'originalLineHeight', sl.css('line-height') ); 526 }); 527 528 // CHANGED FEATURE v3.5 url- / deep linking layers 529 530 if( document.location.hash ){ 531 for( var dl = 0; dl < $(el).find('.ls-slide').length; dl++ ){ 532 if( $(el).find('.ls-slide').eq(dl).data('deeplink') == document.location.hash.split('#')[1] ){ 533 ls.o.firstSlide = dl+1; 534 } 535 } 536 } 537 538 // NEW FEATURE v2.0 linkTo 539 540 $(el).find('*[class*="ls-linkto-"]').each(function(){ 541 var lClasses = $(this).attr('class').split(' '); 542 for( var ll=0; ll<lClasses.length; ll++ ){ 543 if( lClasses[ll].indexOf('ls-linkto-') != -1 ){ 544 var linkTo = parseInt( lClasses[ll].split('ls-linkto-')[1] ); 545 $(this).css({ 546 cursor: 'pointer' 547 }).click(function(e){ 548 e.preventDefault(); 549 $(el).layerSlider( linkTo ); 550 }); 551 } 552 } 553 }); 554 555 // Setting variables 556 557 ls.g.layersNum = $(el).find('.ls-slide').length; 558 559 // NEW FEATURE v3.5 randomSlideshow 560 561 if( ls.o.randomSlideshow && ls.g.layersNum > 2 ){ 562 ls.o.firstSlide == 'random'; 563 ls.o.twoWaySlideshow = false;
564 }else{ 565 ls.o.randomSlideshow = false; 566 } 567 568 // NEW FEATURE v3.0 random firstSlide 569 570 if( ls.o.firstSlide == 'random' ){ 571 ls.o.firstSlide = Math.floor(Math.random() * ls.g.layersNum+1); 572 } 573 574 ls.o.fisrtSlide = ls.o.fisrtSlide < ls.g.layersNum + 1 ? ls.o.fisrtSlide : 1; 575 ls.o.fisrtSlide = ls.o.fisrtSlide < 1 ? 1 : ls.o.fisrtSlide; 576 577 // NEW FEATURE v2.0 loops 578 579 ls.g.nextLoop = 1; 580 581 if( ls.o.animateFirstSlide ){ 582 ls.g.nextLoop = 0; 583 } 584 585 // NEW FEATURE v2.0 videoPreview 586 // IMPROVEMENT v4.6.0 http / https support of embedded videos 587 588 var HTTP = document.location.href.indexOf('file:') === -1 ? '' : 'http:'; 589 590 // Youtube videos 591 592 $(el).find('iframe[src*="www.youtu"], iframe[src*="youtu.be"]').each(function(){ 593 594 // BUGFIX v4.1.0 Firefox embedded video fix 595 596 $(this).parent().addClass('ls-video-layer'); 597 598 if( $(this).parent('[class*="ls-l"]') ){ 599 600 var iframe = $(this); 601 var http = HTTP; 602 603 // Getting thumbnail 604 605 $.getJSON( http + '//gdata.youtube.com/feeds/api/videos/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '?v=2&alt=json&callback=?', function(data) { 606 607 iframe.data( 'videoDuration', parseInt(data['entry']['media$group']['yt$duration']['seconds']) * 1000 ); 608 }); 609
610 var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() ); 611 612 if( ls.o.lazyLoad ){ 613 $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').data('src', http + '//img.youtube.com/vi/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '/' + ls.o.youtubePreview ); 614 }else{ 615 $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').attr('src', http + '//img.youtube.com/vi/' + $(this).attr('src').split('embed/')[1].split('?')[0] + '/' + ls.o.youtubePreview ); 616 } 617 $('<div>').appendTo( vpContainer ).addClass('ls-playvideo'); 618 619 $(this).parent().css({ 620 width : $(this).width(), 621 height : $(this).height() 622 }).click(function(){ 623 624 ls.g.isAnimating = true; 625 626 if( ls.g.paused ){ 627 if( ls.o.autoPauseSlideshow != false ){ 628 ls.g.paused = false; 629 } 630 ls.g.originalAutoSlideshow = true; 631 }else{ 632 ls.g.originalAutoSlideshow = ls.g.autoSlideshow; 633 } 634 635 if( ls.o.autoPauseSlideshow != false ){ 636 ls.stop(); 637 } 638 639 ls.g.pausedByVideo = true; 640 641 http = $(this).find('iframe').data('videoSrc').indexOf('http') === -1 ? HTTP : ''; 642 643 $(this).find('iframe').attr('src', http + $(this).find('iframe').data('videoSrc') ); 644 $(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){ 645 if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){ 646 var videoTimer = setTimeout(function() { 647 ls.start(); 648 }, iframe.data( 'videoDuration') - ls.g.v.d ); 649 iframe.data( 'videoTimer', videoTimer ); 650 } 651 ls.g.isAnimating = false; 652 if( ls.g.resize == true ){ 653 ls.makeResponsive( ls.g.curLayer, function(){ 654 ls.g.resize = false; 655 }); 656 } 657 }); 658 }); 659 660 var sep = '&'; 661 662 if( $(this).attr('src').indexOf('?') == -1 ){ 663 sep = '?'; 664 } 665 666 // BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE) 667 // fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug 668 669 var videoFix = '&wmode=opaque&html5=1'; 670 671 // BUGFIX v5.1.0 Fixed autoplay parameter 672 673 if( $(this).attr('src').indexOf('autoplay') == -1 ){ 674 $(this).data( 'videoSrc', $(this).attr('src') + sep + 'autoplay=1' + videoFix ); 675 }else{ 676 $(this).data( 'videoSrc', $(this).attr('src').replace('autoplay=0','autoplay=1') + videoFix ); 677 } 678 679 $(this).data( 'originalWidth', $(this).attr('width') ); 680 $(this).data( 'originalHeight', $(this).attr('height') ); 681 $(this).attr('src',''); 682 } 683 }); 684 685 // Vimeo videos 686 687 $(el).find('iframe[src*="player.vimeo"]').each(function(){ 688 689 // BUGFIX v4.1.0 Firefox embedded video fix 690 691 $(this).parent().addClass('ls-video-layer'); 692 693 if( $(this).parent('[class*="ls-l"]') ){ 694 695 var iframe = $(this); 696 var http = HTTP; 697 698 // Getting thumbnail 699
700 var vpContainer = $('<div>').addClass('ls-vpcontainer').appendTo( $(this).parent() ); 701 702 $.getJSON( http + '//vimeo.com/api/v2/video/'+ ( $(this).attr('src').split('video/')[1].split('?')[0] ) +'.json?callback=?', function(data){ 703 704 if( ls.o.lazyLoad ){ 705 $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').data('src', data[0]['thumbnail_large'] ); 706 }else{ 707 $('<img>').appendTo( vpContainer ).addClass('ls-videopreview').attr('alt', 'Play video').attr('src', data[0]['thumbnail_large'] ); 708 } 709 iframe.data( 'videoDuration', parseInt( data[0]['duration'] ) * 1000 ); 710 $('<div>').appendTo( vpContainer ).addClass('ls-playvideo'); 711 }); 712 713 714 $(this).parent().css({ 715 width : $(this).width(), 716 height : $(this).height() 717 }).click(function(){ 718 719 ls.g.isAnimating = true; 720 721 if( ls.g.paused ){ 722 if( ls.o.autoPauseSlideshow != false ){ 723 ls.g.paused = false; 724 } 725 ls.g.originalAutoSlideshow = true; 726 }else{ 727 ls.g.originalAutoSlideshow = ls.g.autoSlideshow; 728 } 729 730 if( ls.o.autoPauseSlideshow != false ){ 731 ls.stop(); 732 } 733 734 ls.g.pausedByVideo = true; 735 736 http = $(this).find('iframe').data('videoSrc').indexOf('http') === -1 ? HTTP : ''; 737 738 $(this).find('iframe').attr('src', http + $(this).find('iframe').data('videoSrc') ); 739 $(this).find('.ls-vpcontainer').delay(ls.g.v.d).fadeOut(ls.g.v.fo, function(){ 740 if( ls.o.autoPauseSlideshow == 'auto' && ls.g.originalAutoSlideshow == true ){ 741 var videoTimer = setTimeout(function() { 742 ls.start(); 743 }, iframe.data( 'videoDuration') - ls.g.v.d ); 744 iframe.data( 'videoTimer', videoTimer ); 745 } 746 ls.g.isAnimating = false; 747 if( ls.g.resize == true ){ 748 ls.makeResponsive( ls.g.curLayer, function(){ 749 ls.g.resize = false; 750 }); 751 } 752 }); 753 }); 754 755 var sep = '&'; 756 757 if( $(this).attr('src').indexOf('?') == -1 ){ 758 sep = '?'; 759 } 760 761 // BUGFIX v5.1.0 Fixed several issues with embedded videos (mostly under Firefox and IE) 762 // fixed 'only audio but no video' bug, fixed 'unclickable video controls' bug, fixed 'hidden slider controls' bug 763 764 var videoFix = '&wmode=opaque';
765 766 // BUGFIX v5.1.0 Fixed autoplay parameter 767 768 if( $(this).attr('src').indexOf('autoplay') == -1 ){ 769 $(this).data( 'videoSrc', $(this).attr('src') + sep + 'autoplay=1' + videoFix ); 770 }else{ 771 $(this).data( 'videoSrc', $(this).attr('src').replace('autoplay=0','autoplay=1') + videoFix ); 772 } 773 774 $(this).data( 'originalWidth', $(this).attr('width') ); 775 $(this).data( 'originalHeight', $(this).attr('height') ); 776 $(this).attr('src',''); 777 } 778 }); 779 780 // NEW FEATURE v5.0.0 HTML5 Video Support 781 782 $(el).find('video, audio').each(function(){ 783 784 // BUGFIX v5.1.0 fixed HTML5 video sizing issue (again :) 785 786 var ow = typeof $(this).attr('width') !== 'undefined' ? $(this).attr('width') : '640'; 787 var oh = typeof $(this).attr('height') !== 'undefined' ? $(this).attr('height') : '' + $(this).height(); 788 789 if( ow.indexOf('%') === -1 ){ 790 ow = parseInt( ow ); 791 } 792 793 if( oh.indexOf('%') === -1 ){ 794 oh = parseInt( oh ); 795 } 796 797 if( ow === '100%' && ( oh === 0 || oh === '0' || oh === '100%' ) ){ 798 $(this).attr('height', '100%'); 799 oh = 'auto'; 800 } 801 802 $(this).parent().addClass('ls-video-layer').css({ 803 width : ow, 804 height : oh 805 }).data({ 806 originalWidth : ow, 807 originalHeight : oh 808 }); 809 810 var curVideo = $(this); 811 812 $(this).removeAttr('width').removeAttr('height').css({ 813 width : '100%', 814 height : '100%' 815 }).click(function(){ 816 817 if( typeof curVideo.attr('controls') === "undefined" ){ 818 this.currentTime = 0; 819 this.play(); 820 } 821 822 ls.g.isAnimating = true; 823 824 if( ls.g.paused ){ 825 if( ls.o.autoPauseSlideshow !== false ){ 826 ls.g.paused = false; 827 } 828 ls.g.originalAutoSlideshow = true; 829 }else{ 830 ls.g.originalAutoSlideshow = ls.g.autoSlideshow; 831 } 832 833 if( ls.o.autoPauseSlideshow !== false ){ 834 ls.stop(); 835 } 836 837 ls.g.pausedByVideo = true; 838 839 $(this).on('ended', function(){ 840 if( ls.o.autoPauseSlideshow === 'auto' && ls.g.originalAutoSlideshow === true ){ 841 ls.start(); 842 } 843 }); 844 845 ls.g.isAnimating = false; 846 847 if( ls.g.resize === true ){ 848 ls.makeResponsive( ls.g.curLayer, function(){ 849 ls.g.resize = false; 850 }); 851 } 852 }); 853 }); 854 855 // NEW FEATURE v1.7 animating first layer 856 857 if( ls.o.animateFirstSlide ){ 858 ls.o.firstSlide = ls.o.firstSlide - 1 === 0 ? ls.g.layersNum : ls.o.firstSlide-1; 859 } 860 861 ls.g.curLayerIndex = ls.o.firstSlide; 862 ls.g.curLayer = $(el).find('.ls-slide:eq('+(ls.g.curLayerIndex-1)+')'); 863 864 // Moving all layers to .ls-inner container 865 866 $(el).find('.ls-slide').wrapAll('<div class="ls-inner"></div>'); 867 868 // NEW FEATURE v4.5.0 Timers 869 870 if( ls.o.showBarTimer ){ 871 ls.g.barTimer = $('<div>').addClass('ls-bar-timer').appendTo( $(el).find('.ls-inner') ); 872 } 873 874 if( ls.o.showCircleTimer && !ls.g.ie78 ){ 875 ls.g.circleTimer = $('<div>').addClass('ls-circle-timer').appendTo( $(el).find('.ls-inner') ); 876 ls.g.circleTimer.append( $('<div class="ls-ct-left"><div class="ls-ct-rotate"><div class="ls-ct-hider"><div class="ls-ct-half"></div></div></div></div><div class="ls-ct-right"><div class="ls-ct-rotate"><div class="ls-ct-hider"><div class="ls-ct-half"></div></div></div></div><div class="ls-ct-center"></div>') ); 877 } 878 879 // NEW FEATURE v4.0 Adding loading indicator into the element 880 881 ls.g.li = $('<div>').css({ 882 zIndex: -1, 883 display: 'none' 884 }).addClass('ls-loading-container').appendTo( $(el) ); 885 886 $('<div>').addClass('ls-loading-indicator').appendTo( ls.g.li ); 887 888 // Adding styles 889 890 if( $(el).css('position') == 'static' ){ 891 $(el).css('position','relative'); 892 } 893 894 // IMPROVEMENT & BUGFIX v4.6.0 Fixed transparent global background issue under IE7 & IE8 895 896 if( ls.o.globalBGImage ){ 897 $(el).find('.ls-inner').css({ 898 backgroundImage : 'url('+ls.o.globalBGImage+')', 899 backgroundPosition : ls.o.globalBGPosition, 900 backgroundSize : ls.o.globalBGSize, 901 backgroundRepeat : ls.o.globalBGRepeat, 902 backgroundAttachment : ls.o.globalBGBehaviour 903 }); 904 }else{ 905 $(el).find('.ls-inner').css({ 906 backgroundColor : ls.o.globalBGColor 907 }); 908 } 909 910 if( ls.o.globalBGColor == 'transparent' && ls.o.globalBGImage == false ){ 911 $(el).find('.ls-inner').css({ 912 background : 'none transparent !important' 913 }); 914 } 915 916 // NEW FEATURES v5.0.0 Lazy-load & remove unnecessary width & height attributes from images 917 918 $(el).find('.ls-slide img').each(function(){ 919 920 $(this).removeAttr('width').removeAttr('height'); 921 922 if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){ 923 924 if( typeof $(this).data('src') !== 'string' ){ 925 926 $(this).data('src', $(this).attr('src') ); 927 var src = ls.o.skinsPath+'../../../img/base/blank.gif'; 928 $(this).attr('src',src); 929 } 930 }else{ 931 if( typeof $(this).data('src') === 'string' ){ 932 933 $(this).attr('src',$(this).data('src')); 934 $(this).removeAttr('data-src'); 935 } 936 } 937 938 }); 939 940 // NEW FEATURE v5.0.0 Parallax layers by mousemove 941 942 $(el).find('.ls-slide').on('mouseenter',function(e){ 943 944 ls.g.parallaxStartX = e.pageX - $(this).parent().offset().left; 945 ls.g.parallaxStartY = e.pageY - $(this).parent().offset().top; 946 }); 947 948 $(el).find('.ls-slide').on('mousemove',function(e){ 949 950 var mX0 = $(this).parent().offset().left + ls.g.parallaxStartX; 951 var mY0 = $(this).parent().offset().top + ls.g.parallaxStartY; 952 953 var mX = e.pageX - mX0; 954 var mY = e.pageY - mY0; 955 956 $(this).find('> *:not(.ls-bg)').each(function(){ 957 958 if( typeof $(this).data('parallaxlevel') !== 'undefined' && parseInt( $(this).data('parallaxlevel') ) !== 0 ){ 959 $(this).css({ 960 marginLeft : -mX / 100 * parseInt( $(this).data('parallaxlevel') ), 961 marginTop : -mY / 100 * parseInt( $(this).data('parallaxlevel') ) 962 }); 963 } 964 }); 965 }); 966 967 $(el).find('.ls-slide').on('mouseleave',function(){ 968 969 $(this).find('> *:not(.ls-bg)').each(function(){ 970 971 if( typeof $(this).data('parallaxlevel') !== 'undefined' && parseInt( $(this).data('parallaxlevel') ) !== 0 ){ 972 TweenLite.to( this, .4, {css:{ 973 marginLeft : 0, 974 marginTop : 0 975 } 976 }); 977 } 978 }); 979 }); 980 981 // Creating navigation 982 983 if( ls.o.navPrevNext ){ 984 985 $('<a class="ls-nav-prev" href="#" />').click(function(e){ 986 e.preventDefault(); 987 $(el).layerSlider('prev'); 988 }).appendTo($(el)); 989 990 $('<a class="ls-nav-next" href="#" />').click(function(e){ 991 e.preventDefault(); 992 $(el).layerSlider('next'); 993 }).appendTo($(el)); 994 995 if( ls.o.hoverPrevNext ){ 996 $(el).find('.ls-nav-prev, .ls-nav-next').css({ 997 display: 'none' 998 }); 999 1000 $(el).hover( 1001 function(){ 1002 if( !ls.g.forceHideControls ){ 1003 if( ls.g.ie78 ){ 1004 $(el).find('.ls-nav-prev, .ls-nav-next').css('display','block'); 1005 }else{ 1006 $(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeIn(300); 1007 } 1008 } 1009 }, 1010 function(){ 1011 if( ls.g.ie78 ){ 1012 $(el).find('.ls-nav-prev, .ls-nav-next').css('display','none'); 1013 }else{ 1014 $(el).find('.ls-nav-prev, .ls-nav-next').stop(true,true).fadeOut(300); 1015 } 1016 } 1017 ); 1018 } 1019 } 1020 1021 // Creating bottom navigation 1022 1023 if( ls.o.navStartStop || ls.o.navButtons ){ 1024
1025 var bottomNav = $('<div class="ls-bottom-nav-wrapper" />').appendTo( $(el) ); 1026 1027 ls.g.bottomWrapper = bottomNav; 1028 1029 if( ls.o.thumbnailNavigation == 'always' ){ 1030 bottomNav.addClass('ls-above-thumbnails'); 1031 } 1032 1033 if( ls.o.navButtons && ls.o.thumbnailNavigation != 'always' ){ 1034 1035 $('<span class="ls-bottom-slidebuttons" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') ); 1036 1037 // NEW FEATURE v3.5 thumbnailNavigation ('hover') 1038 1039 if( ls.o.thumbnailNavigation == 'hover' ){ 1040 1041 var thumbs = $('<div class="ls-thumbnail-hover"><div class="ls-thumbnail-hover-inner"><div class="ls-thumbnail-hover-bg"></div><div class="ls-thumbnail-hover-img"><img></div><span></span></div></div>').appendTo( $(el).find('.ls-bottom-slidebuttons') ); 1042 } 1043 1044 for(x=1;x<ls.g.layersNum+1;x++){ 1045 1046 var btn = $('<a href="#" />').appendTo( $(el).find('.ls-bottom-slidebuttons') ).click(function(e){ 1047 e.preventDefault(); 1048 $(el).layerSlider( ($(this).index() + 1) ); 1049 }); 1050 1051 // NEW FEATURE v3.5 thumbnailNavigation ('hover') 1052 1053 if( ls.o.thumbnailNavigation == 'hover' ){ 1054 1055 $(el).find('.ls-thumbnail-hover, .ls-thumbnail-hover-img').css({ 1056 width : ls.o.tnWidth, 1057 height : ls.o.tnHeight 1058 }); 1059 1060 var th = $(el).find('.ls-thumbnail-hover'); 1061 1062 var ti = th.find('img').css({ 1063 height : ls.o.tnHeight 1064 }); 1065 1066 var thi = $(el).find('.ls-thumbnail-hover-inner').css({ 1067 visibility : 'hidden', 1068 display: 'block' 1069 }); 1070 1071 btn.hover( 1072 function(){ 1073 1074 var hoverLayer = $(el).find('.ls-slide').eq( $(this).index() ); 1075 var tnSrc; 1076 1077 if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){ 1078 1079 if( hoverLayer.find('.ls-tn').length ){ 1080 tnSrc = hoverLayer.find('.ls-tn').data('src'); 1081 }else if( hoverLayer.find('.ls-videopreview').length ){ 1082 tnSrc = hoverLayer.find('.ls-videopreview').attr('src'); 1083 }else if( hoverLayer.find('.ls-bg').length ){ 1084 tnSrc = hoverLayer.find('.ls-bg').data('src'); 1085 }else{ 1086 tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png'; 1087 } 1088 }else{ 1089 1090 if( hoverLayer.find('.ls-tn').length ){ 1091 tnSrc = hoverLayer.find('.ls-tn').attr('src'); 1092 }else if( hoverLayer.find('.ls-videopreview').length ){ 1093 tnSrc = hoverLayer.find('.ls-videopreview').attr('src'); 1094 }else if( hoverLayer.find('.ls-bg').length ){ 1095 tnSrc = hoverLayer.find('.ls-bg').attr('src'); 1096 }else{ 1097 tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png'; 1098 } 1099 } 1100 1101 $(el).find('.ls-thumbnail-hover-img').css({ 1102 left: parseInt( th.css('padding-left') ), 1103 top: parseInt( th.css('padding-top') ) 1104 }); 1105 1106 ti.load(function(){ 1107 1108 if( $(this).width() == 0 ){ 1109 ti.css({ 1110 position: 'relative', 1111 margin: '0 auto', 1112 left: 'auto' 1113 }); 1114 }else{ 1115 ti.css({ 1116 position: 'absolute', 1117 marginLeft : - $(this).width() / 2, 1118 left: '50%' 1119 }); 1120 } 1121 }).attr( 'src', tnSrc ); 1122 1123 th.css({ 1124 display: 'block' 1125 }).stop().animate({ 1126 left: $(this).position().left + ( $(this).width() - th.outerWidth() ) / 2 1127 }, 250 ); 1128 1129 thi.css({ 1130 display : 'none', 1131 visibility : 'visible' 1132 }).stop().fadeIn(250); 1133 }, 1134 function(){ 1135 thi.stop().fadeOut(250, function(){ 1136 th.css({ 1137 visibility : 'hidden', 1138 display: 'block' 1139 }); 1140 }); 1141 } 1142 ); 1143 } 1144 } 1145 1146 if( ls.o.thumbnailNavigation == 'hover' ){ 1147 1148 thumbs.appendTo( $(el).find('.ls-bottom-slidebuttons') ); 1149 } 1150 1151 $(el).find('.ls-bottom-slidebuttons a:eq('+(ls.o.firstSlide-1)+')').addClass('ls-nav-active'); 1152 } 1153 1154 if( ls.o.navStartStop ){ 1155 1156 var buttonStart = $('<a class="ls-nav-start" href="#" />').click(function(e){ 1157 e.preventDefault(); 1158 $(el).layerSlider('start'); 1159 }).prependTo( $(el).find('.ls-bottom-nav-wrapper') ); 1160 1161 var buttonStop = $('<a class="ls-nav-stop" href="#" />').click(function(e){ 1162 e.preventDefault(); 1163 $(el).layerSlider('stop'); 1164 }).appendTo( $(el).find('.ls-bottom-nav-wrapper') ); 1165 1166 }else if( ls.o.thumbnailNavigation != 'always' ){ 1167 1168 $('<span class="ls-nav-sides ls-nav-sideleft" />').prependTo( $(el).find('.ls-bottom-nav-wrapper') ); 1169 $('<span class="ls-nav-sides ls-nav-sideright" />').appendTo( $(el).find('.ls-bottom-nav-wrapper') ); 1170 } 1171 1172 if( ls.o.hoverBottomNav && ls.o.thumbnailNavigation != 'always' ){ 1173 1174 bottomNav.css({ 1175 display: 'none' 1176 }); 1177 1178 $(el).hover( 1179 function(){ 1180 if( !ls.g.forceHideControls ){ 1181 if( ls.g.ie78 ){ 1182 bottomNav.css('display','block'); 1183 }else{ 1184 bottomNav.stop(true,true).fadeIn(300); 1185 } 1186 } 1187 }, 1188 function(){ 1189 if( ls.g.ie78 ){ 1190 bottomNav.css('display','none'); 1191 }else{ 1192 bottomNav.stop(true,true).fadeOut(300); 1193 } 1194 } 1195 ) 1196 } 1197 } 1198 1199 // NEW FEATURE v3x.5 thumbnailNavigation ('always') 1200 1201 if( ls.o.thumbnailNavigation == 'always' ){ 1202
1203 ls.g.thumbsWrapper = $('<div class="ls-thumbnail-wrapper"></div>').appendTo( $(el) ); 1204 var thumbs = $('<div class="ls-thumbnail"><div class="ls-thumbnail-inner"><div class="ls-thumbnail-slide-container"><div class="ls-thumbnail-slide"></div></div></div></div>').appendTo( ls.g.thumbsWrapper ); 1205 1206 ls.g.thumbnails = $(el).find('.ls-thumbnail-slide-container'); 1207 1208 if( !('ontouchstart' in window) ){ 1209 ls.g.thumbnails.hover( 1210 function(){ 1211 $(this).addClass('ls-thumbnail-slide-hover'); 1212 }, 1213 function(){ 1214 $(this).removeClass('ls-thumbnail-slide-hover'); 1215 ls.scrollThumb(); 1216 } 1217 ).mousemove(function(e){ 1218 1219 var mL = parseInt(e.pageX - $(this).offset().left ) / $(this).width() * ( $(this).width() - $(this).find('.ls-thumbnail-slide').width() ); 1220 $(this).find('.ls-thumbnail-slide').stop().css({ 1221 marginLeft : mL 1222 }); 1223 }); 1224 }else{ 1225 ls.g.thumbnails.addClass('ls-touchscroll'); 1226 } 1227 1228 $(el).find('.ls-slide').each(function(){ 1229 1230 var tempIndex = $(this).index() + 1; 1231 var tnSrc; 1232 1233 if( ls.o.imgPreload === true && ls.o.lazyLoad === true ){ 1234 1235 if( $(this).find('.ls-tn').length ){ 1236 tnSrc = $(this).find('.ls-tn').data('src'); 1237 }else if( $(this).find('.ls-videopreview').length ){ 1238 tnSrc = $(this).find('.ls-videopreview').data('src'); 1239 }else if( $(this).find('.ls-bg').length ){ 1240 tnSrc = $(this).find('.ls-bg').data('src'); 1241 }else{ 1242 tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png'; 1243 } 1244 }else{ 1245 1246 if( $(this).find('.ls-tn').length ){ 1247 tnSrc = $(this).find('.ls-tn').attr('src'); 1248 }else if( $(this).find('.ls-videopreview').length ){ 1249 tnSrc = $(this).find('.ls-videopreview').attr('src'); 1250 }else if( $(this).find('.ls-bg').length ){ 1251 tnSrc = $(this).find('.ls-bg').attr('src'); 1252 }else{ 1253 tnSrc = ls.o.skinsPath+ls.o.skin+'/nothumb.png'; 1254 } 1255 } 1256 1257 var thumb = $('<a href="#" class="ls-thumb-' + tempIndex + '"><img src="'+tnSrc+'"></a>'); 1258 thumb.appendTo( $(el).find('.ls-thumbnail-slide') ); 1259 1260 if( !('ontouchstart' in window) ){ 1261 1262 thumb.hover( 1263 function(){ 1264 $(this).children().stop().fadeTo(300,ls.o.tnActiveOpacity/100); 1265 }, 1266 function(){ 1267 if( !$(this).children().hasClass('ls-thumb-active') ){ 1268 $(this).children().stop().fadeTo(300,ls.o.tnInactiveOpacity/100); 1269 } 1270 } 1271 ); 1272 } 1273 1274 thumb.click(function(e){ 1275 e.preventDefault(); 1276 $(el).layerSlider( tempIndex ); 1277 }); 1278 }); 1279 1280 if( buttonStart && buttonStop ){ 1281 var lsBottomBelowTN = ls.g.bottomWrapper = $('<div class="ls-bottom-nav-wrapper ls-below-thumbnails"></div>').appendTo( $(el) ); 1282 buttonStart.clone().click(function(e){ 1283 e.preventDefault(); 1284 $(el).layerSlider('start'); 1285 }).appendTo( lsBottomBelowTN ); 1286 buttonStop.clone().click(function(e){ 1287 e.preventDefault(); 1288 $(el).layerSlider('stop'); 1289 }).appendTo( lsBottomBelowTN ); 1290 } 1291 1292 if( ls.o.hoverBottomNav ){ 1293 1294 ls.g.thumbsWrapper.css('display','none'); 1295 1296 if( lsBottomBelowTN ){ 1297 ls.g.bottomWrapper = lsBottomBelowTN.css('display') == 'block' ? lsBottomBelowTN : $(el).find('.ls-above-thumbnails'); 1298 ls.g.bottomWrapper.css('display','none'); 1299 } 1300 1301 // BUGFIXES v4.1.3 Added checking of the bottomWrapper variable 1302 1303 $(el).hover( 1304 function(){ 1305 $(el).addClass('ls-hover'); 1306 if( !ls.g.forceHideControls ){ 1307 if( ls.g.ie78 ){ 1308 ls.g.thumbsWrapper.css('display','block'); 1309 if( ls.g.bottomWrapper ){ 1310 ls.g.bottomWrapper.css('display','block'); 1311 } 1312 }else{ 1313 ls.g.thumbsWrapper.stop(true,true).fadeIn(300); 1314 if( ls.g.bottomWrapper ){ 1315 ls.g.bottomWrapper.stop(true,true).fadeIn(300); 1316 } 1317 } 1318 } 1319 }, 1320 function(){ 1321 $(el).removeClass('ls-hover'); 1322 if( ls.g.ie78 ){ 1323 ls.g.thumbsWrapper.css('display','none'); 1324 if( ls.g.bottomWrapper ){ 1325 ls.g.bottomWrapper.css('display','none'); 1326 } 1327 }else{ 1328 ls.g.thumbsWrapper.stop(true,true).fadeOut(300); 1329 if( ls.g.bottomWrapper ){ 1330 ls.g.bottomWrapper.stop(true,true).fadeOut(300); 1331 } 1332 } 1333 } 1334 ) 1335 } 1336 } 1337 1338 // Adding shadow wrapper 1339
1340 ls.g.shadow = $('<div class="ls-shadow"></div>').appendTo( $(el) ); 1341 if( ls.g.shadow.css('display') == 'block' && !ls.g.shadow.find('img').length ){ 1342 ls.g.showShadow = function(){ 1343 ls.g.shadow.css({ 1344 display: 'none', 1345 visibility: 'visible' 1346 }).fadeIn( 500, function(){ 1347 ls.g.showShadow = false; 1348 }); 1349 } 1350 ls.g.shadowImg = $('<img>').attr('src',ls.o.skinsPath.replace('/css/', '/img/')+ls.o.skin+'/shadow.png').appendTo( ls.g.shadow ); 1351 ls.g.shadowBtmMod = typeof parseInt( $(el).css('padding-bottom') ) == 'number' ? parseInt( $(el).css('padding-bottom') ) : 0; 1352 } 1353 ls.resizeShadow(); 1354 1355 // Adding keyboard navigation if turned on and if number of layers > 1 1356 1357 if( ls.o.keybNav && $(el).find('.ls-slide').length > 1 ){ 1358 1359 $('body').bind('keydown',function(e){ 1360 if( !ls.g.isAnimating && !ls.g.isLoading ){ 1361 if( e.which == 37 ){ 1362 ls.o.cbPrev(ls.g); 1363 ls.prev('clicked'); 1364 }else if( e.which == 39 ){ 1365 ls.o.cbNext(ls.g); 1366 ls.next('clicked'); 1367 } 1368 } 1369 }); 1370 } 1371 1372 // Adding touch-control navigation if number of layers > 1 1373 1374 if('ontouchstart' in window && $(el).find('.ls-slide').length > 1 && ls.o.touchNav ){ 1375 1376 $(el).find('.ls-inner').bind('touchstart', function( e ) { 1377 var t = e.touches ? e.touches : e.originalEvent.touches; 1378 if( t.length == 1 ){ 1379 ls.g.touchStartX = ls.g.touchEndX = t[0].clientX; 1380 } 1381 }); 1382 1383 $(el).find('.ls-inner').bind('touchmove', function( e ) { 1384 var t = e.touches ? e.touches : e.originalEvent.touches; 1385 if( t.length == 1 ){ 1386 ls.g.touchEndX = t[0].clientX; 1387 } 1388 if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){ 1389 e.preventDefault(); 1390 } 1391 }); 1392 1393 $(el).find('.ls-inner').bind('touchend',function( e ){ 1394 if( Math.abs( ls.g.touchStartX - ls.g.touchEndX ) > 45 ){ 1395 if( ls.g.touchStartX - ls.g.touchEndX > 0 ){ 1396 ls.o.cbNext(ls.g); 1397 $(el).layerSlider('next'); 1398 }else{ 1399 ls.o.cbPrev(ls.g); 1400 $(el).layerSlider('prev'); 1401 } 1402 } 1403 }); 1404 } 1405 1406 // Feature: pauseOnHover (if number of layers > 1) 1407 1408 if( ls.o.pauseOnHover == true && $(el).find('.ls-slide').length > 1 ){ 1409 1410 // BUGFIX v1.6 stop was not working because of pause on hover 1411 1412 $(el).find('.ls-inner').hover( 1413 function(){ 1414 1415 // Calling cbPause callback function 1416 1417 ls.o.cbPause(ls.g); 1418 if( ls.g.autoSlideshow ){ 1419 ls.g.paused = true; 1420 ls.stop(); 1421 1422 // Stopping the animation of Timers 1423 1424 if( ls.g.barTimer ){ 1425 ls.g.barTimer.stop(); 1426 } 1427 1428 if( ls.g.circleTimer ){ 1429 if( ls.g.cttl ){ 1430 ls.g.cttl.pause(); 1431 } 1432 } 1433 ls.g.pausedSlideTime = new Date().getTime(); 1434 } 1435 }, 1436 function(){ 1437 if( ls.g.paused == true ){ 1438 ls.start(); 1439 ls.g.paused = false; 1440 } 1441 } 1442 ); 1443 } 1444 1445 ls.resizeSlider(); 1446 1447 // NEW FEATURE v1.7 added yourLogo 1448 1449 if( ls.o.yourLogo ){ 1450 ls.g.yourLogo = $('<img>').addClass('ls-yourlogo').appendTo($(el)).attr('style', ls.o.yourLogoStyle ).css({ 1451 visibility: 'hidden', 1452 display: 'bock' 1453 }).load(function(){ 1454 1455 // NEW FEATURE v3.0 added responsive yourLogo 1456 1457 var logoTimeout = 0; 1458 1459 if( !ls.g.yourLogo ){ 1460 logoTimeout = 1000; 1461 } 1462 1463 setTimeout( function(){ 1464 1465 ls.g.yourLogo.data( 'originalWidth', ls.g.yourLogo.width() ); 1466 ls.g.yourLogo.data( 'originalHeight', ls.g.yourLogo.height() ); 1467 if( ls.g.yourLogo.css('left') != 'auto' ){ 1468 ls.g.yourLogo.data( 'originalLeft', ls.g.yourLogo[0].style.left ); 1469 } 1470 if( ls.g.yourLogo.css('right') != 'auto' ){ 1471 ls.g.yourLogo.data( 'originalRight', ls.g.yourLogo[0].style.right ); 1472 } 1473 if( ls.g.yourLogo.css('top') != 'auto' ){ 1474 ls.g.yourLogo.data( 'originalTop', ls.g.yourLogo[0].style.top ); 1475 } 1476 if( ls.g.yourLogo.css('bottom') != 'auto' ){ 1477 ls.g.yourLogo.data( 'originalBottom', ls.g.yourLogo[0].style.bottom ); 1478 } 1479 1480 // NEW FEATURES v1.8 added yourLogoLink & yourLogoTarget 1481 1482 if( ls.o.yourLogoLink != false ){ 1483 $('<a>').appendTo($(el)).attr( 'href', ls.o.yourLogoLink ).attr('target', ls.o.yourLogoTarget ).css({
1484 textDecoration : 'none', 1485 outline : 'none' 1486 }).append( ls.g.yourLogo ); 1487 } 1488 1489 ls.g.yourLogo.css({ 1490 display: 'none', 1491 visibility: 'visible' 1492 }); 1493 1494 ls.resizeYourLogo(); 1495 1496 }, logoTimeout ); 1497 1498 }).attr( 'src', ls.o.yourLogo ); 1499 } 1500 1501 // NEW FEATURE v1.7 added window resize function for make responsive layout better 1502 1503 $(window).resize(function(){ 1504 1505 ls.g.resize = true; 1506 1507 if( !ls.g.isAnimating ){ 1508 1509 ls.makeResponsive( ls.g.curLayer, function(){ 1510 if( ls.g.ltContainer ){ 1511 ls.g.ltContainer.empty(); 1512 } 1513 ls.g.resize = false; 1514 }); 1515 if( ls.g.yourLogo ){ 1516 ls.resizeYourLogo(); 1517 } 1518 } 1519 }); 1520 1521 ls.g.showSlider = true; 1522 1523 // NEW FEATURE v1.7 animating first layer 1524 1525 if( ls.o.animateFirstSlide == true ){ 1526 if( ls.o.autoStart ){ 1527 ls.g.autoSlideshow = true; 1528 $(el).find('.ls-nav-start').addClass('ls-nav-start-active'); 1529 }else{ 1530 $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active'); 1531 } 1532 ls.next(); 1533 }else{ 1534 ls.imgPreload(ls.g.curLayer,function(){ 1535 ls.g.curLayer.fadeIn(1000, function(){ 1536 1537 ls.g.isLoading = false; 1538 1539 $(this).addClass('ls-active'); 1540 1541 // NEW FEATURE v2.0 autoPlayVideos 1542 1543 if( ls.o.autoPlayVideos ){ 1544 $(this).delay( $(this).data('delayin') + 25 ).queue(function(){ 1545 $(this).find('.ls-videopreview, video, audio').click(); 1546 $(this).dequeue(); 1547 }); 1548 } 1549 1550 // NEW FEATURE v3.0 showUntil sublayers 1551 1552 ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){ 1553 1554 // Setting showUntilTimers 1555 1556 if( $(this).data('showuntil') > 0 ){ 1557 1558 var cursub = $(this); 1559 1560 // IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary 1561 1562 cursub.data('showUntilTimer', setTimeout(function(){ 1563 ls.sublayerShowUntil( cursub ); 1564 }, cursub.data('showuntil') )); 1565 } 1566 }); 1567 }); 1568 1569 ls.changeThumb(ls.g.curLayerIndex) 1570 1571 // If autoStart is true 1572 1573 if( ls.o.autoStart ){ 1574 ls.g.isLoading = false; 1575 ls.start(); 1576 }else{ 1577 $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active'); 1578 } 1579 }); 1580 } 1581 1582 // NEW FEATURE v1.7 added cbInit function 1583 1584 ls.o.cbInit($(el)); 1585 }; 1586 1587 ls.start = function(){ 1588 1589 if( ls.g.autoSlideshow ){ 1590 if( ls.g.prevNext == 'prev' && ls.o.twoWaySlideshow ){ 1591 ls.prev(); 1592 }else{ 1593 ls.next(); 1594 } 1595 }else{ 1596 ls.g.autoSlideshow = true; 1597 if( !ls.g.isAnimating && !ls.g.isLoading ){ 1598 ls.timer(); 1599 } 1600 } 1601 1602 $(el).find('.ls-nav-start').addClass('ls-nav-start-active'); 1603 $(el).find('.ls-nav-stop').removeClass('ls-nav-stop-active'); 1604 }; 1605 1606 ls.timer = function(){ 1607 1608 if( $(el).find('.ls-active').data('ls') ){ 1609 var sD = ls.st.slideDelay; 1610 }else{ 1611 var sD = ls.o.slideDelay; 1612 } 1613 1614 var delaytime = $(el).find('.ls-active').data('slidedelay') ? parseInt( $(el).find('.ls-active').data('slidedelay') ) : sD; 1615 1616 // BUGFIX v3.0 delaytime did not work on first layer if animateFirstSlide was set to off 1617 // BUGFIX v3.5 delaytime did not work on all layers in standalone version after bugfix 3.0 :) 1618 1619 if( !ls.o.animateFirstSlide && !$(el).find('.ls-active').data('slidedelay') ){ 1620 var tempD = $(el).find('.ls-slide:eq('+(ls.o.firstSlide-1)+')').data('slidedelay'); 1621 delaytime = tempD ? tempD : sD; 1622 } 1623 1624 clearTimeout( ls.g.slideTimer ); 1625 1626 // NEW FEATURE v4.5.0 Timers 1627 1628 if( ls.g.pausedSlideTime ){ 1629 if( !ls.g.startSlideTime ){ 1630 ls.g.startSlideTime = new Date().getTime(); 1631 } 1632 if( ls.g.startSlideTime > ls.g.pausedSlideTime ){ 1633 ls.g.pausedSlideTime = new Date().getTime(); 1634 } 1635 if(! ls.g.curSlideTime ){ 1636 ls.g.curSlideTime = delaytime; 1637 } 1638 ls.g.curSlideTime -= (ls.g.pausedSlideTime - ls.g.startSlideTime); 1639 ls.g.pausedSlideTime = false; 1640 ls.g.startSlideTime = new Date().getTime(); 1641 }else{ 1642 ls.g.curSlideTime = delaytime; 1643 ls.g.startSlideTime = new Date().getTime(); 1644 } 1645 1646 // BUGFIX v4.6.0 fixed Bar Timer animation on the fisrt slide if animateFirstSlide is false 1647 1648 ls.g.curSlideTime = parseInt( ls.g.curSlideTime ); 1649 1650 ls.g.slideTimer = setTimeout(function(){ 1651 ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
1652 ls.start(); 1653 }, ls.g.curSlideTime ); 1654 1655 // Animating Timers 1656 1657 if( ls.g.barTimer ){ 1658 ls.g.barTimer.animate({ 1659 width : ls.g.sliderWidth() 1660 }, ls.g.curSlideTime, 'linear', function(){ 1661 $(this).css({ 1662 width: 0 1663 }); 1664 }); 1665 } 1666 1667 if( ls.g.circleTimer ){ 1668 1669 var ct1 = ls.g.circleTimer.find('.ls-ct-right .ls-ct-rotate'); 1670 var ct2 = ls.g.circleTimer.find('.ls-ct-left .ls-ct-rotate'); 1671 1672 if( ls.g.circleTimer.css('display') == 'none' ){ 1673 1674 ct1.css({ 1675 rotate : 0 1676 }); 1677 1678 ct2.css({ 1679 rotate : 0 1680 }); 1681 1682 ls.g.circleTimer.fadeIn(350); 1683 } 1684 1685 if( !ls.g.cttl ){ 1686 ls.g.cttl = new TimelineLite(); 1687 ls.g.cttl.add( TweenLite.fromTo(ct1[0],delaytime/2000,{ 1688 rotation : 0 1689 },{ 1690 ease : Linear.easeNone, 1691 rotation : 180, 1692 onReverseComplete : function(){ 1693 ls.g.cttl = false; 1694 } 1695 })); 1696 ls.g.cttl.add( TweenLite.fromTo(ct2[0],delaytime/2000,{ 1697 rotation : 0 1698 },{ 1699 ease : Linear.easeNone, 1700 rotation : 180 1701 })); 1702 }else{ 1703 ls.g.cttl.resume(); 1704 } 1705 1706 } 1707 }; 1708 1709 ls.stop = function(){ 1710 1711 // Stopping Timers 1712 1713 ls.g.pausedSlideTime = new Date().getTime(); 1714 1715 if( ls.g.barTimer ){ 1716 ls.g.barTimer.stop(); 1717 } 1718 1719 if( ls.g.circleTimer ){ 1720 if( ls.g.cttl ){ 1721 ls.g.cttl.pause(); 1722 } 1723 } 1724 1725 if( !ls.g.paused && !ls.g.originalAutoSlideshow ){ 1726 $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active'); 1727 $(el).find('.ls-nav-start').removeClass('ls-nav-start-active'); 1728 } 1729 clearTimeout( ls.g.slideTimer ); 1730 ls.g.autoSlideshow = false; 1731 }; 1732 1733 ls.forcestop = function(){ 1734 1735 clearTimeout( ls.g.slideTimer ); 1736 ls.g.autoSlideshow = false; 1737 1738 clearTimeout( ls.g.t1 ); 1739 clearTimeout( ls.g.t2 ); 1740 clearTimeout( ls.g.t3 ); 1741 clearTimeout( ls.g.t4 ); 1742 clearTimeout( ls.g.t5 ); 1743 1744 if( ls.g.barTimer ){ 1745 ls.g.barTimer.stop(); 1746 } 1747 1748 if( ls.g.circleTimer ){ 1749 if( ls.g.cttl ){ 1750 ls.g.cttl.pause(); 1751 } 1752 } 1753 1754 $(el).find('*').stop(true,false).dequeue(); 1755 $(el).find('.ls-slide >').each(function(){ 1756 if( $(this).data('tr') ){ 1757 $(this).data('tr').pause(); 1758 } 1759 }); 1760 1761 if( !ls.g.paused && !ls.g.originalAutoSlideshow ){ 1762 $(el).find('.ls-nav-stop').addClass('ls-nav-stop-active'); 1763 $(el).find('.ls-nav-start').removeClass('ls-nav-start-active'); 1764 } 1765 }; 1766 1767 ls.restart = function(){ 1768 1769 $(el).find('*').stop(); 1770 clearTimeout( ls.g.slideTimer ); 1771 ls.change(ls.g.curLayerIndex,ls.g.prevNext); 1772 }; 1773 1774 // Because of an ie7 bug, we have to check & format the strings correctly 1775 1776 ls.ieEasing = function( e ){ 1777 1778 // BUGFIX v1.6 and v1.8 some type of animations didn't work properly 1779 1780 if( $.trim(e.toLowerCase()) == 'swing' || $.trim(e.toLowerCase()) == 'linear'){ 1781 return e.toLowerCase(); 1782 }else{ 1783 return e.replace('easeinout','easeInOut').replace('easein','easeIn').replace('easeout','easeOut').replace('quad','Quad').replace('quart','Quart').replace('cubic','Cubic').replace('quint','Quint').replace('sine','Sine').replace('expo','Expo').replace('circ','Circ').replace('elastic','Elastic').replace('back','Back').replace('bounce','Bounce'); 1784 } 1785 }; 1786 1787 // Calculating prev layer 1788 1789 ls.prev = function(clicked){ 1790 1791 // NEW FEATURE v2.0 loops 1792 1793 if( ls.g.curLayerIndex < 2 ){ 1794 ls.g.nextLoop += 1; 1795 } 1796 1797 if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){ 1798 ls.g.nextLoop = 0; 1799 ls.stop(); 1800 if( ls.o.forceLoopNum == false ){ 1801 ls.o.loops = 0; 1802 } 1803 }else{ 1804 var prev = ls.g.curLayerIndex < 2 ? ls.g.layersNum : ls.g.curLayerIndex - 1; 1805 ls.g.prevNext = 'prev'; 1806 ls.change(prev,ls.g.prevNext); 1807 } 1808 }; 1809 1810 // Calculating next layer 1811 1812 ls.next = function(clicked){ 1813 1814 // NEW FEATURE v2.0 loops 1815 1816 if( !ls.o.randomSlideshow ){ 1817 1818 if( !(ls.g.curLayerIndex < ls.g.layersNum) ){ 1819 ls.g.nextLoop += 1; 1820 } 1821 1822 if( ( ls.g.nextLoop > ls.o.loops ) && ( ls.o.loops > 0 ) && !clicked ){ 1823 1824 ls.g.nextLoop = 0; 1825 ls.stop(); 1826 if( ls.o.forceLoopNum == false ){ 1827 ls.o.loops = 0; 1828 } 1829 }else{ 1830 1831 var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1; 1832 ls.g.prevNext = 'next'; 1833 ls.change(next,ls.g.prevNext); 1834 } 1835 }else if( !clicked ){ 1836 1837 // NEW FEATURE v3.5 randomSlideshow 1838 1839 var next = ls.g.curLayerIndex; 1840 1841 var calcRand = function(){ 1842 1843 next = Math.floor(Math.random() * ls.g.layersNum) + 1; 1844 1845 if( next == ls.g.curLayerIndex ){ 1846 1847 calcRand(); 1848 }else{ 1849 ls.g.prevNext = 'next'; 1850 ls.change(next,ls.g.prevNext); 1851 } 1852 } 1853 1854 calcRand(); 1855 }else if( clicked ){ 1856 1857 var next = ls.g.curLayerIndex < ls.g.layersNum ? ls.g.curLayerIndex + 1 : 1; 1858 ls.g.prevNext = 'next'; 1859 ls.change(next,ls.g.prevNext); 1860 } 1861 1862 }; 1863 1864 ls.change = function(num,prevnext){ 1865 1866 // Stopping Timers if needed 1867 1868 ls.g.startSlideTime = ls.g.pausedSlideTime = ls.g.curSlideTime = false;
1869 1870 // IMPROVEMENT v4.6.0 Bar Timer animation 1871 1872 if( ls.g.barTimer ){ 1873 ls.g.barTimer.stop().delay(300).animate({ 1874 width: 0 1875 },450); 1876 } 1877 if( ls.g.circleTimer ){ 1878 ls.g.circleTimer.fadeOut(500); 1879 if( ls.g.cttl ){ 1880 ls.g.cttl.reverse().duration(.35); 1881 } 1882 } 1883 1884 // NEW FEATURE v2.0 videoPreview & autoPlayVideos 1885 1886 if( ls.g.pausedByVideo == true ){ 1887 1888 ls.g.pausedByVideo = false; 1889 ls.g.autoSlideshow = ls.g.originalAutoSlideshow; 1890 1891 ls.g.curLayer.find('iframe[src*="www.youtu"], iframe[src*="player.vimeo"]').each(function(){ 1892 1893 $(this).parent().find('.ls-vpcontainer').fadeIn(ls.g.v.fi,function(){ 1894 $(this).parent().find('iframe').attr('src',''); 1895 }); 1896 }); 1897 1898 ls.g.curLayer.find('video, audio').each(function(){ 1899 1900 this.pause(); 1901 }); 1902 } 1903 1904 $(el).find('iframe[src*="www.youtu"], iframe[src*="player.vimeo"]').each(function(){ 1905 1906 // Clearing videoTimeouts 1907 1908 clearTimeout( $(this).data( 'videoTimer') ); 1909 }); 1910 1911 clearTimeout( ls.g.slideTimer ); 1912 ls.g.nextLayerIndex = num; 1913 ls.g.nextLayer = $(el).find('.ls-slide:eq('+(ls.g.nextLayerIndex-1)+')'); 1914 1915 // BUGFIX v1.6 fixed wrong directions of animations if navigating by slidebuttons 1916 1917 if( !prevnext ){ 1918 1919 if( ls.g.curLayerIndex < ls.g.nextLayerIndex ){ 1920 ls.g.prevNext = 'next'; 1921 }else{ 1922 ls.g.prevNext = 'prev'; 1923 } 1924 } 1925 1926 // Added timeOut to wait for the fade animation of videoPreview image... 1927 1928 var timeOut = 0; 1929 1930 if( $(el).find('iframe[src*="www.youtu"], iframe[src*="player.vimeo"]').length > 0 ){ 1931 timeOut = ls.g.v.fi; 1932 } 1933 1934 ls.imgPreload(ls.g.nextLayer,function(){ 1935 ls.animate(); 1936 }); 1937 }; 1938 1939 // Preloading images 1940 1941 ls.imgPreload = function(layer,callback){ 1942 1943 ls.g.isLoading = true; 1944 1945 // Showing slider for the first time 1946 1947 if( ls.g.showSlider ){ 1948 $(el).css({ 1949 visibility : 'visible' 1950 }); 1951 } 1952 1953 // If image preload is on 1954 1955 if( ls.o.imgPreload ){ 1956 1957 var preImages = []; 1958 var preloaded = 0; 1959 1960 // NEW FEATURE v1.8 Preloading background images of layers 1961 1962 if( layer.css('background-image') != 'none' && layer.css('background-image').indexOf('url') != -1 && !layer.hasClass('ls-preloaded') && !layer.hasClass('ls-not-preloaded') ){ 1963 var bgi = layer.css('background-image'); 1964 bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, ''); 1965 preImages[preImages.length] = [bgi, layer]; 1966 } 1967 1968 // Images inside layers 1969 1970 layer.find('img:not(.ls-preloaded, .ls-not-preloaded)').each(function(){ 1971 1972 // NEW FEATURE v5.0.0 Lazy-load 1973 1974 if( ls.o.lazyLoad === true ){ 1975 $(this).attr('src',$(this).data('src')); 1976 } 1977 preImages[preImages.length] = [$(this).attr('src'), $(this)]; 1978 }); 1979 1980 // Background images inside layers 1981 1982 layer.find('*').each(function(){ 1983 1984 // BUGFIX v1.7 fixed preload bug with sublayers with gradient backgrounds 1985 1986 if( $(this).css('background-image') != 'none' && $(this).css('background-image').indexOf('url') != -1 && !$(this).hasClass('ls-preloaded') && !$(this).hasClass('ls-not-preloaded') ){ 1987 var bgi = $(this).css('background-image'); 1988 bgi = bgi.match(/url\((.*)\)/)[1].replace(/"/gi, ''); 1989 preImages[preImages.length] = [bgi, $(this)]; 1990 } 1991 }); 1992 1993 // BUGFIX v1.7 if there are no images in a layer, calling the callback function 1994 1995 if(preImages.length == 0){ 1996 1997 $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({ 1998 visibility : 'visible' 1999 }); 2000 2001 ls.makeResponsive(layer, callback); 2002 }else{ 2003 2004 // NEW FEATURE v4.0 Showing loading indicator 2005 2006 if( ls.g.ie78 ){ 2007 ls.g.li.css('display','block'); 2008 }else{ 2009 2010 // BUGIFX v4.1.3 Adding delay to the showing of the loading indicator 2011 2012 ls.g.li.delay(400).fadeIn(300); 2013 } 2014 2015 for(x=0;x<preImages.length;x++){ 2016 2017 $('<img>').data('el',preImages[x]).load(function(){ 2018 2019 $(this).data('el')[1].addClass('ls-preloaded'); 2020 2021 if( ++preloaded == preImages.length ){ 2022 2023 // NEW FEATURE v4.0 Hiding loading indicator 2024 2025 ls.g.li.stop(true,true).css({ 2026 display: 'none' 2027 }); 2028
2029 $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({ 2030 visibility : 'visible' 2031 }); 2032 2033 // We love you so much IE... -.- 2034 2035 if( navigator.userAgent.indexOf('Trident/7') !== -1 || ls.g.ie78 ){ 2036 setTimeout(function(){ 2037 ls.makeResponsive(layer, callback); 2038 },50); 2039 }else{ 2040 ls.makeResponsive(layer, callback); 2041 } 2042 } 2043 }).error(function(){ 2044 var imgURL = $(this).data('el')[0].substring($(this).data('el')[0].lastIndexOf("/") + 1, $(this).data('el')[0].length); 2045 if( window.console ){ 2046 console.log('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.'); 2047 }else{ 2048 alert('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.'); 2049 } 2050 $(this).addClass('ls-not-preloaded'); 2051 preloaded++; 2052 }).attr('src',preImages[x][0]); 2053 } 2054 } 2055 }else{ 2056 2057 $('.ls-thumbnail-wrapper, .ls-nav-next, .ls-nav-prev, .ls-bottom-nav-wrapper').css({ 2058 visibility : 'visible' 2059 }); 2060 2061 ls.makeResponsive(layer, callback); 2062 } 2063 }; 2064 2065 // NEW FEATURE v1.7 making the slider responsive 2066 2067 ls.makeResponsive = function(layer, callback ){ 2068 2069 layer.css({ 2070 visibility: 'hidden', 2071 display: 'block' 2072 }); 2073 2074 if( ls.g.showShadow ){ 2075 ls.g.showShadow(); 2076 } 2077 ls.resizeSlider(); 2078 2079 if( ls.o.thumbnailNavigation == 'always' ){ 2080 ls.resizeThumb(); 2081 } 2082 layer.children().each(function(){ 2083 2084 var sl = $(this); 2085 2086 // positioning 2087 2088 var ol = sl.data('originalLeft') ? sl.data('originalLeft') : '0'; 2089 var ot = sl.data('originalTop') ? sl.data('originalTop') : '0'; 2090 2091 if( sl.is('a') && sl.children().length > 0 ){ 2092 sl.css({ 2093 display : 'block' 2094 }); 2095 sl = sl.children(); 2096 } 2097 2098 var ow = 'auto'; 2099 var oh = 'auto'; 2100 2101 if( sl.data('originalWidth') ){ 2102 2103 if( typeof sl.data('originalWidth') == 'number' ){ 2104 ow = parseInt( sl.data('originalWidth') ) * ls.g.ratio; 2105 }else if( sl.data('originalWidth').indexOf('%') != -1 ){ 2106 ow = sl.data('originalWidth'); 2107 } 2108 } 2109 2110 if( sl.data('originalHeight') ){ 2111 if( typeof sl.data('originalHeight') == 'number' ){ 2112 oh = parseInt( sl.data('originalHeight') ) * ls.g.ratio; 2113 }else if( sl.data('originalHeight').indexOf('%') != -1 ){ 2114 oh = sl.data('originalHeight'); 2115 } 2116 } 2117 2118 // padding 2119 2120 var opl = sl.data('originalPaddingLeft') ? parseInt( sl.data('originalPaddingLeft') ) * ls.g.ratio : 0; 2121 var opr = sl.data('originalPaddingRight') ? parseInt( sl.data('originalPaddingRight') ) * ls.g.ratio : 0; 2122 var opt = sl.data('originalPaddingTop') ? parseInt( sl.data('originalPaddingTop') ) * ls.g.ratio : 0; 2123 var opb = sl.data('originalPaddingBottom') ? parseInt( sl.data('originalPaddingBottom') ) * ls.g.ratio : 0; 2124 2125 // border 2126 2127 var obl = sl.data('originalBorderLeft') ? parseInt( sl.data('originalBorderLeft') ) * ls.g.ratio : 0; 2128 var obr = sl.data('originalBorderRight') ? parseInt( sl.data('originalBorderRight') ) * ls.g.ratio : 0; 2129 var obt = sl.data('originalBorderTop') ? parseInt( sl.data('originalBorderTop') ) * ls.g.ratio : 0; 2130 var obb = sl.data('originalBorderBottom') ? parseInt( sl.data('originalBorderBottom') ) * ls.g.ratio : 0; 2131 2132 // font 2133 2134 var ofs = sl.data('originalFontSize'); 2135 var olh = sl.data('originalLineHeight'); 2136 2137 // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing 2138 // NEW FEATURE v3.5 added responsiveUnder 2139 2140 if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){ 2141 2142 if( sl.is('img') && !sl.hasClass('ls-bg') && sl.attr('src') ){ 2143 2144 sl.css({ 2145 width: 'auto', 2146 height: 'auto' 2147 }); 2148 2149 // IMPROVEMENT v4.5.0 Images can have now starting width / height 2150 2151 if( ( ow == 0 || ow == 'auto' ) && typeof oh == 'number' && oh != 0 ){ 2152 ow = ( oh / sl.height() ) * sl.width(); 2153 } 2154 2155 if( ( oh == 0 || oh == 'auto' ) && typeof ow == 'number' && ow != 0 ){ 2156 oh = ( ow / sl.width() ) * sl.height(); 2157 } 2158 2159 if( ow == 'auto'){ 2160 ow = sl.width() * ls.g.ratio; 2161 } 2162 2163 if( oh == 'auto'){ 2164 oh = sl.height() * ls.g.ratio; 2165 } 2166 2167 sl.css({ 2168 width : ow, 2169 height : oh 2170 }); 2171 } 2172 2173 if( !sl.is('img') ){ 2174 sl.css({ 2175 width : ow, 2176 height : oh, 2177 'font-size' : parseInt(ofs) * ls.g.ratio +'px', 2178 'line-height' : parseInt(olh) * ls.g.ratio + 'px' 2179 }); 2180 } 2181 2182 if( sl.is('div') && sl.find('iframe').data('videoSrc') ){ 2183 2184 var videoIframe = sl.find('iframe'); 2185 videoIframe.attr('width', parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio ).attr('height', parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio ); 2186 2187 sl.css({ 2188 width : parseInt( videoIframe.data('originalWidth') ) * ls.g.ratio, 2189 height : parseInt( videoIframe.data('originalHeight') ) * ls.g.ratio 2190 }); 2191 } 2192 2193 sl.css({ 2194 padding : opt + 'px ' + opr + 'px ' + opb + 'px ' + opl + 'px ', 2195 borderLeftWidth : obl + 'px', 2196 borderRightWidth : obr + 'px', 2197 borderTopWidth : obt + 'px', 2198 borderBottomWidth : obb + 'px' 2199 }); 2200 } 2201 2202 // If it is NOT a bg sublayer 2203 2204 if( !sl.hasClass('ls-bg') ){ 2205 2206 var sl2 = sl; 2207 2208 if( sl.parent().is('a') ){ 2209 sl = sl.parent(); 2210 } 2211 2212 // NEW FEATURE v3.5 sublayerContainer 2213 2214 var slC = 0; 2215 if( ls.o.layersContainer ){ 2216 slC = ls.o.layersContainer > 0 ? ( ls.g.sliderWidth() - ls.o.layersContainer ) / 2 : 0; 2217 }else if( ls.o.sublayerContainer ){ 2218 slC = ls.o.sublayerContainer > 0 ? ( ls.g.sliderWidth() - ls.o.sublayerContainer ) / 2 : 0; 2219 } 2220 slC = slC < 0 ? 0 : slC; 2221 2222 // (RE)positioning sublayer (left property) 2223 2224 if( ol.indexOf('%') != -1 ){ 2225 sl.css({ 2226 left : ls.g.sliderWidth() / 100 * parseInt(ol) - sl2.width() / 2 - opl - obl 2227 }); 2228 }else if( slC > 0 || ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){ 2229 sl.css({ 2230 left : slC + parseInt(ol) * ls.g.ratio 2231 }); 2232 } 2233 2234 // (RE)positioning sublayer (top property) 2235 2236 if( ot.indexOf('%') != -1 ){ 2237 sl.css({ 2238 top : ls.g.sliderHeight() / 100 * parseInt(ot) - sl2.height() / 2 - opt - obt 2239 }); 2240 }else if( ls.g.responsiveMode || ls.o.responsiveUnder > 0 ){ 2241 sl.css({ 2242 top : parseInt(ot) * ls.g.ratio 2243 }); 2244 } 2245 2246 }else{ 2247 2248 var inner = $(el).find('.ls-inner'); 2249 2250 sl.css({ 2251 width : 'auto', 2252 height : 'auto' 2253 }); 2254 2255 ow = sl.width(); 2256 oh = sl.height(); 2257 2258 // IMPROVEMENT v4.5.0 Resizing smaller background images in full width mode as well to fill the whole slide 2259 2260 var or = ls.g.ratio; 2261 2262 if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){ 2263 if( ls.g.sliderWidth() > ow ){ 2264 or = ls.g.sliderWidth() / ow; 2265 if( ls.g.sliderHeight() > oh * or ){ 2266 or = ls.g.sliderHeight() / oh; 2267 } 2268 }else if( ls.g.sliderHeight() > oh ){ 2269 or = ls.g.sliderHeight() / oh; 2270 if( ls.g.sliderWidth() > ow * or ){ 2271 or = ls.g.sliderWidth() / ow; 2272 } 2273 } 2274 } 2275 2276 sl.css({ 2277 width : ow * or, 2278 height : oh * or, 2279 marginLeft : inner.width() / 2 - ow * or / 2, 2280 marginTop : inner.height() / 2 - oh * or / 2 2281 }); 2282// $('#w2 span:eq(0)').html( ( inner.width() / 2 ) - Math.round( ow * or / 2 ) ); 2283 } 2284 }); 2285 2286 layer.css({ 2287 display: 'none', 2288 visibility: 'visible' 2289 }); 2290 2291 // Resizing shadow 2292 2293 ls.resizeShadow(); 2294 2295 callback(); 2296 2297 $(this).dequeue(); 2298 }; 2299 2300 // Resizing shadow 2301 2302 ls.resizeShadow = function(){ 2303 if( ls.g.shadowImg ){ 2304 var resizeShadow = function(){ 2305 if( ls.g.shadowImg.height() > 0 ){ 2306 if( ls.g.shadowBtmMod > 0 ){ 2307 ls.g.shadow.css({ 2308 height: ls.g.shadowImg.height() / 2 2309 }); 2310 }else{ 2311 ls.g.shadow.css({ 2312 height: ls.g.shadowImg.height(), 2313 marginTop: - ls.g.shadowImg.height() / 2 2314 }); 2315 } 2316 }else{ 2317 setTimeout(function(){ 2318 resizeShadow(); 2319 },50); 2320 } 2321 }; 2322 2323 resizeShadow(); 2324 } 2325 }; 2326 2327 // Resizing the slider 2328 2329 ls.resizeSlider = function(){ 2330 2331 if( ls.o.responsiveUnder > 0 ){ 2332 2333 if( $(window).width() < ls.o.responsiveUnder ){ 2334 ls.g.responsiveMode = true; 2335 ls.g.sliderOriginalWidth = ls.o.responsiveUnder + 'px'; 2336 }else{ 2337 ls.g.responsiveMode = false;
2338 ls.g.sliderOriginalWidth = ls.g.sliderOriginalWidthRU; 2339 ls.g.ratio = 1; 2340 } 2341 } 2342 2343 // NEW FEATURE v3.0 added "normal" responsive mode with image and font resizing 2344 2345 if( ls.g.responsiveMode ){ 2346 2347 var parent = $(el).parent(); 2348 2349 // BUGFIX v4.0 there is no need to subtract the values of the left and right paddings of the container element! 2350 2351 if (ls.g.sliderOriginalWidthRU == "100%") { 2352 $(el).css({ 2353 width : $(window).width() 2354 }); 2355 } else { 2356 $(el).css({ 2357 width : parent.width() - parseInt($(el).css('padding-left')) - parseInt($(el).css('padding-right')) 2358 }); 2359 } 2360 ls.g.ratio = $(el).width() / parseInt( ls.g.sliderOriginalWidth ); 2361 $(el).css({ 2362 height : ls.g.ratio * parseInt( ls.g.sliderOriginalHeight ) 2363 }); 2364 2365 }else{ 2366 ls.g.ratio = 1; 2367 $(el).css({ 2368 width : ls.g.sliderOriginalWidth, 2369 height : ls.g.sliderOriginalHeight 2370 }); 2371 } 2372 2373 // WP fullWidth mode (originally forceResponsive mode) 2374 2375 if( $(el).closest('.ls-wp-fullwidth-container').length ){ 2376 2377 $(el).closest('.ls-wp-fullwidth-helper').css({ 2378 height : $(el).outerHeight(true) 2379 }); 2380 2381 $(el).closest('.ls-wp-fullwidth-container').css({ 2382 height : $(el).outerHeight(true) 2383 }); 2384 2385 $(el).closest('.ls-wp-fullwidth-helper').css({ 2386 width : $(window).width(), 2387 left : - $(el).closest('.ls-wp-fullwidth-container').offset().left 2388 }); 2389 2390 if( ls.g.sliderOriginalWidth.indexOf('%') != -1 ){ 2391 2392 var percentWidth = parseInt( ls.g.sliderOriginalWidth ); 2393 var newWidth = $('body').width() / 100 * percentWidth - ( $(el).outerWidth() - $(el).width() ); 2394 $(el).width( newWidth ); 2395 } 2396 } 2397 2398 $(el).find('.ls-inner, .ls-lt-container').css({ 2399 width : ls.g.sliderWidth(), 2400 height : ls.g.sliderHeight() 2401 }); 2402 2403 // BUGFIX v2.0 fixed width problem if firstSlide is not 1 2404 2405 if( ls.g.curLayer && ls.g.nextLayer ){ 2406 2407 ls.g.curLayer.css({ 2408 width : ls.g.sliderWidth(), 2409 height : ls.g.sliderHeight() 2410 }); 2411 2412 ls.g.nextLayer.css({ 2413 width : ls.g.sliderWidth(), 2414 height : ls.g.sliderHeight() 2415 }); 2416 2417 }else{ 2418 2419 $(el).find('.ls-slide').css({ 2420 width : ls.g.sliderWidth(), 2421 height : ls.g.sliderHeight() 2422 }); 2423 } 2424 }; 2425 2426 // NEW FEATURE v3.0 added responsive yourLogo 2427 2428 ls.resizeYourLogo = function(){ 2429 2430 ls.g.yourLogo.css({ 2431 width : ls.g.yourLogo.data( 'originalWidth' ) * ls.g.ratio, 2432 height : ls.g.yourLogo.data( 'originalHeight' ) * ls.g.ratio 2433 }); 2434 2435 if( ls.g.ie78 ){ 2436 ls.g.yourLogo.css('display','block'); 2437 }else{ 2438 ls.g.yourLogo.fadeIn(300); 2439 } 2440 2441 var oL = oR = oT = oB = 'auto'; 2442 2443 if( ls.g.yourLogo.data( 'originalLeft' ) && ls.g.yourLogo.data( 'originalLeft' ).indexOf('%') != -1 ){ 2444 oL = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-left') ); 2445 }else{ 2446 oL = parseInt( ls.g.yourLogo.data( 'originalLeft' ) ) * ls.g.ratio; 2447 } 2448 2449 if( ls.g.yourLogo.data( 'originalRight' ) && ls.g.yourLogo.data( 'originalRight' ).indexOf('%') != -1 ){ 2450 oR = ls.g.sliderWidth() / 100 * parseInt( ls.g.yourLogo.data( 'originalRight' ) ) - ls.g.yourLogo.width() / 2 + parseInt( $(el).css('padding-right') ); 2451 }else{ 2452 oR = parseInt( ls.g.yourLogo.data( 'originalRight' ) ) * ls.g.ratio; 2453 } 2454 2455 if( ls.g.yourLogo.data( 'originalTop' ) && ls.g.yourLogo.data( 'originalTop' ).indexOf('%') != -1 ){ 2456 oT = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalTop' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-top') ); 2457 }else{ 2458 oT = parseInt( ls.g.yourLogo.data( 'originalTop' ) ) * ls.g.ratio; 2459 } 2460 2461 if( ls.g.yourLogo.data( 'originalBottom' ) && ls.g.yourLogo.data( 'originalBottom' ).indexOf('%') != -1 ){ 2462 oB = ls.g.sliderHeight() / 100 * parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) - ls.g.yourLogo.height() / 2 + parseInt( $(el).css('padding-bottom') ); 2463 }else{ 2464 oB = parseInt( ls.g.yourLogo.data( 'originalBottom' ) ) * ls.g.ratio; 2465 } 2466 2467 ls.g.yourLogo.css({ 2468 left : oL, 2469 right : oR, 2470 top : oT, 2471 bottom : oB 2472 }); 2473 }; 2474 2475 // NEW FEATURE v3.5 thumbnailNavigation ('always') 2476 2477 // Resizing thumbnails 2478 2479 ls.resizeThumb = function(){ 2480 2481 ls.bottomNavSizeHelper('on'); 2482 2483 var sliderW = ls.g.sliderOriginalWidth.indexOf('%') == -1 ? parseInt( ls.g.sliderOriginalWidth )
2483: ls.g.sliderWidth(); 2484 2485 $(el).find('.ls-thumbnail-slide a').css({ 2486 width : parseInt( ls.o.tnWidth * ls.g.ratio ), 2487 height : parseInt( ls.o.tnHeight * ls.g.ratio ) 2488 }); 2489 2490 $(el).find('.ls-thumbnail-slide a:last').css({ 2491 margin: 0 2492 }); 2493 2494 $(el).find('.ls-thumbnail-slide').css({ 2495 height : parseInt( ls.o.tnHeight * ls.g.ratio ) 2496 }); 2497 2498 var tn = $(el).find('.ls-thumbnail'); 2499 2500 var originalWidth = ls.o.tnContainerWidth.indexOf('%') == -1 ? parseInt( ls.o.tnContainerWidth ) : parseInt( sliderW / 100 * parseInt( ls.o.tnContainerWidth ) ); 2501 2502 tn.css({ 2503 width : originalWidth * Math.floor( ls.g.ratio * 100 ) / 100 2504 }); 2505 2506 if( tn.width() > $(el).find('.ls-thumbnail-slide').width() ){ 2507 tn.css({ 2508 width : $(el).find('.ls-thumbnail-slide').width() 2509 }); 2510 } 2511 2512 ls.bottomNavSizeHelper('off'); 2513 }; 2514 2515 // Changing thumbnails 2516 2517 ls.changeThumb = function(index){ 2518 2519 var curIndex = index ? index : ls.g.nextLayerIndex; 2520 2521 $(el).find('.ls-thumbnail-slide a:not(.ls-thumb-'+curIndex+')').children().each(function(){ 2522 $(this).removeClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnInactiveOpacity/100); 2523 }); 2524 2525 $(el).find('.ls-thumbnail-slide a.ls-thumb-'+curIndex).children().addClass('ls-thumb-active').stop().fadeTo(750,ls.o.tnActiveOpacity/100); 2526 }; 2527 2528 // Scrolling thumbnails 2529 2530 ls.scrollThumb = function(){ 2531 2532 if( !$(el).find('.ls-thumbnail-slide-container').hasClass('ls-thumbnail-slide-hover') ){ 2533 var curThumb = $(el).find('.ls-thumb-active').length ? $(el).find('.ls-thumb-active').parent() : false; 2534 if( curThumb ){ 2535 var thumbCenter = curThumb.position().left + curThumb.width() / 2; 2536 var mL = $(el).find('.ls-thumbnail-slide-container').width() / 2 - thumbCenter; 2537 mL = mL < $(el).find('.ls-thumbnail-slide-container').width() - $(el).find('.ls-thumbnail-slide').width() ? $(el).find('.ls-thumbnail-slide-container').width() - $(el).find('.ls-thumbnail-slide').width() : mL; 2538 mL = mL > 0 ? 0 : mL; 2539 $(el).find('.ls-thumbnail-slide').animate({ 2540 marginLeft : mL 2541 }, 600 ); 2542 } 2543 } 2544 }; 2545 2546 // IMPROVEMENT v4.1.3 Changed the working of some Thumbnail and Bottom Navigation features 2547 2548 ls.bottomNavSizeHelper = function(val){ 2549 2550 if( ls.o.hoverBottomNav && !$(el).hasClass('ls-hover') ){ 2551 switch(val){ 2552 case 'on': 2553 ls.g.thumbsWrapper.css({ 2554 visibility: 'hidden', 2555 display: 'block' 2556 }); 2557 break; 2558 case 'off': 2559 ls.g.thumbsWrapper.css({ 2560 visibility: 'visible', 2561 display: 'none' 2562 }); 2563 break; 2564 } 2565 } 2566 }; 2567 2568 // Animating layers and sublayers 2569 2570 ls.animate = function(){ 2571 2572 /* GLOBAL (used by both old and new transitions ) */ 2573 2574 // Changing variables 2575 // BUGFIX v4.6.0 If there is only one layer, there is no need to set ls.g.isAnimating to true 2576 2577 if( $(el).find('.ls-slide').length > 1 ){ 2578 ls.g.isAnimating = true; 2579 } 2580 2581 ls.g.isLoading = false; 2582 2583 // Clearing timeouts 2584 2585 clearTimeout( ls.g.slideTimer ); 2586 clearTimeout( ls.g.changeTimer ); 2587 2588 ls.g.stopLayer = ls.g.curLayer; 2589 2590 // Calling cbAnimStart callback function 2591 2592 ls.o.cbAnimStart(ls.g); 2593 2594 // NEW FEATURE v3.5 thumbnailNavigation ('always') 2595 2596 if( ls.o.thumbnailNavigation == 'always' ){ 2597 2598 // ChangeThumb 2599 2600 ls.changeThumb(); 2601 2602 // ScrollThumb 2603 2604 if( !('ontouchstart' in window) ){ 2605 ls.scrollThumb(); 2606 } 2607 } 2608 2609 // Adding .ls-animating class to next layer 2610 2611 ls.g.nextLayer.addClass('ls-animating'); 2612 2613 2614 2615 /* OLD layer transitions (version 3.x) */ 2616 2617 // Setting position and styling of current and next layers 2618 2619 var curLayerLeft = curLayerRight = curLayerTop = curLayerBottom = nextLayerLeft = nextLayerRight = nextLayerTop = nextLayerBottom = layerMarginLeft = layerMarginRight = layerMarginTop = layerMarginBottom = 'auto'; 2620 var curLayerWidth = nextLayerWidth = ls.g.sliderWidth(); 2621 var curLayerHeight = nextLayerHeight = ls.g.sliderHeight(); 2622 2623 // Calculating direction 2624 2625 var prevOrNext = ls.g.prevNext == 'prev' ? ls.g.curLayer : ls.g.nextLayer; 2626 var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection; 2627 2628 // Setting the direction of sliding 2629 2630 var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection]; 2631 2632 if( slideDirection == 'left' || slideDirection == 'right' ){ 2633 curLayerWidth = curLayerTop = nextLayerWidth = nextLayerTop = 0; 2634 layerMarginTop = 0; 2635 } 2636 if( slideDirection == 'top' || slideDirection == 'bottom' ){ 2637 curLayerHeight = curLayerLeft = nextLayerHeight = nextLayerLeft = 0; 2638 layerMarginLeft = 0; 2639 } 2640 2641 switch(slideDirection){ 2642 case 'left': 2643 curLayerRight = nextLayerLeft = 0; 2644 layerMarginLeft = -ls.g.sliderWidth(); 2645 break; 2646 case 'right': 2647 curLayerLeft = nextLayerRight = 0; 2648 layerMarginLeft = ls.g.sliderWidth(); 2649 break; 2650 case 'top': 2651 curLayerBottom = nextLayerTop = 0; 2652 layerMarginTop = -ls.g.sliderHeight(); 2653 break; 2654 case 'bottom': 2655 curLayerTop = nextLayerBottom = 0; 2656 layerMarginTop = ls.g.sliderHeight(); 2657 break; 2658 } 2659 2660 // Setting start positions and styles of layers 2661 2662 ls.g.curLayer.css({ 2663 left : curLayerLeft, 2664 right : curLayerRight, 2665 top : curLayerTop, 2666 bottom : curLayerBottom 2667 }); 2668 ls.g.nextLayer.css({ 2669 width : nextLayerWidth, 2670 height : nextLayerHeight, 2671 left : nextLayerLeft, 2672 right : nextLayerRight, 2673 top : nextLayerTop, 2674 bottom : nextLayerBottom 2675 }); 2676 2677 // Creating variables for the OLD transitions of CURRENT LAYER 2678 2679 // BUGFIX v1.6 fixed some wrong parameters of current layer 2680 // BUGFIX v1.7 fixed using of delayout of current layer 2681 2682 var curDelay = ls.g.curLayer.data('delayout') ? parseInt(ls.g.curLayer.data('delayout')) : ls.o.delayOut; 2683 2684 var curDuration = ls.g.curLayer.data('durationout') ? parseInt(ls.g.curLayer.data('durationout')) : ls.o.durationOut; 2685 var curEasing = ls.g.curLayer.data('easingout') ? ls.g.curLayer.data('easingout') : ls.o.easingOut; 2686 2687 // Creating variables for the OLD transitions of NEXT LAYER 2688 2689 var nextDelay = ls.g.nextLayer.data('delayin') ? parseInt(ls.g.nextLayer.data('delayin')) : ls.o.delayIn; 2690 var nextDuration = ls.g.nextLayer.data('durationin') ? parseInt(ls.g.nextLayer.data('durationin')) : ls.o.durationIn; 2691 var nextEasing = ls.g.nextLayer.data('easingin') ? ls.g.nextLayer.data('easingin') : ls.o.easingIn; 2692 2693 var curLayer = function(){ 2694 2695 // BUGFIX v1.6 added an additional delaytime to current layer to fix the '1px ga
2695p' bug 2696 // BUGFIX v3.0 modified from curDuration / 80 to curDuration / 15 2697 2698 ls.g.curLayer.delay( curDelay + curDuration / 15).animate({ 2699 width : curLayerWidth, 2700 height : curLayerHeight 2701 }, curDuration, curEasing,function(){ 2702 2703 curLayerCallback(); 2704 }); 2705 }; 2706 2707 var curLayerCallback = function(){ 2708 2709 // Stopping current sublayer animations if needed (they are not visible at this point). 2710 2711 ls.g.stopLayer.find(' > *[class*="ls-l"]').each(function(){ 2712 if( $(this).data('tr') ){ 2713 $(this).data('tr').kill(); 2714 } 2715 2716 $(this).css({ 2717 filter: 'none' 2718 }); 2719 }); 2720 2721 // FIXED v4.0 Calling cbAnimStop callback function before changing layer indexes 2722 2723 ls.o.cbAnimStop(ls.g); 2724 2725 // Setting current layer 2726 2727 ls.g.curLayer = ls.g.nextLayer; 2728 ls.g.curLayerIndex = ls.g.nextLayerIndex; 2729 2730 // NEW FEATURE v5.0.0 Lazy-load (preloading here the images of the next layer) 2731 2732 if( ls.o.imgPreload && ls.o.lazyLoad ){ 2733 2734 var preLayerIndex = ls.g.curLayerIndex == ls.g.layersNum ? 1 : ls.g.curLayerIndex + 1; 2735 $(el).find('.ls-slide').eq(preLayerIndex-1).find('img:not(.ls-preloaded)').each(function(){ 2736 $(this).load(function(){ 2737 $(this).addClass('ls-preloaded'); 2738 }).error(function(){ 2739 var imgURL = $(this).data('src').substring($(this).data('src').lastIndexOf("/") + 1, $(this).data('src').length); 2740 if( window.console ){ 2741 console('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.'); 2742 }else{ 2743 alert('LayerSlider error:\r\n\r\nIt seems like the URL of the image or background image "'+imgURL+'" is pointing to a wrong location and it cannot be loaded. Please check the URLs of all your images used in the slider.'); 2744 } 2745 $(this).addClass('ls-not-preloaded'); 2746 }).attr('src', $(this).data('src')); 2747 }); 2748 } 2749 2750 // Changing some css classes 2751 2752 $(el).find('.ls-slide').removeClass('ls-active'); 2753 $(el).find('.ls-slide:eq(' + ( ls.g.curLayerIndex - 1 ) + ')').addClass('ls-active').removeClass('ls-animating'); 2754 $(el).find('.ls-bottom-slidebuttons a').removeClass('ls-nav-active'); 2755 $(el).find('.ls-bottom-slidebuttons a:eq('+( ls.g.curLayerIndex - 1 )+')').addClass('ls-nav-active'); 2756 2757 // Setting timer if needed 2758 2759 if( ls.g.autoSlideshow ){ 2760 ls.timer(); 2761 } 2762 2763 // Changing variables 2764 2765 ls.g.isAnimating = false; 2766 if( ls.g.resize == true ){ 2767 ls.makeResponsive( ls.g.curLayer, function(){ 2768 ls.g.resize = false; 2769 }); 2770 } 2771 }; 2772 2773 var curSubLayers = function(sublayersDurationOut){ 2774 2775 ls.g.curLayer.find(' > *[class*="ls-l"]').each(function(){ 2776 2777 if( !$(this).data('transitiontype') ){ 2778 ls.transitionType( $(this) ); 2779 } 2780 2781 // BUGFIX v5.1.0 Removing ls-videohack class before starting transition 2782 2783 $(this).removeClass('ls-videohack'); 2784 2785 var curSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection; 2786 var lml, lmt; 2787 2788 switch(curSubSlideDir){ 2789 case 'left': 2790 lml = -ls.g.sliderWidth(); 2791 lmt = 0; 2792 break; 2793 case 'right': 2794 lml = ls.g.sliderWidth(); 2795 lmt = 0; 2796 break; 2797 case 'top': 2798 lmt = -ls.g.sliderHeight(); 2799 lml = 0; 2800 break; 2801 case 'bottom': 2802 lmt = ls.g.sliderHeight(); 2803 lml = 0; 2804 break; 2805 case 'fade': 2806 lmt = 0; 2807 lml = 0; 2808 break; 2809 } 2810 2811 // NEW FEATURE v1.6 added slideoutdirection to sublayers 2812 // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties 2813 2814 if( $(this).data('transitiontype') === 'new' ){ 2815 var curSubSlideOutDir = 'new'; 2816 }else{ 2817 var curSubSlideOutDir = $(this).data('slideoutdirection') ? $(this).data('slideoutdirection') : false;
2818 } 2819 2820 switch(curSubSlideOutDir){ 2821 case 'left': 2822 lml = ls.g.sliderWidth(); 2823 lmt = 0; 2824 break; 2825 case 'right': 2826 lml = -ls.g.sliderWidth(); 2827 lmt = 0; 2828 break; 2829 case 'top': 2830 lmt = ls.g.sliderHeight(); 2831 lml = 0; 2832 break; 2833 case 'bottom': 2834 lmt = -ls.g.sliderHeight(); 2835 lml = 0; 2836 break; 2837 case 'fade': 2838 lmt = 0; 2839 lml = 0; 2840 break; 2841 case 'new': 2842 if( $(this).data('offsetxout') ){ 2843 if( $(this).data('offsetxout') === 'left' ){ 2844 lml = ls.g.sliderWidth(); 2845 }else if( $(this).data('offsetxout') === 'right' ){ 2846 lml = -ls.g.sliderWidth(); 2847 }else{ 2848 lml = -parseInt( $(this).data('offsetxout') ); 2849 } 2850 }else{ 2851 lml = -ls.lt.offsetXOut; 2852 } 2853 if( $(this).data('offsetyout') ){ 2854 if( $(this).data('offsetyout') === 'top' ){ 2855 lmt = ls.g.sliderHeight(); 2856 }else if( $(this).data('offsetyout') === 'bottom' ){ 2857 lmt = -ls.g.sliderHeight(); 2858 }else{ 2859 lmt = -parseInt( $(this).data('offsetyout') ); 2860 } 2861 }else{ 2862 lmt = -ls.lt.offsetYOut; 2863 } 2864 break; 2865 } 2866 2867 // NEW FEATURES v4.5.0 Rotating & Scaling sublayers 2868 // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2) 2869 // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions 2870 2871 var curSubRotate = curSubRotateX = curSubRotateY = curSubScale = curSubSkewX = curSubSkewY = curSubScaleX = curSubScaleY = 'none'; 2872// if( !ls.g.ie78 && ls.g.enableCSS3 ){ 2873 curSubRotate = $(this).data('rotateout') ? $(this).data('rotateout') : ls.lt.rotateOut; 2874 curSubRotateX = $(this).data('rotatexout') ? $(this).data('rotatexout') : ls.lt.rotateXOut; 2875 curSubRotateY = $(this).data('rotateyout') ? $(this).data('rotateyout') : ls.lt.rotateYOut; 2876 curSubScale = $(this).data('scaleout') ? $(this).data('scaleout') : ls.lt.scaleOut; 2877 curSubSkewX = $(this).data('skewxout') ? $(this).data('skewxout') : ls.lt.skewXOut; 2878 curSubSkewY = $(this).data('skewyout') ? $(this).data('skewyout') : ls.lt.skewYOut; 2879 if( curSubScale === 1 ){ 2880 curSubScaleX = $(this).data('scalexout') ? $(this).data('scalexout') : ls.lt.scaleXOut; 2881 curSubScaleY = $(this).data('scaleyout') ? $(this).data('scaleyout') : ls.lt.scaleYOut; 2882 }else{ 2883 curSubScaleX = curSubScaleY = curSubScale; 2884 } 2885 var too = $(this).data('transformoriginout') ? $(this).data('transformoriginout').split(' ') : ls.lt.transformOriginOut; 2886 for(var t =0;t<too.length;t++){ 2887 if( too[t].indexOf('%') === -1 && too[t].indexOf('left') !== -1 && too[t].indexOf('right') !== -1 && too[t].indexOf('top') !== -1 && too[t].indexOf('bottom') !== -1 ){ 2888 too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px'; 2889 } 2890 } 2891 var curSubTransformOrigin = too.join(' '); 2892 var curSubPerspective = $(this).data('perspectiveout') ? $(this).data('perspectiveout') : ls.lt.perspectiveOut; 2893// } 2894 2895 // IMPROVEMENT v4.0 Distance (P.level): -1 2896 2897 var endLeft = parseInt( $(this).css('left') ); 2898 var endTop = parseInt( $(this).css('top') ); 2899 2900 var curSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] ); 2901 2902 var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight(); 2903 var modX = parseInt( curSubRotate ) === 0 ? $(this).outerWidth() : wh; 2904 var modY = parseInt( curSubRotate ) === 0 ? $(this).outerHeight() : wh; 2905 2906 if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetxout') === 'left' || $(this).data('offsetxout') === 'right' ) ){ 2907 if( lml < 0 ){ 2908 lml = - ( ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100 ); 2909 }else if( lml > 0 ){ 2910 lml = endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100; 2911 } 2912 }else{ 2913 lml = lml * ls.g.ratio; 2914 } 2915 2916 if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( $(this).data('offsetyout') === 'top' || $(this).data('offsetyout') === 'bottom' ) ){
2917 if( lmt < 0 ){ 2918 lmt = - ( ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100 ); 2919 }else if( lmt > 0 ){ 2920 lmt = endTop + ( curSubScaleY / 2 + .5 ) * modY + 100; 2921 } 2922 }else{ 2923 lmt = lmt * ls.g.ratio; 2924 } 2925 2926 if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){ 2927 var curSubPar = 1; 2928 }else{ 2929 var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut; 2930 var curSubPar = curSubPLevel * curSubParMod; 2931 } 2932 2933 if( $(this).data('transitiontype') === 'new' ){ 2934 var deO = ls.lt.delayOut; 2935 var duO = ls.lt.durationOut; 2936 var eO = ls.lt.easingOut; 2937 }else{ 2938 var deO = ls.o.delayOut; 2939 var duO = ls.o.durationOut; 2940 var eO = ls.o.easingOut; 2941 } 2942 2943 var curSubDelay = $(this).data('delayout') ? parseInt($(this).data('delayout')) : deO; 2944 var curSubTime = $(this).data('durationout') ? parseInt($(this).data('durationout')) : duO; 2945 var curSubEasing = $(this).data('easingout') ? $(this).data('easingout') : eO; 2946 2947 // On new layer transitions, all sublayer will be slide / fade out in 500ms without any delays 2948 2949 if(sublayersDurationOut){ 2950 curSubDelay = 0; 2951 curSubTime = sublayersDurationOut; 2952 // curSubEasing = 'easeInExpo'; 2953 } 2954 2955 // Clearing showUntilTimers 2956 2957 if( $(this).data('showUntilTimer') ){ 2958 clearTimeout( $(this).data('showUntilTimer') ); 2959 } 2960 2961 var css = { 2962 visibility : 'hidden' 2963 }; 2964 2965 var el = $(this); 2966 2967 var transition = { 2968 rotation : curSubRotate, 2969 rotationX : curSubRotateX, 2970 rotationY : curSubRotateY, 2971 skewX : curSubSkewX, 2972 skewY : curSubSkewY, 2973 scaleX : curSubScaleX, 2974 scaleY : curSubScaleY, 2975 x : -lml * curSubPar, 2976 y : -lmt * curSubPar, 2977 delay : curSubDelay/1000, 2978 ease : lsConvertEasing( curSubEasing ), 2979 onComplete : function(){ 2980 el.css( css ); 2981 } 2982 }; 2983 2984 if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir === 'fade' ) || ( $(this).data('fadeout') !== 'false' && $(this).data('transitiontype') === 'new' ) ){ 2985 transition['opacity'] = 0; 2986 css['opacity'] = $(this).data( 'originalOpacity' ); 2987 } 2988 2989 if( $(this).data('tr') ){ 2990 $(this).data('tr').kill(); 2991 } 2992 2993 TweenLite.set( $(this)[0],{ 2994 transformOrigin : curSubTransformOrigin, 2995 transformPerspective : curSubPerspective 2996 }); 2997 2998 $(this).data('tr', TweenLite.to($(this)[0],curSubTime/1000,transition) ); 2999 3000 // $(this).stop(true,false).delay( curSubDelay ).animate( transition, curSubTime, curSubEasing,function(){ 3001 // $(this).css( css ); 3002 // }); 3003 }); 3004 }; 3005 3006 var nextLayer = function(){ 3007 3008 ls.g.nextLayer.delay( curDelay + nextDelay ).animate({ 3009 width : ls.g.sliderWidth(), 3010 height : ls.g.sliderHeight() 3011 }, nextDuration, nextEasing ); 3012 }; 3013 3014 var nextSubLayers = function(){ 3015 3016 if( ls.g.totalDuration ){ 3017 curDelay = 0; 3018 } 3019 3020 // Needed for the Timeline 3021 if( typeof ls.o.cbTimeLineStart === 'function' ){ 3022 ls.o.cbTimeLineStart(ls.g, curDelay+nextDelay ); 3023 } 3024 3025 ls.g.nextLayer.find(' > *[class*="ls-l"]').each(function(){ 3026 3027 // Replacing global parameters with unique if need 3028 // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties 3029 3030 if( !$(this).data('transitiontype') ){ 3031 ls.transitionType( $(this) ); 3032 } 3033 3034 if( $(this).data('transitiontype') === 'new' ){ 3035 var nextSubSlideDir = 'new'; 3036 }else{ 3037 var nextSubSlideDir = $(this).data('slidedirection') ? $(this).data('slidedirection') : slideDirection; 3038 } 3039 var lml, lmt; 3040 3041 switch(nextSubSlideDir){ 3042 case 'left': 3043 lml = -ls.g.sliderWidth(); 3044 lmt = 0; 3045 break; 3046 case 'right': 3047 lml = ls.g.sliderWidth(); 3048 lmt = 0; 3049 break; 3050 case 'top': 3051 lmt = -ls.g.sliderHeight(); 3052 lml = 0; 3053 break; 3054 case 'bottom': 3055 lmt = ls.g.sliderHeight(); 3056 lml = 0; 3057 break; 3058 case 'fade': 3059 lmt = 0; 3060 lml = 0; 3061 break; 3062 case 'new': 3063 if( $(this).data('offsetxin') ){ 3064 if( $(this).data('offsetxin') === 'left' ){ 3065 lml = -ls.g.sliderWidth(); 3066 }else if( $(this).data('offsetxin') === 'right' ){ 3067 lml = ls.g.sliderWidth(); 3068 }else{ 3069 lml = parseInt( $(this).data('offsetxin') ); 3070 } 3071 }else{ 3072 lml = ls.lt.offsetXIn; 3073 } 3074 if( $(this).data('offsetyin') ){ 3075 if( $(this).data('offsetyin') === 'top' ){ 3076 lmt = -ls.g.sliderHeight(); 3077 }else if( $(this).data('offsetyin') === 'bottom' ){ 3078 lmt = ls.g.sliderHeight(); 3079 }else{ 3080 lmt = parseInt( $(this).data('offsetyin') ); 3081 } 3082 }else{ 3083 lmt = ls.lt.offsetYIn; 3084 } 3085 break; 3086 } 3087 3088 // NEW FEATURE v4.5.0 Rotating & Scaling sublayers 3089 // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2) 3090 // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions 3091 3092 var nextSubRotate = nextSubRotateX = nextSubRotateY = nextSubScale = nextSubSkewX
3092= nextSubSkewY = nextSubScaleX = nextSubScaleY = 'none'; 3093// if( !ls.g.ie78 && ls.g.enableCSS3 ){ 3094 nextSubRotate = $(this).data('rotatein') ? $(this).data('rotatein') : ls.lt.rotateIn; 3095 nextSubRotateX = $(this).data('rotatexin') ? $(this).data('rotatexin') : ls.lt.rotateXIn; 3096 nextSubRotateY = $(this).data('rotateyin') ? $(this).data('rotateyin') : ls.lt.rotateYIn; 3097 nextSubScale = $(this).data('scalein') ? $(this).data('scalein') : ls.lt.scaleIn; 3098 nextSubSkewX = $(this).data('skewxin') ? $(this).data('skewxin') : ls.lt.skewXIn; 3099 nextSubSkewY = $(this).data('skewyin') ? $(this).data('skewyin') : ls.lt.skewYIn; 3100 if( nextSubScale === 1 ){ 3101 nextSubScaleX = $(this).data('scalexin') ? $(this).data('scalexin') : ls.lt.scaleXIn; 3102 nextSubScaleY = $(this).data('scaleyin') ? $(this).data('scaleyin') : ls.lt.scaleYIn; 3103 }else{ 3104 nextSubScaleX = nextSubScaleY = nextSubScale; 3105 } 3106 3107 var toi = $(this).data('transformoriginin') ? $(this).data('transformoriginin').split(' ') : ls.lt.transformOriginIn; 3108 for(var t =0;t<toi.length;t++){ 3109 if( toi[t].indexOf('%') === -1 && toi[t].indexOf('left') !== -1 && toi[t].indexOf('right') !== -1 && toi[t].indexOf('top') !== -1 && toi[t].indexOf('bottom') !== -1 ){ 3110 toi[t] = '' + parseInt( toi[t] ) * ls.g.ratio + 'px'; 3111 } 3112 } 3113 var nextSubTransformOrigin = toi.join(' '); 3114 var nextSubPerspective = $(this).data('perspectivein') ? $(this).data('perspectivein') : ls.lt.perspectiveIn; 3115// } 3116 3117 // IMPROVEMENT v4.0 Distance (P.level): -1 3118 3119 var endLeft = parseInt( $(this).css('left') ); 3120 var endTop = parseInt( $(this).css('top') ); 3121 3122 var nextSubPLevel = parseInt( $(this).attr('class').split('ls-l')[1] ); 3123 3124 // BUGFIX v5.0.1 Fixed the starting position of layers with percentage value of width 3125 3126 if( $(this)[0].style.width.indexOf('%') !== -1 ){ 3127 $(this).css({ 3128 width: ls.g.sliderWidth() / 100 * parseInt( $(this)[0].style.width ) 3129 }); 3130 } 3131 3132 var wh = $(this).outerWidth() > $(this).outerHeight() ? $(this).outerWidth() : $(this).outerHeight(); 3133 var modX = parseInt( nextSubRotate ) === 0 ? $(this).outerWidth() : wh; 3134 var modY = parseInt( nextSubRotate ) === 0 ? $(this).outerHeight() : wh; 3135 3136 // console.log( modX, $(this).outerWidth(), $(this).width(), $(this).height(), $(this)[0].style.width, $(this).outerHeight(), wh ); 3137 3138 if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetxin') === 'left' || $(this).data('offsetxin') === 'right' ) ){ 3139 if( lml < 0 ){ 3140 lml = - ( endLeft + ( nextSubScaleX / 2 + .5 ) * modX + 100 ); 3141 }else if( lml > 0 ){ 3142 lml = ls.g.sliderWidth() - endLeft + ( nextSubScaleX / 2 - .5 ) * modX + 100; 3143 } 3144 }else{ 3145 lml = lml * ls.g.ratio; 3146 } 3147 3148 if( ( nextSubPLevel === -1 && nextSubSlideDir !== 'new' ) || ( $(this).data('offsetyin') === 'top' || $(this).data('offsetyin') === 'bottom' ) ){ 3149 3150 if( lmt < 0 ){ 3151 lmt = - ( endTop + ( nextSubScaleY / 2 + .5 ) * modY + 100 ); 3152 }else if( lmt > 0 ){ 3153 lmt = ls.g.sliderHeight() - endTop + ( nextSubScaleY / 2 - .5 ) * modY + 100; 3154 } 3155 }else{ 3156 lmt = lmt * ls.g.ratio; 3157 } 3158 3159 if( nextSubPLevel === -1 || nextSubSlideDir === 'new'){ 3160 var nextSubPar = 1; 3161 }else{ 3162 var nextSubParMod = ls.g.nextLayer.data('parallaxin') ? parseInt(ls.g.nextLayer.data('parallaxin')) : ls.o.parallaxIn; 3163 var nextSubPar = nextSubPLevel * nextSubParMod; 3164 } 3165 3166 if( $(this).data('transitiontype') === 'new' ){ 3167 var deI = ls.lt.delayIn; 3168 var duI = ls.lt.durationIn; 3169 var eI = ls.lt.easingIn; 3170 }else{ 3171 var deI = ls.o.delayIn; 3172 var duI = ls.o.durationIn; 3173 var eI = ls.o.easingIn; 3174 } 3175 3176 var nextSubDelay = $(this).data('delayin') ? parseInt($(this).data('delayin')) : deI; 3177 var nextSubTime = $(this).data('durationin') ? parseInt($(this).data('durationin')) : duI; 3178 var nextSubEasing = $(this).data('easingin') ? $(this).data('easingin') : eI; 3179 3180 var cursub = $(this); 3181 3182 var nextSubCallback = function(){ 3183 3184 // BUGFIX v5.1.0 Removing transition property from video layers 3185 3186 if( cursub.hasClass('ls-video-layer') ){ 3187 cursub.addClass('ls-videohack'); 3188 } 3189 3190 // NEW FEATURE v2.0 autoPlayVideos 3191 3192 if( ls.o.autoPlayVideos == true ){ 3193 3194 cursub.find('.ls-videopreview, video, audio').click(); 3195 } 3196 3197 // NEW FEATURE v3.0 showUntil sublayers 3198 3199 if( cursub.data('showuntil') > 0 ){ 3200 3201 // IMPROVEMENT v4.5.0 sublayerShowUntil will be called anly if necessary 3202 3203 cursub.data('showUntilTimer', setTimeout(function(){ 3204 ls.sublayerShowUntil( cursub ); 3205 }, cursub.data('showuntil') )); 3206 } 3207 }; 3208 3209 $(this).css({ 3210 marginLeft : 0, 3211 marginTop : 0 3212 }); 3213 3214 var css = { 3215 scaleX : nextSubScaleX, 3216 scaleY : nextSubScaleY, 3217 skewX : nextSubSkewX, 3218 skewY : nextSubSkewY, 3219 rotation : nextSubRotate, 3220 rotationX : nextSubRotateX, 3221 rotationY : nextSubRotateY, 3222 visibility : 'visible', 3223 x : lml * nextSubPar, 3224 y : lmt * nextSubPar 3225 }; 3226 3227 var transition = { 3228 rotation : 0, 3229 rotationX : 0, 3230 rotationY : 0, 3231 skewX : 0, 3232 skewY : 0, 3233 scaleX : 1, 3234 scaleY : 1, 3235 ease : lsConvertEasing( nextSubEasing ), 3236 delay : nextSubDelay/1000, 3237 x : 0, 3238 y : 0, 3239 onComplete : function(){ 3240 nextSubCallback(); 3241 } 3242 }; 3243 3244 if( nextSubSlideDir.indexOf('fade') != -1 || ( $(this).data('fadein') !== 'false' && $(this).data('transitiontype') === 'new' ) ){ 3245 css['opacity'] = 0; 3246 transition['opacity'] = $(this).data( 'originalOpacity' ); 3247 } 3248 3249 // $(this).css( css ); 3250 3251 // $(this).stop().delay( curDelay + nextDelay + nextSubDelay ).animate( transition, nextSubTime, nextSubEasing, function(){ 3252 // if( ls.g.ie78 & $(this).data( 'originalOpacity') === 1 ){ 3253 // $(this).get(0).style.removeAttribute('filter'); 3254 // } 3255 // nextSubCallback(); 3256 // }); 3257 3258 if( $(this).data('tr') ){ 3259 $(this).data('tr').kill(); 3260 } 3261 3262 TweenLite.set( $(this)[0],{ 3263 transformPerspective : nextSubPerspective, 3264 transformOrigin : nextSubTransformOrigin 3265 }); 3266 3267 $(this).data('tr', TweenLite.fromTo($(this)[0],nextSubTime/1000,css,transition) ); 3268 }); 3269 }; 3270 3271 /* NEW FEATURE v4.0 2D & 3D Layer Transitions */ 3272 3273 // Selecting ONE transition (random) 3274 // If the browser doesn't support CSS3 3D, 2D fallback mode will be used instead 3275 // In this case, if user didn't specify any 2D transitions, a random will be selected 3276 3277 var selectTransition = function(){ 3278 3279 // if the browser supports CSS3 3D and user specified at least one of 3D transitions 3280 3281 if( lsSupport3D( $(el) ) && ( ls.g.nextLayer.data('transition3d') || ls.g.nextLayer.data('customtransition3d') ) ){ 3282 3283 if( ls.g.nextLayer.data('transition3d') && ls.g.nextLayer.data('customtransition3d') ){ 3284 var rnd = Math.floor(Math.random() * 2); 3285 var rndT = [['3d',ls.g.nextLayer.data('transition3d')],['custom3d',ls.g.nextLayer.data('customtransition3d')]]; 3286 getTransitionType(rndT[rnd][0],rndT[rnd][1]); 3287 }else if( ls.g.nextLayer.data('transition3d') ){ 3288 getTransitionType('3d',ls.g.nextLayer.data('transition3d')); 3289 }else{ 3290 getTransitionType('custom3d',ls.g.nextLayer.data('customtransition3d')); 3291 } 3292 3293 }else{ 3294 3295 if( ls.g.nextLayer.data('transition2d') && ls.g.nextLayer.data('customtransition2d') ){ 3296 var rnd = Math.floor(Math.random() * 2); 3297 var rndT = [['2d',ls.g.nextLayer.data('transition2d')],['custom2d',ls.g.nextLayer.data('customtransition2d')]]; 3298 getTransitionType(rndT[rnd][0],rndT[rnd][1]); 3299 }else if( ls.g.nextLayer.data('transition2d') ){ 3300 getTransitionType('2d',ls.g.nextLayer.data('transition2d')); 3301 }else if( ls.g.nextLayer.data('customtransition2d') ){ 3302 getTransitionType('custom2d',ls.g.nextLayer.data('customtransition2d')); 3303 }else{ 3304 getTransitionType('2d','1'); 3305 } 3306 } 3307 }; 3308 3309 // Needed by the demo page 3310 3311 var selectCustomTransition = function(){ 3312 3313 if( lsSupport3D( $(el) ) && LSCustomTransition.indexOf('3d') != -1 ){
3314 getTransitionType('3d',LSCustomTransition.split(':')[1]); 3315 }else{ 3316 if( LSCustomTransition.indexOf('3d') != -1){ 3317 getTransitionType('2d','all'); 3318 }else{ 3319 getTransitionType('2d',LSCustomTransition.split(':')[1]); 3320 } 3321 } 3322 }; 3323 3324 // Choosing layer transition type (2d, 3d, or both) 3325 3326 var getTransitionType = function(type,transitionlist){ 3327 3328 var tr = type.indexOf('custom') == -1 ? ls.t : ls.ct; 3329 var tt = '3d', lt, number; 3330 3331 if( type.indexOf('2d') != -1 ){ 3332 tt = '2d'; 3333 } 3334 3335 if( transitionlist.indexOf('last') != -1 ){ 3336 number = tr['t'+tt].length-1; 3337 lt = 'last'; 3338 }else if( transitionlist.indexOf('all') != -1){ 3339 number = Math.floor(Math.random() * lsCountProp(tr['t'+tt]) ); 3340 lt = 'random from all'; 3341 }else{ 3342 var t = transitionlist.split(','); 3343 var l = t.length; 3344 number = parseInt(t[Math.floor(Math.random() * l)])-1; 3345 lt = 'random from specified'; 3346 } 3347 3348 slideTransition(tt,tr['t'+tt][number]); 3349 3350// $('.test').html('Originals:<br><br>t3D: '+ls.g.nextLayer.data('transition3d')+'<br>t2D: '+ls.g.nextLayer.data('transition2d')+'<br>custom3D: '+ls.g.nextLayer.data('customtransition3d')+'<br>custom2D: '+ls.g.nextLayer.data('customtransition2d')+'<br><br>Support 3D: '+lsSupport3D( $(el) )+'<br><br>Selected transition:<br><br>Type: '+type+' ('+lt+')<br>Number in transition list: '+(number+1)+'<br>Name of the transition: '+tr['t'+tt][number]['name']); 3351 }; 3352 3353 // The slideTransition function 3354 3355 var slideTransition = function(type,prop){ 3356 3357 var inner = $(el).find('.ls-inner'); 3358 3359 // sublayersDurationOut - for future usage 3360 3361 var sublayersDurationOut = ls.g.curLayer.find('*[class*="ls-l"]').length > 0 ? 1000 : 0; 3362 3363 // Detecting a carousel transition - Transition name must have the carousel string 3364 3365 var carousel = prop.name.toLowerCase().indexOf('carousel') == -1 ? false : true; 3366 3367 // Detecting a crossfade transition - Transition name must have the crossfad string 3368 3369 var crossfade = prop.name.toLowerCase().indexOf('crossfad') == -1 ? false : true; 3370 3371 // Calculating cols and rows 3372 3373 var cols = typeof(prop.cols); 3374 var rows = typeof(prop.rows); 3375 3376 switch( cols ){ 3377 case 'number': 3378 cols = prop.cols; 3379 break; 3380 case 'string': 3381 cols = Math.floor( Math.random() * ( parseInt( prop.cols.split(',')[1] ) - parseInt( prop.cols.split(',')[0] ) + 1) ) + parseInt( prop.cols.split(',')[0] ); 3382 break; 3383 default: 3384 cols = Math.floor( Math.random() * ( prop.cols[1] - prop.cols[0] + 1) ) + prop.cols[0]; 3385 break; 3386 } 3387 3388 switch( rows ){ 3389 case 'number': 3390 rows = prop.rows; 3391 break; 3392 case 'string': 3393 rows = Math.floor( Math.random() * ( parseInt( prop.rows.split(',')[1] ) - parseInt( prop.rows.split(',')[0] ) + 1) ) + parseInt( prop.rows.split(',')[0] ); 3394 break; 3395 default: 3396 rows = Math.floor( Math.random() * ( prop.rows[1] - prop.rows[0] + 1) ) + prop.rows[0]; 3397 break; 3398 } 3399 3400 if( ( ls.g.isMobile() == true && ls.o.optimizeForMobile == true ) || ( ls.g.ie78 && ls.o.optimizeForIE78 == true ) ){ 3401 3402 // Reducing cols in three steps 3403 3404 if( cols >= 15 ){ 3405 cols = 7; 3406 }else if( cols >= 5 ){ 3407 cols = 4; 3408 }else if( cols >= 4 ){ 3409 cols = 3; 3410 }else if( cols > 2 ){ 3411 cols = 2; 3412 } 3413 3414 // Reducing rows in three steps 3415 3416 if( rows >= 15 ){ 3417 rows = 7; 3418 }else if( rows >= 5 ){ 3419 rows = 4; 3420 }else if( rows >= 4 ){ 3421 rows = 3; 3422 }else if( rows > 2 ){ 3423 rows = 2; 3424 } 3425 3426 // Reducing more :) 3427 3428 if( rows > 2 && cols > 2 ){ 3429 rows = 2; 3430 if( cols > 4){ 3431 cols = 4; 3432 } 3433 } 3434 } 3435 3436 var tileWidth = $(el).find('.ls-inner').width() / cols; 3437 var tileHeight = $(el).find('.ls-inner').height() / rows; 3438 3439 // Creating HTML markup for layer transitions 3440 3441 if( !ls.g.ltContainer ){
3442 ls.g.ltContainer = $('<div>').addClass('ls-lt-container').addClass('ls-overflow-hidden').css({ 3443 width : inner.width(), 3444 height : inner.height() 3445 }).prependTo( inner ); 3446 }else{ 3447 ls.g.ltContainer.stop(true,true).empty().css({ 3448 display : 'block', 3449 width : inner.width(), 3450 height : inner.height() 3451 }); 3452 } 3453 3454 // Setting size 3455 3456 var restW = inner.width() - Math.floor(tileWidth) * cols; 3457 var restH = inner.height() - Math.floor(tileHeight) * rows; 3458 3459 var tileSequence = []; 3460 3461 // IMPROVEMENT v4.1.3 Array-randomizer is now a local function 3462 // Randomize array function 3463 3464 tileSequence.randomize = function() { 3465 var i = this.length, j, tempi, tempj; 3466 if ( i == 0 ) return false; 3467 while ( --i ) { 3468 j = Math.floor( Math.random() * ( i + 1 ) ); 3469 tempi = this[i]; 3470 tempj = this[j]; 3471 this[i] = tempj; 3472 this[j] = tempi; 3473 } 3474 return this; 3475 } 3476 3477 for(var ts=0; ts<cols * rows; ts++){ 3478 tileSequence.push(ts); 3479 } 3480 3481 // Setting the sequences of the transition 3482 3483 switch( prop.tile.sequence ){ 3484 case 'reverse': 3485 tileSequence.reverse(); 3486 break; 3487 case 'col-forward': 3488 tileSequence = lsOrderArray(rows,cols,'forward'); 3489 break; 3490 case 'col-reverse': 3491 tileSequence = lsOrderArray(rows,cols,'reverse'); 3492 break; 3493 case 'random': 3494 tileSequence.randomize(); 3495 break; 3496 } 3497 3498 var curBG = ls.g.curLayer.find('.ls-bg'); 3499 var nextBG = ls.g.nextLayer.find('.ls-bg'); 3500 3501 // IMPROVEMENT v4.6.0 If current and next layer both have no BG, skipping the slide transition 3502 3503 if( curBG.length == 0 && nextBG.length == 0 ){ 3504 type = '2d'; 3505 prop = $.extend(true, {}, ls.t['t2d'][0]); 3506 prop.transition.duration = 1 3507 prop.tile.delay = 0; 3508 } 3509 3510 if( type == '3d' ){ 3511 ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay; 3512 3513 var stepDuration = 0; 3514 3515 if( prop.before && prop.before.duration ){ 3516 stepDuration += prop.before.duration; 3517 } 3518 if( prop.animation && prop.animation.duration ){ 3519 stepDuration += prop.animation.duration; 3520 } 3521 if( prop.after && prop.after.duration ){ 3522 stepDuration += prop.after.duration; 3523 } 3524 3525 ls.g.totalDuration += stepDuration; 3526 3527 var stepDelay = 0; 3528 3529 if( prop.before && prop.before.delay ){ 3530 stepDelay += prop.before.delay; 3531 } 3532 if( prop.animation && prop.animation.delay ){ 3533 stepDelay += prop.animation.delay; 3534 } 3535 if( prop.after && prop.after.delay ){ 3536 stepDelay += prop.after.delay; 3537 } 3538 3539 ls.g.totalDuration += stepDelay; 3540 3541 }else{ 3542 ls.g.totalDuration = ((cols * rows) - 1) * prop.tile.delay + prop.transition.duration; 3543 3544 // IMPROVEMENT v4.5.0 Creating separated containers for current and next tiles 3545 3546 ls.g.curTiles = $('<div>').addClass('ls-curtiles').appendTo( ls.g.ltContainer ); 3547 ls.g.nextTiles = $('<div>').addClass('ls-nexttiles').appendTo( ls.g.ltContainer ); 3548 } 3549 3550 var pn = ls.g.prevNext; 3551 3552 // Creating cuboids for 3d or tiles for 2d transition (cols * rows) 3553 3554 for(var tiles=0; tiles < cols * rows; tiles++){ 3555 3556 var rW = tiles%cols == 0 ? restW : 0; 3557 var rH = tiles > (rows-1)*cols-1 ? restH : 0; 3558 3559 var tile = $('<div>').addClass('ls-lt-tile').css({ 3560 width : Math.floor(tileWidth) + rW, 3561 height : Math.floor(tileHeight) + rH 3562 }).appendTo( ls.g.ltContainer ); 3563 3564 var curTile, nextTile; 3565 3566 // If current transition is a 3d transition 3567 3568 if( type == '3d' ){ 3569 3570 tile.addClass('ls-3d-container'); 3571 3572 var W = Math.floor(tileWidth) + rW; 3573 var H = Math.floor(tileHeight) + rH; 3574 var D; 3575 3576 if( prop.animation.direction == 'horizontal' ){ 3577 if( Math.abs(prop.animation.transition.rotateY) > 90 && prop.tile.depth != 'large' ){ 3578 D = Math.floor( W / 7 ) + rW; 3579 }else{ 3580 D = W; 3581 } 3582 }else{ 3583 if( Math.abs(prop.animation.transition.rotateX) > 90 && prop.tile.depth != 'large' ){ 3584 D = Math.floor( H / 7 ) + rH; 3585 }else{ 3586 D = H; 3587 } 3588 } 3589 3590 var W2 = W/2; 3591 var H2 = H/2; 3592 var D2 = D/2; 3593 3594 // createCuboids function will append cuboids with their style settings to their container 3595 3596 var createCuboids = function(c,a,w,h,tx,ty,tz,rx,ry){ 3597 $('<div>').addClass(c).css({ 3598 width: w, 3599 height: h, 3600 '-o-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)', 3601 '-ms-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)', 3602 '-moz-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)', 3603 '-webkit-transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)', 3604 'transform': 'translate3d('+tx+'px, '+ty+'px, '+tz+'px) rotateX('+rx+'deg) rotateY('+ry+'deg) rotateZ(0deg) scale3d(1, 1, 1)' 3605 }).appendTo(a); 3606 }; 3607 3608 createCuboids('ls-3d-box',tile,0,0,0,0,-D2,0,0); 3609 3610 var backRotX = 0 3611 var topRotX = 0 3612 var bottomRotX = 0 3613 3614 if( prop.animation.direction == 'vertical' && Math.abs(prop.animation.transition.rotateX) > 90){ 3615 createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,180,0); 3616 }else{ 3617 createCuboids('ls-3d-back',tile.find('.ls-3d-box'),W,H,-W2,-H2,-D2,0,180); 3618 } 3619 3620 createCuboids('ls-3d-bottom',tile.find('.ls-3d-box'),W,D,-W2,H2-D2,0,-90,0
3620); 3621 createCuboids('ls-3d-top',tile.find('.ls-3d-box'),W,D,-W2,-H2-D2,0,90,0); 3622 createCuboids('ls-3d-front',tile.find('.ls-3d-box'),W,H,-W2,-H2,D2,0,0); 3623 createCuboids('ls-3d-left',tile.find('.ls-3d-box'),D,H,-W2-D2,-H2,0,0,-90); 3624 createCuboids('ls-3d-right',tile.find('.ls-3d-box'),D,H,W2-D2,-H2,0,0,90); 3625 3626 curTile = tile.find('.ls-3d-front'); 3627 3628 if( prop.animation.direction == 'horizontal' ){ 3629 if( Math.abs(prop.animation.transition.rotateY) > 90 ){ 3630 nextTile = tile.find('.ls-3d-back'); 3631 }else{ 3632 nextTile = tile.find('.ls-3d-left, .ls-3d-right'); 3633 } 3634 }else{ 3635 if( Math.abs(prop.animation.transition.rotateX) > 90 ){ 3636 nextTile = tile.find('.ls-3d-back'); 3637 }else{ 3638 nextTile = tile.find('.ls-3d-top, .ls-3d-bottom'); 3639 } 3640 } 3641 3642 // Animating cuboids 3643 3644 var curCubDelay = tileSequence[tiles] * prop.tile.delay; 3645 3646 var curCub = ls.g.ltContainer.find('.ls-3d-container:eq('+tiles+') .ls-3d-box'); 3647 3648 var tl = new TimelineLite(); 3649 3650 if( prop.before && prop.before.transition ){ 3651 prop.before.transition.delay = prop.before.transition.delay ? (prop.before.transition.delay + curCubDelay)/1000 : curCubDelay/1000; 3652 tl.to( curCub[0],prop.before.duration/1000,lsConvertTransition( prop.before.transition, prop.before.easing )); 3653 }else{ 3654 prop.animation.transition.delay = prop.animation.transition.delay ? (prop.animation.transition.delay + curCubDelay)/1000 : curCubDelay/1000; 3655 } 3656 3657 tl.to( curCub[0],prop.animation.duration/1000,lsConvertTransition( prop.animation.transition, prop.animation.easing )); 3658 3659 if( prop.after ){ 3660 if( !prop.after.transition ){ 3661 prop.after.transition = {}; 3662 } 3663 tl.to( curCub[0],prop.after.duration/1000,lsConvertTransition( prop.after.transition, prop.after.easing, 'after' )); 3664 } 3665 3666 }else{ 3667 3668 // If current transition is a 2d transition 3669 3670 var T1 = L1 = T2 = L2 = 'auto'; 3671 var O1 = O2 = 1; 3672 3673 if( prop.transition.direction == 'random' ){ 3674 var dir = ['top','bottom','right','left']; 3675 var direction = dir[Math.floor(Math.random() * dir.length )]; 3676 }else{ 3677 var direction = prop.transition.direction; 3678 } 3679 3680 // IMPROVEMENT v4.5.0 Reversing animation directions if slider is moving backwards 3681 3682 if( prop.name.toLowerCase().indexOf('mirror') != -1 && tiles%2 == 0 ){ 3683 if( pn == 'prev' ){ 3684 pn = 'next'; 3685 }else{ 3686 pn = 'prev'; 3687 } 3688 } 3689 3690 if( pn == 'prev' ){ 3691 3692 switch( direction ){ 3693 case 'top': 3694 direction = 'bottom'; 3695 break; 3696 case 'bottom': 3697 direction = 'top'; 3698 break; 3699 case 'left': 3700 direction = 'right'; 3701 break; 3702 case 'right': 3703 direction = 'left'; 3704 break; 3705 case 'topleft': 3706 direction = 'bottomright'; 3707 break; 3708 case 'topright': 3709 direction = 'bottomleft'; 3710 break; 3711 case 'bottomleft': 3712 direction = 'topright'; 3713 break; 3714 case 'bottomright': 3715 direction = 'topleft'; 3716 break; 3717 } 3718 } 3719 3720 switch( direction ){ 3721 case 'top': 3722 T1 = T2 = -tile.height(); 3723 L1 = L2 = 0; 3724 break; 3725 case 'bottom': 3726 T1 = T2 = tile.height(); 3727 L1 = L2 = 0; 3728 break; 3729 case 'left': 3730 T1 = T2 = 0; 3731 L1 = L2 = -tile.width(); 3732 break; 3733 case 'right': 3734 T1 = T2 = 0; 3735 L1 = L2 = tile.width(); 3736 break; 3737 case 'topleft': 3738 T1 = tile.height(); 3739 T2 = 0; 3740 L1 = tile.width(); 3741 L2 = 0; 3742 break; 3743 case 'topright': 3744 T1 = tile.height(); 3745 T2 = 0; 3746 L1 = - tile.width(); 3747 L2 = 0; 3748 break; 3749 case 'bottomleft': 3750 T1 = - tile.height(); 3751 T2 = 0; 3752 L1 = tile.width(); 3753 L2 = 0; 3754 break; 3755 case 'bottomright': 3756 T1 = - tile.height(); 3757 T2 = 0; 3758 L1 = - tile.width(); 3759 L2 = 0; 3760 break; 3761 } 3762 3763 ls.g.scale2D = prop.transition.scale ? prop.transition.scale : 1; 3764 3765 if( carousel == true && ls.g.scale2D != 1 ){ 3766 3767 T1 = T1 / 2; 3768 T2 = T2 / 2; 3769 L1 = L1 / 2; 3770 L2 = L2 / 2; 3771 } 3772 3773 // Selecting the type of the transition 3774 3775// if( !ls.g.ie78 || ( ls.g.ie78 && !ls.o.optimizeForIE78 ) || ( ls.g.ie78 && ls.o.optimizeForIE78 == true && prop.name.toLowerCase().indexOf('crossfade') != -1 ) ){ 3776 switch( prop.transition.type ){ 3777 case 'fade': 3778 T1 = T2 = L1 = L2 = 0; 3779 O1 = 0; 3780 O2 = 1; 3781 break; 3782 case 'mixed': 3783 O1 = 0; 3784 O2 = 1; 3785 if( ls.g.scale2D == 1 ){ 3786 T2 = L2 = 0; 3787 } 3788 break; 3789 } 3790// } 3791 3792 // IMPROVEMENT v4.5.0 Implemented Rotation and Scale into 2D Transitions 3793 3794 if((( prop.transition.rotate || prop.transition.rotateX || prop.transition.rotateY ) || ls.g.scale2D != 1 ) && !ls.g.ie78 && prop.transition.type != 'slide' ){ 3795 tile.css({ 3796 overflow : 'visible' 3797 }); 3798 }else{ 3799 tile.css({ 3800 overflow : 'hidden' 3801 }); 3802 } 3803 3804 if( carousel == true){ 3805 ls.g.curTiles.css({ 3806 overflow: 'visible' 3807 }); 3808 }else{ 3809 ls.g.curTiles.css({ 3810 overflow: 'hidden' 3811 }); 3812 } 3813 3814 if( crossfade == true || prop.transition.type == 'slide' || carousel == true ){ 3815 var tileInCur = tile.appendTo( ls.g.curTiles ); 3816 var tileInNext = tile.clone().appendTo( ls.g.nextTiles ); 3817 curTile = $('<div>').addClass('ls-curtile').appendTo( tileInCur ); 3818 }else{ 3819 var tileInNext = tile.appendTo( ls.g.nextTiles ); 3820 } 3821 3822 nextTile = $('<div>').addClass('ls-nexttile').appendTo( tileInNext ).css({ 3823 top : -T1, 3824 left : -L1, 3825 dispay : 'block', 3826 opacity : O1 3827 }); 3828 3829 // Animating tiles 3830
3831 var curTileDelay = tileSequence[tiles] * prop.tile.delay; 3832 3833 // IMPROVEMENT v4.5.0 Implemented various types of rotations into 2D Transitions 3834 3835 var r = prop.transition.rotate ? prop.transition.rotate : 0; 3836 var rX = prop.transition.rotateX ? prop.transition.rotateX : 0; 3837 var rY = prop.transition.rotateY ? prop.transition.rotateY : 0; 3838 3839 // Reversing rotation degrees if slider is moving backwards 3840 3841 if( pn == 'prev' ){ 3842 r = -r; 3843 rX = -rX; 3844 rY = -rY; 3845 } 3846 3847 TweenLite.fromTo(nextTile[0],prop.transition.duration/1000,{ 3848 rotation : r, 3849 rotationX : rX, 3850 rotationY : rY, 3851 scale : ls.g.scale2D 3852 },{ 3853 delay : curTileDelay / 1000, 3854 top : 0, 3855 left : 0, 3856 opacity : O2, 3857 rotation : 0, 3858 rotationX : 0, 3859 rotationY : 0, 3860 scale : 1, 3861 ease : lsConvertEasing( prop.transition.easing ) 3862 }); 3863 3864 // IMPROVEMENT v5.0.0 Smart crossfading for semi-transparent PNG and different size JPG backgrounds 3865 3866 if( 3867 crossfade == true && ( 3868 nextBG.length < 1 || ( 3869 nextBG.length > 0 && ( 3870 nextBG.attr('src').toLowerCase().indexOf('png') != -1 || ( 3871 nextBG.width() < ls.g.sliderWidth() || nextBG.height() < ls.g.sliderHeight() 3872 ) 3873 ) 3874 ) 3875 ) 3876 ){ 3877 TweenLite.to(curTile[0],prop.transition.duration/1000,{ 3878 delay : curTileDelay / 1000, 3879 opacity : 0, 3880 ease : lsConvertEasing( prop.transition.easing ) 3881 }); 3882 } 3883 3884 if( ( prop.transition.type == 'slide' || carousel == true ) && prop.name.toLowerCase().indexOf('mirror') == -1 ){ 3885 3886 var r2 = 0; 3887 3888 if( r != 0 ){ 3889 r2 = -r; 3890 } 3891 3892 TweenLite.to(curTile[0],prop.transition.duration/1000,{ 3893 delay : curTileDelay / 1000, 3894 top : T2, 3895 left : L2, 3896 rotation : r2, 3897 scale : ls.g.scale2D, 3898 opacity: O1, 3899 ease : lsConvertEasing( prop.transition.easing ) 3900 }); 3901 } 3902 } 3903 3904 // Appending the background images of current and next layers into the tiles on both of 2d & 3d transitions 3905 // BUGFIX v5.0.0 added Math.floor to prevent '1px bug' under Safari and Firefox 3906 3907 if( curBG.length ){ 3908 if( type == '3d' || ( type == '2d' && ( crossfade == true || prop.transition.type == 'slide' || carousel == true ) ) ){ 3909 curTile.append($('<img>').attr('src', curBG.attr('src')).css({ 3910 width : curBG[0].style.width, 3911 height : curBG[0].style.height, 3912 marginLeft : parseFloat(curBG.css('margin-left')) - parseFloat(tile.position().left), 3913 marginTop : parseFloat(curBG.css('margin-top')) - parseFloat(tile.position().top) 3914 })); 3915 }else if( ls.g.curTiles.children().length == 0 ){ 3916 ls.g.curTiles.append($('<img>').attr('src', curBG.attr('src')).css({ 3917 width : curBG[0].style.width, 3918 height : curBG[0].style.height, 3919 marginLeft : parseFloat(curBG.css('margin-left')), 3920 marginTop : parseFloat(curBG.css('margin-top')) 3921 })); 3922 3923 } 3924 } 3925 3926 if( nextBG.length ){ 3927 nextTile.append($('<img>').attr('src', nextBG.attr('src') ).css({ 3928 width : nextBG[0].style.width, 3929 height : nextBG[0].style.height, 3930 marginLeft : parseFloat(nextBG.css('margin-left')) - parseFloat(tile.position().left), 3931 marginTop : parseFloat(nextBG.css('margin-top')) - parseFloat(tile.position().top) 3932 })); 3933 } 3934 } 3935 3936 // Storing current and next layer elements in a local variable (needed by setTimeout functions in some cases) 3937 3938 var curLayer = ls.g.curLayer; 3939 var nextLayer = ls.g.nextLayer; 3940 3941 // Hiding the background image of the current and next layers (immediately) 3942 3943 setTimeout(function(){ 3944 curLayer.find('.ls-bg').css({ 3945 visibility : 'hidden' 3946 }); 3947 },50); 3948 3949 nextLayer.find('.ls-bg').css({ 3950 visibility : 'hidden' 3951 }); 3952 ls.g.ltContainer.removeClass('ls-overflow-hidden'); 3953 3954 // Sliding out the sublayers of the current layer 3955 // (immediately, delay out and duration out properties are not applied to the sublayers during the new layer transitions) 3956 3957 curSubLayers(sublayersDurationOut); 3958 3959 // Hiding current layer after its sublayers animated out 3960 3961 setTimeout(function(){ 3962 curLayer.css({ 3963 width: 0 3964 }); 3965 },sublayersDurationOut ); 3966 3967 // Calculating next layer delay 3968 3969 var nextLayerTimeShift = parseInt(nextLayer.data('timeshift')) ? parseInt(nextLayer.data('timeshift')) : 0; 3970 var nextLayerDelay = ls.g.totalDuration + nextLayerTimeShift > 0 ? ls.g.totalDuration + nextLayerTimeShift : 0; 3971 3972 // Showing next layer and sliding sublayers of the next layer in after the current layer transition ended 3973 3974 setTimeout(function(){ 3975 if( ls.g.resize == true ){ 3976 ls.g.ltContainer.empty(); 3977 curLayer.removeClass('ls-active'); 3978 ls.makeResponsive( nextLayer, function(){ 3979 ls.g.resize = false;
3980 }); 3981 } 3982 3983 // Sliding in / fading in the sublayers of the next layer 3984 3985 nextSubLayers(); 3986 3987 // NEW FEATURE v4.6.0 Hiding background if the next layer has png BG or has no BG 3988 // BUGFIX v4.6.1 Changed some properties to prevent flickering 3989 3990 if( nextLayer.find('.ls-bg').length < 1 || ( nextLayer.find('.ls-bg').length > 0 && nextLayer.find('.ls-bg').attr('src').toLowerCase().indexOf('png') != -1 ) ){ 3991 3992 ls.g.ltContainer.delay(350).fadeOut(300,function(){ 3993 $(this).empty().show(); 3994 }); 3995 } 3996 3997 // Displaying the next layer (immediately) 3998 3999 nextLayer.css({ 4000 width : ls.g.sliderWidth(), 4001 height : ls.g.sliderHeight() 4002 }); 4003 }, nextLayerDelay ); 4004 4005 // BUGFIX v5.0.1 Added a minimal value of ls.g.totalDuration 4006 // CHANGED in v5.1.0 due to a fading issue in carousel transition 4007 4008 if( ls.g.totalDuration < 300 ){ 4009 ls.g.totalDuration = 1000; 4010 } 4011 4012 // Changing visibility to visible of the background image of the next layer and overflow to hidden of .ls-lt-container after the transition and calling callback function 4013 4014 setTimeout(function(){ 4015 ls.g.ltContainer.addClass('ls-overflow-hidden'); 4016 4017 nextLayer.addClass('ls-active'); 4018 4019 if( nextLayer.find('.ls-bg').length ){ 4020 4021 nextLayer.find('.ls-bg').css({ 4022 display : 'none', 4023 visibility : 'visible' 4024 }); 4025 if( ls.g.ie78 ){ 4026 nextLayer.find('.ls-bg').css('display','block'); 4027 setTimeout(function(){ 4028 curLayerCallback(); 4029 },500); 4030 }else{ 4031 nextLayer.find('.ls-bg').fadeIn(500, function(){ 4032 curLayerCallback(); 4033 }); 4034 } 4035 }else{ 4036 curLayerCallback(); 4037 } 4038 4039 }, ls.g.totalDuration ); 4040 }; 4041 4042 4043 4044 /* Selecting and running the transition */ 4045 4046 var tType = ( ( ls.g.nextLayer.data('transition3d') || ls.g.nextLayer.data('transition2d') ) && ls.t ) || ( ( ls.g.nextLayer.data('customtransition3d') || ls.g.nextLayer.data('customtransition2d') ) && ls.ct ) ? 'new' : 'old'; 4047 4048 if( !ls.g.nextLayer.data('transitiontype') ){ 4049 ls.transitionType( ls.g.nextLayer ); 4050 } 4051 4052 if( ls.g.nextLayer.data('transitiontype') === 'new' ){ 4053 tType = 'new'; 4054 } 4055 4056 if( ls.o.slideTransition ){ 4057 tType = 'forced'; 4058 } 4059 if( ls.o.animateFirstSlide && !ls.g.firstSlideAnimated ){ 4060 4061 // BUGFIX v3.5 there is no need to animate 'current' layer if the following conditions are true 4062 // this fixes the sublayer animation direction bug 4063 4064 if( ls.g.layersNum == 1 ){ 4065 var curDelay = 0; 4066 4067 // IMPROVEMENT v4.1.0 Calling cbAnimStop(); function if only one layer is in the slider 4068 4069 ls.o.cbAnimStop(ls.g); 4070 4071 }else{ 4072 var nextLayerTimeShift = parseInt(ls.g.nextLayer.data('timeshift')) ? parseInt(ls.g.nextLayer.data('timeshift')) : 0; 4073 var d = tType == 'new' ? 0 : curDuration; 4074 ls.g.t5 = setTimeout(function(){ 4075 curLayerCallback(); 4076 }, d + Math.abs(nextLayerTimeShift) ); 4077 } 4078 4079 // curDelay must be 0! 4080 4081 ls.g.totalDuration = true; 4082 4083 // Animating SUBLAYERS of the first layer 4084 4085 nextSubLayers(); 4086 4087 // Displaying the first layer (immediately) 4088 4089 ls.g.nextLayer.css({ 4090 width : ls.g.sliderWidth(), 4091 height : ls.g.sliderHeight() 4092 }); 4093 4094 if( !ls.g.ie78 ){ 4095 ls.g.nextLayer.find('.ls-bg').css({ 4096 display : 'none' 4097 }).fadeIn(500); 4098 } 4099 4100 ls.g.firstSlideAnimated = true; 4101 ls.g.isLoading = false; 4102 }else{ 4103 4104 switch(tType){ 4105 4106 // Old transitions (sliding layers) 4107 4108 case 'old': 4109 4110 ls.g.totalDuration = false; 4111 4112 // BUGFIX v4.5.0 Removing elements from ls-lt-container is necessary 4113 4114 if( ls.g.ltContainer ){ 4115 ls.g.ltContainer.empty(); 4116 } 4117 4118 // Animating CURRENT LAYER and its SUBLAYERS 4119 4120 curLayer(); 4121 curSubLayers(); 4122 4123 // Animating NEXT LAYER and its SUBLAYERS 4124 4125 nextLayer(); 4126 nextSubLayers(); 4127 break; 4128 4129 // NEW FEATURE v4.0 2D & 3D Layer Transitions 4130 4131 case 'new': 4132 4133 if( typeof LSCustomTransition != 'undefined' ){ 4134 selectCustomTransition(); 4135 }else{ 4136 selectTransition(); 4137 } 4138 break; 4139 4140 case 'forced': 4141 slideTransition( ls.o.slideTransition.type, ls.o.slideTransition.obj ); 4142 break; 4143 } 4144 } 4145 }; 4146 4147 ls.transitionType = function( el ){ 4148 4149 var ttype = el.data('ls') || 4150 ( !el.data('ls') && 4151 !el.data('slidedelay') && 4152 !el.data('slidedirection') && 4153 !el.data('slideoutdirection') && 4154 !el.data('delayin') && 4155 !el.data('delayout') && 4156 !el.data('durationin') && 4157 !el.data('durationout') && 4158 !el.data('showuntil') && 4159 !el.data('easingin') && 4160 !el.data('easingout') && 4161 !el.data('scalein') && 4162 !el.data('scaleout') && 4163 !el.data('rotatein') && 4164 !el.data('rotateout') 4165 ) ? 'new' : 'old'; 4166 el.data('transitiontype', ttype); 4167 }; 4168 4169 ls.sublayerShowUntil = function( sublayer ){ 4170 4171 if( !sublayer.data('transitiontype') ){ 4172 ls.transitionType( sublayer ); 4173 } 4174 4175 // BUGFIX v5.1.0 Removing ls-videohack class before starting transition 4176 4177 sublayer.removeClass('ls-videohack'); 4178 4179 var prevOrNext = ls.g.curLayer; 4180 4181 if( ls.g.prevNext != 'prev' && ls.g.nextLayer ){ 4182 prevOrNext = ls.g.nextLayer; 4183 } 4184 4185 var chooseDirection = prevOrNext.data('slidedirection') ? prevOrNext.data('slidedirection') : ls.o.slideDirection; 4186 4187 // Setting the direction of sliding 4188 4189 var slideDirection = ls.g.slideDirections[ls.g.prevNext][chooseDirection]; 4190 4191 var curSubSlideDir = sublayer.data('slidedirection') ? sublayer.data('slidedirection') : slideDirection; 4192 var lml, lmt; 4193 4194 switch(curSubSlideDir){ 4195 case 'left': 4196 lml = -ls.g.sliderWidth(); 4197 lmt = 0; 4198 break; 4199 case 'right': 4200 lml = ls.g.sliderWidth(); 4201 lmt = 0; 4202 break; 4203 case 'top': 4204 lmt = -ls.g.sliderHeight(); 4205 lml = 0; 4206 break; 4207 case 'bottom': 4208 lmt = ls.g.sliderHeight(); 4209 lml = 0; 4210 break; 4211 case 'fade': 4212 lmt = 0; 4213 lml = 0; 4214 break; 4215 } 4216 4217 // NEW FEATURE v1.6 added slideoutdirection to sublayers 4218 // NEW FEATURES 5.0.0 added axis-free transitions with offsetx and offsety properties 4219 4220 if( sublayer.data('transitiontype') === 'new' ){ 4221 var curSubSlideOutDir = 'new'; 4222 }else{ 4223 var curSubSlideOutDir = sublayer.data('slideoutdirection') ? sublayer.data('slideoutdirection') : false;
4224 } 4225 4226 switch(curSubSlideOutDir){ 4227 case 'left': 4228 lml = ls.g.sliderWidth(); 4229 lmt = 0; 4230 break; 4231 case 'right': 4232 lml = -ls.g.sliderWidth(); 4233 lmt = 0; 4234 break; 4235 case 'top': 4236 lmt = ls.g.sliderHeight(); 4237 lml = 0; 4238 break; 4239 case 'bottom': 4240 lmt = -ls.g.sliderHeight(); 4241 lml = 0; 4242 break; 4243 case 'fade': 4244 lmt = 0; 4245 lml = 0; 4246 break; 4247 case 'new': 4248 if( sublayer.data('offsetxout') ){ 4249 if( sublayer.data('offsetxout') === 'left' ){ 4250 lml = ls.g.sliderWidth(); 4251 }else if( sublayer.data('offsetxout') === 'right' ){ 4252 lml = -ls.g.sliderWidth(); 4253 }else{ 4254 lml = -parseInt( sublayer.data('offsetxout') ); 4255 } 4256 }else{ 4257 lml = -ls.lt.offsetXOut; 4258 } 4259 if( sublayer.data('offsetyout') ){ 4260 if( sublayer.data('offsetyout') === 'top' ){ 4261 lmt = ls.g.sliderHeight(); 4262 }else if( sublayer.data('offsetyout') === 'bottom' ){ 4263 lmt = -ls.g.sliderHeight(); 4264 }else{ 4265 lmt = -parseInt( sublayer.data('offsetyout') ); 4266 } 4267 }else{ 4268 lmt = -ls.lt.offsetYOut; 4269 } 4270 break; 4271 } 4272 4273 // NEW FEATURE v4.5.0 Rotating & Scaling sublayers 4274 // BUGFIX v4.5.5 changing the default value from 0 to 'none' (because of old jQuery, 1.7.2) 4275 // NEW FEATURES v5.0.0 Added SkewX, SkewY, ScaleX, ScaleY, RotateX & RotateY transitions 4276 4277 var curSubRotate = curSubRotateX = curSubRotateY = curSubScale = curSubSkewX = curSubSkewY = curSubScaleX = curSubScaleY = 'none'; 4278// if( !ls.g.ie78 && ls.g.enableCSS3 ){ 4279 curSubRotate = sublayer.data('rotateout') ? sublayer.data('rotateout') : ls.lt.rotateOut; 4280 curSubRotateX = sublayer.data('rotatexout') ? sublayer.data('rotatexout') : ls.lt.rotateXOut; 4281 curSubRotateY = sublayer.data('rotateyout') ? sublayer.data('rotateyout') : ls.lt.rotateYOut; 4282 curSubScale = sublayer.data('scaleout') ? sublayer.data('scaleout') : ls.lt.scaleOut; 4283 curSubSkewX = sublayer.data('skewxout') ? sublayer.data('skewxout') : ls.lt.skewXOut; 4284 curSubSkewY = sublayer.data('skewyout') ? sublayer.data('skewyout') : ls.lt.skewYOut; 4285 if( curSubScale === 1 ){ 4286 curSubScaleX = sublayer.data('scalexout') ? sublayer.data('scalexout') : ls.lt.scaleXOut; 4287 curSubScaleY = sublayer.data('scaleyout') ? sublayer.data('scaleyout') : ls.lt.scaleYOut; 4288 }else{ 4289 curSubScaleX = curSubScaleY = curSubScale; 4290 } 4291 var too = sublayer.data('transformoriginout') ? sublayer.data('transformoriginout').split(' ') : ls.lt.transformOriginOut; 4292 4293 for(var t =0;t<too.length;t++){ 4294 if( too[t].indexOf('%') === -1 && too[t].indexOf('left') !== -1 && too[t].indexOf('right') !== -1 && too[t].indexOf('top') !== -1 && too[t].indexOf('bottom') !== -1 ){ 4295 too[t] = '' + parseInt( too[t] ) * ls.g.ratio + 'px'; 4296 } 4297 } 4298 var curSubTransformOrigin = too.join(' '); 4299 var curSubPerspective = sublayer.data('perspectiveout') ? sublayer.data('perspectiveout') : ls.lt.perspectiveOut; 4300 4301// } 4302 4303 // IMPROVEMENT v4.0 Distance (P.level): -1 4304 4305 var endLeft = parseInt( sublayer.css('left') ); 4306 var endTop = parseInt( sublayer.css('top') ); 4307 4308 var curSubPLevel = parseInt( sublayer.attr('class').split('ls-l')[1] ); 4309 4310 var wh = sublayer.outerWidth() > sublayer.outerHeight() ? sublayer.outerWidth() : sublayer.outerHeight(); 4311 var modX = parseInt( curSubRotate ) === 0 ? sublayer.outerWidth() : wh; 4312 var modY = parseInt( curSubRotate ) === 0 ? sublayer.outerHeight() : wh; 4313 4314 if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetxout') === 'left' || sublayer.data('offsetxout') === 'right' ) ){ 4315 if( lml < 0 ){ 4316 lml = - ( ls.g.sliderWidth() - endLeft + ( curSubScaleX / 2 - .5 ) * modX + 100 ); 4317 }else if( lml > 0 ){ 4318 lml = endLeft + ( curSubScaleX / 2 + .5 ) * modX + 100; 4319 } 4320 }else{ 4321 lml = lml * ls.g.ratio; 4322 } 4323 4324 if( ( curSubPLevel === -1 && curSubSlideOutDir !== 'new' ) || ( sublayer.data('offsetyout') === 'top' || sublayer.data('offsetyout') === 'bottom' ) ){ 4325 if( lmt < 0 ){ 4326 lmt = - ( ls.g.sliderHeight() - endTop + ( curSubScaleY / 2 - .5 ) * modY + 100 ); 4327 }else if( lmt > 0 ){ 4328 lmt = endTop + ( curSubScaleY / 2 + .5 ) * modY + 100; 4329 } 4330 }else{ 4331 lmt = lmt * ls.g.ratio; 4332 } 4333 4334 if( curSubPLevel === -1 || curSubSlideOutDir === 'new' ){ 4335 var curSubPar = 1; 4336 }else{ 4337 var curSubParMod = ls.g.curLayer.data('parallaxout') ? parseInt(ls.g.curLayer.data('parallaxout')) : ls.o.parallaxOut; 4338 var curSubPar = curSubPLevel * curSubParMod; 4339 } 4340 4341// var curSubDelay = parseInt( sublayer.data('showuntil') ); 4342 4343 if( sublayer.data('transitiontype') === 'new' ){ 4344 var duO = ls.lt.durationOut; 4345 var eO = ls.lt.easingOut; 4346 }else{ 4347 var duO = ls.o.durationOut; 4348 var eO = ls.o.easingOut; 4349 } 4350 4351 var curSubTime = sublayer.data('durationout') ? parseInt(sublayer.data('durationout')) : duO; 4352 var curSubEasing = sublayer.data('easingout') ? sublayer.data('easingout') : eO; 4353 4354 var css = { 4355 visibility : 'hidden' 4356 }; 4357 4358 var transition = { 4359 rotation : curSubRotate, 4360 rotationX : curSubRotateX, 4361 rotationY : curSubRotateY,
4362 skewX : curSubSkewX, 4363 skewY : curSubSkewY, 4364 scaleX : curSubScaleX, 4365 scaleY : curSubScaleY, 4366 x : -lml * curSubPar, 4367 y : -lmt * curSubPar, 4368 ease : lsConvertEasing( curSubEasing ), 4369 onComplete : function(){ 4370 sublayer.css( css ); 4371 } 4372 }; 4373 4374 if( curSubSlideOutDir == 'fade' || ( !curSubSlideOutDir && curSubSlideDir == 'fade' ) || ( sublayer.data('fadeout') !== 'false' && sublayer.data('transitiontype') === 'new' ) ){ 4375 transition['opacity'] = 0; 4376 css['opacity'] = sublayer.data( 'originalOpacity' ); 4377 } 4378 4379 TweenLite.set( sublayer[0],{ 4380 transformPerspective : curSubPerspective, 4381 transformOrigin : curSubTransformOrigin 4382 }); 4383 4384 TweenLite.to(sublayer[0],curSubTime/1000,transition); 4385 4386 // sublayer.stop(true,false).animate( transition, curSubTime, curSubEasing,function(){ 4387 // sublayer.css( css ); 4388 // }); 4389 }; 4390 4391 // v3.6 Improved Debug Mode 4392 4393 ls.debug = function(){ 4394 4395 ls.d = { 4396 history : $('<div>'), 4397 // adds a H1 (title) 4398 aT : function(content){ 4399 $('<h1>'+content+'</h1>').appendTo( ls.d.history ); 4400 }, 4401 // adds an empty UL 4402 aeU : function(){ 4403 $('<ul>').appendTo( ls.d.history ); 4404 }, 4405 // adds an UL with a LI 4406 aU : function(content){ 4407 $('<ul><li>'+content+'</li></ul>').appendTo( ls.d.history ); 4408 }, 4409 // adds a LI into the last UL 4410 aL : function(content){ 4411 $('<li>'+content+'</li>').appendTo( ls.d.history.find('ul:last') ); 4412 }, 4413 // adds an UL into the last LI of the last UL 4414 aUU : function(content){ 4415 $('<ul>').appendTo( ls.d.history.find('ul:last li:last') ); 4416 }, 4417 // adds a Function to the first LI inside the last UL 4418 aF : function(elem){ 4419 ls.d.history.find('ul:last li:last').hover( 4420 function(){ 4421 elem.css({ 4422 border: '2px solid red', 4423 marginTop : parseInt( elem.css('margin-top') ) - 2, 4424 marginLeft : parseInt( elem.css('margin-left') ) - 2 4425 }); 4426 }, 4427 function(){ 4428 elem.css({ 4429 border: '0px', 4430 marginTop : parseInt( elem.css('margin-top') ) + 2, 4431 marginLeft : parseInt( elem.css('margin-left') ) + 2 4432 }); 4433 } 4434 ); 4435 }, 4436 show : function(){ 4437 if( !$('body').find('.ls-debug-console').length ){ 4438 4439 if( !ls.d.putData ){ 4440 4441 // Init code 4442 4443 ls.d.aT('Init code'); 4444 ls.d.aeU(); 4445 4446 for( var prop in ls.o ){ 4447 ls.d.aL(prop+': <strong>' + ls.o[prop] + '</strong>'); 4448 } 4449 4450// ls.d.aL('sliderOriginalWidth: <strong>' + ls.g.sliderOriginalWidth + '</strong>'); 4451// ls.d.aL('sliderOriginalHeight: <strong>' + ls.g.sliderOriginalHeight + '</strong>'); 4452 4453 // Slides, layers data 4454 4455 ls.d.aT('LayerSlider Content'); 4456 ls.d.aU('Number of slides found: <strong>' + $(el).find('.ls-slide').length + '</strong>'); 4457 4458 $(el).find('.ls-inner .ls-slide, .ls-inner *[class*="ls-l"]').each(function(){ 4459 4460 if( $(this).hasClass('ls-slide') ){ 4461 ls.d.aU('<strong>SLIDE ' + ( $(this).index() + 1 ) + '</strong>'); 4462 ls.d.aUU(); 4463 ls.d.aL('<strong>SLIDE ' + ( $(this).index() + 1 ) + ' properties:</strong><br><br>'); 4464 }else{ 4465 ls.d.aU(' Layer ( '+$(this).prop('tagName')+' )'); 4466 ls.d.aF($(this)); 4467 ls.d.aUU(); 4468 ls.d.aL('<strong>'+$(this).prop('tagName')+' layer properties:</strong><br><br>'); 4469 ls.d.aL('distance / class: <strong>'+$(this).attr('class')+'</strong>'); 4470 } 4471 4472 $.each( $(this).data(),function(name, val) { 4473 ls.d.aL( name +': <strong>' + val + '</strong>'); 4474 }); 4475 }); 4476 4477 ls.d.putData = true; 4478 } 4479 4480 var dc = $('<div>').addClass('ls-debug-console').css({ 4481 position: 'fixed', 4482 zIndex: '10000000000', 4483 top: '10px', 4484 right: '10px', 4485 width: '300px', 4486 padding: '20px', 4487 background: 'black', 4488 'border-radius': '10px', 4489 height: $(window).height() - 60, 4490 opacity: 0, 4491 marginRight: 150 4492 }).appendTo( $('body') ).css({ 4493 marginRight: 0, 4494 opacity: .9 4495 }).click(function(e){ 4496 if(e.shiftKey && e.altKey){ 4497 $(this).remove(); 4498 } 4499 }); 4500 var ds = $('<div>').css({ 4501 width: '100%', 4502 height: '100%', 4503 overflow: 'auto' 4504 }).appendTo( dc ); 4505 var dd = $('<div>').css({ 4506 width: '100%' 4507 }).appendTo( ds ).append( ls.d.history ); 4508 } 4509 }, 4510 hide : function(){ 4511 $('body').find('.ls-debug-console').remove(); 4512 } 4513 }; 4514 4515 $(el).click(function(e){ 4516 if(e.shiftKey && e.altKey){ 4517 ls.d.show(); 4518 } 4519 }); 4520 }; 4521 4522 // initializing 4523 ls.load(); 4524 }; 4525 4526 var lsConvertEasing = function( e ){ 4527 4528 var t; 4529 4530 if( e.toLowerCase().indexOf('swing') !== -1 || e.toLowerCase().indexOf('linear') !== -1 ){ 4531 t = Linear.easeNone; 4532 }else if( e.toLowerCase().indexOf('easeinout') !== -1 ){ 4533 var ee = e.toLowerCase().split('easeinout')[1]; 4534 t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeInOut; 4535 }else if( e.toLowerCase().indexOf('easeout') !== -1 ){ 4536 var ee = e.toLowerCase().split('easeout')[1]; 4537 t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeOut; 4538 }else if( e.toLowerCase().indexOf('easein') !== -1 ){ 4539 var ee = e.toLowerCase().split('easein')[1]; 4540 t = window[ee.charAt(0).toUpperCase() + ee.slice(1)].easeIn; 4541 } 4542 4543 return t; 4544 }; 4545 4546 var lsConvertTransition = function( t, e, type, undef ){ 4547 4548 if( typeof e === 'undefined' ){ 4549 var e = 'easeInOutQuart'; 4550 } 4551 var tt = {}; 4552 4553 if( t.rotate !== undef ){ 4554 tt.rotation = t.rotate; 4555 } 4556 if( t.rotateY !== undef ){ 4557 tt.rotationY = t.rotateY; 4558 } 4559 if( t.rotateX !== undef ){ 4560 tt.rotationX = t.rotateX; 4561 } 4562 if( type === 'after' ){ 4563 tt.scaleX = tt.scaleY = tt.scaleZ = 1; 4564 }else if( t.scale3d !== undef ){ 4565 tt.scaleX = tt.scaleY = tt.scaleZ = t.scale3d; 4566 } 4567 4568 if( t.delay ){ 4569 tt.delay = type === 'after' ? t.delay/1000 : t.delay; 4570 } 4571 4572 tt.ease = lsConvertEasing( e ); 4573 4574 return tt; 4575 }; 4576 4577 // Support3D checks the CSS3 3D capability of the browser (based on the idea of Modernizr.js) 4578 4579 var lsSupport3D = function( el ) { 4580
4581 var testEl = $('<div>'), 4582 s3d1 = false, 4583 s3d2 = false, 4584 properties = ['perspective', 'OPerspective', 'msPerspective', 'MozPerspective', 'WebkitPerspective']; 4585 transform = ['transformStyle','OTransformStyle','msTransformStyle','MozTransformStyle','WebkitTransformStyle']; 4586 4587 for (var i = properties.length - 1; i >= 0; i--){ 4588 s3d1 = s3d1 ? s3d1 : testEl[0].style[properties[i]] != undefined; 4589 }; 4590 4591 // preserve 3D test 4592 4593 for (var i = transform.length - 1; i >= 0; i--){ 4594 testEl.css( 'transform-style', 'preserve-3d' ); 4595 s3d2 = s3d2 ? s3d2 : testEl[0].style[transform[i]] == 'preserve-3d'; 4596 }; 4597 4598 // If browser has perspective capability and it is webkit, we must check it with this solution because Chrome can give false positive result if GPU acceleration is disabled 4599 4600 if (s3d1 && testEl[0].style[properties[4]] != undefined){ 4601 testEl.attr('id','ls-test3d').appendTo( el ); 4602 s3d1 = testEl[0].offsetHeight === 3 && testEl[0].offsetLeft === 9; 4603 testEl.remove(); 4604 } 4605 4606 return (s3d1 && s3d2); 4607 }; 4608 4609 // Order array function 4610 4611 var lsOrderArray = function(x,y,dir) { 4612 var i = []; 4613 if(dir=='forward'){ 4614 for( var a=0; a<x;a++){ 4615 for( var b=0; b<y; b++){ 4616 i.push(a+b*x); 4617 } 4618 } 4619 }else{ 4620 for( var a=x-1; a>-1;a--){ 4621 for( var b=y-1; b>-1; b--){ 4622 i.push(a+b*x); 4623 } 4624 } 4625 } 4626 return i; 4627 }; 4628 4629 // CountProp counts the properties in an object 4630 4631 var lsCountProp = function(obj) { 4632 var count = 0; 4633 4634 for(var prop in obj) { 4635 if(obj.hasOwnProperty(prop)){ 4636 ++count; 4637 } 4638 } 4639 return count; 4640 }; 4641 4642 // We need the browser function (removed from jQuery 1.9) 4643 4644 var lsBrowser = function(){ 4645 4646 uaMatch = function( ua ) { 4647 ua = ua.toLowerCase(); 4648 4649 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || 4650 /(webkit)[ \/]([\w.]+)/.exec( ua ) || 4651 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) || 4652 /(msie) ([\w.]+)/.exec( ua ) || 4653 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) || 4654 []; 4655 4656 return { 4657 browser: match[ 1 ] || "", 4658 version: match[ 2 ] || "0" 4659 }; 4660 }; 4661 4662 var matched = uaMatch( navigator.userAgent ), browser = {}; 4663 4664 if ( matched.browser ) { 4665 browser[ matched.browser ] = true; 4666 browser.version = matched.version; 4667 } 4668 4669 if ( browser.chrome ) { 4670 browser.webkit = true; 4671 } else if ( browser.webkit ) { 4672 browser.safari = true; 4673 } 4674 4675 return browser; 4676 }; 4677 4678 lsPrefixes = function(obj, method){ 4679 4680 var pfx = ['webkit', 'khtml', 'moz', 'ms', 'o', '']; 4681 var p = 0, m, t; 4682 while (p < pfx.length && !obj[m]) { 4683 m = method; 4684 if (pfx[p] == '') { 4685 m = m.substr(0,1).toLowerCase() + m.substr(1); 4686 } 4687 m = pfx[p] + m; 4688 t = typeof obj[m]; 4689 if (t != 'undefined') { 4690 pfx = [pfx[p]]; 4691 return (t == 'function' ? obj[m]() : obj[m]); 4692 } 4693 p++; 4694 } 4695 }; 4696 4697 // Global parameters (Do not change these settings!) 4698 4699 layerSlider.global = { 4700 4701 version : '5.1.0', 4702 4703 isMobile : function(){ 4704 if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) ){ 4705 return true; 4706 }else{ 4707 return false; 4708 } 4709 }, 4710 isHideOn3D : function(el){ 4711 if( el.css('padding-bottom') == 'auto' || el.css('padding-bottom') == 'none' || el.css('padding-bottom') == 0 || el.css('padding-bottom') == '0px' ){ 4712 return true; 4713 }else{ 4714 return false; 4715 } 4716 }, 4717 4718 // NEW FEATURE 4.0 CSS3 transitions 4719 // (beta, currently animating only the new 2D and 3D layer tranisitons with CSS3) 4720 // (2D layer transitions are working also with jQuery fallback mode) 4721 4722// cssTransitions : !lsBrowser().msie || ( lsBrowser().msie && lsBrowser().version > 9 ) ? true : false, 4723 ie78 : lsBrowser().msie && lsBrowser().version < 9 ? true : false, 4724 paused : false, 4725 pausedByVideo : false, 4726 autoSlideshow : false, 4727 isAnimating : false, 4728 layersNum : null, 4729 prevNext : 'next', 4730 slideTimer : null, 4731 sliderWidth : null, 4732 sliderHeight : null, 4733 slideDirections : { 4734 prev : { 4735 left : 'right', 4736 right : 'left', 4737 top : 'bottom', 4738 bottom : 'top' 4739 }, 4740 next : { 4741 left : 'left', 4742 right : 'right', 4743 top : 'top', 4744 bottom : 'bottom' 4745 } 4746 }, 4747 4748 // Default delay time, fadeout and fadein durations of videoPreview images 4749 4750 v : { 4751 d : 500, 4752 fo : 750, 4753 fi : 500 4754 } 4755 }; 4756 4757 // Layer Transition Defaults 4758 4759 layerSlider.layerTransitions = { 4760 4761 offsetXIn : 80, 4762 offsetYIn : 0, 4763 durationIn : 1000, 4764 delayIn : 0, 4765 easingIn : 'easeInOutQuint', 4766 fadeIn : true, 4767 rotateIn : 0, 4768 rotateXIn : 0, 4769 rotateYIn : 0, 4770 scaleIn : 1, 4771 scaleXIn : 1, 4772 scaleYIn : 1, 4773 skewXIn : 0, 4774 skewYIn : 0, 4775 transformOriginIn : ['50%','50%','0'], 4776 perspectiveIn : 500, 4777 4778 offsetXOut : -80, 4779 offsetYOut : 0, 4780 durationOut : 400, 4781 showUntil : 0, 4782 easingOut : 'easeInOutQuint', 4783 fadeOut : true, 4784 rotateOut : 0, 4785 rotateXOut : 0, 4786 rotateYOut : 0, 4787 scaleOut : 1, 4788 scaleXOut : 1, 4789 scaleYOut : 1, 4790 skewXOut : 0, 4791 skewYOut : 0, 4792 transformOriginOut : ['50%','50%','0'], 4793 perspectiveOut : 500 4794 }; 4795 4796 layerSlider.slideTransitions = { 4797 4798 slideDelay : 4000 // Time before the next slide will be loading. 4799 }; 4800 4801 // Global settings (can be modified) 4802 4803 layerSlider.options = { 4804 4805 // Layout 4806 4807 responsive : true, 4808 responsiveUnder : 0, 4809 layersContainer : 0, 4810 4811 // Slideshow 4812 4813 autoStart : true, 4814 pauseOnHover : true, 4815 firstSlide : 1, 4816 animateFirstSlide : true, 4817 loops : 0, 4818 forceLoopNum : true, 4819 twoWaySlideshow : false, 4820 randomSlideshow : false, 4821 4822 // Appearance 4823 4824 skin : 'v5', 4825 skinsPath : '/layerslider/skins/', 4826 globalBGColor : 'transparent', 4827 globalBGImage : false, 4828 4829 // Navigation Area 4830 4831 navPrevNext : true, 4832 navStartStop : true, 4833 navButtons : true, 4834 keybNav : true, 4835 touchNav : true, 4836 hoverPrevNext : true, 4837 hoverBottomNav : false, 4838 showBarTimer : false, 4839 showCircleTimer : true, 4840 4841 // Thumbnail navigation 4842 4843 thumbnailNavigation : 'hover', 4844 tnContainerWidth : '60%', 4845 tnWidth : 100, 4846 tnHeight : 60, 4847 tnActiveOpacity : 35, 4848 tnInactiveOpacity : 100, 4849 4850 // Videos 4851 4852 autoPlayVideos : true, 4853 autoPauseSlideshow : 'auto', 4854 youtubePreview : 'maxresdefault.jpg', 4855 4856 // Preload 4857 4858 imgPreload : true, 4859 lazyLoad : true, 4860 4861 // YourLogo 4862 4863 yourLogo : false, 4864 yourLogoStyle : 'left: -10px; top: -10px;', 4865 yourLogoLink : false, 4866 yourLogoTarget : '_self', 4867 4868 // Optimize for IE7 and IE8 4869 4870 optimizeForMobile : true, 4871 optimizeForIE78 : true, 4872 4873 // API functions 4874 4875 cbInit : function(element){}, 4876 cbStart : function(data){}, 4877 cbStop : function(data){}, 4878 cbPause : function(data){}, 4879 cbAnimStart : function(data){}, 4880 cbAnimStop : function(data){}, 4881 cbPrev : function(data){}, 4882 cbNext : function(data){}, 4883 4884 // !!! IMPORTANT !!! The following properties are deprecated from version 5.0.0 DO NOT USE THEM. 4885 // The slider will recognize these properties in the init code or if you add these properties into the style attribute of the layer 4886 // but we recommend you to use to new html5 data attribute (data-ls) with the new properties 4887 4888 slideDelay : 4000, 4889 slideDirection : 'right', 4890 parallaxIn : .45, 4891 parallaxOut : .45, 4892 durationIn : 1000, 4893 durationOut : 1000, 4894 easingIn : 'easeInOutQuint', 4895 easingOut : 'easeInOutQuint', 4896 delayIn : 0, 4897 delayOut : 0 4898 }; 4899})(window.lsjq || 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.