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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* ------------------------------------------------------------------------------
*
* # Media library
*
* Specific JS code additions for gallery_library.html page
*
* Version: 1.0
* Latest update: Aug 1, 2015
*
* ---------------------------------------------------------------------------- */
$(function() {
// Table setup
// ------------------------------
// Setting datatable defaults
$.extend( $.fn.dataTable.defaults, {
autoWidth: false,
columnDefs: [
{
orderable: false,
width: '20px',
targets: 0
},
{
orderable: false,
width: '100px',
targets: 1
},
{
orderable: false,
width: '90px',
targets: 6
}
],
order: [[ 2, "asc" ]],
lengthMenu: [ 25, 50, 75, 100 ],
displayLength: 25,
dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>',
language: {
search: '<span>Filter:</span> _INPUT_',
searchPlaceholder: 'Type to filter...',
lengthMenu: '<span>Show:</span> _MENU_',
paginate: { 'first': 'First', 'last': 'Last', 'next': '→', 'previous': '←' }
},
drawCallback: function () {
$(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').addClass('dropup');
},
preDrawCallback: function() {
$(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').removeClass('dropup');
}
});
//
// Single row selection
//
// Initialize table
var media_library = $('.media-library').DataTable({
drawCallback: function () {
$(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').addClass('dropup');
},
preDrawCallback: function() {
$(this).find('tbody tr').slice(-3).find('.dropdown, .btn-group').removeClass('dropup');
}
});
// Toggle success class
$('.media-library tbody td input[type=checkbox]').on('change', function () {
if ($(this).is(':checked')) {
$(this).parents('tr').addClass('success');
$.uniform.update();
}
else {
$(this).parents('tr').removeClass('success');
$.uniform.update();
}
});
// External table additions
// ------------------------------
// Lightbox
$('[data-popup="lightbox"]').fancybox({
padding: 3
});
// Styles checkboxes, radios
$('.styled').uniform({
radioClass: 'choice'
});
// Enable Select2 select for the length option
$('.dataTables_length select').select2({
minimumResultsForSearch: Infinity,
width: 'auto'
});
});