Browse Source

Decrease dependence of SecondaryToolbar on UI buttons

Tim van der Meij 12 years ago
parent
commit
46d74bdc51
  1. 36
      web/secondary_toolbar.js

36
web/secondary_toolbar.js

@ -25,11 +25,10 @@ var SecondaryToolbar = {
initialize: function secondaryToolbarInitialize(options) { initialize: function secondaryToolbarInitialize(options) {
this.toolbar = options.toolbar; this.toolbar = options.toolbar;
this.toggleButton = options.toggleButton;
this.buttonContainer = this.toolbar.firstElementChild; this.buttonContainer = this.toolbar.firstElementChild;
// Define the toolbar buttons. // Define the toolbar buttons.
this.toggleButton = options.toggleButton;
this.presentationMode = options.presentationMode; this.presentationMode = options.presentationMode;
this.openFile = options.openFile; this.openFile = options.openFile;
this.print = options.print; this.print = options.print;
@ -40,21 +39,24 @@ var SecondaryToolbar = {
this.pageRotateCcw = options.pageRotateCcw; this.pageRotateCcw = options.pageRotateCcw;
// Attach the event listeners. // Attach the event listeners.
this.toggleButton.addEventListener('click', this.toggle.bind(this)); var elements = [
{ element: this.toggleButton, handler: this.toggle },
this.presentationMode.addEventListener('click', { element: this.presentationMode, handler: this.presentationModeClick },
this.presentationModeClick.bind(this)); { element: this.openFile, handler: this.openFileClick },
this.openFile.addEventListener('click', this.openFileClick.bind(this)); { element: this.print, handler: this.printClick },
this.print.addEventListener('click', this.printClick.bind(this)); { element: this.download, handler: this.downloadClick },
this.download.addEventListener('click', this.downloadClick.bind(this)); { element: this.firstPage, handler: this.firstPageClick },
{ element: this.lastPage, handler: this.lastPageClick },
this.firstPage.addEventListener('click', this.firstPageClick.bind(this)); { element: this.pageRotateCw, handler: this.pageRotateCwClick },
this.lastPage.addEventListener('click', this.lastPageClick.bind(this)); { element: this.pageRotateCcw, handler: this.pageRotateCcwClick }
];
this.pageRotateCw.addEventListener('click',
this.pageRotateCwClick.bind(this)); for (var item in elements) {
this.pageRotateCcw.addEventListener('click', var element = elements[item].element;
this.pageRotateCcwClick.bind(this)); if (element) {
element.addEventListener('click', elements[item].handler.bind(this));
}
}
}, },
// Event handling functions. // Event handling functions.

Loading…
Cancel
Save