var bind = function (t, i) { return function () { return t.apply(i, arguments) } }; ! function ($) { return this.FilmRoll = function () { function t(t) { var i; return this.options = null != t ? t : {}, this.rotateRight = bind(this.rotateRight, this), this.rotateLeft = bind(this.rotateLeft, this), this.resize = bind(this.resize, this), this.moveRight = bind(this.moveRight, this), this.moveLeft = bind(this.moveLeft, this), this.configureWidths = bind(this.configureWidths, this), this.configureSwipe = bind(this.configureSwipe, this), this.configureScroll = bind(this.configureScroll, this), this.configureLoad = bind(this.configureLoad, this), this.configureHover = bind(this.configureHover, this), this.clearScroll = bind(this.clearScroll, this), this.options.container && (this.div = $(this.options.container), this.div.length) ? (i = this.div.data("film_roll_instance")) ? i : (i = this.configure(), this.div.data("film_roll_instance", i), i) : void 0 } return t.prototype.configure = function () { var i; /* return this.children = this.div.children(), this.children.wrapAll('
'), this.children.wrapAll('
'), this.wrapper = this.div.find(".film_roll_wrapper"), this.shuttle = this.div.find(".film_roll_shuttle"), this.rotation = [], this.shuttle.width(this.options.shuttle_width ? parseInt(this.options.shuttle_width, 10) : 1e4), this.options.start_height && this.wrapper.height(parseInt(this.options.start_height, 10)), this.options.vertical_center && this.shuttle.addClass("vertical_center"), this.options.no_css === !0 || document.film_roll_styles_added || ($("").appendTo("head"), document.film_roll_styles_added = !0), this.options.pager !== !1 && (this.pager = $('
'), this.div.append(this.pager), this.children.each(function (t) { */ return this.children = this.div.children(), this.children.wrapAll('
'), this.children.wrapAll('
'), this.wrapper = this.div.find(".film_roll_wrapper"), this.shuttle = this.div.find(".film_roll_shuttle"), this.rotation = [], this.shuttle.width(this.options.shuttle_width ? parseInt(this.options.shuttle_width, 10) : 1e4), this.options.start_height && this.wrapper.height(parseInt(this.options.start_height, 10)), this.options.vertical_center && this.shuttle.addClass("vertical_center"), this.options.no_css === !0 || document.film_roll_styles_added || ($("").appendTo("head"), document.film_roll_styles_added = !0), this.options.pager !== !1 && (this.pager = $('
'), this.div.append(this.pager), this.children.each(function (t) { return function (i, e) { var o; return o = $("" + (i + 1) + ""), t.pager.append(o), o.click(function () { return t.index = i, t.moveToIndex(t.index, "best", !0), !1 }) } }(this))), this.pager_links = this.div.find(".film_roll_pager a"), "scroll" === this.options.hover ? (this.options.scroll = !1, this.hover_in = function (t) { return function () { return clearTimeout(t.hover_timer), t.hover_timer = setTimeout(function () { return t.moveLeft(), t.configureScroll() }, 300) } }(this), this.hover_out = this.clearScroll) : this.options.hover !== !1 && (this.hover_in = function (t) { return function () { return clearTimeout(t.hover_timer), t.hover_timer = setTimeout(function () { return t.clearScroll() }, 300) } }(this), this.hover_out = this.configureScroll), this.options.hover !== !1 && (this.mouse_catcher = $('
'), this.mouse_catcher.appendTo(this.wrapper).mousemove(function (t) { return function () { return t.hover_in(), t.mouse_catcher.remove() } }(this))), i = null, this.children.each(function (t) { return function (i, e) { var o; return o = $(e), o.attr("data-film-roll-child-id", i), o.addClass("film_roll_child"), t.rotation.push(e) } }(this)), this.options.prev !== !1 && (this.options.prev && this.options.next ? this.prev = $(this.options.prev) : (this.wrapper.append(''), this.prev = this.div.find(".film_roll_prev")), this.prev.click(function (t) { return function () { return t.moveRight() } }(this))), this.options.next !== !1 && (this.options.next ? this.next = $(this.options.next) : (this.wrapper.append(''), this.next = this.div.find(".film_roll_next")), this.next.click(function (t) { return function () { return t.moveLeft() } }(this))), this.index = this.options.start_index || 0, this.offset = this.options.offset || 0, this.interval = this.options.interval || 4e3, this.animation = this.options.animation || this.interval / 4, this.easing = this.options.easing || t.default_easing, this.options.resize !== !1 && $(window).resize(function (t) { return function () { return t.resize() } }(this)), this.options.configure_load ? "function" == typeof this.options.configure_load ? this.options.configure_load.apply(this, arguments) : "number" == typeof this.options.configure_load ? setTimeout(function (t) { return function () { return t.configureLoad() } }(this), this.options.configure_load) : this.configureLoad() : $(window).load(this.configureLoad), this.options.swipe !== !1 && this.configureSwipe(), this.div.trigger($.Event("film_roll:dom_ready")), this }, t.prototype.bestDirection = function (t, i) { return i || (i = $.inArray(t, this.rotation)), i < this.children.length / 2 ? "right" : "left" }, t.prototype.cancelClick = function (t) { return $(this).hasClass("fr-no-click") ? (t.preventDefault(), !1) : !0 }, t.prototype.childIndex = function (t) { return $.inArray(t, this.children) }, t.prototype.childWidth = function (t) { var i; return i = this.childIndex(t), this.child_widths[i] || $(t).outerWidth(!0) }, t.prototype.clearScroll = function () { return this.scrolled !== !1 && (clearInterval(this.timer), this.scrolled = !1), this }, t.prototype.configureHover = function () { return this.div.hover(this.hover_in, this.hover_out), this.options.prev && this.options.next ? (this.prev.hover(this.hover_in, this.hover_out), this.next.hover(this.hover_in, this.hover_out)) : void 0 }, t.prototype.configureLoad = function () { return this.configureWidths(), this.options.move_on_start !== !1 && this.moveToIndex(this.index, "right", !0), "scroll" === this.options.hover ? (this.options.scroll = !1, this.configureHover()) : this.options.scroll !== !1 && (this.configureScroll(), this.options.hover !== !1) ? this.configureHover() : void 0 }, t.prototype.configureScroll = function () { return this.scrolled !== !0 && (this.timer = setInterval(function (t) { return function () { return t.moveLeft() } }(this), this.interval), this.scrolled = !0), this }, t.prototype.configureSwipe = function () { return "undefined" != typeof $.fn.swipe ? (this.div.swipe({ swipeStatus: function (t) { return function (i, e, o, r) { var n, s; if ("up" === o || "down" === o) return !1; if ("start" === e) { if (s = t.wrapper.width(), s >= t.real_width || 1 === t.children.length) return !1; t.was_scrolled = t.scrolled, t.scrolled && t.clearScroll(), t.active_half = t.child_widths[t.index] / 2, n = $.inArray(t.children[t.index], t.rotation), t.offscreen_left = parseInt(t.shuttle.css("left"), 10), t.offscreen_right = t.marginRight(n) - (s - t.child_widths[t.index]) / 2, t.div.find("a").addClass("fr-no-click") } else "move" === e ? "left" === o ? (r > t.active_half && ($(t.children[t.index]).removeClass("active"), t.index = (t.index + 1) % t.children.length, $(t.children[t.index]).addClass("active"), t.active_half += t.child_widths[t.index]), r > t.offscreen_right && (t.offscreen_left = t.rotateLeft() + r, t.offscreen_right += t.childWidth(t.rotation[t.rotation.length - 1])), t.shuttle.css("left", t.offscreen_left - r)) : (r > t.active_half && ($(t.children[t.index]).removeClass("active"), t.index -= 1, t.index < 0 && (t.index = t.children.length - 1), $(t.children[t.index]).addClass("active"), t.active_half += t.child_widths[t.index]), r + t.offscreen_left > 0 && (t.offscreen_left = t.rotateRight() - r), t.shuttle.css("left", t.offscreen_left + r)) : ("end" === e ? t.moveToIndex(t.index, o) : "cancel" === e && (t.moveToIndex(t.index, "right" === o ? "left" : "right"), t.div.find("a.fr-no-click").removeClass("fr-no-click")), t.was_scrolled && t.configureScroll()); return !0 } }(this), excludedElements: "label, button, input, select, textarea, .noSwipe", allowPageScroll: "vertical" }), this.div.find("a").on("click", this.cancelClick)) : void 0 }, t.prototype.configureWidths = function () { var t; return this.width = t = 0, this.wrapper.css({ height: "", "min-height": 0 }), this.shuttle.width("").removeClass("film_roll_shuttle").addClass("film_roll_resizing"), this.children.width(""), this.div.trigger($.Event("film_roll:resizing")), this.child_widths = [], this.options.height && this.options.height.toString().match(/^\+/) ? (this.options.height_padding = parseInt(this.options.height, 10), this.options.height = null) : this.options.height_padding = 0, this.children.each(function (i) { return function (e, o) { var r, n, s; return r = $(o), r.width(r.outerWidth(!0)), s = r.outerWidth(!0), i.child_widths.push(s), i.width += s, i.options.height || (n = r.outerHeight(!0), n > t && (t = n)), o } }(this)), this.options.height ? this.wrapper.height(this.options.height) : (this.wrapper.height(""), this.wrapper.css("min-height", t + this.options.height_padding)), this.real_width = this.width, this.shuttle.width(2 * this.real_width).removeClass("film_roll_resizing").addClass("film_roll_shuttle"), this.wrapper.width() > this.real_width ? (this.options.force_buttons || this.options.prev === !1 || this.prev.hide(), this.options.force_buttons || this.options.next === !1 || this.next.hide()) : (this.options.prev !== !1 && this.prev.show(), this.options.next !== !1 && this.next.show()), this }, t.prototype.rotationIndex = function (t) { return $.inArray(t, this.rotation) }, t.prototype.marginLeft = function (t) { var i, e, o, r, n, s; for (n = 0, s = this.rotation, e = o = 0, r = s.length; r > o; e = ++o) i = s[e], t > e && e >= 0 && (n += this.childWidth(i)); return n }, t.prototype.marginRight = function (t) { var i, e, o, r, n, s, h; for (s = this.rotation.length - 1, n = 0, h = this.rotation, e = o = 0, r = h.length; r > o; e = ++o) i = h[e], e > t && s >= e && (n += this.childWidth(i)); return n }, t.prototype.moveLeft = function () { return this.index = (this.index + 1) % this.children.length, this.moveToIndex(this.index, "left", !0), !1 }, t.prototype.moveRight = function () { return this.index -= 1, this.index < 0 && (this.index = this.children.length - 1), this.moveToIndex(this.index, "right", !0), !1 }, t.prototype.moveToChild = function (t) { var i; return i = this.childIndex($(t)[0]), i > -1 ? this.moveToIndex(i) : void 0 }, t.prototype.moveToIndex = function (t, i, e) { var o, r, n, s, h, l, a, d, c; if (null == e && (e = !0), this.index = t, l = this.scrolled, this.clearScroll(), o = this.children[t], h = $.inArray(o, this.rotation), i && "best" !== i || (i = this.bestDirection(o, h)), this.children.removeClass("active"), $(o).addClass("active").trigger($.Event("film_roll:activate")), this.pager_links.removeClass("active"), $(this.pager_links[t]).addClass("active"), c = this.wrapper.width(), s = c - this.child_widths[t], a = "left" === this.options.position ? 0 + this.offset : "right" === this.options.position ? c - this.child_widths[t] + this.offset : s / 2 + this.offset, d = s - a, c < this.real_width && this.children.length > 1 || this.options.force_rotate) if ("right" === i) for (; 0 === h || this.marginLeft(h) < a;) this.rotateRight(), h = $.inArray(o, this.rotation); else for (; h === this.children.length - 1 || this.marginRight(h) < d;) this.rotateLeft(), h = $.inArray(o, this.rotation); return n = -1 * (this.marginLeft(h) - a), e ? (r = "moving_" + i, this.shuttle.addClass(r), this.div.trigger($.Event("film_roll:moving")), this.shuttle.stop().animate({ left: n }, this.animation, this.easing, function (t) { return function () { return t.shuttle.removeClass(r), t.div.trigger($.Event("film_roll:moved")) } }(this))) : (this.shuttle.css("left", n), this.div.trigger($.Event("film_roll:moved"))), l && this.configureScroll(), this }, t.prototype.resize = function () { return clearTimeout(this.resize_timer), this.resize_timer = setTimeout(function (t) { return function () { var i; return i = t.scrolled, t.clearScroll(), i && t.configureScroll(), t.configureWidths(), t.moveToIndex(t.index, "best"), t.div.trigger($.Event("film_roll:resized")) } }(this), 200), this }, t.prototype.rotateLeft = function () { var t, i, e, o; return t = this.shuttle.css("left"), o = t ? parseInt(t, 10) : 0, i = this.rotation.shift(), e = o + this.childWidth(i), this.rotation.push(i), this.shuttle.css("left", e), this.shuttle.append(this.shuttle.children().first().detach()), e }, t.prototype.rotateRight = function () { var t, i, e, o; return t = this.shuttle.css("left"), o = t ? parseInt(t, 10) : 0, i = this.rotation.pop(), e = o - this.childWidth(i), this.rotation.unshift(i), this.shuttle.css("left", e), this.shuttle.prepend(this.shuttle.children().last().detach()), e }, t }(), this.FilmRoll.default_easing = "easeInOutQuint" }(jQuery);