Version Description
Better explanation of some error messages (e.g. attempt to access PDF on a different domain). Forced white background by default - some Theme's CSS would override.
Download this release
Release Info
Developer | danlester |
Plugin | PDF Embedder |
Version | 2.2.5 |
Comparing to | |
See all releases |
Code changes from version 2.2.4 to 2.2.5
- css/pdfemb-embed-pdf.css +1 -0
- js/all-pdfemb-basic.min.js +12 -11
- js/pdfemb-embed-pdf.js +7 -1
- pdf_embedder.php +2 -2
- readme.txt +6 -1
css/pdfemb-embed-pdf.css
CHANGED
@@ -101,6 +101,7 @@ div.pdfemb-viewer canvas {
|
|
101 |
margin: 0px;
|
102 |
padding: 0px;
|
103 |
display: inline-block;
|
|
|
104 |
}
|
105 |
|
106 |
div.pdfemb-toolbar {
|
101 |
margin: 0px;
|
102 |
padding: 0px;
|
103 |
display: inline-block;
|
104 |
+
background-color: white;
|
105 |
}
|
106 |
|
107 |
div.pdfemb-toolbar {
|
js/all-pdfemb-basic.min.js
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
function pdfembGetPDF(b,a){a(b,!1)}function pdfembWantMobile(b,a,f,c){return!1}function pdfembMakeMobile(b,a,f){}function pdfembAddMoreToolbar(b,a,f){};jQuery(document).ready(function(b){b.fn.pdfEmbedder=function(){this.each(function(a,f){var c=b(f);c.append(b("<div></div>",{"class":"pdfemb-loadingmsg"}).append(document.createTextNode("Loading...")));var d=function(a,e){c.empty().append(b("<div></div>",{"class":"pdfemb-inner-div"}).append(b("<canvas></canvas>",{"class":"pdfemb-the-canvas"})));c.data("pdfDoc",a);var d=c.data("toolbar");"bottom"!=d&&b.fn.pdfEmbedder.addToolbar(c,!0,"on"==c.data("toolbar-fixed"),e);"top"!=d&&b.fn.pdfEmbedder.addToolbar(c,
|
2 |
!1,"on"==c.data("toolbar-fixed"),e);c.data("pageCount",a.numPages);c.data("pageNum")||c.data("pageNum",1);c.data("showIsSecure",e);c.data("pageNumPending",null);c.data("zoom",100);b.fn.pdfEmbedder.renderPage(c,c.data("pageNum"));c.find("span.pdfemb-page-count").text(a.numPages);d=new pdfembGrabToPan({element:c.find("div.pdfemb-inner-div")[0]});c.data("grabtopan",d);b(window).resize(function(){setTimeout(function(){b.fn.pdfEmbedder.queueRenderPage(c,c.data("pageNum"))},100)})},g=function(a,e){PDFJS.getDocument(a).then(function(a){d(a,
|
3 |
-
e)},function(a){
|
4 |
-
|
5 |
-
l=h.width,m=h.height;if(0>=l||0>=m)a.empty().append(document.createTextNode("PDF page width or height are invalid"));else{var q=a.parent().width(),h=l,p=m;if("max"==a.data("width"))h=q;else if("auto"==a.data("width"))h=
|
6 |
-
t*w.height():p;var h=Math.floor(h),p=Math.floor(p),n=100,l=h,m=p,y=0,z=0;q||(n=a.data("zoom"),l=h*n/100,m=p*n/100,l<h&&(y=(h-l)/2),m<k&&(z=(k-m)/2));x=d.getViewport(x*n/100);h!=a.width()&&a.width(h);a.height()!=k&&a.height(k+
|
7 |
-
k)&&!q?(k=a.data("fromZoom"),t=a.data("toZoom"),0<k&&0<t&&(y=B+p/2,n.scrollLeft((A+h/2)*t/k-h/2),n.scrollTop(y*t/k-p/2)),a.data("grabtopan").activate()):("on"==a.data("fullScreen")?a.data("grabtopan").activate():a.data("grabtopan").deactivate(),
|
8 |
-
0,0),r.scale(l/u,m/v),r.drawImage(d,0,0)):(e={canvasContext:g[0].getContext("2d"),viewport:x},d.render(e).promise.then(function(){a.data("pageNum",f);a.data("pageRendering",!1);a.find("span.pdfemb-page-num").text(f);f<a.data("pageCount")?
|
9 |
-
"disabled").
|
10 |
-
|
11 |
-
(
|
12 |
-
|
13 |
-
|
|
|
14 |
(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}b.prototype={CSS_CLASS_GRAB:"grab-to-pan-grab",activate:function(){if(!this.active&&(this.active=!0,this.element.addEventListener("mousedown",this._onmousedown,!0),this.element.addEventListener("DOMMouseScroll",this._onmousewheel),this.element.addEventListener("mousewheel",this._onmousewheel),this.element.classList.add(this.CSS_CLASS_GRAB),this.onActiveChanged))this.onActiveChanged(!0)},deactivate:function(){if(this.active&&
|
15 |
(this.active=!1,this.element.removeEventListener("mousedown",this._onmousedown,!0),this._endPan(),this.element.classList.remove(this.CSS_CLASS_GRAB),this.onActiveChanged))this.onActiveChanged(!1)},toggle:function(){this.active?this.deactivate():this.activate()},ignoreTarget:function(e){return e[a]("a[href], a[href] *, input, textarea, button, button *, select, option")},_onmousedown:function(a){if(0===a.button&&!this.ignoreTarget(a.target)){this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=
|
16 |
this.element.scrollTop;this.clientXStart=a.clientX;this.clientYStart=a.clientY;this.document.addEventListener("mousemove",this._onmousemove,!0);this.document.addEventListener("mouseup",this._endPan,!0);this.element.addEventListener("scroll",this._endPan,!0);a.preventDefault();a.stopPropagation();this.document.documentElement.classList.add(this.CSS_CLASS_GRABBING);var b=document.activeElement;b&&!b.contains(a.target)&&b.blur()}},_onmousemove:function(a){this.element.removeEventListener("scroll",this._endPan,
|
1 |
function pdfembGetPDF(b,a){a(b,!1)}function pdfembWantMobile(b,a,f,c){return!1}function pdfembMakeMobile(b,a,f){}function pdfembAddMoreToolbar(b,a,f){};jQuery(document).ready(function(b){b.fn.pdfEmbedder=function(){this.each(function(a,f){var c=b(f);c.append(b("<div></div>",{"class":"pdfemb-loadingmsg"}).append(document.createTextNode("Loading...")));var d=function(a,e){c.empty().append(b("<div></div>",{"class":"pdfemb-inner-div"}).append(b("<canvas></canvas>",{"class":"pdfemb-the-canvas"})));c.data("pdfDoc",a);var d=c.data("toolbar");"bottom"!=d&&b.fn.pdfEmbedder.addToolbar(c,!0,"on"==c.data("toolbar-fixed"),e);"top"!=d&&b.fn.pdfEmbedder.addToolbar(c,
|
2 |
!1,"on"==c.data("toolbar-fixed"),e);c.data("pageCount",a.numPages);c.data("pageNum")||c.data("pageNum",1);c.data("showIsSecure",e);c.data("pageNumPending",null);c.data("zoom",100);b.fn.pdfEmbedder.renderPage(c,c.data("pageNum"));c.find("span.pdfemb-page-count").text(a.numPages);d=new pdfembGrabToPan({element:c.find("div.pdfemb-inner-div")[0]});c.data("grabtopan",d);b(window).resize(function(){setTimeout(function(){b.fn.pdfEmbedder.queueRenderPage(c,c.data("pageNum"))},100)})},g=function(a,e){PDFJS.getDocument(a).then(function(a){d(a,
|
3 |
+
e)},function(a){var e=document.createTextNode(a.message);"UnexpectedResponseException"==a.name&&0==a.status&&(e=b("<span></span>").append(document.createTextNode("Error: URL to the PDF file must be on exactly the same domain as the current web page. ")).append(b('<a href="https://wp-pdf.com/troubleshooting/#unexpected" target="_blank">Click here for more info</a>')));c.empty().append(b("<div></div>",{"class":"pdfemb-errormsg"}).append(e))})};if(c.data("pdfDoc"))d(c.data("pdfDoc"),c.data("showIsSecure"));
|
4 |
+
else{var e=c.attr("data-pdf-url");pdfembGetPDF(e,g)}});return this};b.fn.pdfEmbedder.checkForResize=function(a){var f=b(window).height(),c=b(window).width(),d=a.data("checked-window-height"),g=a.data("checked-window-width");if(!d||!g)a.data("checked-window-height",f),a.data("checked-window-width",c);else if(d!=f||g!=c)b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum")),a.data("checked-window-height",f),a.data("checked-window-width",c);"true"!=a.data("fullScreenClosed")&&setTimeout(function(){b.fn.pdfEmbedder.checkForResize(a)},
|
5 |
+
1E3)};b.fn.pdfEmbedder.renderPage=function(a,f,c){a.data("pageRendering",!0);a.data("pdfDoc").getPage(f).then(function(d){var g=a.find(".pdfemb-the-canvas"),e=null,r=null,u=null,v=null;c&&(u=g.width(),v=g.height(),r=g[0].getContext("2d"),e=r.getImageData(0,0,u,v));var x,h=d.getViewport(1),l=h.width,m=h.height;if(0>=l||0>=m)a.empty().append(document.createTextNode("PDF page width or height are invalid"));else{var q=a.parent().width(),h=l,p=m;if("max"==a.data("width"))h=q;else if("auto"==a.data("width"))h=
|
6 |
+
l;else if(h=parseInt(a.data("width"),10),isNaN(h)||0>=h)h=q;0>=h&&(h=l);h>q&&0<q&&(h=q);x=h/l;var p=m*x,w=a.find("div.pdfemb-toolbar-fixed"),t=(q=pdfembWantMobile(b,a,h,k))?0:w.length,k=parseInt(a.data("height"),10);if(isNaN(k)||0>=k||k>p)k="auto"==a.data("height")?a.parent().height()-t*w.height():p;var h=Math.floor(h),p=Math.floor(p),n=100,l=h,m=p,y=0,z=0;q||(n=a.data("zoom"),l=h*n/100,m=p*n/100,l<h&&(y=(h-l)/2),m<k&&(z=(k-m)/2));x=d.getViewport(x*n/100);h!=a.width()&&a.width(h);a.height()!=k&&a.height(k+
|
7 |
+
t*w.height());var n=a.find("div.pdfemb-inner-div"),A=n[0].scrollLeft,B=n[0].scrollTop;n.width(h);n.height(k);w=w.filter(".pdfemb-toolbar-top");0<t&&n.css("top",w.height());g[0].width=l;g[0].height=m;g.css("width",l);g.css("height",m);g.css("left",y).css("top",z);(l>h||m>p||m>k)&&!q?(k=a.data("fromZoom"),t=a.data("toZoom"),0<k&&0<t&&(y=B+p/2,n.scrollLeft((A+h/2)*t/k-h/2),n.scrollTop(y*t/k-p/2)),a.data("grabtopan").activate()):("on"==a.data("fullScreen")?a.data("grabtopan").activate():a.data("grabtopan").deactivate(),
|
8 |
+
a.find("div.pdfemb-inner-div").scrollLeft(0).scrollTop(0));a.data("fromZoom",0).data("toZoom",0);pdfembMakeMobile(b,q,a);c?(a.data("pageNum",f),a.data("pageRendering",!1),d=b("<canvas>").attr("width",e.width).attr("height",e.height)[0],d.getContext("2d").putImageData(e,0,0),r.scale(l/u,m/v),r.drawImage(d,0,0)):(e={canvasContext:g[0].getContext("2d"),viewport:x},d.render(e).promise.then(function(){a.data("pageNum",f);a.data("pageRendering",!1);a.find("span.pdfemb-page-num").text(f);f<a.data("pageCount")?
|
9 |
+
a.find(".pdfemb-next").removeAttr("disabled").removeClass("pdfemb-btndisabled"):a.find(".pdfemb-next").attr("disabled","disabled").addClass("pdfemb-btndisabled");1<f?a.find(".pdfemb-prev").removeAttr("disabled").removeClass("pdfemb-btndisabled"):a.find(".pdfemb-prev").attr("disabled","disabled").addClass("pdfemb-btndisabled");null!==a.data("pageNumPending")&&(b.fn.pdfEmbedder.renderPage(a,a.data("pageNumPending")),a.data("pageNumPending",null))}))}})};b.fn.pdfEmbedder.queueRenderPage=function(a,f,
|
10 |
+
c){a.data("pageRendering")?a.data("pageNumPending",f):b.fn.pdfEmbedder.renderPage(a,f,c)};b.fn.pdfEmbedder.goFullScreen=function(a){a=b('<div class="pdfemb-fs-window"></div>');b(document.body).append(a)};b.fn.pdfEmbedder.changeZoom=function(a,f){var c=a.data("zoom"),d=c+f;a.data("zoom",d);a.find("span.pdfemb-zoom").text(d+"%");b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum"));a.data("fromZoom",c).data("toZoom",d)};b.fn.pdfEmbedder.magnifyZoom=function(a,f){var c=a.data("zoom"),d=Math.floor(c*
|
11 |
+
f);20>d&&(d=20);500<d&&(d=500);a.data("zoom",d);a.find("span.pdfemb-zoom").text(d+"%");b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum"),!0);a.data("fromZoom",c).data("toZoom",d)};b.fn.pdfEmbedder.addToolbar=function(a,f,c,d){var g=b("<div></div>",{"class":"pdfemb-toolbar pdfemb-toolbar"+(c?"-fixed":"-hover")+" "+(f?" pdfemb-toolbar-top":"pdfemb-toolbar-bottom")}),e=b('<button class="pdfemb-prev" title="Prev"></button>');g.append(e);var r=b('<button class="pdfemb-next" title="Next"></button>');
|
12 |
+
g.append(r);g.append(b('<div>Page <span class="pdfemb-page-num">0</span> / <span class="pdfemb-page-count"></span></div>'));var u=b('<button class="pdfemb-zoomout" title="Zoom Out"></button>');g.append(u);var v=b('<button class="pdfemb-zoomin" title="Zoom In"></button>');g.append(v);g.append(b('<div>Zoom <span class="pdfemb-zoom">100%</span></div>'));d&&g.append(b("<div>Secure</div>"));f?a.prepend(g):a.append(g);e.on("click",function(e){1>=a.data("pageNum")||(a.data("pageNum",a.data("pageNum")-1),
|
13 |
+
b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum")))});r.on("click",function(e){a.data("pageNum")>=a.data("pdfDoc").numPages||(a.data("pageNum",a.data("pageNum")+1),b.fn.pdfEmbedder.queueRenderPage(a,a.data("pageNum")))});v.on("click",function(e){500<=a.data("zoom")||b.fn.pdfEmbedder.changeZoom(a,10)});u.on("click",function(e){20>=a.data("zoom")||b.fn.pdfEmbedder.changeZoom(a,-10)});pdfembAddMoreToolbar(b,g,a);c||(a.on("mouseenter",function(e){e=a.find("div.pdfemb-toolbar-hover");!0!==e.data("no-hover")&&
|
14 |
+
e.show()}),a.on("mouseleave",function(e){a.find("div.pdfemb-toolbar-hover").hide()}))};PDFJS.workerSrc=pdfemb_trans.worker_src;PDFJS.cMapUrl=pdfemb_trans.cmap_url;PDFJS.cMapPacked=!0;b(".pdfemb-viewer").pdfEmbedder()});var pdfembGrabToPan=function(){function b(a){this.element=a.element;this.document=a.element.ownerDocument;"function"===typeof a.ignoreTarget&&(this.ignoreTarget=a.ignoreTarget);this.onActiveChanged=a.onActiveChanged;this.activate=this.activate.bind(this);this.deactivate=this.deactivate.bind(this);this.toggle=this.toggle.bind(this);this._onmousedown=this._onmousedown.bind(this);this._onmousemove=this._onmousemove.bind(this);this._onmousewheel=this._onmousewheel.bind(this);this._endPan=this._endPan.bind(this);
|
15 |
(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}b.prototype={CSS_CLASS_GRAB:"grab-to-pan-grab",activate:function(){if(!this.active&&(this.active=!0,this.element.addEventListener("mousedown",this._onmousedown,!0),this.element.addEventListener("DOMMouseScroll",this._onmousewheel),this.element.addEventListener("mousewheel",this._onmousewheel),this.element.classList.add(this.CSS_CLASS_GRAB),this.onActiveChanged))this.onActiveChanged(!0)},deactivate:function(){if(this.active&&
|
16 |
(this.active=!1,this.element.removeEventListener("mousedown",this._onmousedown,!0),this._endPan(),this.element.classList.remove(this.CSS_CLASS_GRAB),this.onActiveChanged))this.onActiveChanged(!1)},toggle:function(){this.active?this.deactivate():this.activate()},ignoreTarget:function(e){return e[a]("a[href], a[href] *, input, textarea, button, button *, select, option")},_onmousedown:function(a){if(0===a.button&&!this.ignoreTarget(a.target)){this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=
|
17 |
this.element.scrollTop;this.clientXStart=a.clientX;this.clientYStart=a.clientY;this.document.addEventListener("mousemove",this._onmousemove,!0);this.document.addEventListener("mouseup",this._endPan,!0);this.element.addEventListener("scroll",this._endPan,!0);a.preventDefault();a.stopPropagation();this.document.documentElement.classList.add(this.CSS_CLASS_GRABBING);var b=document.activeElement;b&&!b.contains(a.target)&&b.blur()}},_onmousemove:function(a){this.element.removeEventListener("scroll",this._endPan,
|
js/pdfemb-embed-pdf.js
CHANGED
@@ -65,7 +65,13 @@ jQuery(document).ready(function ($) {
|
|
65 |
initPdfDoc(pdfDoc_, showIsSecure)
|
66 |
},
|
67 |
function(e) {
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
);
|
71 |
|
65 |
initPdfDoc(pdfDoc_, showIsSecure)
|
66 |
},
|
67 |
function(e) {
|
68 |
+
var msgnode = document.createTextNode(e.message);
|
69 |
+
if (e.name == 'UnexpectedResponseException' && e.status == 0) {
|
70 |
+
msgnode = $('<span></span>').append(
|
71 |
+
document.createTextNode("Error: URL to the PDF file must be on exactly the same domain as the current web page. "))
|
72 |
+
.append($('<a href="https://wp-pdf.com/troubleshooting/#unexpected" target="_blank">Click here for more info</a>'));
|
73 |
+
}
|
74 |
+
divContainer.empty().append($('<div></div>', {'class': 'pdfemb-errormsg'}).append(msgnode));
|
75 |
}
|
76 |
);
|
77 |
|
pdf_embedder.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: PDF Embedder
|
5 |
* Plugin URI: http://wp-pdf.com/
|
6 |
* Description: Embed PDFs straight into your posts and pages, with flexible width and height. No third-party services required.
|
7 |
-
* Version: 2.2.
|
8 |
* Author: Dan Lester
|
9 |
* Author URI: http://wp-pdf.com/
|
10 |
* License: GPL3
|
@@ -14,7 +14,7 @@ require_once( plugin_dir_path(__FILE__).'/core/core_pdf_embedder.php' );
|
|
14 |
|
15 |
class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
16 |
|
17 |
-
protected $PLUGIN_VERSION = '2.2.
|
18 |
|
19 |
protected function useminified() {
|
20 |
/* using-minified */ return true;
|
4 |
* Plugin Name: PDF Embedder
|
5 |
* Plugin URI: http://wp-pdf.com/
|
6 |
* Description: Embed PDFs straight into your posts and pages, with flexible width and height. No third-party services required.
|
7 |
+
* Version: 2.2.5
|
8 |
* Author: Dan Lester
|
9 |
* Author URI: http://wp-pdf.com/
|
10 |
* License: GPL3
|
14 |
|
15 |
class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
16 |
|
17 |
+
protected $PLUGIN_VERSION = '2.2.5';
|
18 |
|
19 |
protected function useminified() {
|
20 |
/* using-minified */ return true;
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: danlester
|
|
3 |
Tags: doc, docx, pdf, office, powerpoint, google, document, embed, intranet
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 4.3
|
6 |
-
Stable tag: 2.2.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -128,6 +128,11 @@ the Plugins section of your Wordpress admin
|
|
128 |
|
129 |
== Changelog ==
|
130 |
|
|
|
|
|
|
|
|
|
|
|
131 |
= 2.2.4 =
|
132 |
|
133 |
'Download PDF' button added to options, but function is only available in Premium versions.
|
3 |
Tags: doc, docx, pdf, office, powerpoint, google, document, embed, intranet
|
4 |
Requires at least: 3.3
|
5 |
Tested up to: 4.3
|
6 |
+
Stable tag: 2.2.5
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
128 |
|
129 |
== Changelog ==
|
130 |
|
131 |
+
= 2.2.5 =
|
132 |
+
|
133 |
+
Better explanation of some error messages (e.g. attempt to access PDF on a different domain).
|
134 |
+
Forced white background by default - some Theme's CSS would override.
|
135 |
+
|
136 |
= 2.2.4 =
|
137 |
|
138 |
'Download PDF' button added to options, but function is only available in Premium versions.
|