(function($) {
	"use strict";
    $(document).ready(function() {
        // data fetching
        $("#contactDataTable").DataTable({
            ordering: true,
            serverSide: true,
            processing: true,
            searching: false,
            responsive: true,
            paging: true,
            ajax: $('#getData').val(),
            columns: [
                {"data": "name", "name": "contact_us.name"},
                {"data": "email", "name": "contact_us.email"},
                {"data": "message", "name": "message"},
                {"data": "created_at", "name": "created_at"},
                {"data": "action", "name": "action","orderable": false, "searchable": false},
            ],
        });
        // data query
        $(document).on("keyup","#search", function() {
            var value = $(this).val().toLowerCase();
            $("#contactDataTable tbody tr").filter(function() {
                $(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
            });
        });
    });

    $(document).on('click', '#viewModal', function(){
        commonAjaxHelper('GET', $('#getViewRoute').val(),{ id:$(this).data('id') }, contactResponseCallback ,contactResponseCallback)
    });
    function contactResponseCallback(response){
        if (response.status == 'success'){
            $('#dataContent').html(response.html)
            $('.viewModal').modal('show')
        }
    }

})(window.jQuery);
