|
| 1 | +$(document).ready(function() { |
| 2 | + // Initialise all tooltips |
| 3 | + $(function() { |
| 4 | + $('[data-toggle="tooltip"]').tooltip(); |
| 5 | + }); |
| 6 | + |
| 7 | + // KANBAN JS |
| 8 | + if (window.location.pathname == '/kanban/') { |
| 9 | + // Toggle Cancelled column display |
| 10 | + $('#cancelled-checkbox').click(function() { |
| 11 | + $('.kanban-cancelled') |
| 12 | + .parent() |
| 13 | + .toggleClass('d-none'); |
| 14 | + }); |
| 15 | + } |
| 16 | + |
| 17 | + // USER lIST JS |
| 18 | + if (window.location.pathname == '/accounts/user_list/') { |
| 19 | + // Initialize DataTables |
| 20 | + $('#submitters-table').DataTable({ |
| 21 | + language: { |
| 22 | + search: '_INPUT_', |
| 23 | + searchPlaceholder: 'Search...' |
| 24 | + }, |
| 25 | + // Set template of pagination display |
| 26 | + oLanguage: { |
| 27 | + sLengthMenu: 'Show: _MENU_ users', |
| 28 | + sInfo: 'Showing: _START_-_END_ of _TOTAL_' |
| 29 | + } |
| 30 | + }); |
| 31 | + $('#assignees-table').DataTable({ |
| 32 | + language: { |
| 33 | + search: '_INPUT_', |
| 34 | + searchPlaceholder: 'Search...' |
| 35 | + }, |
| 36 | + // Set template of pagination display |
| 37 | + oLanguage: { |
| 38 | + sLengthMenu: 'Show: _MENU_ users', |
| 39 | + sInfo: 'Showing: _START_-_END_ of _TOTAL_' |
| 40 | + } |
| 41 | + }); |
| 42 | + } |
| 43 | + |
| 44 | + // TICKETS JS |
| 45 | + if (window.location.pathname == '/tickets/') { |
| 46 | + console.log('TICKETS PAGE'); |
| 47 | + |
| 48 | + // Field Filtering: Insert a text input to each footer cell of table |
| 49 | + $('#tickets-table tfoot th').each(function() { |
| 50 | + var title = $(this).text(); |
| 51 | + $(this).html('<input type="text" placeholder="Search ' + title + '" />'); |
| 52 | + }); |
| 53 | + |
| 54 | + let ticketsTable = $('#tickets-table').DataTable({ |
| 55 | + // Add Global search box |
| 56 | + language: { |
| 57 | + search: '_INPUT_', |
| 58 | + searchPlaceholder: 'Search All...' |
| 59 | + }, |
| 60 | + // Define Column widths |
| 61 | + columnDefs: [ |
| 62 | + { width: '16px', targets: [0, 2, 5, 6] }, |
| 63 | + { width: '340px', targets: [1] } |
| 64 | + ], |
| 65 | + // Set template of pagination display |
| 66 | + oLanguage: { |
| 67 | + sLengthMenu: 'Show: _MENU_ tickets', |
| 68 | + sInfo: 'Showing: _START_-_END_ of _TOTAL_' |
| 69 | + } |
| 70 | + }); |
| 71 | + // Apply the search |
| 72 | + // Source: https://datatables.net/examples/api/multi_filter.html |
| 73 | + ticketsTable.columns().every(function() { |
| 74 | + let that = this; |
| 75 | + $('input', this.footer()).on('keyup change clear', function() { |
| 76 | + if (that.search() !== this.value) { |
| 77 | + that.search(this.value).draw(); |
| 78 | + } |
| 79 | + }); |
| 80 | + }); |
| 81 | + // Move to search boxes to head of table |
| 82 | + $('#tickets-table tfoot tr').appendTo('#tickets-table thead'); |
| 83 | + // Set search box placeholders to blank |
| 84 | + $('#ticket-search-boxes th input').attr('placeholder', ''); |
| 85 | + // Clickable row |
| 86 | + $('.clickable-row').on('click', function() { |
| 87 | + window.location = $(this).data('url'); |
| 88 | + }); |
| 89 | + } |
| 90 | +}); |
0 commit comments