expressions.js 1.84 KB
$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#expressions tfoot th').each( function (index, value) {
        if (index != 0) {
            var title = $(this).text();
            $(this).html( '<input type="text" placeholder="'+title+'" />' );
        }
    } );

    // DataTable
    var table = $('#expressions').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": ajax_expressions,
        "oLanguage": {
            "sSearch": "Wyszukaj:",
            "sZeroRecords": "Brak wyników do wyświetlenia",
            "sInfo": "_TOTAL_ wpisów do pokazania (_START_ do _END_)",
            "sInfoFiltered": "",
            "sInfoEmpty": "",
            "oPaginate": {
                "sPrevious": "Poprzednie",
                "sNext": "Następne"
            },
            "sLengthMenu": 'Pokaż _MENU_ wpisów',
            "sProcessing": 'Ładowanie...'
        },
        "columnDefs": [
            { "orderable": false, "targets": 1 },
            { "orderable": false, "targets": 2 }
        ]
     });

    table.on('processing.dt', function(e, settings, processing) {
        $('#expressionInfo').empty();
    });

    $('#expressions tbody').on('click', 'tr', function() {
        var data = table.row(this).data();
        $('#expressionInfo').load(ajax_expression_info, 'id='+data[3]);
    });

   $('#expressions_filter input').unbind();
   $('#expressions_filter input').bind('keyup', function(e) {
       if(e.keyCode == 13) {
        table.search(this.value).draw();
    }
   });

    // Apply the search
   table.columns().every( function () {
        var that = this;

        $('input', this.footer()).bind('keypress', function(e) {
            if (e.which == 13 && that.search() !== this.value) {
                that.search(this.value).draw();
            }
        } );
    } );
} );