A few small tweaks of the SecondaryToolbar code
This commit is contained in:
parent
26fb376b65
commit
bee1b734c2
@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFView, PresentationMode, SCROLLBAR_PADDING */
|
||||
/* globals PDFView, SCROLLBAR_PADDING */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -25,11 +25,12 @@ var SecondaryToolbar = {
|
||||
|
||||
initialize: function secondaryToolbarInitialize(options) {
|
||||
this.toolbar = options.toolbar;
|
||||
this.presentationMode = options.presentationMode;
|
||||
this.buttonContainer = this.toolbar.firstElementChild;
|
||||
|
||||
// Define the toolbar buttons.
|
||||
this.toggleButton = options.toggleButton;
|
||||
this.presentationMode = options.presentationMode;
|
||||
this.presentationModeButton = options.presentationModeButton;
|
||||
this.openFile = options.openFile;
|
||||
this.print = options.print;
|
||||
this.download = options.download;
|
||||
@ -41,7 +42,8 @@ var SecondaryToolbar = {
|
||||
// Attach the event listeners.
|
||||
var elements = [
|
||||
{ element: this.toggleButton, handler: this.toggle },
|
||||
{ element: this.presentationMode, handler: this.presentationModeClick },
|
||||
{ element: this.presentationModeButton,
|
||||
handler: this.presentationModeClick },
|
||||
{ element: this.openFile, handler: this.openFileClick },
|
||||
{ element: this.print, handler: this.printClick },
|
||||
{ element: this.download, handler: this.downloadClick },
|
||||
@ -61,7 +63,7 @@ var SecondaryToolbar = {
|
||||
|
||||
// Event handling functions.
|
||||
presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {
|
||||
PresentationMode.request();
|
||||
this.presentationMode.request();
|
||||
this.close();
|
||||
},
|
||||
|
||||
@ -98,7 +100,7 @@ var SecondaryToolbar = {
|
||||
|
||||
// Misc. functions for interacting with the toolbar.
|
||||
setMaxHeight: function secondaryToolbarSetMaxHeight(container) {
|
||||
if (!container) {
|
||||
if (!container || !this.buttonContainer) {
|
||||
return;
|
||||
}
|
||||
this.newContainerHeight = container.clientHeight;
|
||||
@ -136,9 +138,5 @@ var SecondaryToolbar = {
|
||||
} else {
|
||||
this.open();
|
||||
}
|
||||
},
|
||||
|
||||
get isOpen() {
|
||||
return this.opened;
|
||||
}
|
||||
};
|
||||
|
@ -138,8 +138,10 @@ var PDFView = {
|
||||
|
||||
SecondaryToolbar.initialize({
|
||||
toolbar: document.getElementById('secondaryToolbar'),
|
||||
presentationMode: PresentationMode,
|
||||
toggleButton: document.getElementById('secondaryToolbarToggle'),
|
||||
presentationMode: document.getElementById('secondaryPresentationMode'),
|
||||
presentationModeButton:
|
||||
document.getElementById('secondaryPresentationMode'),
|
||||
openFile: document.getElementById('secondaryOpenFile'),
|
||||
print: document.getElementById('secondaryPrint'),
|
||||
download: document.getElementById('secondaryDownload'),
|
||||
@ -1918,7 +1920,7 @@ window.addEventListener('DOMMouseScroll', function(evt) {
|
||||
|
||||
window.addEventListener('click', function click(evt) {
|
||||
if (!PresentationMode.active) {
|
||||
if (SecondaryToolbar.isOpen && PDFView.container.contains(evt.target)) {
|
||||
if (SecondaryToolbar.opened && PDFView.container.contains(evt.target)) {
|
||||
SecondaryToolbar.close();
|
||||
}
|
||||
} else if (evt.button === 0) {
|
||||
@ -2037,7 +2039,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
||||
handled = true;
|
||||
break;
|
||||
case 27: // esc key
|
||||
if (SecondaryToolbar.isOpen) {
|
||||
if (SecondaryToolbar.opened) {
|
||||
SecondaryToolbar.close();
|
||||
handled = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user