Update Bootstrap 2 integration for DataTables 1.10.

Note that DataTables 1.9- is no longer supported with this file. For
integraiton with DataTables 1.9- please use an older version.

This is now basically the same as the Bootstrap 3 integration, but with
BS2 markup. AMD module naming also isn't defined.
pull/119/head
Allan Jardine 10 years ago
parent f0f99a7511
commit 916be03336

@ -1,5 +1,4 @@
div.dataTables_length label { div.dataTables_length label {
float: left;
text-align: left; text-align: left;
} }
@ -7,8 +6,17 @@ div.dataTables_length select {
width: 75px; width: 75px;
} }
div.dataTables_filter {
text-align: right;
}
div.dataTables_filter label { div.dataTables_filter label {
float: right; text-align: left;
}
div.dataTables_filter input {
margin-left: 0.5em;
display: inline-block;
} }
div.dataTables_info { div.dataTables_info {
@ -16,10 +24,23 @@ div.dataTables_info {
} }
div.dataTables_paginate { div.dataTables_paginate {
float: right; text-align: right;
margin: 0; margin: 0;
} }
div.dataTables_paginate div.pagination {
margin: 0;
}
@media screen and (max-width: 767px) {
div.dataTables_length,
div.dataTables_filter,
div.dataTables_info,
div.dataTables_paginate {
text-align: center;
}
}
table.table { table.table {
clear: both; clear: both;
margin-bottom: 6px !important; margin-bottom: 6px !important;

@ -1,121 +1,133 @@
/* Set the defaults for DataTables initialisation */ /*! DataTables Bootstrap 2 integration
$.extend( true, $.fn.dataTable.defaults, { * ©2011-2014 SpryMedia Ltd - datatables.net/license
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", */
"sPaginationType": "bootstrap",
"oLanguage": { /**
"sLengthMenu": "_MENU_ records per page" * DataTables integration for Bootstrap 2. This requires Bootstrap 2 and
} * DataTables 1.10 or newer.
*
* This file sets the defaults and adds options to DataTables to style its
* controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
* for further information.
*/
(function(window, document, $, DataTable, undefined){
$.extend( true, DataTable.defaults, {
"dom":
"<'row-fluid'<'span6'l><'span6'f>r>" +
"<'row-fluid'<'span12't>>" +
"<'row-fluid'<'span6'i><'span6'p>>",
renderer: 'bootstrap'
} ); } );
/* Default class modification */ /* Default class modification */
$.extend( $.fn.dataTableExt.oStdClasses, { $.extend( DataTable.ext.classes, {
"sWrapper": "dataTables_wrapper form-inline" sWrapper: "dataTables_wrapper form-inline dt-bootstrap"
} ); } );
/* API method to get paging information */ /* Bootstrap paging button renderer */
$.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
{ var api = new DataTable.Api( settings );
return { var classes = settings.oClasses;
"iStart": oSettings._iDisplayStart, var lang = settings.oLanguage.oPaginate;
"iEnd": oSettings.fnDisplayEnd(), var btnDisplay, btnClass;
"iLength": oSettings._iDisplayLength,
"iTotal": oSettings.fnRecordsTotal(),
"iFilteredTotal": oSettings.fnRecordsDisplay(),
"iPage": oSettings._iDisplayLength === -1 ?
0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
"iTotalPages": oSettings._iDisplayLength === -1 ?
0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
};
};
/* Bootstrap style pagination control */
$.extend( $.fn.dataTableExt.oPagination, {
"bootstrap": {
"fnInit": function( oSettings, nPaging, fnDraw ) {
var oLang = oSettings.oLanguage.oPaginate;
var fnClickHandler = function ( e ) {
e.preventDefault();
if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
fnDraw( oSettings );
}
};
$(nPaging).addClass('pagination').append(
'<ul>'+
'<li class="prev disabled"><a href="#">&larr; '+oLang.sPrevious+'</a></li>'+
'<li class="next disabled"><a href="#">'+oLang.sNext+' &rarr; </a></li>'+
'</ul>'
);
var els = $('a', nPaging);
$(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
$(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
},
"fnUpdate": function ( oSettings, fnDraw ) {
var iListLength = 5;
var oPaging = oSettings.oInstance.fnPagingInfo();
var an = oSettings.aanFeatures.p;
var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);
if ( oPaging.iTotalPages < iListLength) { var attach = function( container, buttons ) {
iStart = 1; var i, ien, node, button;
iEnd = oPaging.iTotalPages; var clickHandler = function ( e ) {
} e.preventDefault();
else if ( oPaging.iPage <= iHalf ) { if ( !$(e.currentTarget).hasClass('disabled') ) {
iStart = 1; api.page( e.data.action ).draw( false );
iEnd = iListLength;
} else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
iStart = oPaging.iTotalPages - iListLength + 1;
iEnd = oPaging.iTotalPages;
} else {
iStart = oPaging.iPage - iHalf + 1;
iEnd = iStart + iListLength - 1;
} }
};
for ( i=0, ien=an.length ; i<ien ; i++ ) { for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
// Remove the middle elements button = buttons[i];
$('li:gt(0)', an[i]).filter(':not(:last)').remove();
// Add the new list items and their event handlers
for ( j=iStart ; j<=iEnd ; j++ ) {
sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
$('<li '+sClass+'><a href="#">'+j+'</a></li>')
.insertBefore( $('li:last', an[i])[0] )
.bind('click', function (e) {
e.preventDefault();
oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
fnDraw( oSettings );
} );
}
// Add / remove disabled classes from the static elements if ( $.isArray( button ) ) {
if ( oPaging.iPage === 0 ) { attach( container, button );
$('li:first', an[i]).addClass('disabled'); }
} else { else {
$('li:first', an[i]).removeClass('disabled'); btnDisplay = '';
btnClass = '';
switch ( button ) {
case 'ellipsis':
btnDisplay = '&hellip;';
btnClass = 'disabled';
break;
case 'first':
btnDisplay = lang.sFirst;
btnClass = button + (page > 0 ?
'' : ' disabled');
break;
case 'previous':
btnDisplay = lang.sPrevious;
btnClass = button + (page > 0 ?
'' : ' disabled');
break;
case 'next':
btnDisplay = lang.sNext;
btnClass = button + (page < pages-1 ?
'' : ' disabled');
break;
case 'last':
btnDisplay = lang.sLast;
btnClass = button + (page < pages-1 ?
'' : ' disabled');
break;
default:
btnDisplay = button + 1;
btnClass = page === button ?
'active' : '';
break;
} }
if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { if ( btnDisplay ) {
$('li:last', an[i]).addClass('disabled'); node = $('<li>', {
} else { 'class': classes.sPageButton+' '+btnClass,
$('li:last', an[i]).removeClass('disabled'); 'aria-controls': settings.sTableId,
'tabindex': settings.iTabIndex,
'id': idx === 0 && typeof button === 'string' ?
settings.sTableId +'_'+ button :
null
} )
.append( $('<a>', {
'href': '#'
} )
.html( btnDisplay )
)
.appendTo( container );
settings.oApi._fnBindAction(
node, {action: button}, clickHandler
);
} }
} }
} }
} };
} );
attach(
$(host).empty().html('<div class="pagination"><ul/></div>').find('ul'),
buttons
);
};
/* /*
* TableTools Bootstrap compatibility * TableTools Bootstrap compatibility
* Required TableTools 2.1+ * Required TableTools 2.1+
*/ */
if ( $.fn.DataTable.TableTools ) { if ( DataTable.TableTools ) {
// Set the classes that TableTools uses to something suitable for Bootstrap // Set the classes that TableTools uses to something suitable for Bootstrap
$.extend( true, $.fn.DataTable.TableTools.classes, { $.extend( true, DataTable.TableTools.classes, {
"container": "DTTT btn-group", "container": "DTTT btn-group",
"buttons": { "buttons": {
"normal": "btn", "normal": "btn",
@ -137,7 +149,7 @@ if ( $.fn.DataTable.TableTools ) {
} ); } );
// Have the collection use a bootstrap compatible dropdown // Have the collection use a bootstrap compatible dropdown
$.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, { $.extend( true, DataTable.TableTools.DEFAULTS.oTags, {
"collection": { "collection": {
"container": "ul", "container": "ul",
"button": "li", "button": "li",
@ -146,3 +158,5 @@ if ( $.fn.DataTable.TableTools ) {
} ); } );
} }
})(window, document, jQuery, jQuery.fn.dataTable);

@ -0,0 +1,8 @@
/*!
DataTables Bootstrap 2 integration
©2011-2014 SpryMedia Ltd - datatables.net/license
*/
(function(t,u,c,b){c.extend(!0,b.defaults,{dom:"<'row-fluid'<'span6'l><'span6'f>r><'row-fluid'<'span12't>><'row-fluid'<'span6'i><'span6'p>>",renderer:"bootstrap"});c.extend(b.ext.classes,{sWrapper:"dataTables_wrapper form-inline dt-bootstrap"});b.ext.renderer.pageButton.bootstrap=function(f,j,p,q,g,k){var r=new b.Api(f),s=f.oClasses,h=f.oLanguage.oPaginate,d,e,o=function(b,l){var i,m,n,a,j=function(a){a.preventDefault();c(a.currentTarget).hasClass("disabled")||r.page(a.data.action).draw(!1)};i=0;
for(m=l.length;i<m;i++)if(a=l[i],c.isArray(a))o(b,a);else{e=d="";switch(a){case "ellipsis":d="&hellip;";e="disabled";break;case "first":d=h.sFirst;e=a+(0<g?"":" disabled");break;case "previous":d=h.sPrevious;e=a+(0<g?"":" disabled");break;case "next":d=h.sNext;e=a+(g<k-1?"":" disabled");break;case "last":d=h.sLast;e=a+(g<k-1?"":" disabled");break;default:d=a+1,e=g===a?"active":""}d&&(n=c("<li>",{"class":s.sPageButton+" "+e,"aria-controls":f.sTableId,tabindex:f.iTabIndex,id:0===p&&"string"===typeof a?
f.sTableId+"_"+a:null}).append(c("<a>",{href:"#"}).html(d)).appendTo(b),f.oApi._fnBindAction(n,{action:a},j))}};o(c(j).empty().html('<div class="pagination"><ul/></div>').find("ul"),q)};b.TableTools&&(c.extend(!0,b.TableTools.classes,{container:"DTTT btn-group",buttons:{normal:"btn",disabled:"disabled"},collection:{container:"DTTT_dropdown dropdown-menu",buttons:{normal:"",disabled:"disabled"}},print:{info:"DTTT_print_info modal"},select:{row:"active"}}),c.extend(!0,b.TableTools.DEFAULTS.oTags,{collection:{container:"ul",
button:"li",liner:"a"}}))})(window,document,jQuery,jQuery.fn.dataTable);

@ -5,11 +5,11 @@
<title>DataTables Bootstrap 2 example</title> <title>DataTables Bootstrap 2 example</title>
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css"> <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<link rel="stylesheet" type="text/css" href="dataTables.bootstrap.css"> <link rel="stylesheet" type="text/css" href="dataTables.bootstrap.css">
<script type="text/javascript" language="javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script> <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> <script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.3/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="dataTables.bootstrap.js"></script> <script type="text/javascript" language="javascript" src="dataTables.bootstrap.js"></script>
<script type="text/javascript" charset="utf-8"> <script type="text/javascript" charset="utf-8">
$(document).ready(function() { $(document).ready(function() {

@ -1,4 +1,4 @@
/*! DataTables Bootstrap integration /*! DataTables Bootstrap 3 integration
* ©2011-2014 SpryMedia Ltd - datatables.net/license * ©2011-2014 SpryMedia Ltd - datatables.net/license
*/ */

@ -0,0 +1,8 @@
/*!
DataTables Bootstrap 3 integration
©2011-2014 SpryMedia Ltd - datatables.net/license
*/
(function(){var f=function(c,b){c.extend(!0,b.defaults,{dom:"<'row'<'col-sm-6'l><'col-sm-6'f>r><'row'<'col-sm-12't>><'row'<'col-sm-6'i><'col-sm-6'p>>",renderer:"bootstrap"});c.extend(b.ext.classes,{sWrapper:"dataTables_wrapper form-inline dt-bootstrap",sFilterInput:"form-control input-sm",sLengthSelect:"form-control input-sm"});b.ext.renderer.pageButton.bootstrap=function(g,f,p,k,h,l){var q=new b.Api(g),r=g.oClasses,i=g.oLanguage.oPaginate,d,e,o=function(b,f){var j,m,n,a,k=function(a){a.preventDefault();
c(a.currentTarget).hasClass("disabled")||q.page(a.data.action).draw(!1)};j=0;for(m=f.length;j<m;j++)if(a=f[j],c.isArray(a))o(b,a);else{e=d="";switch(a){case "ellipsis":d="&hellip;";e="disabled";break;case "first":d=i.sFirst;e=a+(0<h?"":" disabled");break;case "previous":d=i.sPrevious;e=a+(0<h?"":" disabled");break;case "next":d=i.sNext;e=a+(h<l-1?"":" disabled");break;case "last":d=i.sLast;e=a+(h<l-1?"":" disabled");break;default:d=a+1,e=h===a?"active":""}d&&(n=c("<li>",{"class":r.sPageButton+" "+
e,"aria-controls":g.sTableId,tabindex:g.iTabIndex,id:0===p&&"string"===typeof a?g.sTableId+"_"+a:null}).append(c("<a>",{href:"#"}).html(d)).appendTo(b),g.oApi._fnBindAction(n,{action:a},k))}};o(c(f).empty().html('<ul class="pagination"/>').children("ul"),k)};b.TableTools&&(c.extend(!0,b.TableTools.classes,{container:"DTTT btn-group",buttons:{normal:"btn btn-default",disabled:"disabled"},collection:{container:"DTTT_dropdown dropdown-menu",buttons:{normal:"",disabled:"disabled"}},print:{info:"DTTT_print_info"},
select:{row:"active"}}),c.extend(!0,b.TableTools.DEFAULTS.oTags,{collection:{container:"ul",button:"li",liner:"a"}}))};"function"===typeof define&&define.amd?define(["jquery","datatables"],f):"object"===typeof exports?f(require("jquery"),require("datatables")):jQuery&&f(jQuery,jQuery.fn.dataTable)})(window,document);

@ -0,0 +1,8 @@
/*!
DataTables Foundation integration
©2011-2014 SpryMedia Ltd - datatables.net/license
*/
(function(){var f=function(d,b){d.extend(b.ext.classes,{sWrapper:"dataTables_wrapper dt-foundation"});d.extend(!0,b.defaults,{dom:"<'row'<'small-6 columns'l><'small-6 columns'f>r>t<'row'<'small-6 columns'i><'small-6 columns'p>>",renderer:"foundation"});b.ext.renderer.pageButton.foundation=function(g,f,p,k,h,l){var q=new b.Api(g),r=g.oClasses,i=g.oLanguage.oPaginate,c,e,o=function(b,f){var j,m,n,a,k=function(a){a.preventDefault();"ellipsis"!==a.data.action&&q.page(a.data.action).draw(!1)};j=0;for(m=
f.length;j<m;j++)if(a=f[j],d.isArray(a))o(b,a);else{e=c="";switch(a){case "ellipsis":c="&hellip;";e="unavailable";break;case "first":c=i.sFirst;e=a+(0<h?"":" unavailable");break;case "previous":c=i.sPrevious;e=a+(0<h?"":" unavailable");break;case "next":c=i.sNext;e=a+(h<l-1?"":" unavailable");break;case "last":c=i.sLast;e=a+(h<l-1?"":" unavailable");break;default:c=a+1,e=h===a?"current":""}c&&(n=d("<li>",{"class":r.sPageButton+" "+e,"aria-controls":g.sTableId,tabindex:g.iTabIndex,id:0===p&&"string"===
typeof a?g.sTableId+"_"+a:null}).append(d("<a>",{href:"#"}).html(c)).appendTo(b),g.oApi._fnBindAction(n,{action:a},k))}};o(d(f).empty().html('<ul class="pagination"/>').children("ul"),k)};b.TableTools&&(d.extend(!0,b.TableTools.classes,{container:"DTTT button-group",buttons:{normal:"button",disabled:"disabled"},collection:{container:"DTTT_dropdown dropdown-menu",buttons:{normal:"",disabled:"disabled"}},select:{row:"active"}}),d.extend(!0,b.TableTools.DEFAULTS.oTags,{collection:{container:"ul",button:"li",
liner:"a"}}))};"function"===typeof define&&define.amd?define(["jquery","datatables"],f):"object"===typeof exports?f(require("jquery"),require("datatables")):jQuery&&f(jQuery,jQuery.fn.dataTable)})(window,document);

@ -0,0 +1,9 @@
/*!
DataTables jQuery UI integration
©2011-2014 SpryMedia Ltd - datatables.net/license
*/
(function(){var b=function(a,c){a.extend(!0,c.defaults,{dom:'<"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix ui-corner-tl ui-corner-tr"lfr>t<"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix ui-corner-bl ui-corner-br"ip>',renderer:"jqueryui"});a.extend(c.ext.classes,{sWrapper:"dataTables_wrapper dt-jqueryui",sPageButton:"fg-button ui-button ui-state-default",sPageButtonActive:"ui-state-disabled",sPageButtonDisabled:"ui-state-disabled",sPaging:"dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_",
sSortAsc:"ui-state-default sorting_asc",sSortDesc:"ui-state-default sorting_desc",sSortable:"ui-state-default sorting",sSortableAsc:"ui-state-default sorting_asc_disabled",sSortableDesc:"ui-state-default sorting_desc_disabled",sSortableNone:"ui-state-default sorting_disabled",sSortIcon:"DataTables_sort_icon",sScrollHead:"dataTables_scrollHead ui-state-default",sScrollFoot:"dataTables_scrollFoot ui-state-default",sHeaderTH:"ui-state-default",sFooterTH:"ui-state-default"});c.ext.renderer.header.jqueryui=
function(c,g,e,d){var f="css_right ui-icon ui-icon-carat-2-n-s",b=-1!==a.inArray("asc",e.asSorting),h=-1!==a.inArray("desc",e.asSorting);!e.bSortable||!b&&!h?f="":b&&!h?f="css_right ui-icon ui-icon-carat-1-n":!b&&h&&(f="css_right ui-icon ui-icon-carat-1-s");a("<div/>").addClass("DataTables_sort_wrapper").append(g.contents()).append(a("<span/>").addClass(d.sSortIcon+" "+f)).appendTo(g);a(c.nTable).on("order.dt",function(a,b,h,i){c===b&&(a=e.idx,g.removeClass(d.sSortAsc+" "+d.sSortDesc).addClass("asc"==
i[a]?d.sSortAsc:"desc"==i[a]?d.sSortDesc:e.sSortingClass),g.find("span."+d.sSortIcon).removeClass("css_right ui-icon ui-icon-triangle-1-n css_right ui-icon ui-icon-triangle-1-s css_right ui-icon ui-icon-carat-2-n-s css_right ui-icon ui-icon-carat-1-n css_right ui-icon ui-icon-carat-1-s").addClass("asc"==i[a]?"css_right ui-icon ui-icon-triangle-1-n":"desc"==i[a]?"css_right ui-icon ui-icon-triangle-1-s":f))})};c.TableTools&&a.extend(!0,c.TableTools.classes,{container:"DTTT_container ui-buttonset ui-buttonset-multi",
buttons:{normal:"DTTT_button ui-button ui-state-default"},collection:{container:"DTTT_collection ui-buttonset ui-buttonset-multi"}})};"function"===typeof define&&define.amd?define(["jquery","datatables"],b):"object"===typeof exports?b(require("jquery"),require("datatables")):jQuery&&b(jQuery,jQuery.fn.dataTable)})(window,document);

@ -16,6 +16,11 @@ js_compress $DT_SRC/extensions/Plugins/features/searchHighlight/dataTables.searc
js_compress $DT_SRC/extensions/Plugins/features/alphabetSearch/dataTables.alphabetSearch.js js_compress $DT_SRC/extensions/Plugins/features/alphabetSearch/dataTables.alphabetSearch.js
js_compress $DT_SRC/extensions/Plugins/features/lengthLinks/dataTables.lengthLinks.js js_compress $DT_SRC/extensions/Plugins/features/lengthLinks/dataTables.lengthLinks.js
js_compress $DT_SRC/extensions/Plugins/integration/bootstrap/2/dataTables.bootstrap.js
js_compress $DT_SRC/extensions/Plugins/integration/bootstrap/3/dataTables.bootstrap.js
js_compress $DT_SRC/extensions/Plugins/integration/foundation/dataTables.foundation.js
js_compress $DT_SRC/extensions/Plugins/integration/jqueryui/dataTables.jqueryui.js
# Only copying the integration files # Only copying the integration files
rsync -r integration $OUT_DIR rsync -r integration $OUT_DIR

Loading…
Cancel
Save