Skip to content

Commit

Permalink
Merge #61, Resolve #56 - Fix printing issue on iPad
Browse files Browse the repository at this point in the history
  • Loading branch information
Sathvik P committed Jan 4, 2017
1 parent c26c3c1 commit 66ca777
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Currently this plugin supports the following options:
- Default: `$.Deferred()`
- 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. Can be used [to setup callbacks - see wiki](https://github.com/DoersGuild/jQuery.print/wiki/Using-the-deferred-option-to-set-up-a-callback-after-printing)
####timeout
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jQuery.print",
"main": "jQuery.print.js",
"version": "1.5.0",
"version": "1.5.1",
"homepage": "https://doersguild.github.io/jQuery.print/",
"authors": [
"Sathvik P <[email protected]>"
Expand Down
12 changes: 8 additions & 4 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ <h3 class='avoid-this'>Element 4</h3>
//Add this at top
prepend : "Hello World!!!<br/>",
//Add this on bottom
append : "<br/>Buh Bye!"
append : "<br/>Buh Bye!",
//Log to console when printing is done via a deffered callback
deferred: $.Deferred().done(function() { console.log('Printing done', arguments); })
});
});
</code></pre>
Expand All @@ -94,14 +96,14 @@ <h3 class='avoid-this'>Element 4</h3>
Print page - jQuery.print()
</button>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
window.jQuery || document.write('<script src="../bower_components/jquery/dist/jquery.min.js"><\/script>')
</script>
<script src="../jQuery.print.js"></script>
<script type='text/javascript'>
//<![CDATA[
$(function() {
jQuery(function($) { 'use strict';
$("#ele2").find('.print-link').on('click', function() {
//Print ele2 with default options
$.print("#ele2");
Expand All @@ -122,7 +124,9 @@ <h3 class='avoid-this'>Element 4</h3>
//Add this at top
prepend : "Hello World!!!<br/>",
//Add this on bottom
append : "<br/>Buh Bye!"
append : "<br/>Buh Bye!",
//Log to console when printing is done via a deffered callback
deferred: $.Deferred().done(function() { console.log('Printing done', arguments); })
});
});
// Fork https://github.com/sathvikp/jQuery.print for the full list of options
Expand Down
7 changes: 3 additions & 4 deletions jQuery.print.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* @license
* jQuery.print, version 1.5.0
* jQuery.print, version 1.5.1
* (c) Sathvik Ponangi, Doers' Guild
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
*--------------------------------------------------------------------------*/
Expand Down Expand Up @@ -42,10 +42,9 @@
if (!frameWindow.document.execCommand('print', false, null)) {
// document.execCommand returns false if it failed -http://stackoverflow.com/a/21336448/937891
frameWindow.print();
}else{
// focus body as it is losing focus in iPad and content not getting printed
$('body').focus();
}
// focus body as it is losing focus in iPad and content not getting printed
$('body').focus();
} catch (e) {
frameWindow.print();
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jQuery.print",
"filename": "jQuery.print.min.js",
"version": "1.5.0",
"version": "1.5.1",
"homepage": "https://doersguild.github.io/jQuery.print/",
"authors": [
"Sathvik P <[email protected]>"
Expand Down

0 comments on commit 66ca777

Please sign in to comment.