datatables.net-buttons
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -154,2 +154,3 @@ /*! | ||
sized: false, | ||
sheetName: '', // default sheet name for excel export | ||
@@ -310,2 +311,10 @@ glue: function(elem, title) { | ||
setSheetName: function(newText) { | ||
// set sheet name, for excel | ||
this.sheetName = newText; | ||
if (this.ready) { | ||
this.movie.setSheetName(newText); | ||
} | ||
}, | ||
setAction: function(newText) { | ||
@@ -497,2 +506,6 @@ // set action (save or copy) | ||
if ( typeof filename === 'function' ) { | ||
filename = filename(); | ||
} | ||
if ( filename.indexOf( '*' ) !== -1 ) { | ||
@@ -511,2 +524,18 @@ filename = filename.replace( '*', $('title').text() ); | ||
/** | ||
* Get the sheet name for Excel exports. | ||
* | ||
* @param {object} config Button configuration | ||
*/ | ||
var _sheetname = function ( config ) | ||
{ | ||
var sheetName = 'Sheet1'; | ||
if ( config.sheetName ) { | ||
sheetName = config.sheetName.replace(/[\[\]\*\/\\\?\:]/g, ''); | ||
} | ||
return sheetName; | ||
}; | ||
/** | ||
* Get the title for an exported file. | ||
@@ -520,2 +549,6 @@ * | ||
if ( typeof title === 'function' ) { | ||
title = title(); | ||
} | ||
return title.indexOf( '*' ) !== -1 ? | ||
@@ -599,3 +632,3 @@ title.replace( '*', $('title').text() ) : | ||
var header = config.header ? join( data.header )+newLine : ''; | ||
var footer = config.footer ? newLine+join( data.footer ) : ''; | ||
var footer = config.footer && data.footer ? newLine+join( data.footer ) : ''; | ||
var body = []; | ||
@@ -697,5 +730,8 @@ | ||
var data = _exportData( dt, config ); | ||
var output = config.customize ? | ||
config.customize( data.str, config ) : | ||
data.str; | ||
flash.setAction( 'copy' ); | ||
_setText( flash, data.str ); | ||
_setText( flash, output ); | ||
@@ -729,6 +765,9 @@ dt.buttons.info( | ||
var data = _exportData( dt, config ); | ||
var output = config.customize ? | ||
config.customize( data.str, config ) : | ||
data.str; | ||
flash.setAction( 'csv' ); | ||
flash.setFileName( _filename( config ) ); | ||
_setText( flash, data.str ); | ||
_setText( flash, output ); | ||
}, | ||
@@ -760,3 +799,3 @@ | ||
cells.push( typeof row[i] === 'number' || (row[i].match && row[i].match(/^-?[0-9\.]+$/) && row[i].charAt(0) !== '0') ? | ||
cells.push( typeof row[i] === 'number' || (row[i].match && $.trim(row[i]).match(/^-?\d+(\.\d+)?$/) && row[i].charAt(0) !== '0') ? | ||
'<c t="n"><v>'+row[i]+'</v></c>' : | ||
@@ -768,2 +807,4 @@ '<c t="inlineStr"><is><t>'+( | ||
.replace(/&(?!amp;)/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/[\x00-\x1F\x7F-\x9F]/g, ''))+ // remove control characters | ||
@@ -791,3 +832,5 @@ '</t></is></c>' // they are not valid in XML | ||
flash.setFileName( _filename( config ) ); | ||
flash.setSheetName( _sheetname( config ) ); | ||
_setText( flash, xml ); | ||
}, | ||
@@ -794,0 +837,0 @@ |
@@ -292,2 +292,6 @@ /*! | ||
if ( typeof filename === 'function' ) { | ||
filename = filename(); | ||
} | ||
if ( filename.indexOf( '*' ) !== -1 ) { | ||
@@ -306,2 +310,18 @@ filename = filename.replace( '*', $('title').text() ); | ||
/** | ||
* Get the sheet name for Excel exports. | ||
* | ||
* @param {object} config Button configuration | ||
*/ | ||
var _sheetname = function ( config ) | ||
{ | ||
var sheetName = 'Sheet1'; | ||
if ( config.sheetName ) { | ||
sheetName = config.sheetName.replace(/[\[\]\*\/\\\?\:]/g, ''); | ||
} | ||
return sheetName; | ||
}; | ||
/** | ||
* Get the title for an exported file. | ||
@@ -315,2 +335,6 @@ * | ||
if ( typeof title === 'function' ) { | ||
title = title(); | ||
} | ||
return title.indexOf( '*' ) !== -1 ? | ||
@@ -373,3 +397,3 @@ title.replace( '*', $('title').text() ) : | ||
var header = config.header ? join( data.header )+newLine : ''; | ||
var footer = config.footer ? newLine+join( data.footer ) : ''; | ||
var footer = config.footer && data.footer ? newLine+join( data.footer ) : ''; | ||
var body = []; | ||
@@ -431,3 +455,3 @@ | ||
<sheets>\ | ||
<sheet name="Sheet1" sheetId="1" r:id="rId1"/>\ | ||
<sheet name="__SHEET_NAME__" sheetId="1" r:id="rId1"/>\ | ||
</sheets>\ | ||
@@ -472,2 +496,7 @@ </workbook>', | ||
} ); | ||
if ( config.customize ) { | ||
output = config.customize( output, config ); | ||
} | ||
var textarea = $('<textarea readonly/>') | ||
@@ -566,2 +595,6 @@ .val( output ) | ||
if ( config.customize ) { | ||
output = config.customize( output, config ); | ||
} | ||
if ( charset !== false ) { | ||
@@ -633,3 +666,3 @@ if ( ! charset ) { | ||
// but the start | ||
cells.push( typeof row[i] === 'number' || (row[i].match && row[i].match(/^-?[0-9\.]+$/) && row[i].charAt(0) !== '0') ? | ||
cells.push( typeof row[i] === 'number' || (row[i].match && $.trim(row[i]).match(/^-?\d+(\.\d+)?$/) && row[i].charAt(0) !== '0') ? | ||
'<c t="n"><v>'+row[i]+'</v></c>' : | ||
@@ -641,4 +674,6 @@ '<c t="inlineStr"><is><t>'+( | ||
.replace(/&(?!amp;)/g, '&') | ||
.replace(/[\x00-\x1F\x7F-\x9F]/g, ''))+ // remove control characters | ||
'</t></is></c>' // they are not valid in XML | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, ''))+ // remove control characters | ||
'</t></is></c>' // they are not valid in XML | ||
); | ||
@@ -670,3 +705,3 @@ } | ||
_rels.file( '.rels', excelStrings['_rels/.rels'] ); | ||
xl.file( 'workbook.xml', excelStrings['xl/workbook.xml'] ); | ||
xl.file( 'workbook.xml', excelStrings['xl/workbook.xml'].replace( '__SHEET_NAME__', _sheetname( config ) ) ); | ||
xl_rels.file( 'workbook.xml.rels', excelStrings['xl/_rels/workbook.xml.rels'] ); | ||
@@ -676,3 +711,3 @@ xl_worksheets.file( 'sheet1.xml', excelStrings['xl/worksheets/sheet1.xml'].replace( '__DATA__', xml ) ); | ||
_saveAs( | ||
zip.generate( {type:"blob"} ), | ||
zip.generate( {type:"blob", mimeType:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'} ), | ||
_filename( config ) | ||
@@ -797,3 +832,3 @@ ); | ||
if ( config.customize ) { | ||
config.customize( doc ); | ||
config.customize( doc, config ); | ||
} | ||
@@ -800,0 +835,0 @@ |
@@ -103,3 +103,3 @@ /*! | ||
if ( config.footer ) { | ||
html += '<thead>'+ addRow( data.footer, 'th' ) +'</thead>'; | ||
html += '<tfoot>'+ addRow( data.footer, 'th' ) +'</tfoot>'; | ||
} | ||
@@ -109,4 +109,12 @@ | ||
var win = window.open( '', '' ); | ||
var title = config.title.replace( '*', $('title').text() ); | ||
var title = config.title; | ||
if ( typeof title === 'function' ) { | ||
title = title(); | ||
} | ||
if ( title.indexOf( '*' ) !== -1 ) { | ||
title= title.replace( '*', $('title').text() ); | ||
} | ||
win.document.close(); | ||
@@ -113,0 +121,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! Buttons for DataTables 1.1.0 | ||
/*! Buttons for DataTables 1.1.1 | ||
* ©2015 SpryMedia Ltd - datatables.net/license | ||
@@ -114,14 +114,18 @@ */ | ||
/** | ||
* Add an active class to the button to make to look active | ||
* Add an active class to the button to make to look active or get current | ||
* active state. | ||
* @param {int|string} Button index | ||
* @param {boolean} [flag=true] Enable / disable flag | ||
* @return {Buttons} Self for chaining | ||
* @param {boolean} [flag] Enable / disable flag | ||
* @return {Buttons} Self for chaining or boolean for getter | ||
*/ | ||
active: function ( idx, flag ) { | ||
var button = this._indexToButton( idx ); | ||
button.node.toggleClass( | ||
this.c.dom.button.active, | ||
flag === undefined ? true : flag | ||
); | ||
var klass = this.c.dom.button.active; | ||
if ( flag === undefined ) { | ||
return button.node.hasClass( klass ); | ||
} | ||
button.node.toggleClass( klass, flag === undefined ? true : flag ); | ||
return this; | ||
@@ -467,2 +471,3 @@ }, | ||
var dt = this.s.dt; | ||
var buttonCounter = 0; | ||
@@ -522,3 +527,3 @@ if ( ! container ) { | ||
this._buildButtons( conf.buttons, conf._collection, i ); | ||
this._buildButtons( conf.buttons, conf._collection, buttonCounter ); | ||
} | ||
@@ -531,2 +536,4 @@ | ||
} | ||
buttonCounter++; | ||
} | ||
@@ -619,3 +626,3 @@ }, | ||
var inserter; | ||
if ( buttonContainer ) { | ||
if ( buttonContainer && buttonContainer.tag ) { | ||
inserter = $('<'+buttonContainer.tag+'/>') | ||
@@ -963,3 +970,3 @@ .addClass( buttonContainer.className ) | ||
node: v.node[0], | ||
name: v.name | ||
name: v.conf.name | ||
} ); | ||
@@ -974,3 +981,3 @@ } | ||
node: w.node[0], | ||
name: w.name | ||
name: w.conf.name | ||
} ); | ||
@@ -1108,3 +1115,3 @@ } | ||
*/ | ||
Buttons.version = '1.1.0'; | ||
Buttons.version = '1.1.1'; | ||
@@ -1255,2 +1262,3 @@ | ||
dt.page.len( val ).draw(); | ||
$('div.dt-button-background').click(); | ||
}, | ||
@@ -1323,3 +1331,9 @@ init: function ( dt, node, conf ) { | ||
// Active buttons | ||
DataTable.Api.register( ['buttons().active()', 'button().active()'], function ( flag ) { | ||
DataTable.Api.registerPlural( 'buttons().active()', 'button().active()', function ( flag ) { | ||
if ( flag === undefined ) { | ||
return this.map( function ( set ) { | ||
return set.inst.active( set.idx ); | ||
} ); | ||
} | ||
return this.each( function ( set ) { | ||
@@ -1326,0 +1340,0 @@ set.inst.active( set.idx, flag ); |
{ | ||
"name": "datatables.net-buttons", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Buttons for DataTables ", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97007
3137