`
- tag: 'ActiveXObject' in window ?
- 'a' :
- 'button',
+ tag: 'a',
className: 'dt-button',
active: 'active',
disabled: 'disabled'
@@ -1168,7 +1143,7 @@ Buttons.defaults = {
* @type {string}
* @static
*/
-Buttons.version = '1.5.4';
+Buttons.version = '1.4.2';
$.extend( _dtButtons, {
@@ -1179,30 +1154,20 @@ $.extend( _dtButtons, {
className: 'buttons-collection',
action: function ( e, dt, button, config ) {
var host = button;
- var collectionParent = $(button).parents('div.dt-button-collection');
- var hostPosition = host.position();
+ var hostOffset = host.offset();
var tableContainer = $( dt.table().container() );
var multiLevel = false;
- var insertPoint = host;
// Remove any old collection
- if ( collectionParent.length ) {
- multiLevel = $('.dt-button-collection').position();
- insertPoint = collectionParent;
+ if ( $('div.dt-button-background').length ) {
+ multiLevel = $('.dt-button-collection').offset();
$('body').trigger( 'click.dtb-collection' );
}
- if ( insertPoint.parents('body')[0] !== document.body ) {
- insertPoint = document.body.lastChild;
- }
-
- config._collection.find('.dt-button-collection-title').remove();
- config._collection.prepend(''+config.collectionTitle+'
');
-
config._collection
.addClass( config.collectionLayout )
.css( 'display', 'none' )
- .insertAfter( insertPoint )
+ .appendTo( 'body' )
.fadeIn( config.fade );
var position = config._collection.css( 'position' );
@@ -1215,42 +1180,29 @@ $.extend( _dtButtons, {
}
else if ( position === 'absolute' ) {
config._collection.css( {
- top: hostPosition.top + host.outerHeight(),
- left: hostPosition.left
+ top: hostOffset.top + host.outerHeight(),
+ left: hostOffset.left
} );
// calculate overflow when positioned beneath
var tableBottom = tableContainer.offset().top + tableContainer.height();
- var listBottom = hostPosition.top + host.outerHeight() + config._collection.outerHeight();
+ var listBottom = hostOffset.top + host.outerHeight() + config._collection.outerHeight();
var bottomOverflow = listBottom - tableBottom;
-
+
// calculate overflow when positioned above
- var listTop = hostPosition.top - config._collection.outerHeight();
+ var listTop = hostOffset.top - config._collection.outerHeight();
var tableTop = tableContainer.offset().top;
var topOverflow = tableTop - listTop;
-
- // if bottom overflow is larger, move to the top because it fits better, or if dropup is requested
- if (bottomOverflow > topOverflow || config.dropup) {
- config._collection.css( 'top', hostPosition.top - config._collection.outerHeight() - 5);
+
+ // if bottom overflow is larger, move to the top because it fits better
+ if (bottomOverflow > topOverflow) {
+ config._collection.css( 'top', hostOffset.top - config._collection.outerHeight() - 5);
}
- // Right alignment is enabled on a class, e.g. bootstrap:
- // $.fn.dataTable.Buttons.defaults.dom.collection.className += " dropdown-menu-right";
- if ( config._collection.hasClass( config.rightAlignClassName ) ) {
- config._collection.css( 'left', hostPosition.left + host.outerWidth() - config._collection.outerWidth() );
- }
-
- // Right alignment in table container
- var listRight = hostPosition.left + config._collection.outerWidth();
+ var listRight = hostOffset.left + config._collection.outerWidth();
var tableRight = tableContainer.offset().left + tableContainer.width();
if ( listRight > tableRight ) {
- config._collection.css( 'left', hostPosition.left - ( listRight - tableRight ) );
- }
-
- // Right alignment to window
- var listOffsetRight = host.offset().left + config._collection.outerWidth();
- if ( listOffsetRight > $(window).width() ) {
- config._collection.css( 'left', hostPosition.left - (listOffsetRight-$(window).width()) );
+ config._collection.css( 'left', hostOffset.left - ( listRight - tableRight ) );
}
}
else {
@@ -1264,22 +1216,9 @@ $.extend( _dtButtons, {
}
if ( config.background ) {
- Buttons.background( true, config.backgroundClassName, config.fade, insertPoint );
+ Buttons.background( true, config.backgroundClassName, config.fade );
}
- var close = function () {
- config._collection
- .fadeOut( config.fade, function () {
- config._collection.detach();
- } );
-
- $('div.dt-button-background').off( 'click.dtb-collection' );
- Buttons.background( false, config.backgroundClassName, config.fade, insertPoint );
-
- $('body').off( '.dtb-collection' );
- dt.off( 'buttons-action.b-internal' );
- };
-
// Need to break the 'thread' for the collection button being
// activated by a click - it would also trigger this event
setTimeout( function () {
@@ -1289,38 +1228,36 @@ $.extend( _dtButtons, {
// required to make it work...
$('div.dt-button-background').on( 'click.dtb-collection', function () {} );
- $('body')
- .on( 'click.dtb-collection', function (e) {
- // andSelf is deprecated in jQ1.8, but we want 1.7 compat
- var back = $.fn.addBack ? 'addBack' : 'andSelf';
-
- if ( ! $(e.target).parents()[back]().filter( config._collection ).length ) {
- close();
- }
- } )
- .on( 'keyup.dtb-collection', function (e) {
- if ( e.keyCode === 27 ) {
- close();
- }
- } );
+ $('body').on( 'click.dtb-collection', function (e) {
+ // andSelf is deprecated in jQ1.8, but we want 1.7 compat
+ var back = $.fn.addBack ? 'addBack' : 'andSelf';
- if ( config.autoClose ) {
- dt.on( 'buttons-action.b-internal', function () {
- close();
- } );
- }
+ if ( ! $(e.target).parents()[back]().filter( config._collection ).length ) {
+ config._collection
+ .fadeOut( config.fade, function () {
+ config._collection.detach();
+ } );
+
+ $('div.dt-button-background').off( 'click.dtb-collection' );
+ Buttons.background( false, config.backgroundClassName, config.fade );
+
+ $('body').off( 'click.dtb-collection' );
+ dt.off( 'buttons-action.b-internal' );
+ }
+ } );
}, 10 );
+
+ if ( config.autoClose ) {
+ dt.on( 'buttons-action.b-internal', function () {
+ $('div.dt-button-background').click();
+ } );
+ }
},
background: true,
collectionLayout: '',
- collectionTitle: '',
backgroundClassName: 'dt-button-background',
- rightAlignClassName: 'dt-button-right',
autoClose: false,
- fade: 400,
- attr: {
- 'aria-haspopup': true
- }
+ fade: 400
},
copy: function ( dt, conf ) {
if ( _dtButtons.copyHtml5 ) {
@@ -1648,7 +1585,7 @@ DataTable.Api.register( 'buttons.exportInfo()', function ( conf ) {
return {
filename: _filename( conf ),
title: _title( conf ),
- messageTop: _message(this, conf.message || conf.messageTop, 'top'),
+ messageTop: _message(this, conf.messageTop || conf.message, 'top'),
messageBottom: _message(this, conf.messageBottom, 'bottom')
};
} );
@@ -1664,7 +1601,7 @@ DataTable.Api.register( 'buttons.exportInfo()', function ( conf ) {
var _filename = function ( config )
{
// Backwards compatibility
- var filename = config.filename === '*' && config.title !== '*' && config.title !== undefined && config.title !== null && config.title !== '' ?
+ var filename = config.filename === '*' && config.title !== '*' && config.title !== undefined ?
config.title :
config.filename;
@@ -1677,7 +1614,7 @@ var _filename = function ( config )
}
if ( filename.indexOf( '*' ) !== -1 ) {
- filename = $.trim( filename.replace( '*', $('head > title').text() ) );
+ filename = $.trim( filename.replace( '*', $('title').text() ) );
}
// Strip characters which the OS will object to
@@ -1719,7 +1656,7 @@ var _title = function ( config )
return title === null ?
null : title.indexOf( '*' ) !== -1 ?
- title.replace( '*', $('head > title').text() || 'Exported data' ) :
+ title.replace( '*', $('title').text() || 'Exported data' ) :
title;
};
@@ -1776,8 +1713,7 @@ var _exportData = function ( dt, inOpts )
body: function ( d ) {
return strip( d );
}
- },
- customizeData: null
+ }
}, inOpts );
var strip = function ( str ) {
@@ -1788,9 +1724,6 @@ var _exportData = function ( dt, inOpts )
// Always remove script tags
str = str.replace( /