From 00483f4454094dac814328bc2e71b58eb479d7fa Mon Sep 17 00:00:00 2001 From: Samuel Rouse Date: Sun, 15 Jul 2018 20:17:58 -0400 Subject: [PATCH] 1.13.0 Add removeInlineSelector --- README.md | 7 ++++--- changelog.txt | 4 ++++ package.json | 2 +- printThis.jquery.json | 2 +- printThis.js | 6 ++++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 95e4736..4cf445c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Printing plug-in for jQuery * Preserve page CSS/styling ** or add new CSS; the world is your oyster! * Preserve form entries -* **Canvas support (experimental)** +* Canvas support ## Usage @@ -59,8 +59,8 @@ Use a custom page title on the iframe. This may be reflected on the printed page Eliminates any inline style attributes from the content. Off by default. #### removeInlineSelector -Eliminates custom inline style attributes from the content. Off by default. Requires removeInline to be true. -Excepts custom jquery selectors. Default is "*" +Filter which inline style attributes to remove. Requires `removeInline` to be true. +Accepts custom CSS/jQuery selectors. Default is `"*"` #### printDelay The amount of time to wait before calling `print()` in the printThis iframe. Defaults to 333 milliseconds. @@ -120,6 +120,7 @@ $("#mySelector").printThis({ loadCSS: "path/to/my.css", // path to additional css file - use an array [] for multiple pageTitle: "", // add title to print page removeInline: false, // remove all inline styles from print elements + removeInlineSelector: "*", // filter elements from which to remove inline styles printDelay: 333, // variable print delay; depending on complexity a higher value may be necessary header: null, // prefix to html footer: null, // postfix to html diff --git a/changelog.txt b/changelog.txt index c162092..38c1b15 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +07/15/2018 Add removeInlineSelector to allow filtering which inline styles are removed + Remove "experimental" tag from Canvas support. We're pretty stable at this point. + Bump to 1.13.0 + 03/18/2018 Fixed importStyle Bumped to 1.12.3 diff --git a/package.json b/package.json index 34d12d3..0b86692 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "print-this", - "version": "1.12.3", + "version": "1.13.0", "description": "Printing plug-in for jQuery", "main": "printThis.js", "dependencies": { diff --git a/printThis.jquery.json b/printThis.jquery.json index 0c97903..8372661 100644 --- a/printThis.jquery.json +++ b/printThis.jquery.json @@ -1,6 +1,6 @@ { "name": "printThis", - "version": "1.12.3", + "version": "1.13.0", "title": "printThis", "description": "Printing plug-in for jQuery. Print specific page elements, add print options, maintain or add new styling using jQuery.", "author": { diff --git a/printThis.js b/printThis.js index 9c39b30..09cb3fa 100644 --- a/printThis.js +++ b/printThis.js @@ -225,11 +225,13 @@ // remove inline styles if (opt.removeInline) { + // Ensure there is a selector, even if it's been mistakenly removed + var selector = opt.removeInlineSelector || '*'; // $.removeAttr available jQuery 1.7+ if ($.isFunction($.removeAttr)) { - $body.find(opt.removeInlineSelector).removeAttr("style"); + $body.find(selector).removeAttr("style"); } else { - $body.find(opt.removeInlineSelector).attr("style", ""); + $body.find(selector).attr("style", ""); } }