1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-11-29 11:24:10 +01:00

Fix - styling: Integration with Foundation 6

- F6 changes the paging control (for the better) to require that there
  be no `a` tag for the elements which can't be clicked on in the pager.
  Unforuntately F5 requires them, so we need to detect which one is to
  be used. This is done using a meta tag based on this discussion:
    - http://foundation.zurb.com/forum/posts/36681

- F5 remains the main version for the moment, but will be bumped to F6
  when the next version of DataTables is released
This commit is contained in:
Allan Jardine 2016-01-22 11:24:53 +00:00
parent 8fbefe961f
commit aec81fd557
3 changed files with 15 additions and 5 deletions

View File

@ -1 +1 @@
060acf7e2253ffe59a7d3d7e98c59db19dd57aa5
48c1c8f45aa6fc3b32f907a3b1e638f5b303b965

View File

@ -39,6 +39,11 @@
'use strict';
var DataTable = $.fn.dataTable;
// Detect Foundation 5 / 6 as they have different element and class requirements
var meta = $('<meta class="foundation-mq"/>').appendTo('head');
DataTable.ext.foundationVersion = meta.css('font-family').match(/small|medium|large/) ? 6 : 5;
meta.remove();
$.extend( DataTable.ext.classes, {
sWrapper: "dataTables_wrapper dt-foundation",
@ -64,6 +69,7 @@ DataTable.ext.renderer.pageButton.foundation = function ( settings, host, idx, b
var aria = settings.oLanguage.oAria.paginate || {};
var btnDisplay, btnClass;
var tag;
var v5 = DataTable.ext.foundationVersion === 5;
var attach = function( container, buttons ) {
var i, ien, node, button;
@ -129,6 +135,10 @@ DataTable.ext.renderer.pageButton.foundation = function ( settings, host, idx, b
break;
}
if ( v5 ) {
tag = 'a';
}
if ( btnDisplay ) {
node = $('<li>', {
'class': classes.sPageButton+' '+btnClass,

View File

@ -2,7 +2,7 @@
DataTables Foundation integration
©2011-2015 SpryMedia Ltd - datatables.net/license
*/
(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return d(a,window,document)}):"object"===typeof exports?module.exports=function(a,c){a||(a=window);if(!c||!c.fn.dataTable)c=require("datatables.net")(a,c).$;return d(c,a,a.document)}:d(jQuery,window,document)})(function(d){var a=d.fn.dataTable;d.extend(a.ext.classes,{sWrapper:"dataTables_wrapper dt-foundation",sProcessing:"dataTables_processing panel"});d.extend(!0,a.defaults,{dom:"<'row'<'small-6 columns'l><'small-6 columns'f>r>t<'row'<'small-6 columns'i><'small-6 columns'p>>",
renderer:"foundation"});a.ext.renderer.pageButton.foundation=function(c,l,r,s,e,i){var m=new a.Api(c),t=c.oClasses,j=c.oLanguage.oPaginate,u=c.oLanguage.oAria.paginate||{},f,h,g,q=function(a,n){var k,o,p,b,l=function(a){a.preventDefault();!d(a.currentTarget).hasClass("unavailable")&&m.page()!=a.data.action&&m.page(a.data.action).draw("page")};k=0;for(o=n.length;k<o;k++)if(b=n[k],d.isArray(b))q(a,b);else{h=f="";g=null;switch(b){case "ellipsis":f="&#x2026;";h="unavailable disabled";g=null;break;case "first":f=
j.sFirst;h=b+(0<e?"":" unavailable disabled");g=0<e?"a":null;break;case "previous":f=j.sPrevious;h=b+(0<e?"":" unavailable disabled");g=0<e?"a":null;break;case "next":f=j.sNext;h=b+(e<i-1?"":" unavailable disabled");g=e<i-1?"a":null;break;case "last":f=j.sLast;h=b+(e<i-1?"":" unavailable disabled");g=e<i-1?"a":null;break;default:f=b+1,h=e===b?"current":"",g=e===b?null:"a"}f&&(p=d("<li>",{"class":t.sPageButton+" "+h,"aria-controls":c.sTableId,"aria-label":u[b],tabindex:c.iTabIndex,id:0===r&&"string"===
typeof b?c.sTableId+"_"+b:null}).append(g?d("<"+g+"/>",{href:"#"}).html(f):f).appendTo(a),c.oApi._fnBindAction(p,{action:b},l))}};q(d(l).empty().html('<ul class="pagination"/>').children("ul"),s)};return a});
(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return d(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);if(!b||!b.fn.dataTable)b=require("datatables.net")(a,b).$;return d(b,a,a.document)}:d(jQuery,window,document)})(function(d){var a=d.fn.dataTable,b=d('<meta class="foundation-mq"/>').appendTo("head");a.ext.foundationVersion=b.css("font-family").match(/small|medium|large/)?6:5;b.remove();d.extend(a.ext.classes,
{sWrapper:"dataTables_wrapper dt-foundation",sProcessing:"dataTables_processing panel"});d.extend(!0,a.defaults,{dom:"<'row'<'small-6 columns'l><'small-6 columns'f>r>t<'row'<'small-6 columns'i><'small-6 columns'p>>",renderer:"foundation"});a.ext.renderer.pageButton.foundation=function(b,l,r,s,e,i){var m=new a.Api(b),t=b.oClasses,j=b.oLanguage.oPaginate,u=b.oLanguage.oAria.paginate||{},f,h,g,v=5===a.ext.foundationVersion,q=function(a,n){var k,o,p,c,l=function(a){a.preventDefault();!d(a.currentTarget).hasClass("unavailable")&&
m.page()!=a.data.action&&m.page(a.data.action).draw("page")};k=0;for(o=n.length;k<o;k++)if(c=n[k],d.isArray(c))q(a,c);else{h=f="";g=null;switch(c){case "ellipsis":f="&#x2026;";h="unavailable disabled";g=null;break;case "first":f=j.sFirst;h=c+(0<e?"":" unavailable disabled");g=0<e?"a":null;break;case "previous":f=j.sPrevious;h=c+(0<e?"":" unavailable disabled");g=0<e?"a":null;break;case "next":f=j.sNext;h=c+(e<i-1?"":" unavailable disabled");g=e<i-1?"a":null;break;case "last":f=j.sLast;h=c+(e<i-1?
"":" unavailable disabled");g=e<i-1?"a":null;break;default:f=c+1,h=e===c?"current":"",g=e===c?null:"a"}v&&(g="a");f&&(p=d("<li>",{"class":t.sPageButton+" "+h,"aria-controls":b.sTableId,"aria-label":u[c],tabindex:b.iTabIndex,id:0===r&&"string"===typeof c?b.sTableId+"_"+c:null}).append(g?d("<"+g+"/>",{href:"#"}).html(f):f).appendTo(a),b.oApi._fnBindAction(p,{action:c},l))}};q(d(l).empty().html('<ul class="pagination"/>').children("ul"),s)};return a});