/* 
 * Copyright (c) 2018 Earworks.
 * Codeigniter Advance Template Modification
 * Please contact our email for more information :
 *  contact@earworks.co.id
 */

$(document).ready(function () {
    if ($('.ladda-button').length !== 0) {
        $('.ladda-button').click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            Ladda.bind($(this), {timeout: 500});
            let url = $(this).attr('href');
            let verify = $(this).data('verify');
            if (typeof verify !== 'undefined') {
                var r = confirm(verify);
                if (r === true) {
                    setTimeout(function () {
                        window.location.href = url;
                    }, 600);
                }
            } else {
                setTimeout(function () {
                    window.location.href = url;
                }, 600);
            }
        });
    }
    if ($('.dataTable').length !== 0) 
    {
        $('.dataTable').dataTable({
            "language": {
                "aria": {
                    "sortAscending": ": activate to sort column ascending",
                    "sortDescending": ": activate to sort column descending"
                },
                "emptyTable": msg_emptyTable,
                "info": msg_info,
                "infoEmpty": msg_infoEmpty,
                "infoFiltered": msg_infoFiltered,
                "lengthMenu": msg_lengthMenu,
                "search": msg_search,
                "zeroRecords": msg_zeroRecords
            },
            buttons: [],
            "order": [
                [0, 'asc']
            ],
            "lengthMenu": [
                [5, 10, 15, 20, -1],
                [5, 10, 15, 20, "All"] // change per page values here
            ],
            "pageLength": 10,
            "dom": "<'row' <'col-md-12'B>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable
            // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
            // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js). 
            // So when dropdowns used the scrollable div should be removed. 
            //"dom": "<'row' <'col-md-12'T>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
        });
    }
    if($('.alert').length !== 0){
        
    }
});


