Chromium Code Reviews| Index: chrome/browser/resources/options/font_settings.js |
| diff --git a/chrome/browser/resources/options/font_settings.js b/chrome/browser/resources/options/font_settings.js |
| index e82863516f1b3a8099128350ff28cedeaaa4d05d..0eedacb2c8d7a942b0d74f2f629cccc244b7674b 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,66 @@ 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 = new Array( |
|
arv (Not doing code reviews)
2011/01/11 21:50:35
Use an array literal instead.
[9, 10, ...]
James Hawkins
2011/01/11 23:45:54
Done.
|
| + 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 = new Array( |
| + 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 {Integer} size The font size of the sample text. |
|
arv (Not doing code reviews)
2011/01/11 21:50:35
@param {number}
James Hawkins
2011/01/11 23:45:54
Done.
|
| + * @param {String} font The font family of the sample text. |
|
arv (Not doing code reviews)
2011/01/11 21:50:35
@param {string}
James Hawkins
2011/01/11 23:45:54
Done.
|
| + * @private |
| + */ |
| + setupFontSample_: function(el, size, font) { |
| + el.textContent = size + "pt: " + templateData.fontSettingsLoremIpsum; |
|
arv (Not doing code reviews)
2011/01/11 21:50:35
localStrings.getString for consistency
James Hawkins
2011/01/11 23:45:54
Done.
|
| + 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 |
| }; |
| - |
| }); |