Skip to content

Commit 8a5a61c

Browse files
committed
Fix datatables css
Add table colors .table-primary .table-info .table-success
1 parent 58bf192 commit 8a5a61c

File tree

8 files changed

+281
-185
lines changed

8 files changed

+281
-185
lines changed

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ elixir(function(mix) {
5353

5454
mix
5555
.scripts([
56+
'dataTables.bootstrap.js',
5657
'datatables.js'
5758
], 'public/default/js/datatables.min.js');
5859
});

public/default/css/common.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/default/js/datatables.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/assets.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function resources_url($path)
4646

4747
PackageManager::add('datatables')
4848
->js(null, resources_url('libs/datatables/js/jquery.dataTables.min.js'), ['jquery', 'libraries'])
49-
->js('dataTables-theme', resources_url('libs/datatables/js/dataTables.bootstrap.min.js'), ['datatables'])
5049
->css('dataTables-theme', resources_url('libs/datatables/css/dataTables.bootstrap.min.css'));
5150

5251
PackageManager::add('datetimepicker')
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
/*! DataTables Bootstrap 3 integration
2+
* ©2011-2015 SpryMedia Ltd - datatables.net/license
3+
*/
4+
5+
/**
6+
* DataTables integration for Bootstrap 3. This requires Bootstrap 3 and
7+
* DataTables 1.10 or newer.
8+
*
9+
* This file sets the defaults and adds options to DataTables to style its
10+
* controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
11+
* for further information.
12+
*/
13+
(function( factory ){
14+
if ( typeof define === 'function' && define.amd ) {
15+
// AMD
16+
define( ['jquery', 'datatables.net'], function ( $ ) {
17+
return factory( $, window, document );
18+
} );
19+
}
20+
else if ( typeof exports === 'object' ) {
21+
// CommonJS
22+
module.exports = function (root, $) {
23+
if ( ! root ) {
24+
root = window;
25+
}
26+
27+
if ( ! $ || ! $.fn.dataTable ) {
28+
// Require DataTables, which attaches to jQuery, including
29+
// jQuery if needed and have a $ property so we can access the
30+
// jQuery object that is used
31+
$ = require('datatables.net')(root, $).$;
32+
}
33+
34+
return factory( $, root, root.document );
35+
};
36+
}
37+
else {
38+
// Browser
39+
factory( jQuery, window, document );
40+
}
41+
}(function( $, window, document, undefined ) {
42+
'use strict';
43+
var DataTable = $.fn.dataTable;
44+
45+
46+
/* Set the defaults for DataTables initialisation */
47+
$.extend( true, DataTable.defaults, {
48+
dom:
49+
"<'dt-bootstrap-header'<'row'<'col-sm-6'l><'col-sm-6'f>>>" +
50+
"<'dt-bootstrap-body'<'row'<'col-sm-12'tr>>>" +
51+
"<'dt-bootstrap-footer'<'row'<'col-sm-5'i><'col-sm-7'p>>>",
52+
renderer: 'bootstrap'
53+
} );
54+
55+
56+
/* Default class modification */
57+
$.extend( DataTable.ext.classes, {
58+
sWrapper: "dataTables_wrapper form-inline dt-bootstrap",
59+
sFilterInput: "form-control input-sm",
60+
sLengthSelect: "form-control input-sm",
61+
sProcessing: "dataTables_processing panel panel-default"
62+
} );
63+
64+
65+
/* Bootstrap paging button renderer */
66+
DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
67+
var api = new DataTable.Api( settings );
68+
var classes = settings.oClasses;
69+
var lang = settings.oLanguage.oPaginate;
70+
var aria = settings.oLanguage.oAria.paginate || {};
71+
var btnDisplay, btnClass, counter=0;
72+
73+
var attach = function( container, buttons ) {
74+
var i, ien, node, button;
75+
var clickHandler = function ( e ) {
76+
e.preventDefault();
77+
if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) {
78+
api.page( e.data.action ).draw( 'page' );
79+
}
80+
};
81+
82+
for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
83+
button = buttons[i];
84+
85+
if ( $.isArray( button ) ) {
86+
attach( container, button );
87+
}
88+
else {
89+
btnDisplay = '';
90+
btnClass = '';
91+
92+
switch ( button ) {
93+
case 'ellipsis':
94+
btnDisplay = '&#x2026;';
95+
btnClass = 'disabled';
96+
break;
97+
98+
case 'first':
99+
btnDisplay = lang.sFirst;
100+
btnClass = button + (page > 0 ?
101+
'' : ' disabled');
102+
break;
103+
104+
case 'previous':
105+
btnDisplay = lang.sPrevious;
106+
btnClass = button + (page > 0 ?
107+
'' : ' disabled');
108+
break;
109+
110+
case 'next':
111+
btnDisplay = lang.sNext;
112+
btnClass = button + (page < pages-1 ?
113+
'' : ' disabled');
114+
break;
115+
116+
case 'last':
117+
btnDisplay = lang.sLast;
118+
btnClass = button + (page < pages-1 ?
119+
'' : ' disabled');
120+
break;
121+
122+
default:
123+
btnDisplay = button + 1;
124+
btnClass = page === button ?
125+
'active' : '';
126+
break;
127+
}
128+
129+
if ( btnDisplay ) {
130+
node = $('<li>', {
131+
'class': classes.sPageButton+' '+btnClass,
132+
'id': idx === 0 && typeof button === 'string' ?
133+
settings.sTableId +'_'+ button :
134+
null
135+
} )
136+
.append( $('<a>', {
137+
'href': '#',
138+
'aria-controls': settings.sTableId,
139+
'aria-label': aria[ button ],
140+
'data-dt-idx': counter,
141+
'tabindex': settings.iTabIndex
142+
} )
143+
.html( btnDisplay )
144+
)
145+
.appendTo( container );
146+
147+
settings.oApi._fnBindAction(
148+
node, {action: button}, clickHandler
149+
);
150+
151+
counter++;
152+
}
153+
}
154+
}
155+
};
156+
157+
// IE9 throws an 'unknown error' if document.activeElement is used
158+
// inside an iframe or frame.
159+
var activeEl;
160+
161+
try {
162+
// Because this approach is destroying and recreating the paging
163+
// elements, focus is lost on the select button which is bad for
164+
// accessibility. So we want to restore focus once the draw has
165+
// completed
166+
activeEl = $(host).find(document.activeElement).data('dt-idx');
167+
}
168+
catch (e) {}
169+
170+
attach(
171+
$(host).empty().html('<ul class="pagination"/>').children('ul'),
172+
buttons
173+
);
174+
175+
if ( activeEl ) {
176+
$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
177+
}
178+
};
179+
180+
181+
return DataTable;
182+
}));

0 commit comments

Comments
 (0)