Miscellaneous improvements for the document properties dialog

This commit is contained in:
Tim van der Meij 2014-01-23 00:30:48 +01:00
parent 5a6862decc
commit c952b6fb85
6 changed files with 44 additions and 19 deletions

View File

@ -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:

View File

@ -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:

View File

@ -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)');
}
},

View File

@ -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();

View File

@ -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;

View File

@ -175,8 +175,8 @@ limitations under the License.
<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 -->