Version Description
Download this release
Release Info
Developer | levertechadmin |
Plugin | PDF Embedder |
Version | 4.0 |
Comparing to | |
See all releases |
Code changes from version 3.2 to 4.0
- js/all-pdfemb-basic.min.js +38 -53
- js/pdfemb-blocks.js +12 -10
- pdf_embedder.php +2 -2
- readme.txt +5 -5
js/all-pdfemb-basic.min.js
CHANGED
@@ -1,53 +1,38 @@
|
|
1 |
-
var
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
(this.
|
17 |
-
|
18 |
-
|
19 |
-
this.
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
0,
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
e
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
function(){
|
38 |
-
a
|
39 |
-
b).hide();c.show();a[0].scrollTop=0};e.prototype.renderPage=function(b,a){var c=this,e=c.invalidationRound,k=this.divContainer,g=k.data("pdfDoc"),p=k.find(".pdfemb-pagescontainer"),h=p.find(".pdfemb-page"+b);if(h.length&&h.data("invalidation-round")>=e)a&&c.scrollPageIntoView(b);else{var r=h.data("pending-drawing-round");r>=e||(0<r&&r<e?h.data("pending-drawing-round",e):(h.data("pending-drawing-round",e),g.getPage(b).then(function(g){c.initialResize||(c.initialResize=!0,c.setSizesBasedOnPage(g),c.resizeViewer(),
|
40 |
-
c.createPageInnerDivs(),c.addGrabToPan(),c.pdfembMakeMobile());0==h.length&&(h=p.find(".pdfemb-page"+b));var n=h.data("widthfactor"),l=h.data("heightfactor");if(!n||!l){var m=g.getViewport(1);n=m.width/c.pageWidth;l=m.height/c.pageHeight;h.data("widthfactor",n);h.data("heightfactor",l);1==n&&1==l||c.resizeInnerDivs(b)}var q=h.find(".pdfemb-the-canvas");0==q.length&&(q=d("<canvas></canvas>",{"class":"pdfemb-the-canvas"}),h.append(q));a&&c.scrollPageIntoView(b);var t=c.wantCanvasWidth,y=c.wantCanvasHeight;
|
41 |
-
m=c.canvasscale;var C=c.zoom;q.css("width",t*n);q.css("height",y*l);c.wantMobile?k.data("grabtopan").deactivate():k.data("grabtopan").activate();var z=g.getViewport(m*C/100),x=document.createElement("canvas");x.width=t*f*c.reducefactor*n;x.height=y*f*c.reducefactor*l;var A=x.getContext("2d"),D=function(){q[0].width=t*f*c.reducefactor*n;q[0].height=y*f*c.reducefactor*l;c.preRenderCanvas(A,b,C);var a=A.getImageData(0,0,x.width,x.height);q[0].getContext("2d").putImageData(a,0,0);"undefined"==typeof c.annotationLayerFactories[b]?
|
42 |
-
(a=c.annotationsLayerFactory.createAnnotationsLayerBuilder(h[0],g),c.annotationLayerFactories[b]=a):a=c.annotationLayerFactories[b];null!=a&&a.setupAnnotations(z,c.divContainer.data("newwindow"));"undefined"==typeof c.textLayerFactories[b]?(a=c.textLayerFactory.createTextLayerBuilder(h[0],g),c.textLayerFactories[b]=a):a=c.textLayerFactories[b];null!=a&&a.setupText(z);h.data("invalidation-round",e);r=h.data("pending-drawing-round");h.data("pending-drawing-round","");r>e&&c.renderPage(b,!1)};g.render({canvasContext:A,
|
43 |
-
viewport:z,transform:[f*c.reducefactor,0,0,f*c.reducefactor,0,0]}).promise.then(function(){"requestAnimationFrame"in window?window.requestAnimationFrame(D):setTimeout(D,1)})})))}};e.prototype.changeZoom=function(b){var a=this.divContainer,c=this.zoom;this.zoom=b=c+b;a.find("span.pdfemb-zoom").text(b+"%");this.fromZoom=c;this.toZoom=b;a=a.find(".pdfemb-pagescontainer");this.pccentreLeft=a.width()/2;this.pccentreTop=a.height()/2;this.resizeViewer();this.resizeInnerDivs();this.invalidateAllPages();this.renderPage(this.currentPageNum);
|
44 |
-
this.prerenderNearbyPages(this.currentPageNum)};e.prototype.queueRenderPage=function(b,a){this.renderPage(b,a)};e.prototype.addToolbar=function(b,a,c){var e=this.divContainer,f=this,g=d("<div></div>",{"class":"pdfemb-toolbar pdfemb-toolbar"+(a?"-fixed":"-hover")+" "+(b?" pdfemb-toolbar-top":"pdfemb-toolbar-bottom")}),k=d('<button class="pdfemb-prev" title="'+pdfemb_trans.objectL10n.prev+'" type="button"></button>');g.append(k);var h=d('<button class="pdfemb-next" title="'+pdfemb_trans.objectL10n.next+
|
45 |
-
'" type="button"></button>');g.append(h);g.append(d('<div class="pdfemb-page-area">'+pdfemb_trans.objectL10n.page+' <span class="pdfemb-page-num">0</span> / <span class="pdfemb-page-count"></span></div>'));var r=d('<button class="pdfemb-zoomout" title="'+pdfemb_trans.objectL10n.zoomout+'" type="button"></button>');g.append(r);var t=d('<button class="pdfemb-zoomin" title="'+pdfemb_trans.objectL10n.zoomin+'" type="button"></button>');g.append(t);g.append(d("<div>"+pdfemb_trans.objectL10n.zoom+' <span class="pdfemb-zoom">100%</span></div>'));
|
46 |
-
c&&g.append(d("<div>"+pdfemb_trans.objectL10n.secure+"</div>"));b?e.prepend(g):e.append(g);k.on("click",function(a){1>=f.currentPageNum||(f.gotoPage(f.currentPageNum-1),f.jumpToTop())});h.on("click",function(a){f.currentPageNum>=f.pageCount||0==f.currentPageNum||(f.gotoPage(f.currentPageNum+1),f.jumpToTop())});t.on("click",function(a){500<=f.zoom||f.changeZoom(10)});r.on("click",function(a){20>=f.zoom||f.changeZoom(-10)});f.addMoreToolbar(g);a||(e.on("mouseenter",function(a){a=e.find("div.pdfemb-toolbar-hover");
|
47 |
-
!0!==a.data("no-hover")&&a.show()}),e.on("mouseleave",function(a){e.find("div.pdfemb-toolbar-hover").hide()}),e.on("pdfembTouchTapped",function(a){a.stopPropagation();a.preventDefault();if(!f.locktaps){f.locktaps=!0;a=e.find("div.pdfemb-toolbar-hover");var b=a.is(":visible");1==a.data("no-hover")&&(b=!0);b?a.hide():a.show();setTimeout(function(){f.locktaps=!1},250)}}));pdfemb_trans.poweredby&&g.append(d("<div></div>",{"class":"pdfemb-poweredby"}).append(d('<a href="https://wp-pdf.com/?utm_source=Poweredby&utm_medium=freemium&utm_campaign=Freemium" target="_blank">wp-pdf.com</a>')))};
|
48 |
-
e.prototype.magnifyEvent=function(b){var a=b.originalEvent.magnification;if(-1==a)this.resizeViewer(),this.resizeInnerDivs(),this.invalidateAllPages(),this.renderPage(this.getTopVisiblePageNum());else{var c=this.divContainer.find(".pdfemb-pagescontainer").offset();this.magnifyZoom(a,b.originalEvent.centreLeft-c.left,b.originalEvent.centreTop-c.top)}};e.prototype.magnifyZoom=function(b,a,c){var d=this.zoom;b=Math.floor(d*b);20>b&&(b=20);500<b&&(b=500);this.zoom=b;this.divContainer.find("span.pdfemb-zoom").text(b+
|
49 |
-
"%");this.fromZoom=d;this.toZoom=b;this.pccentreLeft=a;this.pccentreTop=c;this.resizeViewer();this.resizeInnerDivs();this.invalidateAllPages()};e.prototype.pdfembWantMobile=function(b,a){return!1};e.prototype.pdfembMakeMobile=function(){};e.prototype.addMoreToolbar=function(b){};e.prototype.jumpToTop=function(){};e.prototype.preRenderCanvas=function(b,a,c){};PDFEMB_NS.pdfembPagesViewer=e});
|
50 |
-
jQuery(document).ready(function(d){var f=PDFEMB_NS.pdfembPagesViewer;d=function(){f.apply(this,arguments)};d.prototype=new f;PDFEMB_NS.pdfembPagesViewerUsable=d});PDFEMB_NS.pdfembGetPDF=function(d,f){f(d,!1)};
|
51 |
-
jQuery(document).ready(function(d){d.fn.pdfEmbedder=function(){this.each(function(f,g){f=d(g);if(f.is("a")){g=f.data();var k=d("<div></div>",{"class":f.attr("class"),style:f.attr("style")});k.data(d.extend({"pdf-url":f.attr("href")},g));f.replaceWith(k)}else k=f;k.append(d("<div></div>",{"class":"pdfemb-loadingmsg"}).append(document.createTextNode(pdfemb_trans.objectL10n.loading)));"on"==k.data("disablerightclick")&&k.bind("contextmenu",function(b){b.preventDefault()});var e=function(b,a){(new PDFEMB_NS.pdfembPagesViewerUsable(b,
|
52 |
-
k,a)).setup()};f=function(b,a){null===b?k.empty().append(d("<div></div>",{"class":"pdfemb-errormsg"}).append(msgnode=d("<span></span>").append(document.createTextNode("Failed to load and decrypt PDF")))):PDFJS.getDocument(b).then(function(b){e(b,a)},function(a){var b=document.createTextNode(a.message);"UnknownErrorException"==a.name&&"Failed to fetch"==a.message&&(b=d("<span></span>").append(document.createTextNode(a.message+" "+pdfemb_trans.objectL10n.domainerror+" ")).append(d('<a href="https://wp-pdf.com/kb/error-url-to-the-pdf-file-must-be-on-exactly-the-same-domain-as-the-current-web-page/" target="_blank">'+
|
53 |
-
pdfemb_trans.objectL10n.clickhereinfo+"</a>")));k.empty().append(d("<div></div>",{"class":"pdfemb-errormsg"}).append(b))})};k.data("pdfDoc")?e(k.data("pdfDoc"),k.data("showIsSecure")):(g=k.data("pdf-url"),PDFEMB_NS.pdfembGetPDF(g,f))});return this};PDFJS.workerSrc=pdfemb_trans.worker_src;PDFJS.cMapUrl=pdfemb_trans.cmap_url;PDFJS.cMapPacked=!0;d(".pdfemb-viewer").pdfEmbedder()});
|
1 |
+
var pdfembGrabToPan=function(){function g(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);
|
2 |
+
(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}g.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("mousewheel",this._onmousewheel),this.element.addEventListener("wheel",this._onmousewheel),this.element.addEventListener("DOMMouseScroll",this._onmousewheel),this.element.classList.add(this.CSS_CLASS_GRAB),this.onActiveChanged))this.onActiveChanged(!0)},
|
3 |
+
deactivate:function(){if(this.active&&(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(a){return a[k]("a[href], a[href] *, input, textarea, button, button *, select, option")},_onmousedown:function(a){if(0===a.button&&!this.ignoreTarget(a.target)){this.scrollLeftStart=
|
4 |
+
this.element.scrollLeft;this.scrollTopStart=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(c){this.element.removeEventListener("scroll",
|
5 |
+
this._endPan,!0);var b;b="buttons"in c&&p?!(c.buttons|1):d||a?0===c.which:void 0;b?this._endPan():(b=c.clientX-this.clientXStart,this.element.scrollTop=this.scrollTopStart-(c.clientY-this.clientYStart),this.element.scrollLeft=this.scrollLeftStart-b,this.overlay.parentNode||document.body.appendChild(this.overlay))},_onmousewheel:function(a){this.element.removeEventListener("scroll",this._endPan,!0);var b=.5;a.deltaMode&&(1==a.deltaMode&&(b=10),2==a.deltaMode&&(b=1E3));var f=a.deltaY?-a.deltaY:a.wheelDelta?
|
6 |
+
a.wheelDelta:-a.detail;this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=this.element.scrollTop;b*=f;this.element.scrollTop=this.scrollTopStart-b;this.overlay.parentNode||document.body.appendChild(this.overlay);if(this.element.scrollTop!=this.scrollTopStart||0==b)return a.preventDefault(),!1},_endPan:function(){this.element.removeEventListener("scroll",this._endPan,!0);this.document.removeEventListener("mousemove",this._onmousemove,!0);this.document.removeEventListener("mouseup",this._endPan,
|
7 |
+
!0);this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}};var k;["webkitM","mozM","msM","oM","m"].some(function(a){a+="atches";a in document.documentElement&&(k=a);a+="Selector";a in document.documentElement&&(k=a);return k});var p=!document.documentMode||9<document.documentMode,l=window.chrome,d=l&&(l.webstore||l.app),a=/Apple/.test(navigator.vendor)&&/Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);return g}(),PDFEMB_NS={};
|
8 |
+
jQuery(document).ready(function(g){var k=function(){var a=document.createElement("canvas").getContext("2d");return(window.devicePixelRatio||1)/(a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1)}();PDFEMB_NS.PIXEL_RATIO=k;createHiDPICanvas=function(a,c,b){b||(b=k);var f=document.createElement("canvas");f.width=a*b;f.height=c*b;f.style.width=a+"px";f.style.height=c+"px";f.getContext("2d").setTransform(b,0,
|
9 |
+
0,b,0,0);return f};var p=0,l=0;(function(){var a=document.createElement("div");a.style.width="100px";a.style.height="100px";a.style.overflow="scroll";a.style.position="absolute";a.style.top="-9999px";document.body.appendChild(a);p=a.offsetWidth-a.clientWidth;l=a.offsetHeight-a.clientHeight;document.body.removeChild(a)})();PDFEMB_NS.vscrollbarwidth=p;PDFEMB_NS.hscrollbarheight=l;var d=function(a,c,b){this.pdfDoc=a;this.divContainer=c;this.showIsSecure=b;this.initialResize=!1;this.firstPageHeight=this.firstPageWidth=
|
10 |
+
0;this.invalidationRound=1;this.currentPageNum=0;this.zoom=100;this.toZoom=this.fromZoom=0};d.prototype.setup=function(){var a=this,c=this.divContainer,b=this.pdfDoc,f=this.showIsSecure;this.numPages=b.numPages;var e=c.data("scrollbar");this.vscrollbar="both"==e||"vertical"==e;this.hscrollbar="both"==e||"horizontal"==e;e="overflow-y: "+(this.vscrollbar?"scroll":"hidden")+"; ";e+="overflow-x: "+(this.hscrollbar?"scroll":"hidden")+"; ";c.empty().append(g("<div></div>",{"class":"pdfemb-pagescontainer",
|
11 |
+
style:e}));c.data("pdfDoc",b);e=c.data("toolbar");"top"!=e&&"both"!=e||this.addToolbar(!0,"on"==c.data("toolbar-fixed"),f);"bottom"!=e&&"both"!=e||this.addToolbar(!1,"on"==c.data("toolbar-fixed"),f);a.annotationsLayerFactory="undefined"!=typeof PDFEMB_NS.pdfembPremiumAnnotationsLayerFactory?new PDFEMB_NS.pdfembPremiumAnnotationsLayerFactory:{createAnnotationsLayerBuilder:function(a,b){return null}};a.annotationLayerFactories=[];c.on("pdfembGotopage",function(b,c){c>this.numPages||0>=c||(a.gotoPage(c),
|
12 |
+
a.jumpToTop())});c.on("pdfembGotoHash",function(b,c){if(c.dest){dest=c.dest;var f;"string"===typeof dest?(destString=dest,f=a.pdfDoc.getDestination(dest)):f=Promise.resolve(dest);f.then(function(b){b instanceof Array&&!(1>b.length)&&a.pdfDoc.getPageIndex(b[0]).then(function(b){b+=1;b>a.numPages||0>=b||a.currentPageNum==b||(a.gotoPage(b),a.jumpToTop())})})}});c.on("pdfembGotoAction",function(b,c){var f=a.currentPageNum,e=f;switch(c){case "GoBack":--e;break;case "GoForward":++e;break;case "NextPage":++e;
|
13 |
+
break;case "PrevPage":--e;break;case "LastPage":e=a.pageCount;break;case "FirstPage":e=1}e==f||e>a.pageCount||0>=e||a.gotoPage(e)});c.on("pdfembMagnify",function(b){a.magnifyEvent(b)});c.on("pdfembChangeZoom",function(b,c){a.changeZoom(c)});this.pageCount=b.numPages;(!c.data("pagenum")||1>c.data("pagenum")||c.data("pagenum")>this.pageCount)&&c.data("pagenum",1);c.data("showIsSecure",this.showIsSecure);c.data("pageNumPending",null);b="on"==c.data("fullScreen")?parseInt(c.data("startfpzoom")):parseInt(c.data("startzoom"));
|
14 |
+
if(isNaN(b)||20>b||500<b)b=100;this.zoom=b;100!=b&&c.find("span.pdfemb-zoom").text(b+"%");c.find("span.pdfemb-page-count").text(this.pageCount);this.gotoPage(c.data("pagenum"))};d.prototype.checkForResize=function(){var a=this,c=a.divContainer,b=g(window).height(),f=g(window).width(),e=c.data("checked-window-height"),t=c.data("checked-window-width");e&&t||(c.data("checked-window-height",b),c.data("checked-window-width",f));if(e!=b||t!=f)a.resizeViewer(),a.resizeInnerDivs(),a.invalidateAllPages(),
|
15 |
+
a.renderPage(this.currentPageNum),a.prerenderNearbyPages(this.currentPageNum),a.pdfembMakeMobile(),c.data("checked-window-height",b),c.data("checked-window-width",f);"true"!=c.data("fullScreenClosed")&&setTimeout(function(){a.checkForResize()},100)};d.prototype.setSizesBasedOnPage=function(a){a=a.getViewport(1);this.pageWidth=a.width;this.pageHeight=a.height;(0>=this.pageWidth||0>=this.pageHeight)&&this.divContainer.empty().append(document.createTextNode(pdfemb_trans.objectL10n.widthheightinvalid))};
|
16 |
+
d.prototype.createPageInnerDivs=function(){for(var a=this.divContainer.find(".pdfemb-pagescontainer"),c=1;c<=this.pageCount;++c){var b=a.find(".pdfemb-inner-div.pdfemb-page"+c);0==b.length&&(b=g("<div></div>",{"class":"pdfemb-inner-div pdfemb-page"+c}),b.data("pageNum",c),a.append(b))}this.resizeInnerDivs()};d.prototype.addGrabToPan=function(){var a=this,c=a.divContainer,b=c.find("div.pdfemb-pagescontainer"),f=new pdfembGrabToPan({element:b[0]});c.data("grabtopan",f);b.on("scroll",function(b){var c=
|
17 |
+
a.getTopVisiblePageNum();c!=a.currentPageNum&&(a.currentPageNum=c,a.updatePageNumDisplay(c),a.renderPage(c,!1),a.prerenderNearbyPages(c),a.deallocateFarAwayPages(c));b.stopPropagation()});g(window).resize(function(){setTimeout(function(){a.checkForResize()},100)})};d.prototype.resizeInnerDivs=function(a){var c=this,b=c.wantCanvasWidth,f=c.wantCanvasHeight,e=c.wantHeight,d=this.divContainer.find(".pdfemb-pagescontainer").find(".pdfemb-inner-div");a&&(d=d.filter(".pdfemb-page"+a));var w=0;d.each(function(e,
|
18 |
+
h){var n=g(h),m=n.data("widthfactor"),k=n.data("heightfactor");m||(m=1);k||(k=1);n.data("invalidation-round",this.invalidationRound-1);n.css("width",b*m);var l=f*k+(a==c.numPages||!a&&e==d.length-1?0:2);n.css("height",l);w+=l;n=n.find(".pdfemb-the-canvas");n.css("width",b*m);n.css("height",f*k)});var h=0;!a&&w<e&&(h=(e-w)/2);d.first().css("top",h)};d.prototype.invalidateAllPages=function(){++this.invalidationRound};d.prototype.prerenderNearbyPages=function(a){var c=3,b=2;100>this.zoom&&(c*=Math.min(Math.ceil(100/
|
19 |
+
this.zoom),10),b*=Math.min(Math.ceil(100/this.zoom),10));for(b=Math.max(1,a-b);b<=Math.min(a+c,this.numPages);++b)b!=a&&this.renderPage(b,!1)};d.prototype.deallocateFarAwayPages=function(a){var c=50,b=50;if(100>this.zoom)var f=Math.min(Math.ceil(100/this.zoom),50),c=c+f,b=b+f;var f=function(a){a=e.find(".pdfemb-page"+a);var b=a.find(".pdfemb-the-canvas");b.length&&(b.remove(),a.data("invalidation-round",0))},e=this.divContainer.find("div.pdfemb-pagescontainer"),d;for(d=3;d<a-b;++d)f(d);for(d=a+c;d<
|
20 |
+
this.numPages;++d)f(d)};d.prototype.resizeViewer=function(){var a=this.pageWidth,c=this.pageHeight,b=this.divContainer,f=b.find("div.pdfemb-pagescontainer"),e=f[0].scrollLeft,d=f[0].scrollTop,g=b.parent().width(),h=a;if("max"==b.data("width"))h=g;else if("auto"==b.data("width"))h=a;else if(h=parseInt(b.data("width"),10),isNaN(h)||0>=h)h=g;0>=h&&(h=a);h>g&&0<g&&(h=g);var c=c*h/a,r=this.pdfembWantMobile(h,m);this.wantMobile=r;var x=b.find("div.pdfemb-toolbar-fixed"),n=r?0:x.length,m=parseInt(b.data("height"),
|
21 |
+
10);if(isNaN(m)||0>=m||m>c)m="auto"==b.data("height")?b.parent().height()-n*x.height():c;this.userHeight=m;var h=Math.floor(h),c=Math.floor(c),g=100,u=h-(this.vscrollbar?p:0),q=c-(this.hscrollbar?l:0),A=1;r||(g=this.zoom,u=u*g/100,q=q*g/100,16777E3<u*q*k*k&&(A=16777E3/(u*q*k*k)));h!=b.width()&&b.width(h);b.height()!=m&&b.height(m+n*x.height());f.width(h);f.height(m);b=x.filter(".pdfemb-toolbar-top");0<n&&f.css("top",b.height());a=(h-(this.vscrollbar?p:0))/a;0!=this.fromZoom&&0!=this.toZoom&&(f[0].scrollLeft=
|
22 |
+
this.toZoom/this.fromZoom*(e+this.pccentreLeft)-this.pccentreLeft,f[0].scrollTop=this.toZoom/this.fromZoom*(d+this.pccentreTop)-this.pccentreTop);this.toZoom=this.fromZoom=0;this.wantCanvasWidth=u;this.wantCanvasHeight=q;this.reducefactor=A;this.wantWidth=h;this.wantHeight=c;this.canvasscale=a;this.zoom=g};d.prototype.getTopVisiblePageNum=function(){var a=this.divContainer.find(".pdfemb-pagescontainer").find(".pdfemb-inner-div:visible");return 0<a.length?a.first().data("pageNum"):1};d.prototype.gotoPage=
|
23 |
+
function(a){0>=a||a>this.pageCount||(this.renderPage(a,!0),this.currentPageNum=a,this.updatePageNumDisplay(a),this.prerenderNearbyPages(a),this.deallocateFarAwayPages(a))};d.prototype.updatePageNumDisplay=function(a){var c=this.divContainer;c.find("div.pdfemb-toolbar .pdfemb-page-num").each(function(b,c){var e=g(c);e.is("span")?e.text(a):e.val(a)});a<this.pageCount?c.find(".pdfemb-next").removeAttr("disabled").removeClass("pdfemb-btndisabled"):c.find(".pdfemb-next").attr("disabled","disabled").addClass("pdfemb-btndisabled");
|
24 |
+
1<a?c.find(".pdfemb-prev").removeAttr("disabled").removeClass("pdfemb-btndisabled"):c.find(".pdfemb-prev").attr("disabled","disabled").addClass("pdfemb-btndisabled")};d.prototype.scrollPageIntoView=function(a){var c=this.divContainer.find(".pdfemb-pagescontainer"),b=c.find(".pdfemb-page"+a);c.find(".pdfemb-inner-div").not(".pdfemb-page"+a).hide();b.show();c[0].scrollTop=0};d.prototype.renderPage=function(a,c){var b=this,f=b.invalidationRound,e=this.divContainer,d=e.data("pdfDoc"),l=e.find(".pdfemb-pagescontainer"),
|
25 |
+
h=l.find(".pdfemb-page"+a);if(h.length&&h.data("invalidation-round")>=f)c&&b.scrollPageIntoView(a);else{var r=h.data("pending-drawing-round");r>=f||(0<r&&r<f?h.data("pending-drawing-round",f):(h.data("pending-drawing-round",f),d.getPage(a).then(function(d){b.initialResize||(b.initialResize=!0,b.setSizesBasedOnPage(d),b.resizeViewer(),b.createPageInnerDivs(),b.addGrabToPan(),b.pdfembMakeMobile());0==h.length&&(h=l.find(".pdfemb-page"+a));var n=h.data("widthfactor"),m=h.data("heightfactor");if(!n||
|
26 |
+
!m){var t=d.getViewport(1),n=t.width/b.pageWidth,m=t.height/b.pageHeight;h.data("widthfactor",n);h.data("heightfactor",m);1==n&&1==m||b.resizeInnerDivs(a)}var q=h.find(".pdfemb-the-canvas");0==q.length&&(q=g("<canvas></canvas>",{"class":"pdfemb-the-canvas"}),h.append(q));c&&b.scrollPageIntoView(a);var p=b.wantCanvasWidth,y=b.wantCanvasHeight,t=b.canvasscale,B=b.zoom;q.css("width",p*n);q.css("height",y*m);b.wantMobile?e.data("grabtopan").deactivate():e.data("grabtopan").activate();var C=d.getViewport(t*
|
27 |
+
B/100),v=document.createElement("canvas");v.width=p*k*b.reducefactor*n;v.height=y*k*b.reducefactor*m;var z=v.getContext("2d"),D=function(){q[0].width=p*k*b.reducefactor*n;q[0].height=y*k*b.reducefactor*m;b.preRenderCanvas(z,a,B);var c=z.getImageData(0,0,v.width,v.height);q[0].getContext("2d").putImageData(c,0,0);c=null;"undefined"==typeof b.annotationLayerFactories[a]?(c=b.annotationsLayerFactory.createAnnotationsLayerBuilder(h[0],d),b.annotationLayerFactories[a]=c):c=b.annotationLayerFactories[a];
|
28 |
+
null!=c&&c.setupAnnotations(C,b.divContainer.data("newwindow"));h.data("invalidation-round",f);r=h.data("pending-drawing-round");h.data("pending-drawing-round","");r>f&&b.renderPage(a,!1)};d.render({canvasContext:z,viewport:C,transform:[k*b.reducefactor,0,0,k*b.reducefactor,0,0]}).promise.then(function(){"requestAnimationFrame"in window?window.requestAnimationFrame(D):setTimeout(D,1)})})))}};d.prototype.changeZoom=function(a){var c=this.divContainer,b=this.zoom;this.zoom=a=b+a;c.find("span.pdfemb-zoom").text(a+
|
29 |
+
"%");this.fromZoom=b;this.toZoom=a;c=c.find(".pdfemb-pagescontainer");this.pccentreLeft=c.width()/2;this.pccentreTop=c.height()/2;this.resizeViewer();this.resizeInnerDivs();this.invalidateAllPages();this.renderPage(this.currentPageNum);this.prerenderNearbyPages(this.currentPageNum)};d.prototype.queueRenderPage=function(a,c){this.renderPage(a,c)};d.prototype.addToolbar=function(a,c,b){var f=this.divContainer,e=this,d=g("<div></div>",{"class":"pdfemb-toolbar pdfemb-toolbar"+(c?"-fixed":"-hover")+" "+
|
30 |
+
(a?" pdfemb-toolbar-top":"pdfemb-toolbar-bottom")}),k=g('<button class="pdfemb-prev" title="'+pdfemb_trans.objectL10n.prev+'" type="button"></button>');d.append(k);var h=g('<button class="pdfemb-next" title="'+pdfemb_trans.objectL10n.next+'" type="button"></button>');d.append(h);d.append(g('<div class="pdfemb-page-area">'+pdfemb_trans.objectL10n.page+' <span class="pdfemb-page-num">0</span> / <span class="pdfemb-page-count"></span></div>'));var l=g('<button class="pdfemb-zoomout" title="'+pdfemb_trans.objectL10n.zoomout+
|
31 |
+
'" type="button"></button>');d.append(l);var p=g('<button class="pdfemb-zoomin" title="'+pdfemb_trans.objectL10n.zoomin+'" type="button"></button>');d.append(p);d.append(g("<div>"+pdfemb_trans.objectL10n.zoom+' <span class="pdfemb-zoom">100%</span></div>'));b&&d.append(g("<div>"+pdfemb_trans.objectL10n.secure+"</div>"));a?f.prepend(d):f.append(d);k.on("click",function(a){1>=e.currentPageNum||(e.gotoPage(e.currentPageNum-1),e.jumpToTop())});h.on("click",function(a){e.currentPageNum>=e.pageCount||0==
|
32 |
+
e.currentPageNum||(e.gotoPage(e.currentPageNum+1),e.jumpToTop())});p.on("click",function(a){500<=e.zoom||e.changeZoom(10)});l.on("click",function(a){20>=e.zoom||e.changeZoom(-10)});e.addMoreToolbar(d);c||(f.on("mouseenter",function(a){a=f.find("div.pdfemb-toolbar-hover");!0!==a.data("no-hover")&&a.show()}),f.on("mouseleave",function(a){f.find("div.pdfemb-toolbar-hover").hide()}),f.on("pdfembTouchTapped",function(a){a.stopPropagation();a.preventDefault();if(!e.locktaps){e.locktaps=!0;a=f.find("div.pdfemb-toolbar-hover");
|
33 |
+
var b=a.is(":visible");1==a.data("no-hover")&&(b=!0);b?a.hide():a.show();setTimeout(function(){e.locktaps=!1},250)}}));pdfemb_trans.poweredby&&d.append(g("<div></div>",{"class":"pdfemb-poweredby"}).append(g('<a href="https://wp-pdf.com/?utm_source=Poweredby&utm_medium=freemium&utm_campaign=Freemium" target="_blank">wp-pdf.com</a>')))};d.prototype.magnifyEvent=function(a){var c=a.originalEvent.magnification;if(-1==c)this.resizeViewer(),this.resizeInnerDivs(),this.invalidateAllPages(),this.renderPage(this.getTopVisiblePageNum());
|
34 |
+
else{var b=this.divContainer.find(".pdfemb-pagescontainer").offset();this.magnifyZoom(c,a.originalEvent.centreLeft-b.left,a.originalEvent.centreTop-b.top)}};d.prototype.magnifyZoom=function(a,c,b){var d=this.zoom;a=Math.floor(d*a);20>a&&(a=20);500<a&&(a=500);this.zoom=a;this.divContainer.find("span.pdfemb-zoom").text(a+"%");this.fromZoom=d;this.toZoom=a;this.pccentreLeft=c;this.pccentreTop=b;this.resizeViewer();this.resizeInnerDivs();this.invalidateAllPages()};d.prototype.pdfembWantMobile=function(a,
|
35 |
+
c){return!1};d.prototype.pdfembMakeMobile=function(){};d.prototype.addMoreToolbar=function(a){};d.prototype.jumpToTop=function(){};d.prototype.preRenderCanvas=function(a,c,b){};PDFEMB_NS.pdfembPagesViewer=d});jQuery(document).ready(function(g){var k=PDFEMB_NS.pdfembPagesViewer;g=function(){k.apply(this,arguments)};g.prototype=new k;PDFEMB_NS.pdfembPagesViewerUsable=g});PDFEMB_NS.pdfembGetPDF=function(g,k){k(g,!1)};
|
36 |
+
jQuery(document).ready(function(g){g.fn.pdfEmbedder=function(){this.each(function(k,p){var l,d=g(p);if(d.is("a")){var a=d.data();l=g("<div></div>",{"class":d.attr("class"),style:d.attr("style")});l.data(g.extend({"pdf-url":d.attr("href")},a));d.replaceWith(l)}else l=d;l.append(g("<div></div>",{"class":"pdfemb-loadingmsg"}).append(document.createTextNode(pdfemb_trans.objectL10n.loading)));"on"==l.data("disablerightclick")&&l.bind("contextmenu",function(a){a.preventDefault()});var c=function(a,c){(new PDFEMB_NS.pdfembPagesViewerUsable(a,
|
37 |
+
l,c)).setup()},d=function(a,d){null===a?l.empty().append(g("<div></div>",{"class":"pdfemb-errormsg"}).append(msgnode=g("<span></span>").append(document.createTextNode("Failed to load and decrypt PDF")))):PDFJS.getDocument(a).then(function(a){c(a,d)},function(a){var b=document.createTextNode(a.message);"UnknownErrorException"==a.name&&"undefined"===typeof a.status&&(b=g("<span></span>").append(document.createTextNode(a.message+" "+pdfemb_trans.objectL10n.domainerror+" ")).append(g('<a href="https://wp-pdf.com/kb/error-url-to-the-pdf-file-must-be-on-exactly-the-same-domain-as-the-current-web-page/" target="_blank">'+
|
38 |
+
pdfemb_trans.objectL10n.clickhereinfo+"</a>")));l.empty().append(g("<div></div>",{"class":"pdfemb-errormsg"}).append(b))})};l.data("pdfDoc")?c(l.data("pdfDoc"),l.data("showIsSecure")):(a=l.data("pdf-url"),PDFEMB_NS.pdfembGetPDF(a,d))});return this};PDFJS.workerSrc=pdfemb_trans.worker_src;PDFJS.cMapUrl=pdfemb_trans.cmap_url;PDFJS.cMapPacked=!0;g(".pdfemb-viewer").pdfEmbedder()});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js/pdfemb-blocks.js
CHANGED
@@ -4,15 +4,7 @@
|
|
4 |
var __ = wp.i18n.__; // The __() function for internationalization.
|
5 |
var createElement = wp.element.createElement; // The wp.element.createElement() function to create elements.
|
6 |
var registerBlockType = wp.blocks.registerBlockType; // The registerBlockType() function to register blocks.
|
7 |
-
|
8 |
-
var Button = wp.components.Button;
|
9 |
-
var RichText = wp.editor.RichText;
|
10 |
-
var Editable = wp.blocks.Editable; // Editable component of React.
|
11 |
-
var MediaUpload = wp.editor.MediaUpload;
|
12 |
-
var btn = wp.components.Button;
|
13 |
-
var TextControl = wp.components.TextControl;
|
14 |
-
var SelectControl = wp.components.SelectControl;
|
15 |
-
var RadioControl = wp.components.RadioControl;
|
16 |
|
17 |
var make_title_from_url = function(url) {
|
18 |
var re = RegExp('/([^/]+?)(\\.pdf(\\?[^/]*)?)?$', 'i');
|
@@ -63,7 +55,17 @@
|
|
63 |
edit: function( props ) {
|
64 |
|
65 |
var {attributes , setAttributes, focus, className} = props;
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
var onSelectPDF = function(media) {
|
68 |
return props.setAttributes({
|
69 |
url: media.url,
|
4 |
var __ = wp.i18n.__; // The __() function for internationalization.
|
5 |
var createElement = wp.element.createElement; // The wp.element.createElement() function to create elements.
|
6 |
var registerBlockType = wp.blocks.registerBlockType; // The registerBlockType() function to register blocks.
|
7 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
var make_title_from_url = function(url) {
|
10 |
var re = RegExp('/([^/]+?)(\\.pdf(\\?[^/]*)?)?$', 'i');
|
55 |
edit: function( props ) {
|
56 |
|
57 |
var {attributes , setAttributes, focus, className} = props;
|
58 |
+
|
59 |
+
var InspectorControls = wp.editor.InspectorControls;
|
60 |
+
var Button = wp.components.Button;
|
61 |
+
var RichText = wp.editor.RichText;
|
62 |
+
var Editable = wp.blocks.Editable; // Editable component of React.
|
63 |
+
var MediaUpload = wp.editor.MediaUpload;
|
64 |
+
var btn = wp.components.Button;
|
65 |
+
var TextControl = wp.components.TextControl;
|
66 |
+
var SelectControl = wp.components.SelectControl;
|
67 |
+
var RadioControl = wp.components.RadioControl;
|
68 |
+
|
69 |
var onSelectPDF = function(media) {
|
70 |
return props.setAttributes({
|
71 |
url: media.url,
|
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. Compatible with Gutenberg Editor WordPress
|
7 |
-
* Version:
|
8 |
* Author: Dan Lester
|
9 |
* Author URI: http://wp-pdf.com/
|
10 |
* License: GPL3
|
@@ -15,7 +15,7 @@ require_once( plugin_dir_path(__FILE__).'/core/core_pdf_embedder.php' );
|
|
15 |
|
16 |
class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
17 |
|
18 |
-
protected $PLUGIN_VERSION = '
|
19 |
|
20 |
// Singleton
|
21 |
private static $instance = null;
|
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. Compatible with Gutenberg Editor WordPress
|
7 |
+
* Version: 4.0
|
8 |
* Author: Dan Lester
|
9 |
* Author URI: http://wp-pdf.com/
|
10 |
* License: GPL3
|
15 |
|
16 |
class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
17 |
|
18 |
+
protected $PLUGIN_VERSION = '4.0';
|
19 |
|
20 |
// Singleton
|
21 |
private static $instance = null;
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== PDF Embedder ===
|
2 |
Contributors: levertechadmin, danlester
|
3 |
Tags: doc, pdf, pdf viewer, office, google, document, embed, intranet
|
4 |
-
Requires at least:
|
5 |
-
Tested up to:
|
6 |
-
Stable tag:
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -203,9 +203,9 @@ the Plugins section of your Wordpress admin
|
|
203 |
|
204 |
== Changelog ==
|
205 |
|
206 |
-
=
|
207 |
|
208 |
-
Added compatibility
|
209 |
|
210 |
= 3.1.8 =
|
211 |
|
1 |
=== PDF Embedder ===
|
2 |
Contributors: levertechadmin, danlester
|
3 |
Tags: doc, pdf, pdf viewer, office, google, document, embed, intranet
|
4 |
+
Requires at least: 4.0
|
5 |
+
Tested up to: 5.0
|
6 |
+
Stable tag: 4.0
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
203 |
|
204 |
== Changelog ==
|
205 |
|
206 |
+
= 5.0 =
|
207 |
|
208 |
+
Added compatibility for WordPress 5.0
|
209 |
|
210 |
= 3.1.8 =
|
211 |
|