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

Fix: Improve integration for NPM / CommonJS - jQuery object to augment can now be passed in. This applies to DataTables core as well as the integration files for Bootstrap, Foundation and jQuery UI

This commit is contained in:
Allan Jardine 2015-10-06 12:02:51 +01:00
parent 5e34369a56
commit 9fe4110826
9 changed files with 51 additions and 23 deletions

View File

@ -1 +1 @@
80610868103df0b3eff4fd96fb9fdde2dd24454b
03eb4dc832b11b22de992847f192f4cf5389e5c4

View File

@ -194,8 +194,16 @@ if ( typeof define === 'function' && define.amd ) {
define( ['jquery', 'datatables'], factory );
}
else if ( typeof exports === 'object' ) {
// Node/CommonJS
factory( require('jquery'), require('datatables') );
// Node/CommonJS
module.exports = function ($, dt) {
if ( ! $ ) {
$ = require('jquery');
}
if ( ! dt ) {
dt = $.fn.dataTable || require('datatables');
}
factory( $, dt );
};
}
else if ( jQuery ) {
// Otherwise simply initialise as normal, stopping multiple evaluation

View File

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

View File

@ -134,8 +134,16 @@ if ( typeof define === 'function' && define.amd ) {
define( ['jquery', 'datatables'], factory );
}
else if ( typeof exports === 'object' ) {
// Node/CommonJS
factory( require('jquery'), require('datatables') );
// Node/CommonJS
module.exports = function ($, dt) {
if ( ! $ ) {
$ = require('jquery');
}
if ( ! dt ) {
dt = $.fn.dataTable || require('datatables');
}
factory( $, dt );
};
}
else if ( jQuery ) {
// Otherwise simply initialise as normal, stopping multiple evaluation

View File

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

View File

@ -143,8 +143,16 @@ if ( typeof define === 'function' && define.amd ) {
define( ['jquery', 'datatables'], factory );
}
else if ( typeof exports === 'object' ) {
// Node/CommonJS
factory( require('jquery'), require('datatables') );
// Node/CommonJS
module.exports = function ($, dt) {
if ( ! $ ) {
$ = require('jquery');
}
if ( ! dt ) {
dt = $.fn.dataTable || require('datatables');
}
factory( $, dt );
};
}
else if ( jQuery ) {
// Otherwise simply initialise as normal, stopping multiple evaluation

View File

@ -2,8 +2,8 @@
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);
(function(){var c=function(a,b){a.extend(!0,b.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(b.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"});b.ext.renderer.header.jqueryui=
function(b,g,e,d){var f="css_right ui-icon ui-icon-carat-2-n-s",c=-1!==a.inArray("asc",e.asSorting),h=-1!==a.inArray("desc",e.asSorting);!e.bSortable||!c&&!h?f="":c&&!h?f="css_right ui-icon ui-icon-carat-1-n":!c&&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(b.nTable).on("order.dt",function(a,c,h,i){b===c&&(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))})};b.TableTools&&a.extend(!0,b.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"],c):"object"===typeof exports?module.exports=function(a,b){a||(a=require("jquery"));b||(b=a.fn.dataTable||require("datatables"));c(a,b)}:jQuery&&c(jQuery,jQuery.fn.dataTable)})(window,document);

View File

@ -35,7 +35,10 @@
}
else if ( typeof exports === 'object' ) {
// Node/CommonJS
module.exports = factory( require( 'jquery' ) );
module.exports = function ($) {
// Get jQuery if it wasn't passed in
return factory( $ || require('jquery') );
};
}
else if ( jQuery && !jQuery.fn.dataTable ) {
// Define using browser globals otherwise

View File

@ -2,7 +2,7 @@
DataTables 1.10.10-dev
©2008-2015 SpryMedia Ltd - datatables.net/license
*/
(function(c,f,e){c=function(b){var a;require("core.internal.js");require("core.compat.js");require("core.columns.js");require("core.data.js");require("core.draw.js");require("core.ajax.js");require("core.filter.js");require("core.info.js");require("core.init.js");require("core.length.js");require("core.page.js");require("core.processing.js");require("core.scrolling.js");require("core.sizing.js");require("core.sort.js");require("core.state.js");require("core.support.js");a=function(b){require("api.legacy.js");
(function(f,g,e){var c=function(b){var a;require("core.internal.js");require("core.compat.js");require("core.columns.js");require("core.data.js");require("core.draw.js");require("core.ajax.js");require("core.filter.js");require("core.info.js");require("core.init.js");require("core.length.js");require("core.page.js");require("core.processing.js");require("core.scrolling.js");require("core.sizing.js");require("core.sort.js");require("core.state.js");require("core.support.js");a=function(b){require("api.legacy.js");
var c=this.length;b===e&&(b={});this.oApi=this.internal=_ext.internal;for(var d in a.ext.internal)d&&(this[d]=_fnExternApiFunc(d));this.each(function(){var a={};1<c&&_fnExtend(a,b,!0);require("core.constructor.js")});return this};require("api.base.js");require("api.table.js");require("api.draw.js");require("api.page.js");require("api.ajax.js");require("api.selectors.js");require("api.rows.js");require("api.row.details.js");require("api.columns.js");require("api.cells.js");require("api.order.js");
require("api.search.js");require("api.state.js");require("api.static.js");require("api.core.js");a.version="1.10.10-dev";a.settings=[];a.models={};require("model.search.js");require("model.row.js");require("model.column.js");require("model.defaults.js");require("model.defaults.columns.js");require("model.settings.js");require("ext.js");require("ext.classes.js");require("ext.paging.js");require("ext.types.js");require("ext.filter.js");require("ext.sorting.js");require("ext.renderer.js");require("ext.helpers.js");
require("api.internal.js");b.fn.dataTable=a;b.fn.dataTableSettings=a.settings;b.fn.dataTableExt=a.ext;b.fn.DataTable=function(a){return b(this).dataTable(a).api()};b.each(a,function(a,c){b.fn.DataTable[a]=c});return b.fn.dataTable};"function"===typeof define&&define.amd?define("datatables",["jquery"],c):"object"===typeof exports?module.exports=c(require("jquery")):jQuery&&!jQuery.fn.dataTable&&c(jQuery)})(window,document);
require("api.internal.js");b.fn.dataTable=a;b.fn.dataTableSettings=a.settings;b.fn.dataTableExt=a.ext;b.fn.DataTable=function(a){return b(this).dataTable(a).api()};b.each(a,function(a,c){b.fn.DataTable[a]=c});return b.fn.dataTable};"function"===typeof define&&define.amd?define("datatables",["jquery"],c):"object"===typeof exports?module.exports=function(b){return c(b||require("jquery"))}:jQuery&&!jQuery.fn.dataTable&&c(jQuery)})(window,document);