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