Version Description
Redesigned toolbar buttons
Download this release
Release Info
Developer | danlester |
Plugin | PDF Embedder |
Version | 2.2.2 |
Comparing to | |
See all releases |
Code changes from version 2.2 to 2.2.2
- css/pdfemb-embed-pdf.css +96 -28
- img/toolbarButton-pageDown.png +0 -0
- img/toolbarButton-pageUp.png +0 -0
- img/toolbarButton-presentationMode.png +0 -0
- img/toolbarButton-zoomIn.png +0 -0
- img/toolbarButton-zoomOut.png +0 -0
- js/all-pdfemb-basic.min.js +18 -16
- js/pdfemb-embed-pdf.js +105 -29
- pdf_embedder.php +4 -4
- readme.txt +7 -1
css/pdfemb-embed-pdf.css
CHANGED
@@ -108,53 +108,118 @@ div.pdfemb-toolbar {
|
|
108 |
margin: 0px;
|
109 |
border: none;
|
110 |
z-index: 10;
|
111 |
-
|
|
|
112 |
background-color: grey;
|
113 |
width: 100%;
|
114 |
}
|
115 |
|
116 |
div.pdfemb-toolbar-fixed {
|
117 |
display: block;
|
118 |
-
position: absolute;
|
119 |
}
|
120 |
|
121 |
div.pdfemb-toolbar-hover {
|
122 |
display: none;
|
123 |
-
position: absolute;
|
124 |
}
|
125 |
|
126 |
div.pdfemb-toolbar-top {
|
127 |
-
|
128 |
top: 0px;
|
129 |
left: 0px;
|
130 |
}
|
131 |
|
132 |
div.pdfemb-toolbar-bottom {
|
133 |
-
|
134 |
bottom: 0px;
|
135 |
left: 0px;
|
|
|
136 |
}
|
137 |
|
138 |
div.pdfemb-toolbar button {
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
|
160 |
div.pdfemb-toolbar button.pdfemb-btndisabled {
|
@@ -162,20 +227,23 @@ div.pdfemb-toolbar button.pdfemb-btndisabled {
|
|
162 |
}
|
163 |
|
164 |
div.pdfemb-toolbar div {
|
165 |
-
margin: 6px
|
166 |
font-family: sans-serif;
|
167 |
-
font-size:
|
168 |
-
padding:
|
169 |
text-align: center;
|
170 |
letter-spacing: normal;
|
171 |
word-spacing: normal;
|
172 |
-
|
|
|
173 |
text-transform: none;
|
174 |
text-indent: 0px;
|
175 |
text-shadow: none;
|
176 |
font-weight: normal;
|
177 |
display: inline;
|
178 |
color: lightgray;
|
|
|
|
|
179 |
}
|
180 |
|
181 |
div.pdfemb-errormsg {
|
108 |
margin: 0px;
|
109 |
border: none;
|
110 |
z-index: 10;
|
111 |
+
position: absolute;
|
112 |
+
|
113 |
background-color: grey;
|
114 |
width: 100%;
|
115 |
}
|
116 |
|
117 |
div.pdfemb-toolbar-fixed {
|
118 |
display: block;
|
|
|
119 |
}
|
120 |
|
121 |
div.pdfemb-toolbar-hover {
|
122 |
display: none;
|
|
|
123 |
}
|
124 |
|
125 |
div.pdfemb-toolbar-top {
|
|
|
126 |
top: 0px;
|
127 |
left: 0px;
|
128 |
}
|
129 |
|
130 |
div.pdfemb-toolbar-bottom {
|
|
|
131 |
bottom: 0px;
|
132 |
left: 0px;
|
133 |
+
padding-top: 1px;
|
134 |
}
|
135 |
|
136 |
div.pdfemb-toolbar button {
|
137 |
+
background-color: hsla(0,0%,0%,.12);
|
138 |
+
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
139 |
+
background-clip: padding-box;
|
140 |
+
border: 1px solid hsla(0,0%,0%,.35);
|
141 |
+
border-color: hsla(0,0%,0%,.32) hsla(0,0%,0%,.38) hsla(0,0%,0%,.42);
|
142 |
+
box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset,
|
143 |
+
0 0 1px hsla(0,0%,100%,.15) inset,
|
144 |
+
0 1px 0 hsla(0,0%,100%,.05);
|
145 |
+
-webkit-transition-property: background-color, border-color, box-shadow;
|
146 |
+
-webkit-transition-duration: 150ms;
|
147 |
+
-webkit-transition-timing-function: ease;
|
148 |
+
transition-property: background-color, border-color, box-shadow;
|
149 |
+
transition-duration: 150ms;
|
150 |
+
transition-timing-function: ease;
|
151 |
+
|
152 |
+
min-width: 16px;
|
153 |
+
padding: 2px 6px 0;
|
154 |
+
|
155 |
+
border-radius: 2px;
|
156 |
+
color: hsla(0,0%,100%,.8);
|
157 |
+
font-size: 12px;
|
158 |
+
line-height: 14px;
|
159 |
+
-webkit-user-select: none;
|
160 |
+
-moz-user-select: none;
|
161 |
+
-ms-user-select: none;
|
162 |
+
cursor: default;
|
163 |
+
|
164 |
+
margin: 3px 2px 4px 0;
|
165 |
+
|
166 |
+
float: left;
|
167 |
+
|
168 |
+
}
|
169 |
+
|
170 |
+
div.pdfemb-toolbar button:hover {
|
171 |
+
background-color: hsla(0,0%,0%,.2);
|
172 |
+
box-shadow: 0 1px 0 hsla(0,0%,100%,.05) inset,
|
173 |
+
0 0 1px hsla(0,0%,100%,.15) inset,
|
174 |
+
0 0 1px hsla(0,0%,0%,.05);
|
175 |
+
}
|
176 |
+
|
177 |
+
div.pdfemb-toolbar button:first-child {
|
178 |
+
margin-left: 4px;
|
179 |
+
}
|
180 |
+
|
181 |
+
div.pdfemb-toolbar button.pdfemb-toggled {
|
182 |
+
background-color: hsla(0,0%,0%,.3);
|
183 |
+
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
184 |
+
border-color: hsla(0,0%,0%,.4) hsla(0,0%,0%,.45) hsla(0,0%,0%,.5);
|
185 |
+
box-shadow: 0 1px 1px hsla(0,0%,0%,.1) inset,
|
186 |
+
0 0 1px hsla(0,0%,0%,.2) inset,
|
187 |
+
0 1px 0 hsla(0,0%,100%,.05);
|
188 |
+
-webkit-transition-property: background-color, border-color, box-shadow;
|
189 |
+
-webkit-transition-duration: 10ms;
|
190 |
+
-webkit-transition-timing-function: linear;
|
191 |
+
transition-property: background-color, border-color, box-shadow;
|
192 |
+
transition-duration: 10ms;
|
193 |
+
transition-timing-function: linear;
|
194 |
+
}
|
195 |
+
|
196 |
+
div.pdfemb-toolbar button.pdfemb-toggled:hover {
|
197 |
+
background-color: hsla(0,0%,0%,.4);
|
198 |
+
border-color: hsla(0,0%,0%,.4) hsla(0,0%,0%,.5) hsla(0,0%,0%,.55);
|
199 |
+
box-shadow: 0 1px 1px hsla(0,0%,0%,.2) inset,
|
200 |
+
0 0 1px hsla(0,0%,0%,.3) inset,
|
201 |
+
0 1px 0 hsla(0,0%,100%,.05);
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
div.pdfemb-toolbar button.pdfemb-prev::before {
|
206 |
+
content: url('../img/toolbarButton-pageUp.png');
|
207 |
+
}
|
208 |
+
|
209 |
+
div.pdfemb-toolbar button.pdfemb-next::before {
|
210 |
+
content: url('../img/toolbarButton-pageDown.png');
|
211 |
+
}
|
212 |
+
|
213 |
+
div.pdfemb-toolbar button.pdfemb-zoomout::before {
|
214 |
+
content: url('../img/toolbarButton-zoomOut.png');
|
215 |
+
}
|
216 |
+
|
217 |
+
div.pdfemb-toolbar button.pdfemb-zoomin::before {
|
218 |
+
content: url('../img/toolbarButton-zoomIn.png');
|
219 |
+
}
|
220 |
+
|
221 |
+
div.pdfemb-toolbar button.pdfemb-fs::before {
|
222 |
+
content: url('../img/toolbarButton-presentationMode.png');
|
223 |
}
|
224 |
|
225 |
div.pdfemb-toolbar button.pdfemb-btndisabled {
|
227 |
}
|
228 |
|
229 |
div.pdfemb-toolbar div {
|
230 |
+
margin: 6px 15px 6px 2px;
|
231 |
font-family: sans-serif;
|
232 |
+
font-size: 12px;
|
233 |
+
padding: 2px;
|
234 |
text-align: center;
|
235 |
letter-spacing: normal;
|
236 |
word-spacing: normal;
|
237 |
+
font-size: 12px;
|
238 |
+
line-height: 14px;
|
239 |
text-transform: none;
|
240 |
text-indent: 0px;
|
241 |
text-shadow: none;
|
242 |
font-weight: normal;
|
243 |
display: inline;
|
244 |
color: lightgray;
|
245 |
+
|
246 |
+
float: left;
|
247 |
}
|
248 |
|
249 |
div.pdfemb-errormsg {
|
img/toolbarButton-pageDown.png
ADDED
Binary file
|
img/toolbarButton-pageUp.png
ADDED
Binary file
|
img/toolbarButton-presentationMode.png
ADDED
Binary file
|
img/toolbarButton-zoomIn.png
ADDED
Binary file
|
img/toolbarButton-zoomOut.png
ADDED
Binary file
|
js/all-pdfemb-basic.min.js
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
-
function pdfembGetPDF(
|
2 |
-
!1,"on"==
|
3 |
-
|
4 |
-
|
5 |
-
l
|
6 |
-
|
7 |
-
a.
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
(
|
14 |
-
this.
|
15 |
-
|
|
|
|
|
16 |
this.element.scrollTop;this.element.scrollTop=this.scrollTopStart-40*a;this.overlay.parentNode||document.body.appendChild(this.overlay)},_endPan:function(){this.element.removeEventListener("scroll",this._endPan,!0);this.document.removeEventListener("mousemove",this._onmousemove,!0);this.document.removeEventListener("mouseup",this._endPan,!0);this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}};var a;["webkitM","mozM","msM","oM","m"].some(function(b){b+="atches";b in document.documentElement&&
|
17 |
-
(a=b);b+="Selector";b in document.documentElement&&(a=b);return a});var
|
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){c.empty().append(b("<div></div>",{"class":"pdfemb-errormsg"}).append(document.createTextNode(a.message)))})};if(c.data("pdfDoc"))d(c.data("pdfDoc"),c.data("showIsSecure"));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||
|
4 |
+
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)},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),
|
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=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()-
|
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+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>
|
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(),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,
|
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")?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",
|
9 |
+
"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,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",
|
10 |
+
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*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"+
|
11 |
+
(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>');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>'));
|
12 |
+
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),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,
|
13 |
+
-10)});pdfembAddMoreToolbar(b,g,a);c||(a.on("mouseenter",function(e){e=a.find("div.pdfemb-toolbar-hover");!0!==e.data("no-hover")&&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);
|
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,
|
17 |
+
!0);var b;b="buttons"in a&&f?!(a.buttons|1):d||g?0===a.which:void 0;b?this._endPan():(b=a.clientX-this.clientXStart,this.element.scrollTop=this.scrollTopStart-(a.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);a="DOMMouseScroll"===a.type?-a.detail:a.wheelDelta/40;this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=
|
18 |
this.element.scrollTop;this.element.scrollTop=this.scrollTopStart-40*a;this.overlay.parentNode||document.body.appendChild(this.overlay)},_endPan:function(){this.element.removeEventListener("scroll",this._endPan,!0);this.document.removeEventListener("mousemove",this._onmousemove,!0);this.document.removeEventListener("mouseup",this._endPan,!0);this.overlay.parentNode&&this.overlay.parentNode.removeChild(this.overlay)}};var a;["webkitM","mozM","msM","oM","m"].some(function(b){b+="atches";b in document.documentElement&&
|
19 |
+
(a=b);b+="Selector";b in document.documentElement&&(a=b);return a});var f=!document.documentMode||9<document.documentMode,c=window.chrome,d=c&&(c.webstore||c.app),g=/Apple/.test(navigator.vendor)&&/Version\/([6-9]\d*|[1-5]\d+)/.test(navigator.userAgent);return b}();
|
js/pdfemb-embed-pdf.js
CHANGED
@@ -83,8 +83,32 @@ jQuery(document).ready(function ($) {
|
|
83 |
return this;
|
84 |
|
85 |
};
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
divContainer.data('pageRendering', true);
|
90 |
|
@@ -92,8 +116,19 @@ jQuery(document).ready(function ($) {
|
|
92 |
var pdfDoc = divContainer.data('pdfDoc');
|
93 |
|
94 |
pdfDoc.getPage(pageNum).then(function(page) {
|
95 |
-
|
96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
var scale = 1.0;
|
98 |
|
99 |
var vp = page.getViewport(scale);
|
@@ -196,7 +231,10 @@ jQuery(document).ready(function ($) {
|
|
196 |
}
|
197 |
|
198 |
var innerdiv = divContainer.find('div.pdfemb-inner-div');
|
199 |
-
|
|
|
|
|
|
|
200 |
innerdiv.height(userHeight);
|
201 |
|
202 |
var fixedTopToolbars = fixedToolbars.filter('.pdfemb-toolbar-top');
|
@@ -216,7 +254,7 @@ jQuery(document).ready(function ($) {
|
|
216 |
// Need to pan?
|
217 |
|
218 |
if ((wantCanvasWidth > wantWidth || wantCanvasHeight > wantHeight || wantCanvasHeight > userHeight) && !wantMobile) {
|
219 |
-
|
220 |
|
221 |
// Adjust panning offset to ensure a recent zoom change centres the doc?
|
222 |
|
@@ -225,18 +263,22 @@ jQuery(document).ready(function ($) {
|
|
225 |
|
226 |
if (fromZoom > 0 && toZoom > 0) {
|
227 |
|
228 |
-
var oldScrollLeft = innerdiv.scrollLeft();
|
229 |
-
var oldScrollTop = innerdiv.scrollTop();
|
230 |
-
|
231 |
var oldMidX = oldScrollLeft + wantWidth / 2;
|
232 |
var oldMidY = oldScrollTop + wantHeight / 2;
|
233 |
|
234 |
innerdiv.scrollLeft((oldMidX * toZoom / fromZoom) - wantWidth/2);
|
235 |
innerdiv.scrollTop((oldMidY * toZoom / fromZoom) - wantHeight/2);
|
236 |
}
|
|
|
|
|
237 |
}
|
238 |
else {
|
239 |
-
|
|
|
|
|
|
|
|
|
|
|
240 |
divContainer.find('div.pdfemb-inner-div').scrollLeft(0).scrollTop(0); // reset
|
241 |
}
|
242 |
|
@@ -244,6 +286,22 @@ jQuery(document).ready(function ($) {
|
|
244 |
|
245 |
pdfembMakeMobile($, wantMobile, divContainer);
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
// Render PDF page into canvas context
|
248 |
var ctx = canvas[0].getContext('2d');
|
249 |
var renderContext = {
|
@@ -284,33 +342,61 @@ jQuery(document).ready(function ($) {
|
|
284 |
|
285 |
};
|
286 |
|
287 |
-
$.fn.pdfEmbedder.queueRenderPage = function(divContainer, num) {
|
288 |
if (divContainer.data('pageRendering')) {
|
289 |
divContainer.data('pageNumPending', num);
|
290 |
} else {
|
291 |
-
$.fn.pdfEmbedder.renderPage(divContainer, num);
|
292 |
}
|
293 |
};
|
294 |
|
295 |
$.fn.pdfEmbedder.goFullScreen = function(divContainer) {
|
296 |
var fsWindow = $('<div class="pdfemb-fs-window"></div>');
|
297 |
$(document.body).append(fsWindow);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
};
|
299 |
|
300 |
$.fn.pdfEmbedder.addToolbar = function(divContainer, atTop, fixed, showIsSecure){
|
301 |
|
302 |
var toolbar = $('<div></div>', {'class': 'pdfemb-toolbar pdfemb-toolbar'+(fixed ? '-fixed' : '-hover')+' '+(atTop ? ' pdfemb-toolbar-top' : 'pdfemb-toolbar-bottom')});
|
303 |
-
var prevbtn = $('<button class="pdfemb-prev"
|
304 |
toolbar.append(prevbtn);
|
305 |
-
var nextbtn = $('<button class="pdfemb-next"
|
306 |
toolbar.append(nextbtn);
|
307 |
|
308 |
toolbar.append($('<div>Page <span class="pdfemb-page-num">0</span> / <span class="pdfemb-page-count"></span></div>'));
|
309 |
|
310 |
-
var zoomoutbtn = $('<button class="pdfemb-zoomout"
|
311 |
toolbar.append(zoomoutbtn);
|
312 |
|
313 |
-
var zoominbtn = $('<button class="pdfemb-zoomin"
|
314 |
toolbar.append(zoominbtn);
|
315 |
|
316 |
toolbar.append($('<div>Zoom <span class="pdfemb-zoom">100%</span></div>'));
|
@@ -343,28 +429,18 @@ jQuery(document).ready(function ($) {
|
|
343 |
$.fn.pdfEmbedder.queueRenderPage(divContainer, divContainer.data('pageNum'));
|
344 |
});
|
345 |
|
346 |
-
|
347 |
-
var oldzoom = divContainer.data('zoom');
|
348 |
-
var newzoom = oldzoom + zoomdelta;
|
349 |
-
divContainer.data('zoom', newzoom);
|
350 |
-
divContainer.find('span.pdfemb-zoom').text( newzoom + '%' );
|
351 |
-
$.fn.pdfEmbedder.queueRenderPage(divContainer, divContainer.data('pageNum'));
|
352 |
-
|
353 |
-
divContainer.data('fromZoom', oldzoom).data('toZoom', newzoom);
|
354 |
-
};
|
355 |
-
|
356 |
-
zoominbtn.on('click', function (e){
|
357 |
if (divContainer.data('zoom') >= 500) {
|
358 |
return;
|
359 |
}
|
360 |
-
|
361 |
});
|
362 |
|
363 |
zoomoutbtn.on('click', function (e){
|
364 |
if (divContainer.data('zoom') <= 20) {
|
365 |
return;
|
366 |
}
|
367 |
-
changeZoom(-10);
|
368 |
});
|
369 |
|
370 |
|
83 |
return this;
|
84 |
|
85 |
};
|
86 |
+
|
87 |
+
$.fn.pdfEmbedder.checkForResize = function(divContainer) {
|
88 |
+
var newheight = $(window).height();
|
89 |
+
var newwidth = $(window).width();
|
90 |
+
|
91 |
+
var oldheight = divContainer.data('checked-window-height');
|
92 |
+
var oldwidth = divContainer.data('checked-window-width');
|
93 |
+
|
94 |
+
if (!oldheight || !oldwidth) {
|
95 |
+
divContainer.data('checked-window-height', newheight);
|
96 |
+
divContainer.data('checked-window-width', newwidth);
|
97 |
+
}
|
98 |
+
else if (oldheight != newheight || oldwidth != newwidth) {
|
99 |
+
$.fn.pdfEmbedder.queueRenderPage(divContainer, divContainer.data('pageNum'));
|
100 |
+
divContainer.data('checked-window-height', newheight);
|
101 |
+
divContainer.data('checked-window-width', newwidth);
|
102 |
+
}
|
103 |
+
|
104 |
+
if (divContainer.data('fullScreenClosed') != 'true') {
|
105 |
+
setTimeout(function () {
|
106 |
+
$.fn.pdfEmbedder.checkForResize(divContainer);
|
107 |
+
}, 1000);
|
108 |
+
}
|
109 |
+
};
|
110 |
+
|
111 |
+
$.fn.pdfEmbedder.renderPage = function(divContainer, pageNum, noredraw) {
|
112 |
|
113 |
divContainer.data('pageRendering', true);
|
114 |
|
116 |
var pdfDoc = divContainer.data('pdfDoc');
|
117 |
|
118 |
pdfDoc.getPage(pageNum).then(function(page) {
|
119 |
+
|
120 |
+
var canvas = divContainer.find('.pdfemb-the-canvas');
|
121 |
+
var canvasImg = null;
|
122 |
+
var canvasCxt = null;
|
123 |
+
var oldCanvasWidth = null;
|
124 |
+
var oldCanvasHeight = null;
|
125 |
+
if (noredraw) {
|
126 |
+
oldCanvasWidth = canvas.width();
|
127 |
+
oldCanvasHeight = canvas.height();
|
128 |
+
canvasCxt = canvas[0].getContext('2d');
|
129 |
+
canvasImg = canvasCxt.getImageData(0,0,oldCanvasWidth, oldCanvasHeight);
|
130 |
+
}
|
131 |
+
|
132 |
var scale = 1.0;
|
133 |
|
134 |
var vp = page.getViewport(scale);
|
231 |
}
|
232 |
|
233 |
var innerdiv = divContainer.find('div.pdfemb-inner-div');
|
234 |
+
var oldScrollLeft = innerdiv[0].scrollLeft;
|
235 |
+
var oldScrollTop = innerdiv[0].scrollTop;
|
236 |
+
|
237 |
+
innerdiv.width(wantWidth);
|
238 |
innerdiv.height(userHeight);
|
239 |
|
240 |
var fixedTopToolbars = fixedToolbars.filter('.pdfemb-toolbar-top');
|
254 |
// Need to pan?
|
255 |
|
256 |
if ((wantCanvasWidth > wantWidth || wantCanvasHeight > wantHeight || wantCanvasHeight > userHeight) && !wantMobile) {
|
257 |
+
|
258 |
|
259 |
// Adjust panning offset to ensure a recent zoom change centres the doc?
|
260 |
|
263 |
|
264 |
if (fromZoom > 0 && toZoom > 0) {
|
265 |
|
|
|
|
|
|
|
266 |
var oldMidX = oldScrollLeft + wantWidth / 2;
|
267 |
var oldMidY = oldScrollTop + wantHeight / 2;
|
268 |
|
269 |
innerdiv.scrollLeft((oldMidX * toZoom / fromZoom) - wantWidth/2);
|
270 |
innerdiv.scrollTop((oldMidY * toZoom / fromZoom) - wantHeight/2);
|
271 |
}
|
272 |
+
|
273 |
+
divContainer.data('grabtopan').activate();
|
274 |
}
|
275 |
else {
|
276 |
+
if (divContainer.data('fullScreen') == 'on') {
|
277 |
+
divContainer.data('grabtopan').activate();
|
278 |
+
}
|
279 |
+
else {
|
280 |
+
divContainer.data('grabtopan').deactivate();
|
281 |
+
}
|
282 |
divContainer.find('div.pdfemb-inner-div').scrollLeft(0).scrollTop(0); // reset
|
283 |
}
|
284 |
|
286 |
|
287 |
pdfembMakeMobile($, wantMobile, divContainer);
|
288 |
|
289 |
+
if (noredraw) {
|
290 |
+
divContainer.data('pageNum', pageNum);
|
291 |
+
divContainer.data('pageRendering', false);
|
292 |
+
|
293 |
+
var newCanvas = $("<canvas>")
|
294 |
+
.attr("width", canvasImg.width)
|
295 |
+
.attr("height", canvasImg.height)[0];
|
296 |
+
|
297 |
+
newCanvas.getContext("2d").putImageData(canvasImg, 0, 0);
|
298 |
+
|
299 |
+
canvasCxt.scale(wantCanvasWidth/oldCanvasWidth, wantCanvasHeight/oldCanvasHeight);
|
300 |
+
canvasCxt.drawImage(newCanvas, 0, 0);
|
301 |
+
|
302 |
+
return;
|
303 |
+
}
|
304 |
+
|
305 |
// Render PDF page into canvas context
|
306 |
var ctx = canvas[0].getContext('2d');
|
307 |
var renderContext = {
|
342 |
|
343 |
};
|
344 |
|
345 |
+
$.fn.pdfEmbedder.queueRenderPage = function(divContainer, num, noredraw) {
|
346 |
if (divContainer.data('pageRendering')) {
|
347 |
divContainer.data('pageNumPending', num);
|
348 |
} else {
|
349 |
+
$.fn.pdfEmbedder.renderPage(divContainer, num, noredraw);
|
350 |
}
|
351 |
};
|
352 |
|
353 |
$.fn.pdfEmbedder.goFullScreen = function(divContainer) {
|
354 |
var fsWindow = $('<div class="pdfemb-fs-window"></div>');
|
355 |
$(document.body).append(fsWindow);
|
356 |
+
};
|
357 |
+
|
358 |
+
$.fn.pdfEmbedder.changeZoom = function(divContainer, zoomdelta) {
|
359 |
+
var oldzoom = divContainer.data('zoom');
|
360 |
+
var newzoom = oldzoom + zoomdelta;
|
361 |
+
divContainer.data('zoom', newzoom);
|
362 |
+
divContainer.find('span.pdfemb-zoom').text( newzoom + '%' );
|
363 |
+
|
364 |
+
$.fn.pdfEmbedder.queueRenderPage(divContainer, divContainer.data('pageNum'));
|
365 |
+
divContainer.data('fromZoom', oldzoom).data('toZoom', newzoom);
|
366 |
+
};
|
367 |
+
|
368 |
+
$.fn.pdfEmbedder.magnifyZoom = function(divContainer, magnification) {
|
369 |
+
var oldzoom = divContainer.data('zoom');
|
370 |
+
var newzoom = Math.floor(oldzoom * magnification);
|
371 |
+
|
372 |
+
if (newzoom < 20) {
|
373 |
+
newzoom = 20;
|
374 |
+
}
|
375 |
+
if (newzoom > 500) {
|
376 |
+
newzoom = 500;
|
377 |
+
}
|
378 |
+
divContainer.data('zoom', newzoom);
|
379 |
+
divContainer.find('span.pdfemb-zoom').text( newzoom + '%' );
|
380 |
+
|
381 |
+
$.fn.pdfEmbedder.queueRenderPage(divContainer, divContainer.data('pageNum'), true);
|
382 |
+
divContainer.data('fromZoom', oldzoom).data('toZoom', newzoom);
|
383 |
+
|
384 |
};
|
385 |
|
386 |
$.fn.pdfEmbedder.addToolbar = function(divContainer, atTop, fixed, showIsSecure){
|
387 |
|
388 |
var toolbar = $('<div></div>', {'class': 'pdfemb-toolbar pdfemb-toolbar'+(fixed ? '-fixed' : '-hover')+' '+(atTop ? ' pdfemb-toolbar-top' : 'pdfemb-toolbar-bottom')});
|
389 |
+
var prevbtn = $('<button class="pdfemb-prev" title="Prev"></button>');
|
390 |
toolbar.append(prevbtn);
|
391 |
+
var nextbtn = $('<button class="pdfemb-next" title="Next"></button>');
|
392 |
toolbar.append(nextbtn);
|
393 |
|
394 |
toolbar.append($('<div>Page <span class="pdfemb-page-num">0</span> / <span class="pdfemb-page-count"></span></div>'));
|
395 |
|
396 |
+
var zoomoutbtn = $('<button class="pdfemb-zoomout" title="Zoom Out"></button>');
|
397 |
toolbar.append(zoomoutbtn);
|
398 |
|
399 |
+
var zoominbtn = $('<button class="pdfemb-zoomin" title="Zoom In"></button>');
|
400 |
toolbar.append(zoominbtn);
|
401 |
|
402 |
toolbar.append($('<div>Zoom <span class="pdfemb-zoom">100%</span></div>'));
|
429 |
$.fn.pdfEmbedder.queueRenderPage(divContainer, divContainer.data('pageNum'));
|
430 |
});
|
431 |
|
432 |
+
zoominbtn.on('click', function (e){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
433 |
if (divContainer.data('zoom') >= 500) {
|
434 |
return;
|
435 |
}
|
436 |
+
$.fn.pdfEmbedder.changeZoom(divContainer, 10);
|
437 |
});
|
438 |
|
439 |
zoomoutbtn.on('click', function (e){
|
440 |
if (divContainer.data('zoom') <= 20) {
|
441 |
return;
|
442 |
}
|
443 |
+
$.fn.pdfEmbedder.changeZoom(divContainer, -10);
|
444 |
});
|
445 |
|
446 |
|
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;
|
@@ -34,8 +34,8 @@ class pdfemb_basic_pdf_embedder extends core_pdf_embedder {
|
|
34 |
|
35 |
public function pdfemb_wp_enqueue_scripts() {
|
36 |
if (!$this->useminified()) {
|
37 |
-
wp_register_script( 'pdfemb_versionspecific_pdf_js', $this->my_plugin_url().'js/pdfemb-basic.js');
|
38 |
-
wp_register_script( 'pdfemb_grabtopan_js', $this->my_plugin_url().'js/grabtopan-basic.js');
|
39 |
wp_register_script( 'pdfemb_embed_pdf_js', $this->my_plugin_url().'js/pdfemb-embed-pdf.js', array('pdfemb_versionspecific_pdf_js', 'pdfemb_grabtopan_js', 'jquery') );
|
40 |
}
|
41 |
else {
|
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.2
|
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.2';
|
18 |
|
19 |
protected function useminified() {
|
20 |
/* using-minified */ return true;
|
34 |
|
35 |
public function pdfemb_wp_enqueue_scripts() {
|
36 |
if (!$this->useminified()) {
|
37 |
+
wp_register_script( 'pdfemb_versionspecific_pdf_js', $this->my_plugin_url().'js/pdfemb-basic.js', array('jquery'));
|
38 |
+
wp_register_script( 'pdfemb_grabtopan_js', $this->my_plugin_url().'js/grabtopan-basic.js', array('jquery'));
|
39 |
wp_register_script( 'pdfemb_embed_pdf_js', $this->my_plugin_url().'js/pdfemb-embed-pdf.js', array('pdfemb_versionspecific_pdf_js', 'pdfemb_grabtopan_js', 'jquery') );
|
40 |
}
|
41 |
else {
|
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 |
|
@@ -60,6 +60,8 @@ See our website [wp-pdf.com](http://wp-pdf.com/secure/?utm_source=PDF%20Readme%2
|
|
60 |
|
61 |
= How can I obtain support for this product? =
|
62 |
|
|
|
|
|
63 |
Please feel free to email [contact@wp-pdf.com](mailto:contact@wp-pdf.com) with any questions.
|
64 |
|
65 |
Always include your full shortcode, plus links to the relevant pages, and screenshots if they would be helpful too.
|
@@ -119,6 +121,10 @@ the Plugins section of your Wordpress admin
|
|
119 |
|
120 |
== Changelog ==
|
121 |
|
|
|
|
|
|
|
|
|
122 |
= 2.2 =
|
123 |
|
124 |
New version of PDF.js, fixes some PDF rendering bugs.
|
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.2
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
60 |
|
61 |
= How can I obtain support for this product? =
|
62 |
|
63 |
+
We have [instructions](https://wp-pdf.com/free-instructions/) and [troubleshooting](https://wp-pdf.com/troubleshooting/) pages explaining common setup queries and issues.
|
64 |
+
|
65 |
Please feel free to email [contact@wp-pdf.com](mailto:contact@wp-pdf.com) with any questions.
|
66 |
|
67 |
Always include your full shortcode, plus links to the relevant pages, and screenshots if they would be helpful too.
|
121 |
|
122 |
== Changelog ==
|
123 |
|
124 |
+
= 2.2.2 =
|
125 |
+
|
126 |
+
Redesigned toolbar buttons
|
127 |
+
|
128 |
= 2.2 =
|
129 |
|
130 |
New version of PDF.js, fixes some PDF rendering bugs.
|