Skip to content

Commit

Permalink
Add support for multiple stylesheets #107
Browse files Browse the repository at this point in the history
  • Loading branch information
CitizenOfRome committed Jun 12, 2021
1 parent fe95bc6 commit 12a18d3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Currently this plugin supports the following options:
#### stylesheet

- Default: `null`
- Acceptable-Values: URL-string
- Acceptable-Values: URL-string or Array of URL-strings
- Function: URL of an external stylesheet to be included

#### noPrintSelector
Expand Down
23 changes: 0 additions & 23 deletions bower.json

This file was deleted.

4 changes: 2 additions & 2 deletions dist/jQuery.print.min.js

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

2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface JQuery {
interface IPrintConfig {
globalStyles?: boolean;
mediaPrint?: boolean;
stylesheet?: string;
stylesheet?: string | Array;
noPrintSelector?: string;
iframe?: boolean;
append?: string | JQuery<HTMLElement>;
Expand Down
11 changes: 8 additions & 3 deletions jQuery.print.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @license
* jQuery.print, version 1.6.1
* jQuery.print, version 1.6.2
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
*--------------------------------------------------------------------------*/
(function ($) {
Expand Down Expand Up @@ -223,8 +223,13 @@
$styles = $("link[media=print]");
}
if (options.stylesheet) {
// Add a custom stylesheet if given
$styles = $.merge($styles, $('<link rel="stylesheet" href="' + options.stylesheet + '">'));
// Add a custom stylesheet(s) if given
if (!(($.isArray ? $.isArray : Array.isArray)(options.stylesheet))) {
options.stylesheet = [options.stylesheet]
}
for(var i = 0; i < options.stylesheet.length; i++) {
$styles = $.merge($styles, $('<link rel="stylesheet" href="' + options.stylesheet[i] + '">'));
}
}
// Create a copy of the element to print
var copy = jQueryCloneWithSelectAndTextAreaValues($this, true, true);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jQuery.print",
"filename": "jQuery.print.min.js",
"main": "jQuery.print.js",
"version": "1.6.1",
"version": "1.6.2",
"homepage": "https://doersguild.github.io/jQuery.print/",
"description": "Easy to use, Element Printing Plugin for jQuery, for printing specific parts of a page",
"keywords": [
Expand Down

0 comments on commit 12a18d3

Please sign in to comment.