From 5d03e97ed8e5266f74b175eded9f54beee695cc0 Mon Sep 17 00:00:00 2001 From: Tom Heady Date: Sun, 12 Aug 2012 17:12:34 -0700 Subject: [PATCH 1/2] can now have a callback that gets called when the print preview is closed --- src/jquery.print-preview.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/jquery.print-preview.js b/src/jquery.print-preview.js index 4565a48..a06ec38 100644 --- a/src/jquery.print-preview.js +++ b/src/jquery.print-preview.js @@ -26,6 +26,7 @@ // Private functions var mask, size, print_modal, print_controls; $.printPreview = { + close_cb: function(){}, loadPrintPreview: function() { // Declare DOM objects print_modal = $(''); @@ -126,6 +127,7 @@ }, 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(); @@ -133,6 +135,7 @@ }); mask.fadeOut('slow', function() { mask.remove(); + self.close_cb.call(self); }); $(document).unbind("keydown.printPreview.mask"); @@ -189,4 +192,4 @@ mask.css({width: size[0], height: size[1]}); } } -})(jQuery); \ No newline at end of file +})(jQuery); From 0b276ca4ef813deb2c31d258d205e7ed18f45d89 Mon Sep 17 00:00:00 2001 From: Tom Heady Date: Sun, 12 Aug 2012 17:20:51 -0700 Subject: [PATCH 2/2] add documentation on how to use the close_cb property --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 848c58a..0c1a25a 100644 --- a/README.md +++ b/README.md @@ -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