Merge pull request #8919 from Snuffleupagus/issue-8915
Ignore 'change' events that didn't originate in the viewer (issue 8915)
This commit is contained in:
commit
c84c23c4cb
32
web/app.js
32
web/app.js
@ -1330,18 +1330,6 @@ let PDFViewerApplication = {
|
|||||||
window.addEventListener('hashchange', _boundEvents.windowHashChange);
|
window.addEventListener('hashchange', _boundEvents.windowHashChange);
|
||||||
window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
|
window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
|
||||||
window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
|
window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
|
||||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
|
||||||
_boundEvents.windowChange = (evt) => {
|
|
||||||
let files = evt.target.files;
|
|
||||||
if (!files || files.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
eventBus.dispatch('fileinputchange', {
|
|
||||||
fileInput: evt.target,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
window.addEventListener('change', _boundEvents.windowChange);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
unbindEvents() {
|
unbindEvents() {
|
||||||
@ -1396,10 +1384,6 @@ let PDFViewerApplication = {
|
|||||||
window.removeEventListener('hashchange', _boundEvents.windowHashChange);
|
window.removeEventListener('hashchange', _boundEvents.windowHashChange);
|
||||||
window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
|
window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
|
||||||
window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
|
window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
|
||||||
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
|
||||||
window.removeEventListener('change', _boundEvents.windowChange);
|
|
||||||
_boundEvents.windowChange = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_boundEvents.windowResize = null;
|
_boundEvents.windowResize = null;
|
||||||
_boundEvents.windowHashChange = null;
|
_boundEvents.windowHashChange = null;
|
||||||
@ -1492,6 +1476,16 @@ function webViewerInitialized() {
|
|||||||
} else {
|
} else {
|
||||||
fileInput.value = null;
|
fileInput.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileInput.addEventListener('change', function(evt) {
|
||||||
|
let files = evt.target.files;
|
||||||
|
if (!files || files.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PDFViewerApplication.eventBus.dispatch('fileinputchange', {
|
||||||
|
fileInput: evt.target,
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
|
appConfig.toolbar.openFile.setAttribute('hidden', 'true');
|
||||||
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
|
appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
|
||||||
@ -1859,8 +1853,10 @@ function webViewerPresentationMode() {
|
|||||||
PDFViewerApplication.requestPresentationMode();
|
PDFViewerApplication.requestPresentationMode();
|
||||||
}
|
}
|
||||||
function webViewerOpenFile() {
|
function webViewerOpenFile() {
|
||||||
let openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
|
if (typeof PDFJSDev === 'undefined' || PDFJSDev.test('GENERIC')) {
|
||||||
document.getElementById(openFileInputName).click();
|
let openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
|
||||||
|
document.getElementById(openFileInputName).click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function webViewerPrint() {
|
function webViewerPrint() {
|
||||||
window.print();
|
window.print();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user