diff --git a/dist/jquery.printelement.js b/dist/jquery.printelement.js index d294f99..d81f353 100644 --- a/dist/jquery.printelement.js +++ b/dist/jquery.printelement.js @@ -1,19 +1,12 @@ -/*! jQuery printElement - v2.0.1 - 2014-08-22 +/*! jQuery printElement - v2.0.1 - 2016-02-17 * https://github.com/erikzaadi/jQuery.printElement -* Copyright (c) 2014 erikzaadi; Licensed MIT, GPL */ +* Copyright (c) 2016 erikzaadi; Licensed MIT, GPL */ /*global window,focus,setTimeout,navigator*/ (function (window, undefined) { var document = window.document; var $ = window.jQuery; $.fn.printElement = function (options) { var mainOptions = $.extend({}, $.fn.printElement.defaults, options); - //iframe mode is not supported for opera and chrome 3.0 (it prints the entire page). - //http://www.google.com/support/forum/p/Webmasters/thread?tid=2cb0f08dce8821c3&hl=en - if (mainOptions.printMode === 'iframe') { - if (/chrome/.test(navigator.userAgent.toLowerCase())) { - mainOptions.printMode = 'popup'; - } - } //Remove previously printed iframe if exists $("[id^='printElement_']").remove(); diff --git a/dist/jquery.printelement.min.js b/dist/jquery.printelement.min.js index 7a29cb9..fe4a0fe 100644 --- a/dist/jquery.printelement.min.js +++ b/dist/jquery.printelement.min.js @@ -1,4 +1,4 @@ -/*! jQuery printElement - v2.0.1 - 2014-08-22 +/*! jQuery printElement - v2.0.1 - 2016-02-17 * https://github.com/erikzaadi/jQuery.printElement -* Copyright (c) 2014 erikzaadi; Licensed MIT, GPL */ -!function(a){function b(b,d){var e=f(b,d),i=null,j=null;if("popup"===d.printMode.toLowerCase())i=a.open("about:blank","printElementWindow","width=650,height=440,scrollbars=yes"),j=i.document;else{var k="printElement_"+Math.round(99999*Math.random()).toString(),l=g.createElement("IFRAME");h(l).attr({style:d.iframeElementOptions.styleToAdd,id:k,className:d.iframeElementOptions.classNameToAdd,frameBorder:0,scrolling:"no",src:"about:blank"}),g.body.appendChild(l),j=l.contentWindow||l.contentDocument,j.document&&(j=j.document),l=g.frames?g.frames[k]:g.getElementById(k),i=l.contentWindow||l}focus(),j.open(),j.write(e),j.close(),c(i)}function c(a){a&&a.printPage?a.printPage():setTimeout(function(){c(a)},50)}function d(a){var b=h(a);h(":checked",b).each(function(){this.setAttribute("checked","checked")}),h("input[type='text'],input[type='number']",b).each(function(){this.setAttribute("value",h(this).val())}),h("select",b).each(function(){var a=h(this);h("option",a).each(function(){a.val()===h(this).val()&&this.setAttribute("selected","selected")})}),h("textarea",b).each(function(){var a=h(this).attr("value");this.firstChild?this.firstChild.textContent=a:this.innerHTML=a});var c=h("
").append(b.clone()).html();return c}function e(){var b=a.location.port?":"+a.location.port:"";return a.location.protocol+"//"+a.location.hostname+b+a.location.pathname}function f(a,b){var c=h(a),f=d(a),i=[];if(i.push(""+b.pageTitle+""),b.overrideElementCSS){if(b.overrideElementCSS.length>0)for(var j=0;j');else{var l=k.media||"";i.push('')}}}else h("link",g).filter(function(){return"stylesheet"===h(this).attr("rel").toLowerCase()}).each(function(){var a=h(this).attr("media")||"";i.push('')});return i.push(''),i.push(''),i.push('
'+f+"
"),i.push('"),i.push(""),i.join("")}var g=a.document,h=a.jQuery;h.fn.printElement=function(a){var c=h.extend({},h.fn.printElement.defaults,a);return"iframe"===c.printMode&&/chrome/.test(navigator.userAgent.toLowerCase())&&(c.printMode="popup"),h("[id^='printElement_']").remove(),this.each(function(){var a=h.meta?h.extend({},c,h(this).data()):c;b(h(this),a)})},h.fn.printElement.defaults={printMode:"iframe",pageTitle:"",overrideElementCSS:null,printBodyOptions:{styleToAdd:"padding:10px;margin:10px;",classNameToAdd:""},leaveOpen:!1,iframeElementOptions:{styleToAdd:"border:none;position:absolute;width:0px;height:0px;bottom:0px;left:0px;",classNameToAdd:""}},h.fn.printElement.cssElement={href:"",media:""}}(window); \ No newline at end of file +* Copyright (c) 2016 erikzaadi; Licensed MIT, GPL */ +!function(a,b){function c(b,c){var e=g(b,c),f=null,j=null;if("popup"===c.printMode.toLowerCase())f=a.open("about:blank","printElementWindow","width=650,height=440,scrollbars=yes"),j=f.document;else{var k="printElement_"+Math.round(99999*Math.random()).toString(),l=h.createElement("IFRAME");i(l).attr({style:c.iframeElementOptions.styleToAdd,id:k,className:c.iframeElementOptions.classNameToAdd,frameBorder:0,scrolling:"no",src:"about:blank"}),h.body.appendChild(l),j=l.contentWindow||l.contentDocument,j.document&&(j=j.document),l=h.frames?h.frames[k]:h.getElementById(k),f=l.contentWindow||l}focus(),j.open(),j.write(e),j.close(),d(f)}function d(a){a&&a.printPage?a.printPage():setTimeout(function(){d(a)},50)}function e(a){var b=i(a);i(":checked",b).each(function(){this.setAttribute("checked","checked")}),i("input[type='text'],input[type='number']",b).each(function(){this.setAttribute("value",i(this).val())}),i("select",b).each(function(){var a=i(this);i("option",a).each(function(){a.val()===i(this).val()&&this.setAttribute("selected","selected")})}),i("textarea",b).each(function(){var a=i(this).attr("value");this.firstChild?this.firstChild.textContent=a:this.innerHTML=a});var c=i("
").append(b.clone()).html();return c}function f(){var b=a.location.port?":"+a.location.port:"";return a.location.protocol+"//"+a.location.hostname+b+a.location.pathname}function g(a,b){var c=i(a),d=e(a),g=[];if(g.push(""+b.pageTitle+""),b.overrideElementCSS){if(b.overrideElementCSS.length>0)for(var j=0;j');else{var l=k.media||"";g.push('')}}}else i("link",h).filter(function(){return"stylesheet"===i(this).attr("rel").toLowerCase()}).each(function(){var a=i(this).attr("media")||"";g.push('')});return g.push(''),g.push(''),g.push('
'+d+"
"),g.push('"),g.push(""),g.join("")}var h=a.document,i=a.jQuery;i.fn.printElement=function(a){var b=i.extend({},i.fn.printElement.defaults,a);return i("[id^='printElement_']").remove(),this.each(function(){var a=i.meta?i.extend({},b,i(this).data()):b;c(i(this),a)})},i.fn.printElement.defaults={printMode:"iframe",pageTitle:"",overrideElementCSS:null,printBodyOptions:{styleToAdd:"padding:10px;margin:10px;",classNameToAdd:""},leaveOpen:!1,iframeElementOptions:{styleToAdd:"border:none;position:absolute;width:0px;height:0px;bottom:0px;left:0px;",classNameToAdd:""}},i.fn.printElement.cssElement={href:"",media:""}}(window); \ No newline at end of file diff --git a/src/jquery.printelement.js b/src/jquery.printelement.js index ba0f499..511eda0 100644 --- a/src/jquery.printelement.js +++ b/src/jquery.printelement.js @@ -18,13 +18,6 @@ var $ = window.jQuery; $.fn.printElement = function (options) { var mainOptions = $.extend({}, $.fn.printElement.defaults, options); - //iframe mode is not supported for opera and chrome 3.0 (it prints the entire page). - //http://www.google.com/support/forum/p/Webmasters/thread?tid=2cb0f08dce8821c3&hl=en - if (mainOptions.printMode === 'iframe') { - if (/chrome/.test(navigator.userAgent.toLowerCase())) { - mainOptions.printMode = 'popup'; - } - } //Remove previously printed iframe if exists $("[id^='printElement_']").remove();