123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- /* ------------------------------------------------------------------------------
- *
- * # Invoice archive
- *
- * Demo JS code for invoice_archive.html page
- *
- * ---------------------------------------------------------------------------- */
- // Setup module
- // ------------------------------
- var InvoiceArchive = function() {
- //
- // Setup module components
- //
- // Datatable
- var _componentDatatable = function() {
- if (!$().DataTable) {
- console.warn('Warning - datatables.min.js is not loaded.');
- return;
- }
- // Initialize
- $('.invoice-archive').DataTable({
- autoWidth: false,
- columnDefs: [
- {
- width: 30,
- targets: 0
- },
- {
- visible: false,
- targets: 1
- },
- {
- orderable: false,
- width: 120,
- targets: 7
- },
- {
- width: '15%',
- targets: [4, 5]
- },
- {
- width: '15%',
- targets: 6
- },
- {
- width: '15%',
- targets: 3
- }
- ],
- order: [[ 0, 'desc' ]],
- dom: '<"datatable-header"fl><"datatable-scroll-lg"t><"datatable-footer"ip>',
- language: {
- search: '<span>Filter:</span> _INPUT_',
- searchPlaceholder: 'Type to filter...',
- lengthMenu: '<span>Show:</span> _MENU_',
- paginate: { 'first': 'First', 'last': 'Last', 'next': $('html').attr('dir') == 'rtl' ? '←' : '→', 'previous': $('html').attr('dir') == 'rtl' ? '→' : '←' }
- },
- lengthMenu: [ 25, 50, 75, 100 ],
- displayLength: 25,
- drawCallback: function ( settings ) {
- var api = this.api();
- var rows = api.rows( {page:'current'} ).nodes();
- var last=null;
-
- api.column(1, {page:'current'} ).data().each( function ( group, i ) {
- if ( last !== group ) {
- $(rows).eq( i ).before(
- '<tr class="table-active table-border-double"><td colspan="8" class="font-weight-semibold">'+group+'</td></tr>'
- );
-
- last = group;
- }
- });
- // Initializw Select2
- if (!$().select2) {
- console.warn('Warning - select2.min.js is not loaded.');
- return;
- }
- $('.form-control-select2').select2({
- width: 150,
- minimumResultsForSearch: Infinity
- });
- }
- });
- };
- // Select2 for length menu styling
- var _componentSelect2 = function() {
- if (!$().select2) {
- console.warn('Warning - select2.min.js is not loaded.');
- return;
- }
- // Initialize
- $('.dataTables_length select').select2({
- minimumResultsForSearch: Infinity,
- dropdownAutoWidth: true,
- width: 'auto'
- });
- };
- //
- // Return objects assigned to module
- //
- return {
- init: function() {
- _componentDatatable();
- _componentSelect2();
- }
- }
- }();
- // Initialize module
- // ------------------------------
- document.addEventListener('DOMContentLoaded', function() {
- InvoiceArchive.init();
- });
|