mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Secondary toolbar
This commit is contained in:
parent
189d444ded
commit
3c0ac37292
28 changed files with 801 additions and 283 deletions
BIN
web/images/secondaryToolbarButton-firstPage.png
Normal file
BIN
web/images/secondaryToolbarButton-firstPage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
web/images/secondaryToolbarButton-lastPage.png
Normal file
BIN
web/images/secondaryToolbarButton-lastPage.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
web/images/secondaryToolbarButton-rotateCcw.png
Normal file
BIN
web/images/secondaryToolbarButton-rotateCcw.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
BIN
web/images/secondaryToolbarButton-rotateCw.png
Normal file
BIN
web/images/secondaryToolbarButton-rotateCw.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
BIN
web/images/toolbarButton-secondaryToolbarToggle.png
Normal file
BIN
web/images/toolbarButton-secondaryToolbarToggle.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 302 B |
139
web/secondary_toolbar.js
Normal file
139
web/secondary_toolbar.js
Normal file
|
@ -0,0 +1,139 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
/* Copyright 2012 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFView, SCROLLBAR_PADDING */
|
||||
|
||||
'use strict';
|
||||
|
||||
var SecondaryToolbar = {
|
||||
opened: false,
|
||||
previousContainerHeight: null,
|
||||
newContainerHeight: null,
|
||||
|
||||
initialize: function secondaryToolbarInitialize(options) {
|
||||
this.toolbar = options.toolbar;
|
||||
this.toggleButton = options.toggleButton;
|
||||
|
||||
this.buttonContainer = this.toolbar.firstElementChild;
|
||||
|
||||
// Define the toolbar buttons.
|
||||
this.presentationMode = options.presentationMode;
|
||||
this.openFile = options.openFile;
|
||||
this.print = options.print;
|
||||
this.download = options.download;
|
||||
this.firstPage = options.firstPage;
|
||||
this.lastPage = options.lastPage;
|
||||
this.pageRotateCw = options.pageRotateCw;
|
||||
this.pageRotateCcw = options.pageRotateCcw;
|
||||
|
||||
// Attach the event listeners.
|
||||
this.toggleButton.addEventListener('click', this.toggle.bind(this));
|
||||
|
||||
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));
|
||||
},
|
||||
|
||||
// Event handling functions.
|
||||
presentationModeClick: function secondaryToolbarPresentationModeClick(evt) {
|
||||
PDFView.presentationMode();
|
||||
this.close();
|
||||
},
|
||||
|
||||
openFileClick: function secondaryToolbarOpenFileClick(evt) {
|
||||
document.getElementById('fileInput').click();
|
||||
this.close(evt.target);
|
||||
},
|
||||
|
||||
printClick: function secondaryToolbarPrintClick(evt) {
|
||||
window.print();
|
||||
this.close(evt.target);
|
||||
},
|
||||
|
||||
downloadClick: function secondaryToolbarDownloadClick(evt) {
|
||||
PDFView.download();
|
||||
this.close(evt.target);
|
||||
},
|
||||
|
||||
firstPageClick: function secondaryToolbarFirstPageClick(evt) {
|
||||
PDFView.page = 1;
|
||||
},
|
||||
|
||||
lastPageClick: function secondaryToolbarLastPageClick(evt) {
|
||||
PDFView.page = PDFView.pdfDocument.numPages;
|
||||
},
|
||||
|
||||
pageRotateCwClick: function secondaryToolbarPageRotateCwClick(evt) {
|
||||
PDFView.rotatePages(90);
|
||||
},
|
||||
|
||||
pageRotateCcwClick: function secondaryToolbarPageRotateCcwClick(evt) {
|
||||
PDFView.rotatePages(-90);
|
||||
},
|
||||
|
||||
// Misc. functions for interacting with the toolbar.
|
||||
setMaxHeight: function secondaryToolbarSetMaxHeight(container) {
|
||||
this.newContainerHeight = container.clientHeight;
|
||||
if (this.previousContainerHeight === this.newContainerHeight) {
|
||||
return;
|
||||
}
|
||||
this.buttonContainer.setAttribute('style',
|
||||
'max-height: ' + (this.newContainerHeight - SCROLLBAR_PADDING) + 'px;');
|
||||
this.previousContainerHeight = this.newContainerHeight;
|
||||
},
|
||||
|
||||
open: function secondaryToolbarOpen() {
|
||||
if (this.opened) {
|
||||
return;
|
||||
}
|
||||
this.opened = true;
|
||||
this.toggleButton.classList.add('toggled');
|
||||
this.toolbar.classList.remove('hidden');
|
||||
},
|
||||
|
||||
close: function secondaryToolbarClose(target) {
|
||||
if (!this.opened) {
|
||||
return;
|
||||
} else if (target && !this.toolbar.contains(target)) {
|
||||
return;
|
||||
}
|
||||
this.opened = false;
|
||||
this.toolbar.classList.add('hidden');
|
||||
this.toggleButton.classList.remove('toggled');
|
||||
},
|
||||
|
||||
toggle: function secondaryToolbarToggle() {
|
||||
if (this.opened) {
|
||||
this.close();
|
||||
} else {
|
||||
this.open();
|
||||
}
|
||||
},
|
||||
|
||||
get isOpen() {
|
||||
return this.opened;
|
||||
}
|
||||
};
|
277
web/viewer.css
277
web/viewer.css
|
@ -36,7 +36,7 @@ select {
|
|||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
display: none !important;
|
||||
}
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
|
@ -75,7 +75,6 @@ select {
|
|||
cursor: none;
|
||||
}
|
||||
|
||||
|
||||
:-webkit-full-screen .page {
|
||||
margin-bottom: 100%;
|
||||
}
|
||||
|
@ -241,7 +240,7 @@ html[dir='rtl'] #sidebarContent {
|
|||
0 0 1px hsla(0,0%,0%,.1);
|
||||
}
|
||||
|
||||
#toolbarContainer, .findbar {
|
||||
#toolbarContainer, .findbar, .secondaryToolbar {
|
||||
position: relative;
|
||||
height: 32px;
|
||||
background-color: #474747; /* fallback */
|
||||
|
@ -311,7 +310,7 @@ html[dir='rtl'] #sidebarContent {
|
|||
animation: progressIndeterminate 2s linear infinite;
|
||||
}
|
||||
|
||||
.findbar {
|
||||
.findbar, .secondaryToolbar {
|
||||
top: 32px;
|
||||
position: absolute;
|
||||
z-index: 10000;
|
||||
|
@ -346,12 +345,32 @@ html[dir='rtl'] .findbar {
|
|||
background-position: right;
|
||||
}
|
||||
|
||||
.doorHanger {
|
||||
.secondaryToolbar {
|
||||
padding: 6px;
|
||||
height: auto;
|
||||
z-index: 30000;
|
||||
}
|
||||
html[dir='ltr'] .secondaryToolbar {
|
||||
right: 4px;
|
||||
}
|
||||
html[dir='rtl'] .secondaryToolbar {
|
||||
left: 4px;
|
||||
}
|
||||
|
||||
#secondaryToolbarButtonContainer {
|
||||
max-width: 200px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.doorHanger,
|
||||
.doorHangerRight {
|
||||
border: 1px solid hsla(0,0%,0%,.5);
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.doorHanger:after, .doorHanger:before {
|
||||
.doorHanger:after, .doorHanger:before,
|
||||
.doorHangerRight:after, .doorHangerRight:before {
|
||||
bottom: 100%;
|
||||
border: solid transparent;
|
||||
content: " ";
|
||||
|
@ -360,31 +379,37 @@ html[dir='rtl'] .findbar {
|
|||
position: absolute;
|
||||
pointer-events: none;
|
||||
}
|
||||
.doorHanger:after {
|
||||
.doorHanger:after,
|
||||
.doorHangerRight:after {
|
||||
border-bottom-color: hsla(0,0%,32%,.99);
|
||||
border-width: 8px;
|
||||
}
|
||||
.doorHanger:before {
|
||||
.doorHanger:before,
|
||||
.doorHangerRight:before {
|
||||
border-bottom-color: hsla(0,0%,0%,.5);
|
||||
border-width: 9px;
|
||||
}
|
||||
|
||||
html[dir='ltr'] .doorHanger:after {
|
||||
html[dir='ltr'] .doorHanger:after,
|
||||
html[dir='rtl'] .doorHangerRight:after {
|
||||
left: 13px;
|
||||
margin-left: -8px;
|
||||
}
|
||||
|
||||
html[dir='ltr'] .doorHanger:before {
|
||||
html[dir='ltr'] .doorHanger:before,
|
||||
html[dir='rtl'] .doorHangerRight:before {
|
||||
left: 13px;
|
||||
margin-left: -9px;
|
||||
}
|
||||
|
||||
html[dir='rtl'] .doorHanger:after {
|
||||
html[dir='rtl'] .doorHanger:after,
|
||||
html[dir='ltr'] .doorHangerRight:after {
|
||||
right: 13px;
|
||||
margin-right: -8px;
|
||||
}
|
||||
|
||||
html[dir='rtl'] .doorHanger:before {
|
||||
html[dir='rtl'] .doorHanger:before,
|
||||
html[dir='ltr'] .doorHangerRight:before {
|
||||
right: 13px;
|
||||
margin-right: -9px;
|
||||
}
|
||||
|
@ -450,7 +475,8 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton {
|
|||
float: right;
|
||||
}
|
||||
|
||||
.toolbarButton {
|
||||
.toolbarButton,
|
||||
.secondaryToolbarButton {
|
||||
border: 0 none;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
width: 32px;
|
||||
|
@ -464,7 +490,8 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton {
|
|||
overflow: hidden;
|
||||
}
|
||||
|
||||
.toolbarButton[disabled] {
|
||||
.toolbarButton[disabled],
|
||||
.secondaryToolbarButton[disabled] {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
|
@ -528,7 +555,7 @@ html[dir='rtl'] .splitToolbarButton > .toolbarButton:first-child {
|
|||
.splitToolbarButtonSeparator {
|
||||
padding: 8px 0;
|
||||
width: 1px;
|
||||
background-color: hsla(0,0%,00%,.5);
|
||||
background-color: hsla(0,0%,0%,.5);
|
||||
z-index: 99;
|
||||
box-shadow: 0 0 0 1px hsla(0,0%,100%,.08);
|
||||
display: inline-block;
|
||||
|
@ -554,12 +581,13 @@ html[dir='rtl'] .splitToolbarButtonSeparator {
|
|||
}
|
||||
|
||||
.toolbarButton,
|
||||
.dropdownToolbarButton {
|
||||
.dropdownToolbarButton,
|
||||
.secondaryToolbarButton {
|
||||
min-width: 16px;
|
||||
padding: 2px 6px 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 2px;
|
||||
color: hsl(0,0%,95%);
|
||||
color: hsla(0,0%,100%,.8);
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
-webkit-user-select: none;
|
||||
|
@ -586,7 +614,9 @@ html[dir='rtl'] .dropdownToolbarButton {
|
|||
|
||||
.toolbarButton:hover,
|
||||
.toolbarButton:focus,
|
||||
.dropdownToolbarButton {
|
||||
.dropdownToolbarButton,
|
||||
.secondaryToolbarButton:hover,
|
||||
.secondaryToolbarButton:focus {
|
||||
background-color: hsla(0,0%,0%,.12);
|
||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
background-clip: padding-box;
|
||||
|
@ -598,7 +628,8 @@ html[dir='rtl'] .dropdownToolbarButton {
|
|||
}
|
||||
|
||||
.toolbarButton:hover:active,
|
||||
.dropdownToolbarButton:hover:active {
|
||||
.dropdownToolbarButton:hover:active,
|
||||
.secondaryToolbarButton:hover:active {
|
||||
background-color: hsla(0,0%,0%,.2);
|
||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
border-color: hsla(0,0%,0%,.35) hsla(0,0%,0%,.4) hsla(0,0%,0%,.45);
|
||||
|
@ -614,7 +645,8 @@ html[dir='rtl'] .dropdownToolbarButton {
|
|||
}
|
||||
|
||||
.toolbarButton.toggled,
|
||||
.splitToolbarButton.toggled > .toolbarButton.toggled {
|
||||
.splitToolbarButton.toggled > .toolbarButton.toggled,
|
||||
.secondaryToolbarButton.toggled {
|
||||
background-color: hsla(0,0%,0%,.3);
|
||||
background-image: linear-gradient(hsla(0,0%,100%,.05), hsla(0,0%,100%,0));
|
||||
border-color: hsla(0,0%,0%,.4) hsla(0,0%,0%,.45) hsla(0,0%,0%,.5);
|
||||
|
@ -630,7 +662,8 @@ html[dir='rtl'] .dropdownToolbarButton {
|
|||
}
|
||||
|
||||
.toolbarButton.toggled:hover:active,
|
||||
.splitToolbarButton.toggled > .toolbarButton.toggled:hover:active {
|
||||
.splitToolbarButton.toggled > .toolbarButton.toggled:hover:active,
|
||||
.secondaryToolbarButton.toggled:hover:active {
|
||||
background-color: hsla(0,0%,0%,.4);
|
||||
border-color: hsla(0,0%,0%,.4) hsla(0,0%,0%,.5) hsla(0,0%,0%,.55);
|
||||
box-shadow: 0 1px 1px hsla(0,0%,0%,.2) inset,
|
||||
|
@ -701,11 +734,6 @@ html[dir='rtl'] .toolbarButton:first-child {
|
|||
min-width: 30px;
|
||||
}
|
||||
|
||||
.toolbarButton#sidebarToggle::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-sidebarToggle.png);
|
||||
}
|
||||
|
||||
html[dir='ltr'] #findPrevious {
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
@ -719,83 +747,96 @@ html[dir='rtl'] #findPrevious {
|
|||
html[dir='rtl'] #findNext {
|
||||
margin-left: 3px;
|
||||
}
|
||||
.toolbarButton::before {
|
||||
|
||||
.toolbarButton::before,
|
||||
.secondaryToolbarButton::before {
|
||||
/* All matching images have a size of 16x16
|
||||
* (except for the print button: 18x16)
|
||||
* All relevant containers have a size of 32x25 */
|
||||
position: absolute;
|
||||
display: inline-block;
|
||||
top: 4px;
|
||||
left: 7px;
|
||||
}
|
||||
html[dir="ltr"] .secondaryToolbarButton::before {
|
||||
left: 4px;
|
||||
}
|
||||
html[dir="rtl"] .secondaryToolbarButton::before {
|
||||
right: 4px;
|
||||
}
|
||||
|
||||
.toolbarButton#sidebarToggle::before {
|
||||
content: url(images/toolbarButton-sidebarToggle.png);
|
||||
}
|
||||
|
||||
.toolbarButton#secondaryToolbarToggle::before {
|
||||
content: url(images/toolbarButton-secondaryToolbarToggle.png);
|
||||
}
|
||||
|
||||
html[dir='ltr'] .toolbarButton.findPrevious::before {
|
||||
display: inline-block;
|
||||
content: url(images/findbarButton-previous.png);
|
||||
}
|
||||
|
||||
html[dir='rtl'] .toolbarButton.findPrevious::before {
|
||||
display: inline-block;
|
||||
content: url(images/findbarButton-previous-rtl.png);
|
||||
}
|
||||
|
||||
html[dir='ltr'] .toolbarButton.findNext::before {
|
||||
display: inline-block;
|
||||
content: url(images/findbarButton-next.png);
|
||||
}
|
||||
|
||||
html[dir='rtl'] .toolbarButton.findNext::before {
|
||||
display: inline-block;
|
||||
content: url(images/findbarButton-next-rtl.png);
|
||||
}
|
||||
|
||||
html[dir='ltr'] .toolbarButton.pageUp::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-pageUp.png);
|
||||
}
|
||||
|
||||
html[dir='rtl'] .toolbarButton.pageUp::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-pageUp-rtl.png);
|
||||
}
|
||||
|
||||
html[dir='ltr'] .toolbarButton.pageDown::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-pageDown.png);
|
||||
}
|
||||
|
||||
html[dir='rtl'] .toolbarButton.pageDown::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-pageDown-rtl.png);
|
||||
}
|
||||
|
||||
.toolbarButton.zoomOut::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-zoomOut.png);
|
||||
}
|
||||
|
||||
.toolbarButton.zoomIn::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-zoomIn.png);
|
||||
}
|
||||
|
||||
.toolbarButton.presentationMode::before {
|
||||
display: inline-block;
|
||||
.toolbarButton.presentationMode::before,
|
||||
.secondaryToolbarButton.presentationMode::before {
|
||||
content: url(images/toolbarButton-presentationMode.png);
|
||||
}
|
||||
|
||||
.toolbarButton.print::before {
|
||||
display: inline-block;
|
||||
.toolbarButton.print::before,
|
||||
.secondaryToolbarButton.print::before {
|
||||
content: url(images/toolbarButton-print.png);
|
||||
left: 6px;
|
||||
}
|
||||
html[dir="ltr"] .secondaryToolbarButton.print::before {
|
||||
left: 3px;
|
||||
}
|
||||
html[dir="rtl"] .secondaryToolbarButton.print::before {
|
||||
right: 3px;
|
||||
}
|
||||
|
||||
.toolbarButton.openFile::before {
|
||||
display: inline-block;
|
||||
.toolbarButton.openFile::before,
|
||||
.secondaryToolbarButton.openFile::before {
|
||||
content: url(images/toolbarButton-openFile.png);
|
||||
}
|
||||
|
||||
.toolbarButton.download::before {
|
||||
display: inline-block;
|
||||
.toolbarButton.download::before,
|
||||
.secondaryToolbarButton.download::before {
|
||||
content: url(images/toolbarButton-download.png);
|
||||
}
|
||||
|
||||
|
@ -817,20 +858,86 @@ html[dir='rtl'] .toolbarButton.pageDown::before {
|
|||
}
|
||||
|
||||
#viewThumbnail.toolbarButton::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-viewThumbnail.png);
|
||||
}
|
||||
|
||||
#viewOutline.toolbarButton::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-viewOutline.png);
|
||||
}
|
||||
|
||||
#viewFind.toolbarButton::before {
|
||||
display: inline-block;
|
||||
content: url(images/toolbarButton-search.png);
|
||||
}
|
||||
|
||||
.secondaryToolbarButton {
|
||||
position: relative;
|
||||
margin: 0 0 4px 0;
|
||||
padding: 3px 0 1px 0;
|
||||
height: auto;
|
||||
min-height: 25px;
|
||||
width: auto;
|
||||
min-width: 100%;
|
||||
white-space: normal;
|
||||
}
|
||||
html[dir="ltr"] .secondaryToolbarButton {
|
||||
padding-left: 24px;
|
||||
text-align: left;
|
||||
}
|
||||
html[dir="rtl"] .secondaryToolbarButton {
|
||||
padding-right: 24px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#secondaryToolbarButtonContainer :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
html[dir="ltr"] .secondaryToolbarButton > span {
|
||||
padding-right: 4px;
|
||||
}
|
||||
html[dir="rtl"] .secondaryToolbarButton > span {
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.secondaryToolbarButton.firstPage::before {
|
||||
content: url(images/secondaryToolbarButton-firstPage.png);
|
||||
}
|
||||
|
||||
.secondaryToolbarButton.lastPage::before {
|
||||
content: url(images/secondaryToolbarButton-lastPage.png);
|
||||
}
|
||||
|
||||
.secondaryToolbarButton.rotateCcw::before {
|
||||
content: url(images/secondaryToolbarButton-rotateCcw.png);
|
||||
}
|
||||
|
||||
.secondaryToolbarButton.rotateCw::before {
|
||||
content: url(images/secondaryToolbarButton-rotateCw.png);
|
||||
}
|
||||
|
||||
.verticalToolbarSeparator {
|
||||
display: block;
|
||||
padding: 8px 0;
|
||||
margin: 8px 4px;
|
||||
width: 1px;
|
||||
background-color: hsla(0,0%,0%,.5);
|
||||
box-shadow: 0 0 0 1px hsla(0,0%,100%,.08);
|
||||
}
|
||||
html[dir='ltr'] .verticalToolbarSeparator {
|
||||
margin-left: 2px;
|
||||
}
|
||||
html[dir='rtl'] .verticalToolbarSeparator {
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.horizontalToolbarSeparator {
|
||||
display: block;
|
||||
margin: 0 0 4px 0;
|
||||
height: 1px;
|
||||
width: 100%;
|
||||
background-color: hsla(0,0%,0%,.5);
|
||||
box-shadow: 0 0 0 1px hsla(0,0%,100%,.08);
|
||||
}
|
||||
|
||||
.toolbarField {
|
||||
padding: 3px 6px;
|
||||
|
@ -1276,7 +1383,7 @@ canvas {
|
|||
}
|
||||
|
||||
/* Rules for browsers that don't support mozPrintCallback. */
|
||||
#sidebarContainer, .toolbar, #loadingBox, #errorWrapper, .textLayer {
|
||||
#sidebarContainer, #secondaryToolbar, .toolbar, #loadingBox, #errorWrapper, .textLayer {
|
||||
display: none;
|
||||
}
|
||||
#viewerContainer {
|
||||
|
@ -1314,16 +1421,40 @@ canvas {
|
|||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 950px) {
|
||||
.visibleLargeView,
|
||||
.visibleMediumView,
|
||||
.visibleSmallView {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media all and (max-width: 960px) {
|
||||
html[dir='ltr'] #outerContainer.sidebarMoving .outerCenter,
|
||||
html[dir='ltr'] #outerContainer.sidebarOpen .outerCenter {
|
||||
float: left;
|
||||
left: 180px;
|
||||
left: 185px;
|
||||
}
|
||||
html[dir='rtl'] #outerContainer.sidebarMoving .outerCenter,
|
||||
html[dir='rtl'] #outerContainer.sidebarOpen .outerCenter {
|
||||
float: right;
|
||||
right: 180px;
|
||||
right: 185px;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 900px) {
|
||||
.sidebarOpen .hiddenLargeView {
|
||||
display: none;
|
||||
}
|
||||
.sidebarOpen .visibleLargeView {
|
||||
display: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 860px) {
|
||||
.sidebarOpen .hiddenMediumView {
|
||||
display: none;
|
||||
}
|
||||
.sidebarOpen .visibleMediumView {
|
||||
display: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1349,11 +1480,38 @@ canvas {
|
|||
|
||||
html[dir='ltr'] .outerCenter {
|
||||
float: left;
|
||||
left: 180px;
|
||||
left: 185px;
|
||||
}
|
||||
html[dir='rtl'] .outerCenter {
|
||||
float: right;
|
||||
right: 180px;
|
||||
right: 185px;
|
||||
}
|
||||
|
||||
#outerContainer .hiddenLargeView,
|
||||
#outerContainer .hiddenMediumView {
|
||||
display: inherit;
|
||||
}
|
||||
#outerContainer .visibleLargeView,
|
||||
#outerContainer .visibleMediumView {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 700px) {
|
||||
#outerContainer .hiddenLargeView {
|
||||
display: none;
|
||||
}
|
||||
#outerContainer .visibleLargeView {
|
||||
display: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 660px) {
|
||||
#outerContainer .hiddenMediumView {
|
||||
display: none;
|
||||
}
|
||||
#outerContainer .visibleMediumView {
|
||||
display: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1361,10 +1519,17 @@ canvas {
|
|||
.hiddenSmallView {
|
||||
display: none;
|
||||
}
|
||||
.visibleSmallView {
|
||||
display: inherit;
|
||||
}
|
||||
html[dir='ltr'] #outerContainer.sidebarMoving .outerCenter,
|
||||
html[dir='ltr'] #outerContainer.sidebarOpen .outerCenter,
|
||||
html[dir='ltr'] .outerCenter {
|
||||
left: 156px;
|
||||
}
|
||||
html[dir='rtr'] .outerCenter {
|
||||
html[dir='rtl'] #outerContainer.sidebarMoving .outerCenter,
|
||||
html[dir='rtl'] #outerContainer.sidebarOpen .outerCenter,
|
||||
html[dir='rtl'] .outerCenter {
|
||||
right: 156px;
|
||||
}
|
||||
.toolbarButtonSpacer {
|
||||
|
@ -1372,7 +1537,7 @@ canvas {
|
|||
}
|
||||
}
|
||||
|
||||
@media all and (max-width: 500px) {
|
||||
@media all and (max-width: 510px) {
|
||||
#scaleSelectContainer, #pageNumberLabel {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ limitations under the License.
|
|||
<script type="text/javascript" src="pdf_find_bar.js"></script>
|
||||
<script type="text/javascript" src="pdf_find_controller.js"></script>
|
||||
<script type="text/javascript" src="pdf_history.js"></script>
|
||||
<script type="text/javascript" src="secondary_toolbar.js"></script>
|
||||
<!--#endif-->
|
||||
|
||||
<script type="text/javascript" src="debugger.js"></script>
|
||||
|
@ -97,22 +98,61 @@ limitations under the License.
|
|||
<div id="mainContainer">
|
||||
<div class="findbar hidden doorHanger hiddenSmallView" id="findbar">
|
||||
<label for="findInput" class="toolbarLabel" data-l10n-id="find_label">Find:</label>
|
||||
<input id="findInput" class="toolbarField" tabindex="21">
|
||||
<input id="findInput" class="toolbarField" tabindex="41">
|
||||
<div class="splitToolbarButton">
|
||||
<button class="toolbarButton findPrevious" title="" id="findPrevious" tabindex="22" data-l10n-id="find_previous">
|
||||
<button class="toolbarButton findPrevious" title="" id="findPrevious" tabindex="42" data-l10n-id="find_previous">
|
||||
<span data-l10n-id="find_previous_label">Previous</span>
|
||||
</button>
|
||||
<div class="splitToolbarButtonSeparator"></div>
|
||||
<button class="toolbarButton findNext" title="" id="findNext" tabindex="23" data-l10n-id="find_next">
|
||||
<button class="toolbarButton findNext" title="" id="findNext" tabindex="43" data-l10n-id="find_next">
|
||||
<span data-l10n-id="find_next_label">Next</span>
|
||||
</button>
|
||||
</div>
|
||||
<input type="checkbox" id="findHighlightAll" class="toolbarField">
|
||||
<label for="findHighlightAll" class="toolbarLabel" tabindex="24" data-l10n-id="find_highlight">Highlight all</label>
|
||||
<label for="findHighlightAll" class="toolbarLabel" tabindex="44" data-l10n-id="find_highlight">Highlight all</label>
|
||||
<input type="checkbox" id="findMatchCase" class="toolbarField">
|
||||
<label for="findMatchCase" class="toolbarLabel" tabindex="25" data-l10n-id="find_match_case_label">Match case</label>
|
||||
<label for="findMatchCase" class="toolbarLabel" tabindex="45" data-l10n-id="find_match_case_label">Match case</label>
|
||||
<span id="findMsg" class="toolbarLabel"></span>
|
||||
</div>
|
||||
</div> <!-- findbar -->
|
||||
|
||||
<div id="secondaryToolbar" class="secondaryToolbar hidden doorHangerRight">
|
||||
<div id="secondaryToolbarButtonContainer">
|
||||
<button id="secondaryPresentationMode" class="secondaryToolbarButton presentationMode visibleLargeView" title="Switch to Presentation Mode" tabindex="18" data-l10n-id="presentation_mode">
|
||||
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
||||
</button>
|
||||
|
||||
<button id="secondaryOpenFile" class="secondaryToolbarButton openFile visibleLargeView" title="Open File" tabindex="19" data-l10n-id="open_file">
|
||||
<span data-l10n-id="open_file_label">Open</span>
|
||||
</button>
|
||||
|
||||
<button id="secondaryPrint" class="secondaryToolbarButton print visibleMediumView" title="Print" tabindex="20" data-l10n-id="print">
|
||||
<span data-l10n-id="print_label">Print</span>
|
||||
</button>
|
||||
|
||||
<button id="secondaryDownload" class="secondaryToolbarButton download visibleMediumView" title="Download" tabindex="21" data-l10n-id="download">
|
||||
<span data-l10n-id="download_label">Download</span>
|
||||
</button>
|
||||
|
||||
<div class="horizontalToolbarSeparator visibleLargeView"></div>
|
||||
|
||||
<button id="firstPage" class="secondaryToolbarButton firstPage" title="Go to First Page" tabindex="22" data-l10n-id="first_page">
|
||||
<span data-l10n-id="first_page_label">Go to First Page</span>
|
||||
</button>
|
||||
<button id="lastPage" class="secondaryToolbarButton lastPage" title="Go to Last Page" tabindex="23" data-l10n-id="last_page">
|
||||
<span data-l10n-id="last_page_label">Go to Last Page</span>
|
||||
</button>
|
||||
|
||||
<div class="horizontalToolbarSeparator"></div>
|
||||
|
||||
<button id="pageRotateCw" class="secondaryToolbarButton rotateCw" title="Rotate Clockwise" tabindex="24" data-l10n-id="page_rotate_cw">
|
||||
<span data-l10n-id="page_rotate_cw_label">Rotate Clockwise</span>
|
||||
</button>
|
||||
<button id="pageRotateCcw" class="secondaryToolbarButton rotateCcw" title="Rotate Counterclockwise" tabindex="25" data-l10n-id="page_rotate_ccw">
|
||||
<span data-l10n-id="page_rotate_ccw_label">Rotate Counterclockwise</span>
|
||||
</button>
|
||||
</div>
|
||||
</div> <!-- secondaryToolbar -->
|
||||
|
||||
<div class="toolbar">
|
||||
<div id="toolbarContainer">
|
||||
<div id="toolbarViewer">
|
||||
|
@ -139,23 +179,29 @@ limitations under the License.
|
|||
<span id="numPages" class="toolbarLabel"></span>
|
||||
</div>
|
||||
<div id="toolbarViewerRight">
|
||||
<button id="presentationMode" class="toolbarButton presentationMode hiddenSmallView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
|
||||
<button id="presentationMode" class="toolbarButton presentationMode hiddenLargeView" title="Switch to Presentation Mode" tabindex="12" data-l10n-id="presentation_mode">
|
||||
<span data-l10n-id="presentation_mode_label">Presentation Mode</span>
|
||||
</button>
|
||||
|
||||
<button id="openFile" class="toolbarButton openFile hiddenSmallView" title="Open File" tabindex="13" data-l10n-id="open_file">
|
||||
<span data-l10n-id="open_file_label">Open</span>
|
||||
<button id="openFile" class="toolbarButton openFile hiddenLargeView" title="Open File" tabindex="13" data-l10n-id="open_file">
|
||||
<span data-l10n-id="open_file_label">Open</span>
|
||||
</button>
|
||||
|
||||
<button id="print" class="toolbarButton print" title="Print" tabindex="14" data-l10n-id="print">
|
||||
<button id="print" class="toolbarButton print hiddenMediumView" title="Print" tabindex="14" data-l10n-id="print">
|
||||
<span data-l10n-id="print_label">Print</span>
|
||||
</button>
|
||||
|
||||
<button id="download" class="toolbarButton download" title="Download" tabindex="15" data-l10n-id="download">
|
||||
<button id="download" class="toolbarButton download hiddenMediumView" title="Download" tabindex="15" data-l10n-id="download">
|
||||
<span data-l10n-id="download_label">Download</span>
|
||||
</button>
|
||||
<!-- <div class="toolbarButtonSpacer"></div> -->
|
||||
<a href="#" id="viewBookmark" class="toolbarButton bookmark hiddenSmallView" title="Current view (copy or open in new window)" tabindex="16" data-l10n-id="bookmark"><span data-l10n-id="bookmark_label">Current View</span></a>
|
||||
|
||||
<div class="verticalToolbarSeparator hiddenSmallView"></div>
|
||||
|
||||
<button id="secondaryToolbarToggle" class="toolbarButton" title="Tools" tabindex="17" data-l10n-id="tools">
|
||||
<span data-l10n-id="tools_label">Tools</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="outerCenter">
|
||||
<div class="innerCenter" id="toolbarViewerMiddle">
|
||||
|
@ -196,14 +242,14 @@ limitations under the License.
|
|||
</div>
|
||||
|
||||
<menu type="context" id="viewerContextMenu">
|
||||
<menuitem id="firstPage" label="First Page"
|
||||
data-l10n-id="first_page" ></menuitem>
|
||||
<menuitem id="lastPage" label="Last Page"
|
||||
data-l10n-id="last_page" ></menuitem>
|
||||
<menuitem id="pageRotateCcw" label="Rotate Counter-Clockwise"
|
||||
data-l10n-id="page_rotate_ccw" ></menuitem>
|
||||
<menuitem id="pageRotateCw" label="Rotate Clockwise"
|
||||
data-l10n-id="page_rotate_cw" ></menuitem>
|
||||
<menuitem id="contextFirstPage" label="First Page"
|
||||
data-l10n-id="first_page"></menuitem>
|
||||
<menuitem id="contextLastPage" label="Last Page"
|
||||
data-l10n-id="last_page"></menuitem>
|
||||
<menuitem id="contextPageRotateCw" label="Rotate Clockwise"
|
||||
data-l10n-id="page_rotate_cw"></menuitem>
|
||||
<menuitem id="contextPageRotateCcw" label="Rotate Counter-Clockwise"
|
||||
data-l10n-id="page_rotate_ccw"></menuitem>
|
||||
</menu>
|
||||
|
||||
<!--#if (FIREFOX || MOZCENTRAL) -->
|
||||
|
@ -211,7 +257,7 @@ limitations under the License.
|
|||
<!--#else -->
|
||||
<div id="viewerContainer" tabindex="0">
|
||||
<!--#endif -->
|
||||
<div id="viewer" contextmenu="viewerContextMenu"></div>
|
||||
<div id="viewer"></div>
|
||||
</div>
|
||||
|
||||
<div id="errorWrapper" hidden='true'>
|
||||
|
|
138
web/viewer.js
138
web/viewer.js
|
@ -17,7 +17,7 @@
|
|||
/* globals PDFJS, PDFBug, FirefoxCom, Stats, Cache, PDFFindBar, CustomStyle,
|
||||
PDFFindController, ProgressBar, TextLayerBuilder, DownloadManager,
|
||||
getFileName, getOutputScale, scrollIntoView, getPDFFileNameFromURL,
|
||||
PDFHistory, ThumbnailView, noContextMenuHandler */
|
||||
PDFHistory, ThumbnailView, noContextMenuHandler, SecondaryToolbar */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
@ -167,6 +167,7 @@ var currentPageNumber = 1;
|
|||
//#include pdf_find_bar.js
|
||||
//#include pdf_find_controller.js
|
||||
//#include pdf_history.js
|
||||
//#include secondary_toolbar.js
|
||||
|
||||
var PDFView = {
|
||||
pages: [],
|
||||
|
@ -204,21 +205,34 @@ var PDFView = {
|
|||
this.watchScroll(thumbnailContainer, this.thumbnailViewScroll,
|
||||
this.renderHighestPriority.bind(this));
|
||||
|
||||
SecondaryToolbar.initialize({
|
||||
toolbar: document.getElementById('secondaryToolbar'),
|
||||
toggleButton: document.getElementById('secondaryToolbarToggle'),
|
||||
presentationMode: document.getElementById('secondaryPresentationMode'),
|
||||
openFile: document.getElementById('secondaryOpenFile'),
|
||||
print: document.getElementById('secondaryPrint'),
|
||||
download: document.getElementById('secondaryDownload'),
|
||||
firstPage: document.getElementById('firstPage'),
|
||||
lastPage: document.getElementById('lastPage'),
|
||||
pageRotateCw: document.getElementById('pageRotateCw'),
|
||||
pageRotateCcw: document.getElementById('pageRotateCcw')
|
||||
});
|
||||
|
||||
PDFFindBar.initialize({
|
||||
bar: document.getElementById('findbar'),
|
||||
toggleButton: document.getElementById('viewFind'),
|
||||
findField: document.getElementById('findInput'),
|
||||
highlightAllCheckbox: document.getElementById('findHighlightAll'),
|
||||
caseSensitiveCheckbox: document.getElementById('findMatchCase'),
|
||||
findMsg: document.getElementById('findMsg'),
|
||||
findStatusIcon: document.getElementById('findStatusIcon'),
|
||||
findPreviousButton: document.getElementById('findPrevious'),
|
||||
findNextButton: document.getElementById('findNext')
|
||||
bar: document.getElementById('findbar'),
|
||||
toggleButton: document.getElementById('viewFind'),
|
||||
findField: document.getElementById('findInput'),
|
||||
highlightAllCheckbox: document.getElementById('findHighlightAll'),
|
||||
caseSensitiveCheckbox: document.getElementById('findMatchCase'),
|
||||
findMsg: document.getElementById('findMsg'),
|
||||
findStatusIcon: document.getElementById('findStatusIcon'),
|
||||
findPreviousButton: document.getElementById('findPrevious'),
|
||||
findNextButton: document.getElementById('findNext')
|
||||
});
|
||||
|
||||
PDFFindController.initialize({
|
||||
pdfPageSource: this,
|
||||
integratedFind: this.supportsIntegratedFind
|
||||
pdfPageSource: this,
|
||||
integratedFind: this.supportsIntegratedFind
|
||||
});
|
||||
|
||||
this.initialized = true;
|
||||
|
@ -1410,6 +1424,9 @@ var PDFView = {
|
|||
this.page = this.presentationModeArgs.page;
|
||||
this.parseScale('page-fit', true);
|
||||
this.showPresentationControls();
|
||||
|
||||
var viewer = document.getElementById('viewer');
|
||||
viewer.setAttribute('contextmenu', 'viewerContextMenu');
|
||||
},
|
||||
|
||||
exitPresentationMode: function pdfViewExitPresentationMode() {
|
||||
|
@ -1420,6 +1437,9 @@ var PDFView = {
|
|||
this.hidePresentationControls();
|
||||
this.presentationModeArgs = null;
|
||||
|
||||
var viewer = document.getElementById('viewer');
|
||||
viewer.removeAttribute('contextmenu');
|
||||
|
||||
// Ensure that the thumbnail of the current page is visible
|
||||
// when exiting presentation mode.
|
||||
scrollIntoView(document.getElementById('thumbnailContainer' + this.page));
|
||||
|
@ -2169,11 +2189,13 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||
|
||||
if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
|
||||
document.getElementById('openFile').setAttribute('hidden', 'true');
|
||||
document.getElementById('secondaryOpenFile').setAttribute('hidden', 'true');
|
||||
} else {
|
||||
document.getElementById('fileInput').value = null;
|
||||
}
|
||||
//#else
|
||||
//document.getElementById('openFile').setAttribute('hidden', 'true');
|
||||
//document.getElementById('secondaryOpenFile').setAttribute('hidden', 'true');
|
||||
//#endif
|
||||
|
||||
// Special debugging flags in the hash section of the URL.
|
||||
|
@ -2240,10 +2262,13 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||
|
||||
if (!PDFView.supportsPrinting) {
|
||||
document.getElementById('print').classList.add('hidden');
|
||||
document.getElementById('secondaryPrint').classList.add('hidden');
|
||||
}
|
||||
|
||||
if (!PDFView.supportsFullscreen) {
|
||||
document.getElementById('presentationMode').classList.add('hidden');
|
||||
document.getElementById('secondaryPresentationMode').
|
||||
classList.add('hidden');
|
||||
}
|
||||
|
||||
if (PDFView.supportsIntegratedFind) {
|
||||
|
@ -2311,28 +2336,6 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||
PDFView.zoomOut();
|
||||
});
|
||||
|
||||
document.getElementById('presentationMode').addEventListener('click',
|
||||
function() {
|
||||
PDFView.presentationMode();
|
||||
});
|
||||
|
||||
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||
document.getElementById('openFile').addEventListener('click',
|
||||
function() {
|
||||
document.getElementById('fileInput').click();
|
||||
});
|
||||
//#endif
|
||||
|
||||
document.getElementById('print').addEventListener('click',
|
||||
function() {
|
||||
window.print();
|
||||
});
|
||||
|
||||
document.getElementById('download').addEventListener('click',
|
||||
function() {
|
||||
PDFView.download();
|
||||
});
|
||||
|
||||
document.getElementById('pageNumber').addEventListener('click',
|
||||
function() {
|
||||
this.select();
|
||||
|
@ -2353,25 +2356,29 @@ document.addEventListener('DOMContentLoaded', function webViewerLoad(evt) {
|
|||
PDFView.parseScale(this.value);
|
||||
});
|
||||
|
||||
document.getElementById('firstPage').addEventListener('click',
|
||||
function() {
|
||||
PDFView.page = 1;
|
||||
});
|
||||
document.getElementById('presentationMode').addEventListener('click',
|
||||
SecondaryToolbar.presentationModeClick.bind(SecondaryToolbar));
|
||||
|
||||
document.getElementById('lastPage').addEventListener('click',
|
||||
function() {
|
||||
PDFView.page = PDFView.pdfDocument.numPages;
|
||||
});
|
||||
document.getElementById('openFile').addEventListener('click',
|
||||
SecondaryToolbar.openFileClick.bind(SecondaryToolbar));
|
||||
|
||||
document.getElementById('pageRotateCcw').addEventListener('click',
|
||||
function() {
|
||||
PDFView.rotatePages(-90);
|
||||
});
|
||||
document.getElementById('print').addEventListener('click',
|
||||
SecondaryToolbar.printClick.bind(SecondaryToolbar));
|
||||
|
||||
document.getElementById('pageRotateCw').addEventListener('click',
|
||||
function() {
|
||||
PDFView.rotatePages(90);
|
||||
});
|
||||
document.getElementById('download').addEventListener('click',
|
||||
SecondaryToolbar.downloadClick.bind(SecondaryToolbar));
|
||||
|
||||
document.getElementById('contextFirstPage').addEventListener('click',
|
||||
SecondaryToolbar.firstPageClick.bind(SecondaryToolbar));
|
||||
|
||||
document.getElementById('contextLastPage').addEventListener('click',
|
||||
SecondaryToolbar.lastPageClick.bind(SecondaryToolbar));
|
||||
|
||||
document.getElementById('contextPageRotateCw').addEventListener('click',
|
||||
SecondaryToolbar.pageRotateCwClick.bind(SecondaryToolbar));
|
||||
|
||||
document.getElementById('contextPageRotateCcw').addEventListener('click',
|
||||
SecondaryToolbar.pageRotateCcwClick.bind(SecondaryToolbar));
|
||||
|
||||
//#if (FIREFOX || MOZCENTRAL)
|
||||
//PDFView.setTitleUsingUrl(file);
|
||||
|
@ -2458,6 +2465,9 @@ window.addEventListener('resize', function webViewerResize(evt) {
|
|||
PDFView.parseScale(document.getElementById('scaleSelect').value);
|
||||
}
|
||||
updateViewarea();
|
||||
|
||||
// Set the 'max-height' CSS property of the secondary toolbar.
|
||||
SecondaryToolbar.setMaxHeight(PDFView.container);
|
||||
});
|
||||
|
||||
window.addEventListener('hashchange', function webViewerHashchange(evt) {
|
||||
|
@ -2486,6 +2496,7 @@ window.addEventListener('change', function webViewerChange(evt) {
|
|||
// URL does not reflect proper document location - hiding some icons.
|
||||
document.getElementById('viewBookmark').setAttribute('hidden', 'true');
|
||||
document.getElementById('download').setAttribute('hidden', 'true');
|
||||
document.getElementById('secondaryDownload').setAttribute('hidden', 'true');
|
||||
}, true);
|
||||
|
||||
function selectScaleOption(value) {
|
||||
|
@ -2506,10 +2517,10 @@ function selectScaleOption(value) {
|
|||
window.addEventListener('localized', function localized(evt) {
|
||||
document.getElementsByTagName('html')[0].dir = mozL10n.getDirection();
|
||||
|
||||
// Adjust the width of the zoom box to fit the content.
|
||||
// Note: This is only done if the zoom box is actually visible,
|
||||
// since otherwise element.clientWidth will return 0.
|
||||
PDFView.animationStartedPromise.then(function() {
|
||||
// Adjust the width of the zoom box to fit the content.
|
||||
// Note: This is only done if the zoom box is actually visible,
|
||||
// since otherwise element.clientWidth will return 0.
|
||||
var container = document.getElementById('scaleSelectContainer');
|
||||
if (container.clientWidth > 0) {
|
||||
var select = document.getElementById('scaleSelect');
|
||||
|
@ -2520,6 +2531,9 @@ window.addEventListener('localized', function localized(evt) {
|
|||
container.setAttribute('style', 'min-width: ' + width + 'px; ' +
|
||||
'max-width: ' + width + 'px;');
|
||||
}
|
||||
|
||||
// Set the 'max-height' CSS property of the secondary toolbar.
|
||||
SecondaryToolbar.setMaxHeight(PDFView.container);
|
||||
});
|
||||
}, true);
|
||||
|
||||
|
@ -2609,9 +2623,13 @@ window.addEventListener('mousedown', function mousedown(evt) {
|
|||
}, false);
|
||||
|
||||
window.addEventListener('click', function click(evt) {
|
||||
if (PDFView.isPresentationMode && evt.button === 0) {
|
||||
if (!PDFView.isPresentationMode) {
|
||||
if (SecondaryToolbar.isOpen && PDFView.container.contains(evt.target)) {
|
||||
SecondaryToolbar.close();
|
||||
}
|
||||
} else if (evt.button === 0) {
|
||||
// Necessary since preventDefault() in 'mousedown' won't stop
|
||||
// the event propagation in all circumstances.
|
||||
// the event propagation in all circumstances in presentation mode.
|
||||
evt.preventDefault();
|
||||
}
|
||||
}, false);
|
||||
|
@ -2670,6 +2688,7 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||
switch (evt.keyCode) {
|
||||
case 80: // p
|
||||
PDFView.presentationMode();
|
||||
SecondaryToolbar.close();
|
||||
handled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2685,7 +2704,10 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||
var curElement = document.activeElement || document.querySelector(':focus');
|
||||
if (curElement && (curElement.tagName.toUpperCase() === 'INPUT' ||
|
||||
curElement.tagName.toUpperCase() === 'SELECT')) {
|
||||
return;
|
||||
// Make sure that the secondary toolbar is closed when Escape is pressed.
|
||||
if (evt.keyCode !== 27) { // 'Esc'
|
||||
return;
|
||||
}
|
||||
}
|
||||
var controlsElement = document.getElementById('toolbar');
|
||||
while (curElement) {
|
||||
|
@ -2717,6 +2739,10 @@ window.addEventListener('keydown', function keydown(evt) {
|
|||
handled = true;
|
||||
break;
|
||||
case 27: // esc key
|
||||
if (SecondaryToolbar.isOpen) {
|
||||
SecondaryToolbar.close();
|
||||
handled = true;
|
||||
}
|
||||
if (!PDFView.supportsIntegratedFind && PDFFindBar.opened) {
|
||||
PDFFindBar.close();
|
||||
handled = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue