From f4882f2aad89802120d4da9f9b457643648673a8 Mon Sep 17 00:00:00 2001 From: Ezra Pool Date: Wed, 1 Feb 2012 11:42:56 +0100 Subject: [PATCH 1/2] Lots of changes, sadly unreadable because of formatting differences :-( Basic changes: + Use $prefix on all jQuery variables + Use var print_frame_ref = $print_frame.get(0).contentDocument; to get contentDocument of iframe. + Use $print_frame.height($print_frame.contents().height()); to get/set height of iframe contents + Also clone() scripts to the iframe, (I needed them for my layout) + Use $('img').on('load', print_frame_ref, function(){ $print_frame.height($print_frame.contents().height()); }) To bind load events of images inside the iframe. + Rename distroyPrintPreview to destroyPrintPreview. + Rename resize..printPreview.mask to resize.printPreview.mask NOTE: Uses the new on method so requires jQuery 1.7 --- src/jquery.print-preview.js | 366 +++++++++++++++++++----------------- 1 file changed, 196 insertions(+), 170 deletions(-) diff --git a/src/jquery.print-preview.js b/src/jquery.print-preview.js index 4565a48..2426d23 100644 --- a/src/jquery.print-preview.js +++ b/src/jquery.print-preview.js @@ -1,192 +1,218 @@ /*! - * jQuery Print Previw Plugin v1.0.1 + * jQuery Print Preview Plugin v1.0.2 * * Copyright 2011, Tim Connell * Licensed under the GPL Version 2 license * http://www.gnu.org/licenses/gpl-2.0.html * * Date: Wed Jan 25 00:00:00 2012 -000 + * + * @author Ezra Pool + * @version 1.0.2 + * @since jQuery 1.7 */ - -(function($) { - + +(function($) { + // Initialization $.fn.printPreview = function() { this.each(function() { $(this).bind('click', function(e) { - e.preventDefault(); - if (!$('#print-modal').length) { - $.printPreview.loadPrintPreview(); - } + e.preventDefault(); + if (!$('#print-modal').length) { + $.printPreview.loadPrintPreview(); + } }); }); return this; }; - - // Private functions - var mask, size, print_modal, print_controls; - $.printPreview = { - loadPrintPreview: function() { - // Declare DOM objects - print_modal = $(''); - print_controls = $('