"use strict";
!(function (d){
var a={
direction: "prev",
mode: "horizontal",
speed: 1,
delay: 30,
pauseOnHover: !1,
onCarouselTickerLoad: function (){},
};
d.fn.carouselTicker=function (t){
if(0==this.length) return this;
if(1 < this.length)
return (
this.each(function (){
d(this).carouselTicker(t);
}),
this
);
function i(){
(l.settings=d.extend({}, a, t)),
(l.intervalPointer=null),
(l.directionSwitcher="prev"===l.settings.direction ? -1:1),
(l.itemsWidth=0),
(l.childsWidth=0),
(l.itemsHeight=0),
(l.childsHeight=0),
(l.$list=n),
(l.$items=l.$list.children()),
(l.isInitialize = !1),
(l.isMousemove = !1),
(l.$parent=n.parent()),
(l.wrapCls="carouselTicker__wrap"),
(l.listCls="carouselTicker__list"),
(l.loaderCls="carouselTicker__loader"),
(l.cloneCls="carouselTicker__clone"),
(l.touch="ontouchstart" in document.documentElement),
(l.eventTypes={
mousedown: l.touch ? "touchstart":"mousedown",
mousemove: l.touch ? "touchmove":"mousemove",
mouseup: l.touch ? "touchend":"mouseup",
}),
e();
}
var l={},
s=this,
n=d(this),
e=function (){
function e(){
n.children().hasClass(l.wrapCls) ||
(d("<div class='" + l.loaderCls + "'></div>").appendTo(n),
n.find("." + l.wrapCls).css({ position: "relative" }),
l.$list.wrap("<div class='carouselTicker__wrap' style='position: relative; overflow: hidden; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none;'></div>"
),
l.$items.clone().addClass(l.cloneCls).appendTo(l.$list),
l.$list.css({ position: "relative" }),
(l.isInitialize = !0),
l.settings.onCarouselTickerLoad(),
o());
}
"horizontal"===l.settings.mode
? (c(),
l.itemsWidth > l.$parent.width() &&
(n.find("." + l.wrapCls).css({ width: l.$parent.width() + "px" }),
l.$list.css({ width: 2 * l.itemsWidth, left: 0 }),
e()))
: "vertical"===l.settings.mode &&
((l.itemsHeight=0),
l.$items.each(function (){
var e=d(this);
e.hasClass(l.cloneCls)||(l.itemsHeight +=e.outerHeight(!0));
}),
l.itemsHeight > l.$parent.height() &&
(n
.find("." + l.wrapCls)
.css({ height: l.$parent.height() + "px" }),
l.$list.css({ height: 2 * l.itemsHeight, top: 0 }),
e())),
l.isInitialize &&
n.on("dragstart", function (e){
if("IMG"==e.target.nodeName.toUpperCase() ||
"A"==e.target.nodeName.toUpperCase()
)
return !1;
});
},
o=function (){
var a;
n.find("." + l.loaderCls).length&&n.find("." + l.loaderCls).remove(),
(l.intervalPointer=setInterval(function (){
r();
}, l.settings.delay)),
l.settings.pauseOnHover &&
(n.on("mouseover", h), n.on("mouseleave", u)),
(a = !1),
l.$list.on(l.eventTypes.mousedown, function (e){
var s=e.clientX||event.touches[0].pageX,
n=e.clientY||event.touches[0].pageY,
o=d(this),
r=parseFloat(d(this).css("left")),
c=parseFloat(d(this).css("top"));
d(e.target).off("click"),
clearInterval(l.intervalPointer),
(l.intervalPointer = !1),
(a = !0),
o.on(l.eventTypes.mousemove, function (e){
var t=e.clientX||event.touches[0].pageX,
i=e.clientY||event.touches[0].pageY,
t=s - t,
i=n - i;
l.touch &&
d(document).on("touchmove", function (e){
e.preventDefault();
}),
"horizontal"===l.settings.mode
? (l.directionSwitcher=0 <=t ? -1:1)
: "vertical"===l.settings.mode &&
(l.directionSwitcher=0 <=i ? -1:1),
(l.isMousemove = !0),
a &&
("horizontal"===l.settings.mode
? (0 <=r - t &&
1===l.directionSwitcher &&
(o.css("left", "-=" + l.itemsWidth),
(r=-l.itemsWidth),
(s=e.clientX||event.touches[0].pageX),
(t=0)),
r - t <=-l.itemsWidth &&
-1===l.directionSwitcher &&
(o.css("left", 0),
(t=r = 0),
(s=e.clientX||event.touches[0].pageX)),
o.css("left", r - t + "px"))
: "vertical"===l.settings.mode &&
(0 <=c - i &&
1===l.directionSwitcher &&
(o.css("top", "-=" + l.itemsHeight),
(c=-l.itemsHeight),
(n=e.clientY||event.touches[0].pageY),
(i=0)),
c - i <=-l.itemsHeight &&
-1===l.directionSwitcher &&
(o.css("top", 0),
(i=c = 0),
(n=e.clientY||event.touches[0].pageY)),
o.css("top", c - i + "px")));
});
}),
l.$list.on(l.eventTypes.mouseup, function (e){
var t=d(e.target);
(t.attr("href")||(t.parents().attr("href")&&l.isMousemove)) &&
(e.preventDefault(),
t.on("click", function (e){
e.preventDefault();
})),
(a = !1),
(l.isMousemove = !1),
(l.settings.direction =
1===l.directionSwitcher ? "next":"prev"),
d(this).off(l.eventTypes.mousemove),
l.touch&&d(document).off("touchmove"),
l.intervalPointer&&clearInterval(l.intervalPointer),
l.touch &&
(l.intervalPointer=setInterval(function (){
r();
}, l.settings.delay));
});
},
r=function (){
var e="horizontal"===l.settings.mode ? "left":"top",
t="horizontal"===l.settings.mode ? l.itemsWidth:l.itemsHeight;
l.$list.css(e, "+=" + l.directionSwitcher * l.settings.speed + "px"),
"prev"===l.settings.direction &&
Math.abs(parseInt(l.$list.css(e))) >=t &&
l.$list.css(e, 0),
"next"===l.settings.direction &&
0 <=parseInt(l.$list.css(e)) &&
l.$list.css(e, -t + "px");
};
function c(){
(l.itemsWidth=0),
l.$items.each(function (){
var e=d(this),
t=this.currentStyle||window.getComputedStyle(this),
t=parseFloat(t.marginLeft) + parseFloat(t.marginRight);
e.hasClass(l.cloneCls) ||
(l.itemsWidth +=this.getBoundingClientRect().width + t);
});
}
function h(){
("horizontal"===l.settings.mode
? l.itemsWidth > l.$parent.width()
: l.itemsHeight > l.$parent.height()) &&
(clearInterval(l.intervalPointer), (l.intervalPointer = !1));
}
function u(){
var e =
"horizontal"===l.settings.mode
? l.itemsWidth > l.$parent.width()
: l.itemsHeight > l.$parent.height();
l.isMousemove &&
(l.$list.off(l.eventTypes.mousemove),
l.$list.trigger(l.eventTypes.mouseup)),
e &&
(l.intervalPointer ||
(l.intervalPointer=setInterval(function (){
r();
}, l.settings.delay)));
}
return (
(s.resizeTicker=function (){
c(),
l.itemsWidth > l.$parent.width()
? l.isInitialize||i()
: l.isInitialize&&s.destructor();
}),
(s.stop=function (){
l.settings.pauseOnHover &&
(n.off("mouseover", h), n.off("mouseleave", u)),
clearInterval(l.intervalPointer),
(l.intervalPointer = !1);
}),
(s.run=function (){
o();
}),
(s.destructor=function (){
var e;
n.find("." + l.cloneCls).remove(),
n.find("." + l.wrapCls).length &&
((e=n.find("." + l.listCls)).unwrap(),
e.css({ left: "auto", position: "static", width: "auto" }),
n.css({ width: "auto", position: "static" })),
s.stop(),
(l.isInitialize = !1);
}),
(s.reloadCarouselTicker=function (e){
null!=e&&(t=e), s.destructor(), i();
}),
(s.next=function (){
s.stop(),
(l.settings.direction="next"),
(l.directionSwitcher="prev"===l.settings.direction ? -1:1),
s.run();
}),
(s.prev=function (){
s.stop(),
(l.settings.direction="prev"),
(l.directionSwitcher="prev"===l.settings.direction ? -1:1),
s.run();
}),
"loading"===document.readyState
? d(window).on("load", function (){
i();
})
: i(),
this
);
};})(jQuery);