Features: UMD for pageResize and scrollResize

pull/378/head
Allan Jardine 7 years ago
parent 18cbcbb5d9
commit 5695ffe40c

@ -34,8 +34,34 @@
* For more detailed information please see:
* http://datatables.net/blog/2015-04-10
*/
(function( factory ){
if ( typeof define === 'function' && define.amd ) {
// AMD
define( ['jquery', 'datatables.net'], function ( $ ) {
return factory( $, window, document );
} );
}
else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = function (root, $) {
if ( ! root ) {
root = window;
}
if ( ! $ || ! $.fn.dataTable ) {
$ = require('datatables.net')(root, $).$;
}
return factory( $, root, root.document );
};
}
else {
// Browser
factory( jQuery, window, document );
}
}(function( $, window, document, undefined ) {
'use strict';
(function($){
var PageResize = function ( dt, pageResizeManualDelta )
{
@ -160,5 +186,5 @@ $(document).on( 'init.dt', function ( e, settings ) {
}
} );
}(jQuery));
}));

@ -25,6 +25,7 @@
PageResize for DataTables v1.0.0
2015 SpryMedia Ltd - datatables.net/license
*/
(function(b){var e=function(a,c){var d=a.table();this.s={dt:a,host:b(d.container()).parent(),header:b(d.header()),footer:b(d.footer()),body:b(d.body()),container:b(d.container()),table:b(d.node()),delta:c};a=this.s.host;"static"===a.css("position")&&a.css("position","relative");this._attach();this._size()};e.prototype={_size:function(){var a=this.s,c=a.dt,d=c.table(),k=b(a.table).offset().top,g=b("tr",a.body),g=g.eq(1<g.length?1:0).height(),f=a.host.height(),e=d.header().parentNode!==d.body().parentNode,
h=a.delta;e||(d.header()&&(f-=a.header.height()),d.footer()&&(f-=a.footer.height()));f=f-k-(a.container.height()-(k+a.table.height()));!isNaN(parseFloat(h))&&isFinite(h)&&(f-=h);a=Math.floor(f/g);Infinity!==a&&-Infinity!==a&&!isNaN(a)&&0<a&&a!==c.page.len()&&c.page.len(a).draw()},_attach:function(){var a=this,c=b("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");c[0].onload=function(){var b=this.contentDocument.body,c=b.offsetHeight;
this.contentDocument.defaultView.onresize=function(){var d=b.clientHeight||b.offsetHeight;d!==c&&(c=d,a._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};b.fn.dataTable.PageResize=e;b.fn.DataTable.PageResize=e;b(document).on("init.dt",function(a,c){"dt"===a.namespace&&(a=new b.fn.dataTable.Api(c),(b(a.table().node()).hasClass("pageResize")||c.oInit.pageResize||b.fn.dataTable.defaults.pageResize)&&new e(a,c.oInit.pageResizeManualDelta))})})(jQuery);
(function(b){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(d){return b(d,window,document)}):"object"===typeof exports?module.exports=function(d,c){d||(d=window);c&&c.fn.dataTable||(c=require("datatables.net")(d,c).$);return b(c,d,d.document)}:b(jQuery,window,document)})(function(b,d,c,l){var f=function(a,h){var e=a.table();this.s={dt:a,host:b(e.container()).parent(),header:b(e.header()),footer:b(e.footer()),body:b(e.body()),container:b(e.container()),table:b(e.node()),
delta:h};a=this.s.host;"static"===a.css("position")&&a.css("position","relative");this._attach();this._size()};f.prototype={_size:function(){var a=this.s,h=a.dt,e=h.table(),d=b(a.table).offset().top,c=b("tr",a.body),c=c.eq(1<c.length?1:0).height(),g=a.host.height(),f=e.header().parentNode!==e.body().parentNode,k=a.delta;f||(e.header()&&(g-=a.header.height()),e.footer()&&(g-=a.footer.height()));g=g-d-(a.container.height()-(d+a.table.height()));!isNaN(parseFloat(k))&&isFinite(k)&&(g-=k);a=Math.floor(g/
c);Infinity!==a&&-Infinity!==a&&!isNaN(a)&&0<a&&a!==h.page.len()&&h.page.len(a).draw()},_attach:function(){var a=this,c=b("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");c[0].onload=function(){var b=this.contentDocument.body,c=b.offsetHeight;this.contentDocument.defaultView.onresize=function(){var d=b.clientHeight||b.offsetHeight;d!==c&&(c=d,a._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};b.fn.dataTable.PageResize=
f;b.fn.DataTable.PageResize=f;b(c).on("init.dt",function(a,c){"dt"===a.namespace&&(a=new b.fn.dataTable.Api(c),(b(a.table().node()).hasClass("pageResize")||c.oInit.pageResize||b.fn.dataTable.defaults.pageResize)&&new f(a,c.oInit.pageResizeManualDelta))})});

@ -5,7 +5,7 @@
<title>DataTables page resize example</title>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<style type="text/css">
div.container {
margin: 0 auto;
@ -47,8 +47,8 @@
}
</style>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="dataTables.pageResize.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {

@ -5,7 +5,7 @@
<title>DataTables page resize example</title>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.6/css/jquery.dataTables.min.css">
<style type="text/css">
div.container {
margin: 0 auto;
@ -47,8 +47,8 @@
}
</style>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="https://cdn.datatables.net/1.10.6/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="dataTables.pageResize.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready( function () {

@ -30,8 +30,34 @@
* * Creating a new instance: `new $.fn.dataTable.ScrollResize( table );` where
* `table` is a DataTable's API instance.
*/
(function( factory ){
if ( typeof define === 'function' && define.amd ) {
// AMD
define( ['jquery', 'datatables.net'], function ( $ ) {
return factory( $, window, document );
} );
}
else if ( typeof exports === 'object' ) {
// CommonJS
module.exports = function (root, $) {
if ( ! root ) {
root = window;
}
if ( ! $ || ! $.fn.dataTable ) {
$ = require('datatables.net')(root, $).$;
}
return factory( $, root, root.document );
};
}
else {
// Browser
factory( jQuery, window, document );
}
}(function( $, window, document, undefined ) {
'use strict';
(function($){
var ScrollResize = function ( dt )
{
@ -152,5 +178,4 @@ $(document).on( 'init.dt', function ( e, settings ) {
}
} );
}(jQuery));
}));

@ -21,6 +21,7 @@
ScrollResize for DataTables v1.0.0
2015 SpryMedia Ltd - datatables.net/license
*/
(function(a){var e=function(d){var c=this,b=d.table();this.s={dt:d,host:a(b.container()).parent(),header:a(b.header()),footer:a(b.footer()),body:a(b.body()),container:a(b.container()),table:a(b.node())};b=this.s.host;"static"===b.css("position")&&b.css("position","relative");d.on("draw",function(){c._size()});this._attach();this._size()};e.prototype={_size:function(){var d=this.s,c=d.dt,b=c.table(),h=a(d.table).offset().top,g=d.host.height(),f=a("div.dataTables_scrollBody",b.container()),g=g-h-(d.container.height()-
(h+f.height()));a("div.dataTables_scrollBody",b.container()).css({maxHeight:g,height:g});c.fixedColumns&&c.fixedColumns().relayout()},_attach:function(){var d=this,c=a("<iframe/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1,border:0}).attr("frameBorder","0").attr("src","about:blank");c[0].onload=function(){var b=this.contentDocument.body,a=b.offsetHeight,c=this.contentDocument;(c.defaultView||c.parentWindow).onresize=function(){var f=b.clientHeight||b.offsetHeight,
e=c.documentElement.clientHeight;!f&&e&&(f=e);f!==a&&(a=f,d._size())}};c.appendTo(this.s.host).attr("data","about:blank")}};a.fn.dataTable.ScrollResize=e;a.fn.DataTable.ScrollResize=e;a(document).on("init.dt",function(d,c){"dt"===d.namespace&&(d=new a.fn.dataTable.Api(c),(c.oInit.scrollResize||a.fn.dataTable.defaults.scrollResize)&&new e(d))})})(jQuery);
(function(a){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(b){return a(b,window,document)}):"object"===typeof exports?module.exports=function(b,d){b||(b=window);d&&d.fn.dataTable||(d=require("datatables.net")(b,d).$);return a(d,b,b.document)}:a(jQuery,window,document)})(function(a,b,d,k){var g=function(e){var f=this,c=e.table();this.s={dt:e,host:a(c.container()).parent(),header:a(c.header()),footer:a(c.footer()),body:a(c.body()),container:a(c.container()),table:a(c.node())};
c=this.s.host;"static"===c.css("position")&&c.css("position","relative");e.on("draw",function(){f._size()});this._attach();this._size()};g.prototype={_size:function(){var e=this.s,f=e.dt,c=f.table(),b=a(e.table).offset().top,h=e.host.height(),d=a("div.dataTables_scrollBody",c.container()),h=h-b-(e.container.height()-(b+d.height()));a("div.dataTables_scrollBody",c.container()).css({maxHeight:h,height:h});f.fixedColumns&&f.fixedColumns().relayout()},_attach:function(){var e=this,b=a("<iframe/>").css({position:"absolute",
top:0,left:0,height:"100%",width:"100%",zIndex:-1,border:0}).attr("frameBorder","0").attr("src","about:blank");b[0].onload=function(){var a=this.contentDocument.body,b=a.offsetHeight,d=this.contentDocument;(d.defaultView||d.parentWindow).onresize=function(){var c=a.clientHeight||a.offsetHeight,f=d.documentElement.clientHeight;!c&&f&&(c=f);c!==b&&(b=c,e._size())}};b.appendTo(this.s.host).attr("data","about:blank")}};a.fn.dataTable.ScrollResize=g;a.fn.DataTable.ScrollResize=g;a(d).on("init.dt",function(b,
d){"dt"===b.namespace&&(b=new a.fn.dataTable.Api(d),(d.oInit.scrollResize||a.fn.dataTable.defaults.scrollResize)&&new g(b))})});

@ -20,6 +20,6 @@ h);this.s={dt:b};b.settings()[0].searchPane=this;b.columns(this.c.columns).eq(0)
typeof b?b(this.s.dt):b;"prepend"===this.c.insert?a(this.dom.container).prependTo(b):a(this.dom.container).appendTo(b)},_binData:function(a){var b={};a.each(function(a){a&&(b[a]?b[a]++:b[a]=1)});return b},_clear:function(a){var b=this.classes,f=b.item.selected;a.find("li."+f).removeClass(f);a.removeClass(b.pane.active);this.s.dt.column(a.data("column")).search("").draw()},_pane:function(b){var h=this.classes,f=h.item,h=h.pane,c=this.s.dt.column(b),e=a("<ul/>"),d=this._binData(c.data().flatten());
if(!(this._variance(d)<this.c.threshold)){for(var g=c.search(),g=g?g.substr(1,g.length-2).split("|"):[],m=c.data().unique().sort().toArray(),k=0,l=m.length;k<l;k++)if(m[k]){var n=a("<li/>").html('<span class="'+f.label+'">'+m[k]+"</span>").data("filter",m[k]).append(a("<span/>").addClass(f.count).html(d[m[k]]));if(g.length){var p=m[k].replace?a.fn.dataTable.util.escapeRegex(m[k]):m[k];-1!==a.inArray(p,g)&&n.addClass(f.selected)}e.append(n)}f=a("<div/>").data("column",b).addClass(h.container).addClass(g.length?
h.active:"").append(a('<button type="button">&times;</button>').addClass(this.classes.clear)).append(a("<div/>").addClass(h.title).html(a(c.header()).text())).append(a("<div/>").addClass(h.scroller).append(e));h=this.dom.container;c=h.children().map(function(){if(a(this).data("column")==b)return this});c.length?c.replaceWith(f):a(h).append(f)}},_toggle:function(b){var c=this.classes,f=c.item.selected,e=this.s.dt;b=a(b);var d=b.closest("div."+c.pane.container);b.toggleClass(f,!b.hasClass(f));b=d.find("li."+
f);0===b.length?(d.removeClass(c.pane.active),e.column(d.data("column")).search("").draw()):(d.addClass(c.pane.active),e.column(d.data("column")).search("^"+a.map(b,function(b){b=a(b).data("filter").toString();return a.fn.dataTable.util.escapeRegex(b)}).join("|")+"$",!0,!1).draw())},_variance:function(b){b=a.map(b,function(a,b){return a});for(var c=b.length,f=0,d=0,e=c;d<e;d++)f+=b[d];for(var f=f/c,g=0,d=0,e=c;d<e;d++)g+=Math.pow(f-b[d],2);return g/(c-1)}});d.classes={container:"dt-searchPanes",clear:"clear",
pane:{active:"filtering",container:"pane",title:"title",scroller:"scroller"},item:{selected:"selected",label:"label",count:"count"}};d.defaults={container:function(a){return a.table().container()},columns:g,insert:"prepend",threshold:.5};d.version="0.0.1";a.fn.dataTable.SearchPanes=d;a.fn.DataTable.SearchPanes=d;l.Api.register("searchPanes.rebuild()",function(){return this.iterator("table",function(a){a.searchPane&&a.searchPane.rebuild()})});a(c).on("init.dt",function(b,c,e){"dt"===b.namespace&&(b=
c.oInit.searchPane,e=l.defaults.searchPane,b||e)&&(e=a.extend({},b,e),!1!==b&&new d(c,e))})});
f);0===b.length?(d.removeClass(c.pane.active),e.column(d.data("column")).search("").draw()):(d.addClass(c.pane.active),e.column(d.data("column")).search("^("+a.map(b,function(b){b=a(b).data("filter").toString();return a.fn.dataTable.util.escapeRegex(b)}).join("|")+")$",!0,!1).draw())},_variance:function(b){b=a.map(b,function(a,b){return a});for(var c=b.length,f=0,d=0,e=c;d<e;d++)f+=b[d];for(var f=f/c,g=0,d=0,e=c;d<e;d++)g+=Math.pow(f-b[d],2);return g/(c-1)}});d.classes={container:"dt-searchPanes",
clear:"clear",pane:{active:"filtering",container:"pane",title:"title",scroller:"scroller"},item:{selected:"selected",label:"label",count:"count"}};d.defaults={container:function(a){return a.table().container()},columns:g,insert:"prepend",threshold:.5};d.version="0.0.1";a.fn.dataTable.SearchPanes=d;a.fn.DataTable.SearchPanes=d;l.Api.register("searchPanes.rebuild()",function(){return this.iterator("table",function(a){a.searchPane&&a.searchPane.rebuild()})});a(c).on("init.dt",function(b,c,e){"dt"===
b.namespace&&(b=c.oInit.searchPane,e=l.defaults.searchPane,b||e)&&(e=a.extend({},b,e),!1!==b&&new d(c,e))})});

Loading…
Cancel
Save