/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

var board_cu = function () {

    var hosturl = $('#hosturl').val();
    var path = $('#path').val();
    //specailized vaildation
    var handleSummernote = function () {
        $('.summernote_1').summernote({height: 300});
    };

    var datepicker = function () {
        $('.datepickertoday').datepicker('setDate', '+0');
        $('.date-picker').datepicker();
    };
    var initTable1 = function () {
        var table = $('#sample_1');
        $.extend(true, $.fn.DataTable.TableTools.classes, {
            "container": "btn-group tabletools-dropdown-on-portlet",
            "buttons": {
                "normal": "btn btn-sm default",
                "disabled": "btn btn-sm default disabled"
            },
            "collection": {
                "container": "DTTT_dropdown dropdown-menu tabletools-dropdown-menu"
            }
        });
        var oTable = table.dataTable({
            "language": {
                "aria": {
                    "sortAscending": ": activate to sort column ascending",
                    "sortDescending": ": activate to sort column descending"
                },
                "emptyTable": "No data available in table",
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
                "infoEmpty": "No entries found",
                "infoFiltered": "(filtered1 from _MAX_ total entries)",
                "lengthMenu": "Show _MENU_ entries",
                "search": "Search:",
                "zeroRecords": "No matching records found"
            },
            "order": [
                [0, 'asc']
            ],
            "lengthMenu": [
                [5, 10, 15, 20, -1],
                [5, 10, 15, 20, "All"]
            ],
            "pageLength": 10,
            "dom": "<'row' <'col-md-12'T>><'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>>",
            "tableTools": {
                "sSwfPath": "../../assets/global/plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf",
                "aButtons": [{
                        "sExtends": "pdf",
                        "sButtonText": "PDF"
                    }, {
                        "sExtends": "csv",
                        "sButtonText": "CSV"
                    }, {
                        "sExtends": "xls",
                        "sButtonText": "Excel"
                    }, {
                        "sExtends": "print",
                        "sButtonText": "Print",
                        "sInfo": 'Please press "CTR+P" to print or "ESC" to quit',
                        "sMessage": "Generated by DataTables"
                    }]
            }
        });
        var tableWrapper = $('#sample_1_wrapper');
        tableWrapper.find('.dataTables_length select').select2();
    }
//    var handleRecords = function () {
//        var grid = new Datatable();
//        grid.init({src: $(".datatable_ajax"), onSuccess: function (grid, response) {
//            }, onError: function (grid) {
//            }, onDataLoad: function (grid) {
//            }, loadingMessage: 'Loading...', dataTable: {"bStateSave": true, "lengthMenu": [[10, 20, 50, 100, 150, -1], [10, 20, 50, 100, 150, "All"]], "pageLength": 50, "ajax": {"url": "demo/table_ajax.php", }, "order": [[1, "asc"]]}});
//        grid.getTableWrapper().on('click', '.table-group-action-submit', function (e) {
//            e.preventDefault();
//            var action = $(".table-group-action-input", grid.getTableWrapper());
//            if (action.val() != "" && grid.getSelectedRowsCount() > 0) {
//                grid.setAjaxParam("customActionType", "group_action");
//                grid.setAjaxParam("customActionName", action.val());
//                grid.setAjaxParam("id", grid.getSelectedRows());
//                grid.getDataTable().ajax.reload();
//                grid.clearAjaxParams();
//            } else if (action.val() == "") {
//                Metronic.alert({type: 'danger', icon: 'warning', message: 'Please select an action', container: grid.getTableWrapper(), place: 'prepend'});
//            } else if (grid.getSelectedRowsCount() === 0) {
//                Metronic.alert({type: 'danger', icon: 'warning', message: 'No record selected', container: grid.getTableWrapper(), place: 'prepend'});
//            }
//        });
//
//    }


    return {
        //main function to initiate the module
        init: function () {
            handleSummernote();
            datepicker();
            initTable1();
            //handleRecords();
        }

    };
}();