vendor/assets/javascripts/pdf.js in better-pdfjs-rails-1.6.380.5 vs vendor/assets/javascripts/pdf.js in better-pdfjs-rails-1.6.422.0

- old
+ new

@@ -21,12 +21,12 @@ } else { factory(root['pdfjsDistBuildPdf'] = {}); } }(this, function (exports) { 'use strict'; - var pdfjsVersion = '1.6.380'; - var pdfjsBuild = '00a006e'; + var pdfjsVersion = '1.6.422'; + var pdfjsBuild = 'aabfb77'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null; var pdfjsLibs = {}; (function pdfjsWrapper() { (function (root, factory) { factory(root.pdfjsSharedUtil = {}); @@ -3798,10 +3798,19 @@ case AnnotationType.WIDGET: var fieldType = parameters.data.fieldType; switch (fieldType) { case 'Tx': return new TextWidgetAnnotationElement(parameters); + case 'Btn': + if (parameters.data.radioButton) { + return new RadioButtonWidgetAnnotationElement(parameters); + } else if (parameters.data.checkBox) { + return new CheckboxWidgetAnnotationElement(parameters); + } else { + warn('Unimplemented button widget annotation: pushbutton'); + } + break; case 'Ch': return new ChoiceWidgetAnnotationElement(parameters); } return new WidgetAnnotationElement(parameters); case AnnotationType.POPUP: @@ -4065,10 +4074,49 @@ style.fontFamily = fontFamily + fallbackName; } }); return TextWidgetAnnotationElement; }(); + var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() { + function CheckboxWidgetAnnotationElement(parameters) { + WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); + } + Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, { + render: function CheckboxWidgetAnnotationElement_render() { + this.container.className = 'buttonWidgetAnnotation checkBox'; + var element = document.createElement('input'); + element.disabled = this.data.readOnly; + element.type = 'checkbox'; + if (this.data.fieldValue && this.data.fieldValue !== 'Off') { + element.setAttribute('checked', true); + } + this.container.appendChild(element); + return this.container; + } + }); + return CheckboxWidgetAnnotationElement; + }(); + var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() { + function RadioButtonWidgetAnnotationElement(parameters) { + WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); + } + Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, { + render: function RadioButtonWidgetAnnotationElement_render() { + this.container.className = 'buttonWidgetAnnotation radioButton'; + var element = document.createElement('input'); + element.disabled = this.data.readOnly; + element.type = 'radio'; + element.name = this.data.fieldName; + if (this.data.fieldValue === this.data.buttonValue) { + element.setAttribute('checked', true); + } + this.container.appendChild(element); + return this.container; + } + }); + return RadioButtonWidgetAnnotationElement; + }(); var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() { function ChoiceWidgetAnnotationElement(parameters) { WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms); } Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, { @@ -7092,15 +7140,15 @@ error('Should not call beginImageData'); }, paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) { this.save(); this.baseTransformStack.push(this.baseTransform); - if (isArray(matrix) && 6 === matrix.length) { + if (isArray(matrix) && matrix.length === 6) { this.transform.apply(this, matrix); } this.baseTransform = this.ctx.mozCurrentTransform; - if (isArray(bbox) && 4 === bbox.length) { + if (isArray(bbox) && bbox.length === 4) { var width = bbox[2] - bbox[0]; var height = bbox[3] - bbox[1]; this.ctx.rect(bbox[0], bbox[1], width, height); this.clip(); this.endPath(); @@ -7224,11 +7272,11 @@ endAnnotations: function CanvasGraphics_endAnnotations() { this.restore(); }, beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) { this.save(); - if (isArray(rect) && 4 === rect.length) { + if (isArray(rect) && rect.length === 4) { var width = rect[2] - rect[0]; var height = rect[3] - rect[1]; this.ctx.rect(rect[0], rect[1], width, height); this.clip(); this.endPath(); @@ -8302,10 +8350,11 @@ this.pdfDataRangeTransport = pdfDataRangeTransport; this.commonObjs = new PDFObjects(); this.fontLoader = new FontLoader(loadingTask.docId); this.destroyed = false; this.destroyCapability = null; + this._passwordCapability = null; this.pageCache = []; this.pagePromises = []; this.downloadInfoCapability = createPromiseCapability(); this.setupMessageHandler(); } @@ -8314,10 +8363,13 @@ if (this.destroyCapability) { return this.destroyCapability.promise; } this.destroyed = true; this.destroyCapability = createPromiseCapability(); + if (this._passwordCapability) { + this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback')); + } var waitOn = []; this.pageCache.forEach(function (page) { if (page) { waitOn.push(page._destroy()); } @@ -8341,13 +8393,11 @@ }, this.destroyCapability.reject); return this.destroyCapability.promise; }, setupMessageHandler: function WorkerTransport_setupMessageHandler() { var messageHandler = this.messageHandler; - function updatePassword(password) { - messageHandler.send('UpdatePassword', password); - } + var loadingTask = this.loadingTask; var pdfDataRangeTransport = this.pdfDataRangeTransport; if (pdfDataRangeTransport) { pdfDataRangeTransport.addRangeListener(function (begin, chunk) { messageHandler.send('OnDataRange', { begin: begin, @@ -8370,21 +8420,22 @@ var loadingTask = this.loadingTask; var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask); this.pdfDocument = pdfDocument; loadingTask._capability.resolve(pdfDocument); }, this); - messageHandler.on('NeedPassword', function transportNeedPassword(exception) { - var loadingTask = this.loadingTask; + messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) { + this._passwordCapability = createPromiseCapability(); if (loadingTask.onPassword) { - return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD); + var updatePassword = function (password) { + this._passwordCapability.resolve({ password: password }); + }.bind(this); + loadingTask.onPassword(updatePassword, exception.code); + } else { + this._passwordCapability.reject(new PasswordException(exception.message, exception.code)); } - loadingTask._capability.reject(new PasswordException(exception.message, exception.code)); + return this._passwordCapability.promise; }, this); - messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) { - var loadingTask = this.loadingTask; - if (loadingTask.onPassword) { - return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD); - } + messageHandler.on('PasswordException', function transportPasswordException(exception) { loadingTask._capability.reject(new PasswordException(exception.message, exception.code)); }, this); messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) { this.loadingTask._capability.reject(new InvalidPDFException(exception.message)); }, this); \ No newline at end of file