Decrease dependence of SecondaryToolbar on UI buttons

This commit is contained in:
Tim van der Meij 2013-10-17 23:49:30 +02:00
parent 1c9fc5d7bb
commit 46d74bdc51

View File

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