From c952b6fb8503b1f1ed16893e35fb9d847a65054b Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Thu, 23 Jan 2014 00:30:48 +0100 Subject: [PATCH] Miscellaneous improvements for the document properties dialog --- l10n/en-US/viewer.properties | 8 ++++---- l10n/nl/viewer.properties | 8 ++++---- web/document_properties.js | 31 +++++++++++++++++++++++-------- web/password_prompt.js | 2 +- web/viewer.css | 10 ++++++++++ web/viewer.html | 4 ++-- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/l10n/en-US/viewer.properties b/l10n/en-US/viewer.properties index 97e2a9401..a10bb8f22 100644 --- a/l10n/en-US/viewer.properties +++ b/l10n/en-US/viewer.properties @@ -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: diff --git a/l10n/nl/viewer.properties b/l10n/nl/viewer.properties index 44f6b4420..9058c1534 100644 --- a/l10n/nl/viewer.properties +++ b/l10n/nl/viewer.properties @@ -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: diff --git a/web/document_properties.js b/web/document_properties.js index 1fea86759..5dfeef3f7 100644 --- a/web/document_properties.js +++ b/web/document_properties.js @@ -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, @@ -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); @@ -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 }, @@ -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)'); } }, diff --git a/web/password_prompt.js b/web/password_prompt.js index 3a1078019..498fb2d7f 100644 --- a/web/password_prompt.js +++ b/web/password_prompt.js @@ -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(); diff --git a/web/viewer.css b/web/viewer.css index a524c424a..5cb807d8d 100644 --- a/web/viewer.css +++ b/web/viewer.css @@ -1486,6 +1486,16 @@ html[dir='rtl'] #documentPropertiesContainer .row > * { text-align: right; } +#documentPropertiesContainer .row span { + width: 125px; + word-wrap: break-word; +} + +#documentPropertiesContainer .row p { + max-width: 225px; + word-wrap: break-word; +} + #documentPropertiesContainer .buttonRow { margin-top: 10px; text-align: center; diff --git a/web/viewer.html b/web/viewer.html index 1bff71f1a..46d7109c4 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -175,8 +175,8 @@ limitations under the License.
-