mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 01:35:43 +02:00
Convert the only remaining consumer (in hand_tool.js
) of the 'localized' event to use the localized
Promise instead, and only re-dispatch the 'localized' event on the eventBus
for GENERIC
builds
Ideally we'd remove the 'localized' event from the `eventBus`, but for backwards compatibility we keep it in `GENERIC` builds. Note that while we want to ensure that the direction attribute of the HTML is updated as soon as the `localized` Promise is resolved, we purposely wait until the viewer has been initialized to ensure that the 'localized' event will always be dispatched.
This commit is contained in:
parent
648024f5d0
commit
a96b0f80dd
2 changed files with 21 additions and 15 deletions
|
@ -18,17 +18,19 @@
|
|||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs-web/hand_tool', ['exports', 'pdfjs-web/grab_to_pan',
|
||||
'pdfjs-web/preferences'], factory);
|
||||
'pdfjs-web/preferences', 'pdfjs-web/ui_utils'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('./grab_to_pan.js'), require('./preferences.js'));
|
||||
factory(exports, require('./grab_to_pan.js'), require('./preferences.js'),
|
||||
require('./ui_utils.js'));
|
||||
} else {
|
||||
factory((root.pdfjsWebHandTool = {}), root.pdfjsWebGrabToPan,
|
||||
root.pdfjsWebPreferences);
|
||||
root.pdfjsWebPreferences, root.pdfjsWebUIUtils);
|
||||
}
|
||||
}(this, function (exports, grabToPan, preferences) {
|
||||
}(this, function (exports, grabToPan, preferences, uiUtils) {
|
||||
|
||||
var GrabToPan = grabToPan.GrabToPan;
|
||||
var Preferences = preferences.Preferences;
|
||||
var localized = uiUtils.localized;
|
||||
|
||||
/**
|
||||
* @typedef {Object} HandToolOptions
|
||||
|
@ -59,13 +61,12 @@ var HandTool = (function HandToolClosure() {
|
|||
|
||||
this.eventBus.on('togglehandtool', this.toggle.bind(this));
|
||||
|
||||
this.eventBus.on('localized', function (e) {
|
||||
Preferences.get('enableHandToolOnLoad').then(function resolved(value) {
|
||||
if (value) {
|
||||
Promise.all([localized, Preferences.get('enableHandToolOnLoad')]).then(
|
||||
function resolved(values) {
|
||||
if (values[1] === true) {
|
||||
this.handTool.activate();
|
||||
}
|
||||
}.bind(this), function rejected(reason) {});
|
||||
}.bind(this));
|
||||
}.bind(this)).catch(function rejected(reason) { });
|
||||
|
||||
this.eventBus.on('presentationmodechanged', function (e) {
|
||||
if (e.switchInProgress) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue