
(function ($) {
    $.view_list_employee = function (element, options) {
        let defaults = {
            render_employee_item:'',
            list_employee:[],
            items_per_page: 8,
            visiblePages: 3,
            title:''
        };
        let plugin = this;
        plugin.settings = {};
        let $element = $(element);
        plugin.init = function () {
            plugin.settings = $.extend({}, defaults, options);
            let title = plugin.settings.title;
            if(title.trim() === '') {
                $('body').find('.entry-title').html('List employee');
                $('body').find('.nb-breadcrumb .fbc-page li.active span').html('List employee');
            } else {
                $('body').find('.entry-title').html(title)
            }
            let $wrapper_employee_row = $element.find('.wrapper-employee-row');
            let list_employee = plugin.settings.list_employee;
            let $render_employee_item = $(plugin.settings.render_employee_item);
            let $list_employee_render = $render_employee_item.filter('.list-employee-render');
            let items_per_page = plugin.settings.items_per_page;
            let total_result = $list_employee_render.length;
            let total_page = Math.ceil(total_result / items_per_page);
            let visiblePages = (total_page <= 4) ? (total_page % 4): 4;


            // $element.find('.pagination-list-employee').twbsPagination({
            //     totalPages: (total_page === 0)?1:total_page ,
            //     visiblePages: visiblePages,
            //     onPageClick: function (event, page) {
            //         var data_page = $list_employee_render.slice((page - 1) * items_per_page, page * items_per_page);
            //         $wrapper_employee_row.empty();
            //         $.each(data_page, function (index, employee) {
            //             $wrapper_employee_row.append(employee.outerHTML)
            //         });

            //     }
            // });
            $element.find('.wrapper-employee').hover(function (e) {
                let $wrapper_employee = $(this).closest('.wrapper-employee');
                $wrapper_employee.addClass('hover');
            }, function (e) {
                let $wrapper_employee = $(this).closest('.wrapper-employee');
                $wrapper_employee.removeClass('hover');
            })
        };
        plugin.example_function = function () {
        };
        plugin.init();
    };
    $.fn.view_list_employee = function (options) {
        return this.each(function () {
            if (undefined === $(this).data('view_list_employee')) {
                let plugin = new $.view_list_employee(this, options);
                $(this).data('view_list_employee', plugin);
            }
        });
    }
})(jQuery);
