utils.js
2.52 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function editMeaning(id) {
$("#edit-meaning-dialog").load(ajax_edit_meaning_form, "id="+id).dialog('open');
}
function saveMeaning(id) {
var comment = null;
var status = null;
var this_form = $('.edit-meaning-form');
var form_data = this_form.serializeArray();
$.map(form_data, function(elem) {
if (elem.name == 'status')
status = elem.value;
else if (elem.name == 'comment')
comment = elem.value;
});
$.post(ajax_meaning_form_submit, {id: id, status: status, comment: comment},
function(result){
$('#meaningsInfo').empty();
$('#meaningsInfo').load(ajax_refresh_meanings, 'id='+id)
$("#edit-meaning-dialog").dialog('close');
}
);
}
$(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
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) {
$('#meaningsInfo').empty();
});
$('#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();
}
});
});
$("#edit-meaning-dialog").dialog({
title: "Edycja znaczenia:",
width: "auto",
autoOpen: false
});
});