mirror of
https://github.com/wahyd4/jQuery.print.git
synced 2026-08-11 05:46:02 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6364d933ec | ||
|
|
35733cc057 | ||
|
|
3e5ed110d7 | ||
|
|
43daec10ef | ||
|
|
5ab3f500df | ||
|
|
a690a4b513 |
@@ -34,7 +34,8 @@ You can submit the options object like:
|
|||||||
append: null,
|
append: null,
|
||||||
prepend: null,
|
prepend: null,
|
||||||
manuallyCopyFormValues: true,
|
manuallyCopyFormValues: true,
|
||||||
deferred: $.Deferred()
|
deferred: $.Deferred(),
|
||||||
|
timeout: 250
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -88,6 +89,13 @@ Currently this plugin supports the following options:
|
|||||||
- Acceptable-Values: Any valid `jQuery.Deferred` object
|
- Acceptable-Values: Any valid `jQuery.Deferred` object
|
||||||
- Function: A jQuery.Deferred object that is resolved once the print function is called
|
- Function: A jQuery.Deferred object that is resolved once the print function is called
|
||||||
|
|
||||||
|
####timeout
|
||||||
|
|
||||||
|
- Default: `250`
|
||||||
|
- Acceptable-Values: Time in Milliseconds for `setTimeout`
|
||||||
|
- Function: To change the amount of time to wait for the content, etc to load before printing the element from the new window/iframe created
|
||||||
|
|
||||||
|
|
||||||
## Tested with
|
## Tested with
|
||||||
|
|
||||||
### jQuery
|
### jQuery
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "jQuery.print",
|
"name": "jQuery.print",
|
||||||
"main": "jQuery.print.js",
|
"main": "jQuery.print.js",
|
||||||
"version": "1.3.2",
|
"version": "1.3.3",
|
||||||
"homepage": "https://doersguild.github.io/jQuery.print/",
|
"homepage": "https://doersguild.github.io/jQuery.print/",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Sathvik P <sathvik@doersguild.com>"
|
"Sathvik P <sathvik@doersguild.com>"
|
||||||
|
|||||||
+11
-10
@@ -1,5 +1,5 @@
|
|||||||
/* @license
|
/* @license
|
||||||
* jQuery.print, version 1.3.2
|
* jQuery.print, version 1.3.3
|
||||||
* (c) Sathvik Ponangi, Doers' Guild
|
* (c) Sathvik Ponangi, Doers' Guild
|
||||||
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
|
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
|
||||||
*--------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------*/
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
return jqObj;
|
return jqObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
function printFrame(frameWindow) {
|
function printFrame(frameWindow, timeout) {
|
||||||
// Print the selected window/iframe
|
// Print the selected window/iframe
|
||||||
var def = $.Deferred();
|
var def = $.Deferred();
|
||||||
try {
|
try {
|
||||||
@@ -37,19 +37,19 @@
|
|||||||
}
|
}
|
||||||
frameWindow.close();
|
frameWindow.close();
|
||||||
def.resolve();
|
def.resolve();
|
||||||
}, 250);
|
}, timeout);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
def.reject(err);
|
def.reject(err);
|
||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
function printContentInNewWindow(content) {
|
function printContentInNewWindow(content, timeout) {
|
||||||
// Open a new window and print selected content
|
// Open a new window and print selected content
|
||||||
var w = window.open();
|
var w = window.open();
|
||||||
w.document.write(content);
|
w.document.write(content);
|
||||||
w.document.close();
|
w.document.close();
|
||||||
return printFrame(w);
|
return printFrame(w, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNode(o) {
|
function isNode(o) {
|
||||||
@@ -99,7 +99,8 @@
|
|||||||
append: null,
|
append: null,
|
||||||
prepend: null,
|
prepend: null,
|
||||||
manuallyCopyFormValues: true,
|
manuallyCopyFormValues: true,
|
||||||
deferred: $.Deferred()
|
deferred: $.Deferred(),
|
||||||
|
timeout: 250
|
||||||
};
|
};
|
||||||
// Merge with user-options
|
// Merge with user-options
|
||||||
options = $.extend({}, defaults, (options || {}));
|
options = $.extend({}, defaults, (options || {}));
|
||||||
@@ -185,7 +186,7 @@
|
|||||||
wdoc.open();
|
wdoc.open();
|
||||||
wdoc.write(content);
|
wdoc.write(content);
|
||||||
wdoc.close();
|
wdoc.close();
|
||||||
printFrame(w)
|
printFrame(w, options.timeout)
|
||||||
.done(function () {
|
.done(function () {
|
||||||
// Success
|
// Success
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
@@ -199,7 +200,7 @@
|
|||||||
.fail(function (err) {
|
.fail(function (err) {
|
||||||
// Use the pop-up method if iframe fails for some reason
|
// Use the pop-up method if iframe fails for some reason
|
||||||
console.error("Failed to print from iframe", err);
|
console.error("Failed to print from iframe", err);
|
||||||
printContentInNewWindow(content);
|
printContentInNewWindow(content, options.timeout);
|
||||||
})
|
})
|
||||||
.always(function () {
|
.always(function () {
|
||||||
try {
|
try {
|
||||||
@@ -211,7 +212,7 @@
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Use the pop-up method if iframe fails for some reason
|
// Use the pop-up method if iframe fails for some reason
|
||||||
console.error("Failed to print from iframe", e.stack, e.message);
|
console.error("Failed to print from iframe", e.stack, e.message);
|
||||||
printContentInNewWindow(content)
|
printContentInNewWindow(content, options.timeout)
|
||||||
.always(function () {
|
.always(function () {
|
||||||
try {
|
try {
|
||||||
options.deferred.resolve();
|
options.deferred.resolve();
|
||||||
@@ -222,7 +223,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use a new window for printing
|
// Use a new window for printing
|
||||||
printContentInNewWindow(content)
|
printContentInNewWindow(content, options.timeout)
|
||||||
.always(function () {
|
.always(function () {
|
||||||
try {
|
try {
|
||||||
options.deferred.resolve();
|
options.deferred.resolve();
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "jquery.print",
|
||||||
|
"filename": "jQuery.print.min.js",
|
||||||
|
"version": "1.3.3",
|
||||||
|
"main": "jQuery.print.js",
|
||||||
|
"homepage": "https://doersguild.github.io/jQuery.print/",
|
||||||
|
"authors": [
|
||||||
|
"Sathvik P <sathvik@doersguild.com>"
|
||||||
|
],
|
||||||
|
"description": "Easy to use, Element Printing Plugin for jQuery, for printing specific parts of a page",
|
||||||
|
"keywords": [
|
||||||
|
"print",
|
||||||
|
"element printing",
|
||||||
|
"jquery print"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"jquery": ">=1.7.2"
|
||||||
|
},
|
||||||
|
"license": "CC-BY",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/DoersGuild/jQuery.print.git"
|
||||||
|
},
|
||||||
|
"autoupdate": {
|
||||||
|
"source": "git",
|
||||||
|
"target": "git://github.com/DoersGuild/jQuery.print.git",
|
||||||
|
"basePath": "",
|
||||||
|
"files": [
|
||||||
|
"jQuery.print*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user