Merge pull request #9587 from Snuffleupagus/cursorToolOnLoad
Move the `cursorToolOnLoad` preference handling into `AppOptions` (PR 9493 follow-up)
This commit is contained in:
commit
3bfc797bc7
@ -179,6 +179,9 @@ let PDFViewerApplication = {
|
|||||||
preferences.get('sidebarViewOnLoad').then(function resolved(value) {
|
preferences.get('sidebarViewOnLoad').then(function resolved(value) {
|
||||||
AppOptions.set('sidebarViewOnLoad', value);
|
AppOptions.set('sidebarViewOnLoad', value);
|
||||||
}),
|
}),
|
||||||
|
preferences.get('cursorToolOnLoad').then(function resolved(value) {
|
||||||
|
AppOptions.set('cursorToolOnLoad', value);
|
||||||
|
}),
|
||||||
preferences.get('pdfBugEnabled').then(function resolved(value) {
|
preferences.get('pdfBugEnabled').then(function resolved(value) {
|
||||||
AppOptions.set('pdfBugEnabled', value);
|
AppOptions.set('pdfBugEnabled', value);
|
||||||
}),
|
}),
|
||||||
@ -434,7 +437,7 @@ let PDFViewerApplication = {
|
|||||||
this.pdfCursorTools = new PDFCursorTools({
|
this.pdfCursorTools = new PDFCursorTools({
|
||||||
container,
|
container,
|
||||||
eventBus,
|
eventBus,
|
||||||
preferences: this.preferences,
|
cursorToolOnLoad: AppOptions.get('cursorToolOnLoad'),
|
||||||
});
|
});
|
||||||
|
|
||||||
this.toolbar = new Toolbar(appConfig.toolbar, container, eventBus,
|
this.toolbar = new Toolbar(appConfig.toolbar, container, eventBus,
|
||||||
|
@ -28,6 +28,11 @@ const OptionKind = {
|
|||||||
* compare with the format of `default_preferences.json`.
|
* compare with the format of `default_preferences.json`.
|
||||||
*/
|
*/
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
cursorToolOnLoad: {
|
||||||
|
/** @type {number} */
|
||||||
|
value: 0,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
defaultUrl: {
|
defaultUrl: {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
value: 'compressed.tracemonkey-pldi-09.pdf',
|
value: 'compressed.tracemonkey-pldi-09.pdf',
|
||||||
|
@ -25,15 +25,16 @@ const CursorTool = {
|
|||||||
* @typedef {Object} PDFCursorToolsOptions
|
* @typedef {Object} PDFCursorToolsOptions
|
||||||
* @property {HTMLDivElement} container - The document container.
|
* @property {HTMLDivElement} container - The document container.
|
||||||
* @property {EventBus} eventBus - The application event bus.
|
* @property {EventBus} eventBus - The application event bus.
|
||||||
* @property {BasePreferences} preferences - Object for reading/writing
|
* @property {number} cursorToolOnLoad - (optional) The cursor tool that will be
|
||||||
* persistent settings.
|
* enabled on load; the constants from {CursorTool} should be used.
|
||||||
|
* The default value is `CursorTool.SELECT`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class PDFCursorTools {
|
class PDFCursorTools {
|
||||||
/**
|
/**
|
||||||
* @param {PDFCursorToolsOptions} options
|
* @param {PDFCursorToolsOptions} options
|
||||||
*/
|
*/
|
||||||
constructor({ container, eventBus, preferences, }) {
|
constructor({ container, eventBus, cursorToolOnLoad = CursorTool.SELECT, }) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
@ -46,9 +47,9 @@ class PDFCursorTools {
|
|||||||
|
|
||||||
this._addEventListeners();
|
this._addEventListeners();
|
||||||
|
|
||||||
preferences.get('cursorToolOnLoad').then((value) => {
|
Promise.resolve().then(() => {
|
||||||
this.switchTool(value);
|
this.switchTool(cursorToolOnLoad);
|
||||||
}).catch(() => { });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -491,16 +491,6 @@ let animationStarted = new Promise(function (resolve) {
|
|||||||
window.requestAnimationFrame(resolve);
|
window.requestAnimationFrame(resolve);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* (deprecated) External localization service.
|
|
||||||
*/
|
|
||||||
let mozL10n;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* (deprecated) Promise that is resolved when UI localization is finished.
|
|
||||||
*/
|
|
||||||
let localized = Promise.resolve();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple event bus for an application. Listeners are attached using the
|
* Simple event bus for an application. Listeners are attached using the
|
||||||
* `on` and `off` methods. To raise an event, the `dispatch` method shall be
|
* `on` and `off` methods. To raise an event, the `dispatch` method shall be
|
||||||
@ -636,7 +626,6 @@ export {
|
|||||||
PresentationModeState,
|
PresentationModeState,
|
||||||
RendererType,
|
RendererType,
|
||||||
TextLayerMode,
|
TextLayerMode,
|
||||||
mozL10n,
|
|
||||||
NullL10n,
|
NullL10n,
|
||||||
EventBus,
|
EventBus,
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
@ -652,7 +641,6 @@ export {
|
|||||||
binarySearchFirstItem,
|
binarySearchFirstItem,
|
||||||
normalizeWheelEventDelta,
|
normalizeWheelEventDelta,
|
||||||
animationStarted,
|
animationStarted,
|
||||||
localized,
|
|
||||||
WaitOnType,
|
WaitOnType,
|
||||||
waitOnEventOrTimeout,
|
waitOnEventOrTimeout,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user