diff --git a/static/js/PDFViewer.js b/static/js/PDFViewer.js new file mode 100644 index 00000000..6590a7cc --- /dev/null +++ b/static/js/PDFViewer.js @@ -0,0 +1,100 @@ +'use strict'; + +/*@ +Ox.PDFViewer PDF Viewer + options Options + center <[n]|s|'auto'> Center ([x, y] or 'auto') + height Viewer height in px + maxZoom Maximum zoom (minimum zoom is 'fit') + pdfjsURL URL to pdf.js + url PDF URL + width Viewer width in px + zoom Zoom (number or 'fit' or 'fill') + self Shared private variable + ([options[, self]]) -> PDF Viewer + center Center changed + center <[n]|s> Center + zoom Zoom changed + zoom Zoom + page Page changed + page Page +@*/ +Ox.PDFViewer = function(options, self) { + + self = self || {}; + var that = Ox.Element({}, self) + .defaults({ + center: 'auto', + height: 384, + pdfjsURL: '/static/pdf.js/', + page: 1, + maxZoom: 16, + url: '', + width: 512, + zoom: 'fit' + }) + .options(options || {}) + .update({ + center: function() { + setCenterAndZoom(); + }, + page: updatePage, + // allow for setting height and width at the same time + height: updateSize, + url: function() { + self.$iframe.postMessage('pdf', {pdf: self.options.url}); + }, + width: updateSize, + zoom: function() { + setCenterAndZoom(); + } + }) + .addClass('OxPDFViewer') + .on({ + }) + .bindEvent({ + }); + + self.$iframe = Ox.Element('