Skip to content
This repository has been archived by the owner on Jul 25, 2021. It is now read-only.

Commit

Permalink
v3.3.8 - add 'trimWhitespace' property, closes #42
Browse files Browse the repository at this point in the history
  • Loading branch information
clarketm committed Jan 21, 2017
1 parent d607b53 commit 691609f
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ $("table").tableExport({
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file
ignoreCSS: ".tableexport-ignore", // (selector, selector[]), selector(s) to exclude cells from the exported file
emptyCSS: ".tableexport-empty", // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file
trimWhitespace: false // (Boolean), remove all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of cell text
trimWhitespace: false // (Boolean), remove all leading/trailing newlines, spaces (including non-breaking spaces), and tabs from cell text
});
```
> **Note:** to use the xlsx filetype, you must include the third-party scripts listed in the Dependencies section.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tableexport.js",
"version": "3.3.7",
"version": "3.3.8",
"authors": [
"clarketm <[email protected]>"
],
Expand Down
2 changes: 1 addition & 1 deletion dist/css/tableexport.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* TableExport.js v3.3.7 (https://www.travismclarke.com)
* TableExport.js v3.3.8 (https://www.travismclarke.com)
* Copyright 2016 Travis Clarke
* Licensed under the MIT license
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/css/tableexport.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 20 additions & 13 deletions dist/js/tableexport.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* TableExport.js v3.3.7 (https://www.travismclarke.com)
* TableExport.js v3.3.8 (https://www.travismclarke.com)
* Copyright 2016 Travis Clarke
* Licensed under the MIT license
*/
Expand All @@ -15,7 +15,7 @@
// Browser globals
factory(root, root.jQuery, root.Blob, root.saveAs, root.XLSX);
}
}(this, function (exports, $, Blob, saveAs, XLSX) {
}(this || window, function (exports, $, Blob, saveAs, XLSX) {
'use strict';
/**
* TableExport main plugin constructor
Expand Down Expand Up @@ -259,23 +259,30 @@
}
);

function trimWhitespace(string) {
if (self.settings.trimWhitespace) {
return $.trim(string);
}
return string;
}

/**
* Removes leading/trailing whitespace from cell string
* @param string {String}
* @returns {String} trimmed string
*/
function formatValue(string) {
string = trimWhitespace(string);
return string;
return self.settings.trimWhitespace ? string.trim() : string;
}

/**
* Initializes table caption with export buttons
* @param exportButton {HTMLButtonElement}
*/
function checkCaption(exportButton) {
var $caption = $el.find('caption:not(.head)');
$caption.length ? $caption.append(exportButton) : $el.prepend('<caption class="' + bootstrapSpacing + self.settings.position + '">' + exportButton + '</caption>');
}

/**
* Creates file export buttons
* @param dataObject {JSON}
* @param myContent {String}
* @param myClass {String}
*/
function createObjButton(dataObject, myContent, myClass) {
var exportButton = "<button data-fileblob='" + dataObject + "' class='" + bootstrapClass + bootstrapTheme + myClass + "'>" + myContent + "</button>";
checkCaption(exportButton);
Expand All @@ -302,7 +309,7 @@
* Version.
* @memberof TableExport.prototype
*/
version: "3.3.7",
version: "3.3.8",
/**
* Default plugin options.
* @memberof TableExport.prototype
Expand All @@ -318,7 +325,7 @@
ignoreCols: null, // (Number, Number[]), column indices to exclude from the exported file (default: null)
ignoreCSS: ".tableexport-ignore", // (selector, selector[]), selector(s) to exclude cells from the exported file (default: ".tableexport-ignore")
emptyCSS: ".tableexport-empty", // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file (default: ".tableexport-empty")
trimWhitespace: false // (Boolean), remove all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of cell text
trimWhitespace: false // (Boolean), remove all leading/trailing newlines, spaces (including non-breaking spaces), and tabs from cell text (default: false)
},
/**
* Character set (character encoding) of the HTML.
Expand Down
Loading

0 comments on commit 691609f

Please sign in to comment.