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 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);