mirror of
https://github.com/wahyd4/jQuery.print.git
synced 2026-08-09 04:46:31 +10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38f12da807 | ||
|
|
1b8610b182 | ||
|
|
fdf979b239 | ||
|
|
bf8dd435fb | ||
|
|
1a5fae505e | ||
|
|
c6a57a9cbe |
@@ -5,30 +5,39 @@ jQuery.print is a plugin for printing specific parts of a page
|
||||
## Usage
|
||||
|
||||
Include it in your HTML after importing jQuery, like:
|
||||
|
||||
```html
|
||||
<script type="text/JavaScript" src="path/to/jquery.print.js" />
|
||||
```
|
||||
|
||||
Use it like:
|
||||
|
||||
```js
|
||||
$("#myElementId").print(/*options*/);
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```js
|
||||
$.print("#myElementId" /*, options*/);
|
||||
|
||||
```
|
||||
|
||||
You can submit the options object like:
|
||||
|
||||
```js
|
||||
$("#myElementId").print({
|
||||
globalStyles: true,
|
||||
mediaPrint: false,
|
||||
stylesheet: null,
|
||||
noPrintSelector: ".no-print",
|
||||
iframe: true,
|
||||
append: null,
|
||||
prepend: null,
|
||||
manuallyCopyFormValues: true,
|
||||
deferred: $.Deferred()
|
||||
globalStyles: true,
|
||||
mediaPrint: false,
|
||||
stylesheet: null,
|
||||
noPrintSelector: ".no-print",
|
||||
iframe: true,
|
||||
append: null,
|
||||
prepend: null,
|
||||
manuallyCopyFormValues: true,
|
||||
deferred: $.Deferred()
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
Currently this plugin supports the following options:
|
||||
|
||||
####globalStyles
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jQuery.print",
|
||||
"main": "jQuery.print.js",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.2",
|
||||
"homepage": "https://doersguild.github.io/jQuery.print/",
|
||||
"authors": [
|
||||
"Sathvik P <sathvik@doersguild.com>"
|
||||
@@ -23,4 +23,4 @@
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -98,10 +98,10 @@
|
||||
iframe : false,
|
||||
//Don't print this
|
||||
noPrintSelector : ".avoid-this",
|
||||
//Add this on top
|
||||
append : "Hello World!!!<br/>",
|
||||
//Add this at bottom
|
||||
prepend : "<br/>Buh Bye!"
|
||||
//Add this at top
|
||||
prepend : "Hello World!!!<br/>",
|
||||
//Add this on bottom
|
||||
append : "<br/>Buh Bye!"
|
||||
});
|
||||
});
|
||||
// Fork https://github.com/sathvikp/jQuery.print for the full list of options
|
||||
@@ -109,4 +109,4 @@
|
||||
//]]>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
+11
-5
@@ -1,5 +1,5 @@
|
||||
/* @license
|
||||
* jQuery.print, version 1.3.1
|
||||
* jQuery.print, version 1.3.2
|
||||
* (c) Sathvik Ponangi, Doers' Guild
|
||||
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
|
||||
*--------------------------------------------------------------------------*/
|
||||
@@ -132,20 +132,26 @@
|
||||
if (options.manuallyCopyFormValues) {
|
||||
// Manually copy form values into the HTML for printing user-modified input fields
|
||||
// http://stackoverflow.com/a/26707753
|
||||
copy.find("input, select, textarea")
|
||||
copy.find("input")
|
||||
.each(function () {
|
||||
var $field = $(this);
|
||||
if ($field.is("[type='radio']") || $field.is("[type='checkbox']")) {
|
||||
if ($field.prop("checked")) {
|
||||
$field.attr("checked", "checked");
|
||||
}
|
||||
} else if ($field.is("select")) {
|
||||
$field.find(":selected")
|
||||
.attr("selected", "selected");
|
||||
} else {
|
||||
$field.attr("value", $field.val());
|
||||
}
|
||||
});
|
||||
copy.find("select").each(function () {
|
||||
var $field = $(this);
|
||||
$field.find(":selected").attr("selected", "selected");
|
||||
});
|
||||
copy.find("textarea").each(function () {
|
||||
// Fix for https://github.com/DoersGuild/jQuery.print/issues/18#issuecomment-96451589
|
||||
var $field = $(this);
|
||||
$field.text($field.val());
|
||||
});
|
||||
}
|
||||
// Get the HTML markup string
|
||||
var content = copy.html();
|
||||
|
||||
Reference in New Issue
Block a user