|
|
@ -34,6 +34,9 @@ var mozL10n = uiUtils.mozL10n; |
|
|
|
* @property {HTMLDivElement} toolbar - Container for the secondary toolbar. |
|
|
|
* @property {HTMLDivElement} toolbar - Container for the secondary toolbar. |
|
|
|
* @property {HTMLButtonElement} toggleButton - Button to toggle the visibility |
|
|
|
* @property {HTMLButtonElement} toggleButton - Button to toggle the visibility |
|
|
|
* of the secondary toolbar. |
|
|
|
* of the secondary toolbar. |
|
|
|
|
|
|
|
* @property {HTMLDivElement} toolbarButtonContainer - Container where all the |
|
|
|
|
|
|
|
* toolbar buttons are placed. The maximum height of the toolbar is controlled |
|
|
|
|
|
|
|
* dynamically by adjusting the 'max-height' CSS property of this DOM element. |
|
|
|
* @property {HTMLButtonElement} presentationModeButton - Button for entering |
|
|
|
* @property {HTMLButtonElement} presentationModeButton - Button for entering |
|
|
|
* presentation mode. |
|
|
|
* presentation mode. |
|
|
|
* @property {HTMLButtonElement} openFileButton - Button to open a file. |
|
|
|
* @property {HTMLButtonElement} openFileButton - Button to open a file. |
|
|
@ -63,11 +66,13 @@ var SecondaryToolbar = (function SecondaryToolbarClosure() { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @constructs SecondaryToolbar |
|
|
|
* @constructs SecondaryToolbar |
|
|
|
* @param {SecondaryToolbarOptions} options |
|
|
|
* @param {SecondaryToolbarOptions} options |
|
|
|
|
|
|
|
* @param {HTMLDivElement} mainContainer |
|
|
|
* @param {EventBus} eventBus |
|
|
|
* @param {EventBus} eventBus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function SecondaryToolbar(options, eventBus) { |
|
|
|
function SecondaryToolbar(options, mainContainer, eventBus) { |
|
|
|
this.toolbar = options.toolbar; |
|
|
|
this.toolbar = options.toolbar; |
|
|
|
this.toggleButton = options.toggleButton; |
|
|
|
this.toggleButton = options.toggleButton; |
|
|
|
|
|
|
|
this.toolbarButtonContainer = options.toolbarButtonContainer; |
|
|
|
this.buttons = [ |
|
|
|
this.buttons = [ |
|
|
|
{ element: options.presentationModeButton, eventName: 'presentationmode', |
|
|
|
{ element: options.presentationModeButton, eventName: 'presentationmode', |
|
|
|
close: true }, |
|
|
|
close: true }, |
|
|
@ -87,16 +92,19 @@ var SecondaryToolbar = (function SecondaryToolbarClosure() { |
|
|
|
eventName: 'documentproperties', close: true } |
|
|
|
eventName: 'documentproperties', close: true } |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.mainContainer = mainContainer; |
|
|
|
this.eventBus = eventBus; |
|
|
|
this.eventBus = eventBus; |
|
|
|
|
|
|
|
|
|
|
|
this.opened = false; |
|
|
|
this.opened = false; |
|
|
|
|
|
|
|
this.containerHeight = null; |
|
|
|
this.previousContainerHeight = null; |
|
|
|
this.previousContainerHeight = null; |
|
|
|
this.newContainerHeight = null; |
|
|
|
|
|
|
|
this.buttonContainer = this.toolbar.firstElementChild; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bind the event listeners for click and hand tool actions.
|
|
|
|
// Bind the event listeners for click and hand tool actions.
|
|
|
|
this._bindClickListeners(); |
|
|
|
this._bindClickListeners(); |
|
|
|
this._bindHandToolListener(options.toggleHandToolButton); |
|
|
|
this._bindHandToolListener(options.toggleHandToolButton); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bind the event listener for adjusting the 'max-height' of the toolbar.
|
|
|
|
|
|
|
|
this.eventBus.on('resize', this._setMaxHeight.bind(this)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SecondaryToolbar.prototype = { |
|
|
|
SecondaryToolbar.prototype = { |
|
|
@ -119,7 +127,7 @@ var SecondaryToolbar = (function SecondaryToolbarClosure() { |
|
|
|
|
|
|
|
|
|
|
|
element.addEventListener('click', function (eventName, close) { |
|
|
|
element.addEventListener('click', function (eventName, close) { |
|
|
|
if (eventName !== null) { |
|
|
|
if (eventName !== null) { |
|
|
|
this.eventBus.dispatch(eventName); |
|
|
|
this.eventBus.dispatch(eventName, { source: this, }); |
|
|
|
} |
|
|
|
} |
|
|
|
if (close) { |
|
|
|
if (close) { |
|
|
|
this.close(); |
|
|
|
this.close(); |
|
|
@ -155,6 +163,8 @@ var SecondaryToolbar = (function SecondaryToolbarClosure() { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.opened = true; |
|
|
|
this.opened = true; |
|
|
|
|
|
|
|
this._setMaxHeight(); |
|
|
|
|
|
|
|
|
|
|
|
this.toggleButton.classList.add('toggled'); |
|
|
|
this.toggleButton.classList.add('toggled'); |
|
|
|
this.toolbar.classList.remove('hidden'); |
|
|
|
this.toolbar.classList.remove('hidden'); |
|
|
|
}, |
|
|
|
}, |
|
|
@ -176,18 +186,22 @@ var SecondaryToolbar = (function SecondaryToolbarClosure() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
setMaxHeight: function SecondaryToolbar_setMaxHeight(container) { |
|
|
|
/** |
|
|
|
if (!container || !this.buttonContainer) { |
|
|
|
* @private |
|
|
|
return; |
|
|
|
*/ |
|
|
|
|
|
|
|
_setMaxHeight: function SecondaryToolbar_setMaxHeight() { |
|
|
|
|
|
|
|
if (!this.opened) { |
|
|
|
|
|
|
|
return; // Only adjust the 'max-height' if the toolbar is visible.
|
|
|
|
} |
|
|
|
} |
|
|
|
this.newContainerHeight = container.clientHeight; |
|
|
|
this.containerHeight = this.mainContainer.clientHeight; |
|
|
|
if (this.previousContainerHeight === this.newContainerHeight) { |
|
|
|
|
|
|
|
|
|
|
|
if (this.containerHeight === this.previousContainerHeight) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var maxHeight = this.newContainerHeight - SCROLLBAR_PADDING; |
|
|
|
this.toolbarButtonContainer.setAttribute('style', |
|
|
|
this.buttonContainer.setAttribute('style', |
|
|
|
'max-height: ' + (this.containerHeight - SCROLLBAR_PADDING) + 'px;'); |
|
|
|
'max-height: ' + maxHeight + 'px;'); |
|
|
|
|
|
|
|
this.previousContainerHeight = this.newContainerHeight; |
|
|
|
this.previousContainerHeight = this.containerHeight; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|