odoo.define('kingfisher.front_js', function(require) {
    "use strict";

    var animation = require('web_editor.snippets.animation');
    animation.registry.kingfisher_product_slider = animation.Class.extend({
        selector: ".oe_product_slider",
        start: function(editable_mode) {
            var self = this;
            if (editable_mode) {
                $('.oe_product_slider .slider_product_slider .owl-carousel').empty();
            }
            if (!editable_mode) {
                $.get("/shop/get_products_slider", {
                    'product_count': self.$target.attr('data-product-count') || 0,
                    'slider_type': self.$target.attr('data-slider-type') || '',
                    'product_label': self.$target.attr('data-product-label') || '',
                }).then(function(data) {
                    if (data) {
                        self.$target.empty().append(data);
                        $(".oe_product_slider").removeClass('hidden');
                        $.getScript("/kingfisher/static/src/js/owl.carousel.min.js");
                        $.getScript("/kingfisher/static/src/js/custom.js");
                    }
                });
            }
        }
    });
    animation.registry.kingfisher_brand_slider = animation.Class.extend({
        selector: ".oe_brand_slider",
        start: function(editable_mode) {
            var self = this;
            if (editable_mode) {
                $('.oe_brand_slider .owl-carousel').empty();
            }
            if (!editable_mode) {
                $.get("/shop/get_brand_slider", {
                    'product_label': self.$target.attr('data-product-label') || '',
                }).then(function(data) {
                    if (data) {
                        self.$target.empty().append(data);
                        $(".oe_brand_slider").removeClass('hidden');
                        $.getScript("/kingfisher/static/src/js/owl.carousel.min.js");
                        $.getScript("/kingfisher/static/src/js/custom.js");
                    }
                });
            }
        }
    });
});