Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ Using the plugin:
``$('#foo').prepend('Print this page');
$('a.print-preview').printPreview();``

Properties:

close_cb - Add a function callback that is called when the preview is closed.

Example:
$('a.preview').bind('click', function(e) {
e.preventDefault();
var pp = jQuery.printPreview;
pp.close_cb = function(){ alert('all done') };
pp.loadPrintPreview();
});

## Supported Browsers
- Internet Explorer 6, 7, 8 and 9
- Safari
Expand Down
5 changes: 4 additions & 1 deletion src/jquery.print-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
// Private functions
var mask, size, print_modal, print_controls;
$.printPreview = {
close_cb: function(){},
loadPrintPreview: function() {
// Declare DOM objects
print_modal = $('<div id="print-modal"></div>');
Expand Down Expand Up @@ -126,13 +127,15 @@
},

distroyPrintPreview: function() {
var self = this;
print_controls.fadeOut(100);
print_modal.animate({ top: $(window).scrollTop() - $(window).height(), opacity: 1}, 400, 'linear', function(){
print_modal.remove();
$('body').css({overflowY: 'auto', height: 'auto'});
});
mask.fadeOut('slow', function() {
mask.remove();
self.close_cb.call(self);
});

$(document).unbind("keydown.printPreview.mask");
Expand Down Expand Up @@ -189,4 +192,4 @@
mask.css({width: size[0], height: size[1]});
}
}
})(jQuery);
})(jQuery);