/*!
* jQuery Conveyor Ticker (jConveyorTicker)
* Description: jQuery plugin to create simple horizontal conveyor belt animated tickers.
*
* Copyright (c) 2017 Luis Luz - UXD Lda
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* https://github.com/lluz/jquery-conveyor-ticker
*
* Version: 1.1.0
*
*/ !function(e,n,r,i){e.fn.jConveyorTicker=function(n){if(this===i||0===this.length)return console.log("jquery.jConveyorTicker() INITIALIZATION ERROR: You need to select one or more elements. See documentation form more information."),!1;var r={anim_duration:200,reverse_elm:!1,force_loop:!1,start_paused:!1,is_rtl:!1},t=r.anim_duration,o=r.reverse_elm,a=r.force_loop,s=r.start_paused,c=r.is_rtl;n&&(i!==n.anim_duration&&(t=n.anim_duration),i!==n.reverse_elm&&(o=n.reverse_elm),i!==n.force_loop&&(a=n.force_loop),i!==n.start_paused&&(s=n.start_paused),i!==n.is_rtl&&(c=n.is_rtl),e.extend(r,n));var l=e(this),m=l.children("ul"),u={init:function(){l.each(function(){u.destroy(),m.css({margin:"0",padding:"0","list-style":"none"}).children("li").css({display:"inline-block"});var n=m.width(),r=m.parent().width()/2-20;m.removeAttr("style").children("li").removeAttr("style"),l.addClass("jctkr-wrapper");var i=function(){var n=m.clone().children("li");n.each(function(){e(this).addClass("clone")}),m.append(n);var r=0;m.children().each(function(){r+=e(this).outerWidth()}),m.width(r),l.on("mouseenter",function(){u.pauseAnim()}).on("mouseleave",function(){u.pauseAnim(),u.conveyorAnimate("normal")}),o&&l.prev(".jctkr-label").on("mouseenter",function(){u.pauseAnim(),u.conveyorAnimate("reverse")}).on("mouseleave",function(){u.pauseAnim(),u.conveyorAnimate("normal")}).click(function(){return!1}),u.conveyorAnimate("normal")};if(n>=r)i();else if(a){var t,s=0,c=function(){var n=m.clone().children("li");if(n.each(function(){e(this).addClass("clone")}),m.append(n),!((t=m.width())<(s=m.parent().width())))return i(),!1;c()};for(c();t<s;){if(t>=r){i();break}c()}}l.addClass("jctkr-initialized")}),s&&u.pauseAnim()},destroy:function(){l.each(function(){u.pauseAnim(),e(this).off().removeData().removeClass("jctkr-wrapper jctkr-initialized"),m.off().removeData().removeAttr("style").find(".clone").remove()})},conveyorAnimate:function(e){var n,r=m.width();if(c)var o=m.position().right;else var o=m.position().left;var a="-",s="normal";if(e!==i&&"reverse"===e){if(n=r/2,o>0){c?m.css("right","-"+n+"px"):m.css("left","-"+n+"px"),u.conveyorAnimate("reverse");return}a="+",s="reverse"}else if(o<(n=-1*(r/2))){var l=-1*(n-o);c?m.css("right",l+"px"):m.css("left",l+"px"),u.conveyorAnimate(s);return}c?m.stop().animate({right:a+"=10px"},t,"linear",function(){u.conveyorAnimate(s)}):m.stop().animate({left:a+"=10px"},t,"linear",function(){u.conveyorAnimate(s)})},pauseAnim:function(){m.stop()},playAnim:function(){u.conveyorAnimate("normal")}};return u.init(),u}}(jQuery,window,document);