
/*
	* LayerSlider Add-On: Timeline
	*
	* (c) 2011-2026 George Krupa, John Gera & Kreatura Media
	*
	* LayerSlider home:		https://layerslider.com/
	* Licensing:			https://layerslider.com/licensing/
*/



;(function(a){window._layerSlider.plugins.timeline=function(b,c,d,e){var f=this;f.pluginData={name:"Timeline Add-On for LayerSlider",version:"1.6",requiredLSVersion:"8.0.0",authorName:"Kreatura",releaseDate:"2025. 10. 07."},f.pluginDefaults={eventNamespace:"TL",showCurrentTime:!0,showLayersInfo:!0,showLayersProperties:!1},f.init=function(){this.applySettings(),this.createMarkup(),this.createEvents()},f.applySettings=function(){this.settings=a.extend(!0,{},this.pluginDefaults,e)},f.createMarkup=function(){var b=a("[data-timeline-for=\""+c.attr("id")+"\"]");this.removeElement=!b.length,this.$timelineElement=b.length?b:a("<div>").css({maxWidth:c.css("max-width")}).insertAfter(c),this.$strechedElement=a("<div>").addClass("ls-timeline-streched").appendTo(this.$timelineElement),this.$infoElement=a("<div>").addClass("ls-timeline-layer-info").appendTo(this.$timelineElement),this.$layerTweensWrapper=a("<div>").addClass("ls-layer-tweens-wrapper").appendTo(this.$strechedElement),this.$timingsWrapper=a("<div>").addClass("ls-timings-wrapper").appendTo(this.$strechedElement),this.$timelineElement.addClass("ls-slide-timeline "+(this.settings.showLayersInfo?"ls-show-layer-info":"")),this.$strechedElement.append(a("<div data-slidebar-for=\""+d+"\"></div>")),this.settings.showCurrentTime&&(this.$currentTimeElement=a("<div>").addClass("ls-current-time")),this.$legendWrapper=a("<div class=\"ls-timeline-legend\"><span class=\"ls-tl-leg\">legend</span><span class=\"ls-tl-leg-delay\">delay</span><span class=\"ls-tl-leg-in\">in</span><span class=\"ls-tl-leg-out\">out</span><span class=\"ls-tl-leg-textin\">text in</span><span class=\"ls-tl-leg-textout\">text out</span><span class=\"ls-tl-leg-loop\">loop / middle</span><span class=\"ls-tl-leg-static\">static</span></div>").appendTo(this.$timelineElement)},f.round=function(a,b){return b=b?b*=10:1e3,Math.round(a*b)/b},f.createEvents=function(){c.on("sliderDidLoad.layerSlider",function(){f.settings.showCurrentTime&&f.$strechedElement.find(".ls-slidebar-slider").append(f.$currentTimeElement)}).on("slideTimelineDidCreate.layerSlider",function(c,e){f.slideTimelineDuration=e.slideTimelineDuration,f.slideTimelineDurationRatio=e.slideTimeline.duration()<e.slideTimelineDuration?1:f.slideTimelineDuration/e.slideTimeline.duration();var g,h,i,j,k,m,n,o,p=e.layersOnSlideTimeline.filter(":not( .ls-bg, .ls-clone )"),q=p.length,r=f.slideTimelineDuration/100;f.$layerTweensWrapper.empty(),f.$timingsWrapper.empty(),f.$infoElement.empty();for(var t=0;t<Math.floor(f.slideTimelineDuration)+1&&(g=t*(100/f.slideTimelineDuration),g=100<g?100:g,o=99<=g?" ls-timeline-seconds-last":"",a("<div class=\"ls-timeline-seconds"+o+"\"><div class=\"ls-timeline-sec\">"+t+"s</div></div>").css({left:g+"%"}).appendTo(f.$timingsWrapper),!(100<=g));t++);for(var u=1;u<10*f.slideTimelineDuration&&(g=u*(100/(10*f.slideTimelineDuration)),g=100<g?100:g,0!=u%10&&a("<div class=\"ls-timeline-dsecond\"></div>").css({left:g+"%"}).appendTo(f.$timingsWrapper),!(100<=g));u++);for(var v=0;v<q;v++){var w,x,y="";if(h=p.eq(v),i=h.data(b.defaults.init.dataKey),j=a("<div>").addClass("ls-layer-tweens").data("lsTweensOfLayer",h).prependTo(f.$layerTweensWrapper),k=a("<div>").addClass("ls-layer-tweens-inner").appendTo(j),f.settings.showLayersInfo&&(m=a("<div>").data("ls",{$layer:h,layerData:i,$outerWrapper:i.elements.$outerWrapper}).addClass("ls-layer-info").prependTo(f.$infoElement).on("mouseenter."+f.settings.eventNamespace+d,function(){a(this).data("ls").$outerWrapper.attr("id","ls-wrapper-highlighted")}).on("mouseleave."+f.settings.eventNamespace+d,function(){a(this).data("ls").$outerWrapper.removeAttr("id")}),h.is("img")&&m.append(a("<div><a href=\""+h.attr("src")+"\" target=\"_blank\"></a></div>").css({backgroundImage:"url("+h.attr("src")+")"})),x=h.children().first().length&&h.children().first().is("iframe, video, audio")?"MEDIA LAYER":h[0].innerText,f.settings.showLayersProperties&&(y+="<tr><td>Type & Content</td><td>"+h[0].tagName+(x?" | "+x:"")+"</td></tr>",y+="<tr><td>Original styles</td><td>"+i.original.styles.replace(/:/g,": ").replace(/;/g,"; ")+"</td></tr>",y+="<tr><td>Original data-ls</td><td>"+i.original.dataLS.replace(/:/g,": ").replace(/;/g,"; ")+"</td></tr>",h[0].src&&(y+="<tr><td>Image URL</td><td>"+h[0].src+"</td></tr>"),w="<div class=\"ls-layer-properties\"><table><thead><tr><th colspan=\"2\">Layer Properties</th></tr></thead><tbody>"+y+"</tbody></table></div>"),m.append("<h1>"+(w?w:"")+h[0].tagName+"<span>"+x+"</span></h1> ")),i.is.static&&b.slides.next.index!==i.settings.slideIn||(a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-transition-in").css({left:f.round(i.timeline.transitioninstart)/r+"%",width:f.round(i.timeline.transitioninend-i.timeline.transitioninstart)/r+"%"}),0<i.timeline.transitioninstart&&a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-delay-in").css({left:0,width:f.round(i.timeline.transitioninstart)/r+"%"})),a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-text-in").css({left:f.round(i.timeline.textinstart)/r+"%",width:f.round(i.timeline.textinend-i.timeline.textinstart)/r+"%"}),n=-1===i.loop.count?f.slideTimelineDuration:i.timeline.loopend,a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-loop").css({left:f.round(i.timeline.loopstart)/r+"%",width:f.round(n-i.timeline.loopstart)/r+"%"}),a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-text-out").css({left:f.round(1e3*i.timeline.textoutstart)/1e3/r+"%",width:f.round(1e3*(i.timeline.textoutend-i.timeline.textoutstart))/1e3/r+"%"}),b.slides.next.index===i.settings.slideOut&&a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-transition-out").css({left:f.round(i.timeline.transitionoutstart)/r+"%",width:f.round(i.timeline.transitionoutend-i.timeline.transitionoutstart)/r+"%"}),!i.is.static)a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-showuntil").css({left:f.round(i.timeline.transitioninend)/r+"%",width:f.round(i.timeline.transitionoutstart-i.timeline.transitioninend)/r+"%"});else if(b.slides.next.index===i.settings.slideOut){var z="slidechangeonly"===i.out.startAt?"static":"showuntil";a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-"+z).css({left:0,width:"100%"===i.timeline.staticto?i.timeline.staticto:f.round(i.timeline.transitionoutstart)/r+"%"})}else a("<div>").appendTo(k).addClass("ls-layer-tween ls-layer-static").css({left:f.round(i.timeline.staticfrom)/r+"%",width:"100%"})}0===q&&a("<div class=\"ls-layer-info no-layers\"><h1>No layers found</h1></div>").prependTo(f.$infoElement)}).on("slideTimelineDidUpdate.layerSlider",function(a,b){var c;f.settings.showCurrentTime&&(c=parseInt(1e3*(f.slideTimelineDuration/f.slideTimelineDurationRatio*b.progress()))/1e3,c!==c&&(c=0),f.$currentTimeElement.text(c.toFixed(3)))}).on("sliderDidDestroy.layerSlider",function(){f.api.destroy()})},f.api={destroy:function(){a(window).add("body").add(c).add(c.find("*")).add(f.$timelineElement).add(f.$timelineElement.find("*")).off("."+f.settings.eventNamespace+d),this.removeElement?f.$timelineElement.remove():f.$timelineElement.empty()}}}})(jQuery,void 0);