Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous improvements for the document properties dialog #4167

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions l10n/en-US/viewer.properties
Expand Up @@ -63,12 +63,12 @@ hand_tool_disable.title=Disable hand tool
hand_tool_disable_label=Disable hand tool

# Document properties dialog box
document_properties.title=Document Properties
document_properties_label=Document Properties
document_properties.title=Document Properties
document_properties_label=Document Properties
document_properties_file_name=File name:
document_properties_file_size=File size:
document_properties_kb={{size_kb}} KB
document_properties_mb={{size_mb}} MB
document_properties_kb={{size_kb}} KB ({{size_b}} bytes)
document_properties_mb={{size_mb}} MB ({{size_b}} bytes)
document_properties_title=Title:
document_properties_author=Author:
document_properties_subject=Subject:
Expand Down
8 changes: 4 additions & 4 deletions l10n/nl/viewer.properties
Expand Up @@ -63,12 +63,12 @@ hand_tool_disable.title=Handcursor uitschakelen
hand_tool_disable_label=Handcursor uitschakelen

# Document properties dialog box
document_properties.title=Documenteigenschappen
document_properties_label=Documenteigenschappen
document_properties.title=Documenteigenschappen
document_properties_label=Documenteigenschappen
document_properties_file_name=Bestandsnaam:
document_properties_file_size=Bestandsgrootte:
document_properties_kb={{size_kb}} KB
document_properties_mb={{size_mb}} MB
document_properties_kb={{size_kb}} KB ({{size_b}} bytes)
document_properties_mb={{size_mb}} MB ({{size_b}} bytes)
document_properties_title=Titel:
document_properties_author=Auteur:
document_properties_subject=Onderwerp:
Expand Down
31 changes: 23 additions & 8 deletions web/document_properties.js
Expand Up @@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFView, mozL10n */
/* globals PDFView, mozL10n, getPDFFileNameFromURL */

'use strict';

var DocumentProperties = {
overlayContainer: null,
fileName: '',
fileSize: '',
visible: false,

Expand Down Expand Up @@ -58,11 +59,22 @@ var DocumentProperties = {
if (options.closeButton) {
options.closeButton.addEventListener('click', this.hide.bind(this));
}

// Bind the event listener for the Esc key (to close the dialog).
window.addEventListener('keydown',
function (e) {
if (e.keyCode === 27) { // Esc key
this.hide();
}
}.bind(this));
},

getProperties: function documentPropertiesGetProperties() {
var self = this;

// Get the file name.
this.fileName = getPDFFileNameFromURL(PDFView.url);

// Get the file size.
PDFView.pdfDocument.dataLoaded().then(function(data) {
self.setFileSize(data.length);
Expand All @@ -71,7 +83,7 @@ var DocumentProperties = {
// Get the other document properties.
PDFView.pdfDocument.getMetadata().then(function(data) {
var fields = [
{ field: self.fileNameField, content: PDFView.url },
{ field: self.fileNameField, content: self.fileName },
{ field: self.fileSizeField, content: self.fileSize },
{ field: self.titleField, content: data.info.Title },
{ field: self.authorField, content: data.info.Author },
Expand Down Expand Up @@ -99,14 +111,17 @@ var DocumentProperties = {
},

setFileSize: function documentPropertiesSetFileSize(fileSize) {
var kb = Math.round(fileSize / 1024);
var kb = fileSize / 1024;
if (kb < 1024) {
this.fileSize = mozL10n.get('document_properties_kb',
{size_kb: kb}, '{{size_kb}} KB');
this.fileSize = mozL10n.get('document_properties_kb', {
size_kb: (+kb.toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_kb}} KB ({{size_b}} bytes)');
} else {
var mb = Math.round((kb / 1024) * 100) / 100;
this.fileSize = mozL10n.get('document_properties_mb',
{size_mb: mb}, '{{size_mb}} MB');
this.fileSize = mozL10n.get('document_properties_mb', {
size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
size_b: fileSize.toLocaleString()
}, '{{size_mb}} MB ({{size_b}} bytes)');
}
},

Expand Down
2 changes: 1 addition & 1 deletion web/password_prompt.js
Expand Up @@ -48,7 +48,7 @@ var PasswordPrompt = {
}
}.bind(this));

this.overlayContainer.addEventListener('keydown',
window.addEventListener('keydown',
function (e) {
if (e.keyCode === 27) { // Esc key
this.hide();
Expand Down
10 changes: 10 additions & 0 deletions web/viewer.css
Expand Up @@ -1486,6 +1486,16 @@ html[dir='rtl'] #documentPropertiesContainer .row > * {
text-align: right;
}

#documentPropertiesContainer .row span {
width: 125px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be max-width here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that, but the problem would still remain. You can try it out by opening the generated viewer and using the web console to change width to max-width and then adding a longer text.

word-wrap: break-word;
}

#documentPropertiesContainer .row p {
max-width: 225px;
word-wrap: break-word;
}

#documentPropertiesContainer .buttonRow {
margin-top: 10px;
text-align: center;
Expand Down
4 changes: 2 additions & 2 deletions web/viewer.html
Expand Up @@ -175,8 +175,8 @@

<div class="horizontalToolbarSeparator"></div>

<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties" tabindex="28" data-l10n-id="document_properties">
<span data-l10n-id="document_properties_label">Document Properties</span>
<button id="documentProperties" class="secondaryToolbarButton documentProperties" title="Document Properties" tabindex="28" data-l10n-id="document_properties">
<span data-l10n-id="document_properties_label">Document Properties</span>
</button>
</div>
</div> <!-- secondaryToolbar -->
Expand Down