Skip to content

Commit 12a18d3

Browse files
author
CitizenOfRome
committed
Add support for multiple stylesheets #107
1 parent fe95bc6 commit 12a18d3

File tree

6 files changed

+13
-31
lines changed

6 files changed

+13
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Currently this plugin supports the following options:
5858
#### stylesheet
5959

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

6464
#### noPrintSelector

bower.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

dist/jQuery.print.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface JQuery {
77
interface IPrintConfig {
88
globalStyles?: boolean;
99
mediaPrint?: boolean;
10-
stylesheet?: string;
10+
stylesheet?: string | Array;
1111
noPrintSelector?: string;
1212
iframe?: boolean;
1313
append?: string | JQuery<HTMLElement>;

jQuery.print.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* @license
2-
* jQuery.print, version 1.6.1
2+
* jQuery.print, version 1.6.2
33
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
44
*--------------------------------------------------------------------------*/
55
(function ($) {
@@ -223,8 +223,13 @@
223223
$styles = $("link[media=print]");
224224
}
225225
if (options.stylesheet) {
226-
// Add a custom stylesheet if given
227-
$styles = $.merge($styles, $('<link rel="stylesheet" href="' + options.stylesheet + '">'));
226+
// Add a custom stylesheet(s) if given
227+
if (!(($.isArray ? $.isArray : Array.isArray)(options.stylesheet))) {
228+
options.stylesheet = [options.stylesheet]
229+
}
230+
for(var i = 0; i < options.stylesheet.length; i++) {
231+
$styles = $.merge($styles, $('<link rel="stylesheet" href="' + options.stylesheet[i] + '">'));
232+
}
228233
}
229234
// Create a copy of the element to print
230235
var copy = jQueryCloneWithSelectAndTextAreaValues($this, true, true);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "jQuery.print",
33
"filename": "jQuery.print.min.js",
44
"main": "jQuery.print.js",
5-
"version": "1.6.1",
5+
"version": "1.6.2",
66
"homepage": "https://doersguild.github.io/jQuery.print/",
77
"description": "Easy to use, Element Printing Plugin for jQuery, for printing specific parts of a page",
88
"keywords": [

0 commit comments

Comments
 (0)