summaryrefslogtreecommitdiff
blob: 95200ea9ec23f75d2a51bbdf7c9c090521f61036 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import "core-js/stable";
import "regenerator-runtime/runtime";
require("turbolinks").start();
import 'bootstrap';


window.dataTables = [];
window.RequestsDataTables = [];
window.DraftsDataTables = [];
window.ArchivesDataTables = [];
window.AllDataTables = [];

require( 'datatables.net' )( window, $ );
require( 'datatables.net-bs4' )( window, $ );
require( 'datatables.net-buttons' )( window, $ );
require( 'datatables.net-buttons-bs4/js/buttons.bootstrap4.min' )( window, $ );
require('datatables.net-buttons/js/buttons.colVis.js')( window, $ );

import requests from './src/javascript/requests';
import all from './src/javascript/all';
import drafts from './src/javascript/drafts';
import archive from './src/javascript/archive';
import cvetool from './src/javascript/cvetool';

document.addEventListener("turbolinks:load", () => {
    requests.initDatatable();
    drafts.initDatatable();
    archive.initDatatable();
    cvetool.initDatatable();
    all.initDatatable();
});

document.addEventListener("turbolinks:before-cache", () => {
    requests.destroyDatatable();
    drafts.destroyDatatable();
    archive.destroyDatatable();
    cvetool.destroyDatatable();
    all.destroyDatatable();
});


// double shift press

var delta = 500;
var lastKeypressTime = 0;
function KeyHandler(event) {
    if ( event.ctrlKey ){
        var thisKeypressTime = new Date();
        if ( thisKeypressTime - lastKeypressTime <= delta ) {
            doDoubleKeypress();
            thisKeypressTime = 0;
        }
        lastKeypressTime = thisKeypressTime;
    }
}

function doDoubleKeypress() {
    if($('#large-quicksearch').length){
        $('#large-quicksearch').val('');
        $('#large-quicksearch').focus();
    }else if($('#quicksearch').length){
        $('#quicksearch').val('');
        $('#quicksearch').focus();
    }
}

// keyboard navigation is disabled for now
//document.addEventListener('keydown', KeyHandler);