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