From ceab4af8f3ffad0c92b2c97d28114deb8acf4dcf Mon Sep 17 00:00:00 2001 From: Varun Vachhar Date: Sat, 24 Jan 2015 22:27:49 -0500 Subject: [PATCH] merged bugfix for show/hide toolbar --- bower.json | 2 +- dist/angular-pdf-viewer.min.js | 2 +- package.json | 2 +- readme.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index e2d4ec4..8ff983f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-pdf-viewer", - "version": "0.2.1", + "version": "0.2.2", "description": "An AngularJS directive to display PDFs", "main": "./dist/angular-pdf-viewer.min.js", "license": "MIT", diff --git a/dist/angular-pdf-viewer.min.js b/dist/angular-pdf-viewer.min.js index 2d0b185..6646da6 100644 --- a/dist/angular-pdf-viewer.min.js +++ b/dist/angular-pdf-viewer.min.js @@ -1 +1 @@ -function delegateService(e){return["$log",function(t){function n(e){this.handle=e}var a=this,o=this._instances=[];this._registerInstance=function(e,t){return e.$$delegateHandle=t,o.push(e),function(){var t=o.indexOf(e);-1!==t&&o.splice(t,1)}},this.$getByHandle=function(e){return e?new n(e):a},e.forEach(function(e){n.prototype[e]=function(){var n,a,r=this.handle,l=arguments,u=0;return o.forEach(function(t){t.$$delegateHandle===r&&(u++,a=t[e].apply(t,l),1===u&&(n=a))}),u?n:t.warn('Delegate for handle "'+this.handle+'" could not find a corresponding element with delegate-handle="'+this.handle+'"! '+e+"() was not called!\nPossible cause: If you are calling "+e+'() immediately, and your element with delegate-handle="'+this.handle+'" is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to '+e+"() and try again.")},a[e]=function(){var t,n,a=arguments;return o.forEach(function(o,r){n=o[e].apply(o,a),0===r&&(t=n)}),t}})}]}angular.module("pdf",[]).service("pdfDelegate",delegateService(["prev","next","zoomIn","zoomOut","rotate","getPageCount","getCurrentPage","goToPage","load"])),angular.module("pdf").controller("PdfCtrl",["$scope","$element","$attrs","pdfDelegate","$log",function(e,t,n,a,o){var r=a._registerInstance(this,n.delegateHandle);e.$on("$destroy",r);var l,u=this,i=e.$eval(n.url);e.pageCount=0;var c=1,d=0,g=n.scale?n.scale:1,s=t.find("canvas")[0],f=s.getContext("2d"),p=function(e){angular.isNumber(e)||(e=parseInt(e)),l.getPage(e).then(function(e){var t=e.getViewport(g);s.height=t.height,s.width=t.width;var n={canvasContext:f,viewport:t};e.render(n)})},m=function(){s.style.webkitTransform="rotate("+d+"deg)",s.style.MozTransform="rotate("+d+"deg)",s.style.msTransform="rotate("+d+"deg)",s.style.OTransform="rotate("+d+"deg)",s.style.transform="rotate("+d+"deg)"};u.prev=function(){1>=c||(c=parseInt(c,10)-1,p(c))},u.next=function(){c>=l.numPages||(c=parseInt(c,10)+1,p(c))},u.zoomIn=function(){return g=parseFloat(g)+.2,p(c),g},u.zoomOut=function(){return g=parseFloat(g)-.2,p(c),g},u.rotate=function(){d=0===d?90:90===d?180:180===d?270:0,m()},u.getPageCount=function(){return e.pageCount},u.getCurrentPage=function(){return c},u.goToPage=function(e){null!==l&&(c=e,p(e))},u.load=function(t){t&&(i=t),PDFJS.getDocument(i).then(function(t){l=t,p(1),e.$apply(function(){e.pageCount=t.numPages})},o.error)},u.load()}]),angular.module("pdf").directive("pdfViewerToolbar",["pdfDelegate",function(e){return{restrict:"E",template:'
BackNextZoom InZoom OutRotatePage / {{pageCount}}
',scope:{pageCount:"="},link:function(t,n,a){var o=a.delegateHandle;t.currentPage=1,t.prev=function(){e.$getByHandle(o).prev(),r()},t.next=function(){e.$getByHandle(o).next(),r()},t.zoomIn=function(){e.$getByHandle(o).zoomIn()},t.zoomOut=function(){e.$getByHandle(o).zoomOut()},t.rotate=function(){e.$getByHandle(o).rotate()},t.goToPage=function(){e.$getByHandle(o).goToPage(t.currentPage)};var r=function(){t.currentPage=e.$getByHandle(o).getCurrentPage()}}}}]),angular.module("pdf").directive("pdfViewer",["$window","$log","pdfDelegate",function(){return{restrict:"E",template:'',scope:!0,controller:"PdfCtrl",link:function(e,t,n){e.id=n.delegateHandle,e.showToolbar=e.$eval(n.showToolbar)||!1}}}]); \ No newline at end of file +function delegateService(e){return["$log",function(t){function n(e){this.handle=e}var a=this,o=this._instances=[];this._registerInstance=function(e,t){return e.$$delegateHandle=t,o.push(e),function(){var t=o.indexOf(e);-1!==t&&o.splice(t,1)}},this.$getByHandle=function(e){return e?new n(e):a},e.forEach(function(e){n.prototype[e]=function(){var n,a,r=this.handle,l=arguments,u=0;return o.forEach(function(t){t.$$delegateHandle===r&&(u++,a=t[e].apply(t,l),1===u&&(n=a))}),u?n:t.warn('Delegate for handle "'+this.handle+'" could not find a corresponding element with delegate-handle="'+this.handle+'"! '+e+"() was not called!\nPossible cause: If you are calling "+e+'() immediately, and your element with delegate-handle="'+this.handle+'" is a child of your controller, then your element may not be compiled yet. Put a $timeout around your call to '+e+"() and try again.")},a[e]=function(){var t,n,a=arguments;return o.forEach(function(o,r){n=o[e].apply(o,a),0===r&&(t=n)}),t}})}]}angular.module("pdf",[]).service("pdfDelegate",delegateService(["prev","next","zoomIn","zoomOut","rotate","getPageCount","getCurrentPage","goToPage","load"])),angular.module("pdf").controller("PdfCtrl",["$scope","$element","$attrs","pdfDelegate","$log",function(e,t,n,a,o){var r=a._registerInstance(this,n.delegateHandle);e.$on("$destroy",r);var l,u=this,i=e.$eval(n.url);e.pageCount=0;var c=1,g=0,d=n.scale?n.scale:1,s=t.find("canvas")[0],f=s.getContext("2d"),p=function(e){angular.isNumber(e)||(e=parseInt(e)),l.getPage(e).then(function(e){var t=e.getViewport(d);s.height=t.height,s.width=t.width;var n={canvasContext:f,viewport:t};e.render(n)})},h=function(){s.style.webkitTransform="rotate("+g+"deg)",s.style.MozTransform="rotate("+g+"deg)",s.style.msTransform="rotate("+g+"deg)",s.style.OTransform="rotate("+g+"deg)",s.style.transform="rotate("+g+"deg)"};u.prev=function(){1>=c||(c=parseInt(c,10)-1,p(c))},u.next=function(){c>=l.numPages||(c=parseInt(c,10)+1,p(c))},u.zoomIn=function(){return d=parseFloat(d)+.2,p(c),d},u.zoomOut=function(){return d=parseFloat(d)-.2,p(c),d},u.rotate=function(){g=0===g?90:90===g?180:180===g?270:0,h()},u.getPageCount=function(){return e.pageCount},u.getCurrentPage=function(){return c},u.goToPage=function(e){null!==l&&(c=e,p(e))},u.load=function(t){t&&(i=t),PDFJS.getDocument(i).then(function(t){l=t,p(1),e.$apply(function(){e.pageCount=t.numPages})},o.error)},u.load()}]),angular.module("pdf").directive("pdfViewerToolbar",["pdfDelegate",function(e){return{restrict:"E",template:'
BackNextZoom InZoom OutRotatePage / {{pageCount}}
',scope:{pageCount:"="},link:function(t,n,a){var o=a.delegateHandle;t.currentPage=1,t.prev=function(){e.$getByHandle(o).prev(),r()},t.next=function(){e.$getByHandle(o).next(),r()},t.zoomIn=function(){e.$getByHandle(o).zoomIn()},t.zoomOut=function(){e.$getByHandle(o).zoomOut()},t.rotate=function(){e.$getByHandle(o).rotate()},t.goToPage=function(){e.$getByHandle(o).goToPage(t.currentPage)};var r=function(){t.currentPage=e.$getByHandle(o).getCurrentPage()}}}}]),angular.module("pdf").directive("pdfViewer",["$window","$log","pdfDelegate",function(){return{restrict:"E",template:'',scope:!0,controller:"PdfCtrl",link:function(e,t,n){e.id=n.delegateHandle,e.showToolbar=e.$eval(n.showToolbar)||!1}}}]); \ No newline at end of file diff --git a/package.json b/package.json index 623393a..3362337 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-pdf-viewer", - "version": "0.2.1", + "version": "0.2.2", "author": "Varun Vachhar", "description": "An AngularJS directive to display PDFs", "repository": { diff --git a/readme.md b/readme.md index b0982dd..c9cc65b 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# Angular PDF Viewer (0.2.1) +# Angular PDF Viewer (0.2.2) An AngularJS directive to display PDFs. [DEMO](http://codepen.io/winkerVSbecks/full/50010e383d0f80deab97858571400d86/)