Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
var TableManaged = function () {
2
 
3
    var initTable1 = function () {
4
 
5
        var table = $('#sample_1');
6
 
7
        // begin first table
8
        table.dataTable({
9
 
10
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
11
            "language": {
12
                "aria": {
13
                    "sortAscending": ": activate to sort column ascending",
14
                    "sortDescending": ": activate to sort column descending"
15
                },
16
                "emptyTable": "No data available in table",
17
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
18
                "infoEmpty": "No entries found",
19
                "infoFiltered": "(filtered1 from _MAX_ total entries)",
20
                "lengthMenu": "Show _MENU_ entries",
21
                "search": "Search:",
22
                "zeroRecords": "No matching records found"
23
            },
24
 
25
            // Or you can use remote translation file
26
            //"language": {
27
            //   url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
28
            //},
29
 
30
            // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
31
            // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js). 
32
            // So when dropdowns used the scrollable div should be removed. 
33
            //"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
34
 
35
            "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
36
 
37
            "columns": [{
38
                "orderable": false
39
            }, {
40
                "orderable": true
41
            }, {
42
                "orderable": false
43
            }, {
44
                "orderable": false
45
            }, {
46
                "orderable": true
47
            }, {
48
                "orderable": false
49
            }],
50
            "lengthMenu": [
51
                [5, 15, 20, -1],
52
                [5, 15, 20, "All"] // change per page values here
53
            ],
54
            // set the initial value
55
            "pageLength": 5,            
56
            "pagingType": "bootstrap_full_number",
57
            "language": {
58
                "search": "My search: ",
59
                "lengthMenu": "  _MENU_ records",
60
                "paginate": {
61
                    "previous":"Prev",
62
                    "next": "Next",
63
                    "last": "Last",
64
                    "first": "First"
65
                }
66
            },
67
            "columnDefs": [{  // set default column settings
68
                'orderable': false,
69
                'targets': [0]
70
            }, {
71
                "searchable": false,
72
                "targets": [0]
73
            }],
74
            "order": [
75
                [1, "asc"]
76
            ] // set first column as a default sort by asc
77
        });
78
 
79
        var tableWrapper = jQuery('#sample_1_wrapper');
80
 
81
        table.find('.group-checkable').change(function () {
82
            var set = jQuery(this).attr("data-set");
83
            var checked = jQuery(this).is(":checked");
84
            jQuery(set).each(function () {
85
                if (checked) {
86
                    $(this).attr("checked", true);
87
                    $(this).parents('tr').addClass("active");
88
                } else {
89
                    $(this).attr("checked", false);
90
                    $(this).parents('tr').removeClass("active");
91
                }
92
            });
93
            jQuery.uniform.update(set);
94
        });
95
 
96
        table.on('change', 'tbody tr .checkboxes', function () {
97
            $(this).parents('tr').toggleClass("active");
98
        });
99
 
100
        tableWrapper.find('.dataTables_length select').addClass("form-control input-xsmall input-inline"); // modify table per page dropdown
101
    }
102
 
103
    var initTable2 = function () {
104
 
105
        var table = $('#sample_2');
106
 
107
        table.dataTable({
108
 
109
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
110
            "language": {
111
                "aria": {
112
                    "sortAscending": ": activate to sort column ascending",
113
                    "sortDescending": ": activate to sort column descending"
114
                },
115
                "emptyTable": "No data available in table",
116
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
117
                "infoEmpty": "No entries found",
118
                "infoFiltered": "(filtered1 from _MAX_ total entries)",
119
                "lengthMenu": "Show _MENU_ entries",
120
                "search": "Search:",
121
                "zeroRecords": "No matching records found"
122
            },
123
 
124
            // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
125
            // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js). 
126
            // So when dropdowns used the scrollable div should be removed. 
127
            //"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
128
 
129
            "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
130
 
131
            "lengthMenu": [
132
                [5, 15, 20, -1],
133
                [5, 15, 20, "All"] // change per page values here
134
            ],
135
            // set the initial value
136
            "pageLength": 5,
137
            "language": {
138
                "lengthMenu": " _MENU_ records",
139
                "paging": {
140
                    "previous": "Prev",
141
                    "next": "Next"
142
                }
143
            },
144
            "columnDefs": [{  // set default column settings
145
                'orderable': false,
146
                'targets': [0]
147
            }, {
148
                "searchable": false,
149
                "targets": [0]
150
            }],
151
            "order": [
152
                [1, "asc"]
153
            ] // set first column as a default sort by asc
154
        });
155
 
156
        var tableWrapper = jQuery('#sample_2_wrapper');
157
 
158
        table.find('.group-checkable').change(function () {
159
            var set = jQuery(this).attr("data-set");
160
            var checked = jQuery(this).is(":checked");
161
            jQuery(set).each(function () {
162
                if (checked) {
163
                    $(this).attr("checked", true);
164
                } else {
165
                    $(this).attr("checked", false);
166
                }
167
            });
168
            jQuery.uniform.update(set);
169
        });
170
 
171
        tableWrapper.find('.dataTables_length select').select2(); // initialize select2 dropdown
172
    }
173
 
174
    var initTable3 = function () {
175
 
176
        var table = $('#sample_3');
177
 
178
        // begin: third table
179
        table.dataTable({
180
 
181
            // Internationalisation. For more info refer to http://datatables.net/manual/i18n
182
            "language": {
183
                "aria": {
184
                    "sortAscending": ": activate to sort column ascending",
185
                    "sortDescending": ": activate to sort column descending"
186
                },
187
                "emptyTable": "No data available in table",
188
                "info": "Showing _START_ to _END_ of _TOTAL_ entries",
189
                "infoEmpty": "No entries found",
190
                "infoFiltered": "(filtered1 from _MAX_ total entries)",
191
                "lengthMenu": "Show _MENU_ entries",
192
                "search": "Search:",
193
                "zeroRecords": "No matching records found"
194
            },
195
 
196
            // Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
197
            // setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js). 
198
            // So when dropdowns used the scrollable div should be removed. 
199
            //"dom": "<'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
200
 
201
            "bStateSave": true, // save datatable state(pagination, sort, etc) in cookie.
202
 
203
            "lengthMenu": [
204
                [5, 15, 20, -1],
205
                [5, 15, 20, "All"] // change per page values here
206
            ],
207
            // set the initial value
208
            "pageLength": 5,
209
            "language": {
210
                "lengthMenu": " _MENU_ records"
211
            },
212
            "columnDefs": [{  // set default column settings
213
                'orderable': false,
214
                'targets': [0]
215
            }, {
216
                "searchable": false,
217
                "targets": [0]
218
            }],
219
            "order": [
220
                [1, "asc"]
221
            ] // set first column as a default sort by asc
222
        });
223
 
224
        var tableWrapper = jQuery('#sample_3_wrapper');
225
 
226
        table.find('.group-checkable').change(function () {
227
            var set = jQuery(this).attr("data-set");
228
            var checked = jQuery(this).is(":checked");
229
            jQuery(set).each(function () {
230
                if (checked) {
231
                    $(this).attr("checked", true);
232
                } else {
233
                    $(this).attr("checked", false);
234
                }
235
            });
236
            jQuery.uniform.update(set);
237
        });
238
 
239
        tableWrapper.find('.dataTables_length select').select2(); // initialize select2 dropdown
240
    }
241
 
242
    return {
243
 
244
        //main function to initiate the module
245
        init: function () {
246
            if (!jQuery().dataTable) {
247
                return;
248
            }
249
 
250
            initTable1();
251
            initTable2();
252
            initTable3();
253
        }
254
 
255
    };
256
 
257
}();