6 Commits
Author SHA1 Message Date
Sathvik Ponangi 38f12da807 Update README.md 2015-04-27 17:19:25 +05:30
Sathvik Ponangi 1b8610b182 Update README.md 2015-04-27 17:03:04 +05:30
Sathvik Ponangi fdf979b239 Update README.md 2015-04-27 17:02:43 +05:30
Sathvik Ponangi bf8dd435fb Bump version to 1.3.2 2015-04-27 17:01:41 +05:30
Sathvik Ponangi 1a5fae505e Fix for #18, Manually update textarea content 2015-04-27 17:01:02 +05:30
Sathvik Ponangi c6a57a9cbe Fixes #17 - the append-prepend text mixup 2015-04-08 18:55:42 +05:30
4 changed files with 38 additions and 23 deletions
+20 -11
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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();