jQuery(document).ready(function($) {
    $("body").delegate('.woccommerce-cb-dashicons-dismiss', 'click', function(e) {

        var $this = $(this);
        var $card_index = $this.data('index-id');
        var $card_token = $this.data('card-token');

        var values = {
            'card_index': $card_index,
            'card_token': $card_token
        };

        var data = {
            'action': 'wccb-ajax-request',
            'func': 'remove_card_token',
            'method': 'WCCB_Ajax_Call',
            'data': values,

        };

        $this.hide().after('<div class="woocommerce-cb-load-spinner" style="display: inline !important;"><img src="' + wccbAjaxService.site_url + '/wp-includes/images/spinner.gif" /></div>');

        $.post(wccbAjaxService.ajax_url, data, function(response) {

            $(".woocommerce-cb-load-spinner").hide();


            if (response.success === true) {
                $this.parent().remove();
            }

        });

        e.preventDefault();
    });

    if( wccbAjaxService.maskcvc == "yes" ){
        setTimeout(function () {
            $("#cybsawm-card-cvc").attr("type","password");
            //console.log($("#cybsawm-card-cvc").attr("type"));
            $("body").delegate('#cybsawm-card-cvc', 'focusin', function(e) {
                $("#cybsawm-card-cvc").attr("type","password");
                
            });
            $("body").delegate('#cybsawm-card-cvc', 'focusout', function(e) {
                $("#cybsawm-card-cvc").attr("type","password");
            });
            
        }, 5000);
    }

});