summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options/font_settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/resources/options/font_settings.js')
-rw-r--r--chrome/browser/resources/options/font_settings.js73
1 files changed, 53 insertions, 20 deletions
diff --git a/chrome/browser/resources/options/font_settings.js b/chrome/browser/resources/options/font_settings.js
index e828635..99bde5a 100644
--- a/chrome/browser/resources/options/font_settings.js
+++ b/chrome/browser/resources/options/font_settings.js
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -8,7 +8,7 @@ cr.define('options', function() {
/**
* FontSettings class
- * Encapsulated handling of the 'Font Settings' page.
+ * Encapsulated handling of the 'Fonts and Encoding' page.
* @class
*/
function FontSettings() {
@@ -27,34 +27,67 @@ cr.define('options', function() {
* Initialize the page.
*/
initializePage: function() {
- // Call base class implementation to starts preference initialization.
OptionsPage.prototype.initializePage.call(this);
- }
- };
- FontSettings.setupFontPreview = function(id, font, size) {
- $(id).textContent = font + " " + size;
- $(id).style.fontFamily = font;
- $(id).style.fontSize = size + "pt";
- }
+ var serifFontRange = $('serif-font-size');
+ serifFontRange.valueMap = $('fixed-font-size').valueMap = [9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 44,
+ 48, 56, 64, 72];
+ serifFontRange.continuous = false;
+ serifFontRange.fontSampleEl = $('serif-font-sample');
+ serifFontRange.notifyChange = this.rangeChanged_.bind(this);
+
+ var minimumFontRange = $('minimum-font-size');
+ minimumFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20,
+ 22, 24];
+ minimumFontRange.continuous = false;
+ minimumFontRange.fontSampleEl = $('minimum-font-sample');
+ minimumFontRange.notifyChange = this.rangeChanged_.bind(this);
+ },
+
+ /**
+ * @inheritDoc
+ */
+ rangeChanged_: function(el, value) {
+ this.setupFontSample_(
+ el.fontSampleEl, value, el.fontSampleEl.style.fontFamily);
+ },
+
+ /**
+ * Sets the text, font size and font family of the sample text.
+ * @param {Element} el The div containing the sample text.
+ * @param {number} size The font size of the sample text.
+ * @param {string} font The font family of the sample text.
+ * @private
+ */
+ setupFontSample_: function(el, size, font) {
+ el.textContent =
+ size + "pt: " + localStrings.getString('fontSettingsLoremIpsum');
+ el.style.fontSize = size + "pt";
+ if (font)
+ el.style.fontFamily = font;
+ },
+ };
// Chrome callbacks
- FontSettings.setupSerifFontPreview = function(text, size) {
- this.setupFontPreview('fontSettingsSerifPreview', text, size);
- }
+ FontSettings.setupSerifFontSample = function(font, size) {
+ FontSettings.getInstance().setupFontSample_(
+ $('serif-font-sample'), size, font);
+ };
- FontSettings.setupSansSerifFontPreview = function(text, size) {
- this.setupFontPreview('fontSettingsSansSerifPreview', text, size);
- }
+ FontSettings.setupFixedFontSample = function(font, size) {
+ FontSettings.getInstance().setupFontSample_(
+ $('fixed-font-sample'), size, font);
+ };
- FontSettings.setupFixedFontPreview = function(text, size) {
- this.setupFontPreview('fontSettingsFixedWidthPreview', text, size);
- }
+ FontSettings.setupMinimumFontSample = function(size) {
+ FontSettings.getInstance().setupFontSample_(
+ $('minimum-font-sample'), size);
+ };
// Export
return {
FontSettings: FontSettings
};
-
});