##// END OF EJS Templates
datatables: use new way of generating labels for count of dynamic datatables....
marcink -
r2726:a9ece9dd default
parent child Browse files
Show More
@@ -22,21 +22,21 b''
22 $(document).ready(function() {
22 $(document).ready(function() {
23 var $sshKeyListTable = $('#ssh_keys_table');
23 var $sshKeyListTable = $('#ssh_keys_table');
24
24
25 var getDatatableCount = function(){
26 var table = $sshKeyListTable.dataTable();
27 var page = table.api().page.info();
28 var active = page.recordsDisplay;
29 var total = page.recordsTotal;
30
31 var _text = _gettext("{0} out of {1} ssh keys").format(active, total);
32 $('#ssh_keys_count').text(_text);
33 };
34
35 // user list
25 // user list
36 $sshKeyListTable.DataTable({
26 $sshKeyListTable.DataTable({
37 processing: true,
27 processing: true,
38 serverSide: true,
28 serverSide: true,
39 ajax: "${h.route_path('admin_permissions_ssh_keys_data')}",
29 ajax: {
30 "url": "${h.route_path('admin_permissions_ssh_keys_data')}",
31 "dataSrc": function ( json ) {
32 var filteredCount = json.recordsFiltered;
33 var total = json.recordsTotal;
34
35 var _text = _gettext("{0} out of {1} ssh keys").format(filteredCount, total);
36 $('#ssh_keys_count').text(_text);
37 return json.data;
38 }
39 },
40 dom: 'rtp',
40 dom: 'rtp',
41 pageLength: ${c.visual.admin_grid_items},
41 pageLength: ${c.visual.admin_grid_items},
42 order: [[ 0, "asc" ]],
42 order: [[ 0, "asc" ]],
@@ -75,11 +75,6 b''
75 $sshKeyListTable.css('opacity', 0.3);
75 $sshKeyListTable.css('opacity', 0.3);
76 });
76 });
77
77
78 // refresh counters on draw
79 $sshKeyListTable.on('draw.dt', function(){
80 getDatatableCount();
81 });
82
83 // filter
78 // filter
84 $('#q_filter').on('keyup',
79 $('#q_filter').on('keyup',
85 $.debounce(250, function() {
80 $.debounce(250, function() {
@@ -43,23 +43,15 b''
43 <script type="text/javascript">
43 <script type="text/javascript">
44
44
45 $(document).ready(function() {
45 $(document).ready(function() {
46 var $userListTable = $('#fork_list_table');
46 var $forksListTable = $('#fork_list_table');
47
47
48 var getDatatableCount = function(){
48 // fork list
49 var table = $userListTable.dataTable();
49 $forksListTable.DataTable({
50 var page = table.api().page.info();
51 var active = page.recordsDisplay;
52 var total = page.recordsTotal;
53
54 var _text = _gettext("{0} out of {1} users").format(active, total);
55 $('#user_count').text(_text);
56 };
57
58 // user list
59 $userListTable.DataTable({
60 processing: true,
50 processing: true,
61 serverSide: true,
51 serverSide: true,
62 ajax: "${h.route_path('repo_forks_data', repo_name=c.repo_name)}",
52 ajax: {
53 "url": "${h.route_path('repo_forks_data', repo_name=c.repo_name)}",
54 },
63 dom: 'rtp',
55 dom: 'rtp',
64 pageLength: ${c.visual.dashboard_items},
56 pageLength: ${c.visual.dashboard_items},
65 order: [[ 0, "asc" ]],
57 order: [[ 0, "asc" ]],
@@ -92,23 +84,18 b''
92 }
84 }
93 });
85 });
94
86
95 $userListTable.on('xhr.dt', function(e, settings, json, xhr){
87 $forksListTable.on('xhr.dt', function(e, settings, json, xhr){
96 $userListTable.css('opacity', 1);
88 $forksListTable.css('opacity', 1);
97 });
89 });
98
90
99 $userListTable.on('preXhr.dt', function(e, settings, data){
91 $forksListTable.on('preXhr.dt', function(e, settings, data){
100 $userListTable.css('opacity', 0.3);
92 $forksListTable.css('opacity', 0.3);
101 });
102
103 // refresh counters on draw
104 $userListTable.on('draw.dt', function(){
105 getDatatableCount();
106 });
93 });
107
94
108 // filter
95 // filter
109 $('#q_filter').on('keyup',
96 $('#q_filter').on('keyup',
110 $.debounce(250, function() {
97 $.debounce(250, function() {
111 $userListTable.DataTable().search(
98 $forksListTable.DataTable().search(
112 $('#q_filter').val()
99 $('#q_filter').val()
113 ).draw();
100 ).draw();
114 })
101 })
General Comments 0
You need to be logged in to leave comments. Login now