Decrease dependence of SecondaryToolbar on UI buttons
This commit is contained in:
parent
1c9fc5d7bb
commit
46d74bdc51
@ -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 },
|
||||||
|
{ 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',
|
for (var item in elements) {
|
||||||
this.presentationModeClick.bind(this));
|
var element = elements[item].element;
|
||||||
this.openFile.addEventListener('click', this.openFileClick.bind(this));
|
if (element) {
|
||||||
this.print.addEventListener('click', this.printClick.bind(this));
|
element.addEventListener('click', elements[item].handler.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));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Event handling functions.
|
// Event handling functions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user