var Wick = Wick || {};
Wick.CharityDonations = function () {

    var cConst = {
        $charity: $('.charity'),
        $label: $('.charity label'),
        $orderLine: $('.order-line_charity'),
        charityHide: 'charity_hide',
        orderLineShow: 'order-line_charity_show',
        orderLineDelete: '.order-line__delete'
    };

    function init() {
        //add donation to the list
        cConst.$label.on('click', function () {
            cConst.$charity.addClass(cConst.charityHide);
            cConst.$orderLine.addClass(cConst.orderLineShow);
        });

        //remove donation from the list
        cConst.$orderLine.find(cConst.orderLineDelete).on('click', function () {
            cConst.$label.trigger('click');
            cConst.$charity.removeClass(cConst.charityHide);
            cConst.$orderLine.removeClass(cConst.orderLineShow);
        })
    }

    if (!cConst.$charity.length) {
        return;
    }

    init();
}();

