(function() {
    'use strict';

    var website = openerp.website;
    website.openerp_website = {};

    website.snippet.animationRegistry.kingfisher_product_slider = website.snippet.Animation.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) {
                $.post("/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') || '',
                }, 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");
                    }
                });
            }
        }
    });
    website.snippet.animationRegistry.kingfisher_brand_slider = website.snippet.Animation.extend({
        selector: ".oe_brand_slider",
        start: function(editable_mode) {
            var self = this;
            if (editable_mode) {
                $('.oe_brand_slider .owl-carousel').empty();
            }
            if (!editable_mode) {
                $.post("/shop/get_brand_slider", {
                    'product_label': self.$target.attr('data-product-label') || '',
                }, 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");
                    }
                });
            }
        }
    });
})();