Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: chrome/browser/resources/options/font_settings.js

Issue 6155008: DOMUI: Implement the new Fonts and Encoding page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix 3. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 6
7 var OptionsPage = options.OptionsPage; 7 var OptionsPage = options.OptionsPage;
8 8
9 /** 9 /**
10 * FontSettings class 10 * FontSettings class
11 * Encapsulated handling of the 'Font Settings' page. 11 * Encapsulated handling of the 'Fonts and Encoding' page.
12 * @class 12 * @class
13 */ 13 */
14 function FontSettings() { 14 function FontSettings() {
15 OptionsPage.call(this, 15 OptionsPage.call(this,
16 'fontSettings', 16 'fontSettings',
17 templateData.fontSettingsTitle, 17 templateData.fontSettingsTitle,
18 'font-settings'); 18 'font-settings');
19 } 19 }
20 20
21 cr.addSingletonGetter(FontSettings); 21 cr.addSingletonGetter(FontSettings);
22 22
23 FontSettings.prototype = { 23 FontSettings.prototype = {
24 __proto__: OptionsPage.prototype, 24 __proto__: OptionsPage.prototype,
25 25
26 /** 26 /**
27 * Initialize the page. 27 * Initialize the page.
28 */ 28 */
29 initializePage: function() { 29 initializePage: function() {
30 // Call base class implementation to starts preference initialization.
31 OptionsPage.prototype.initializePage.call(this); 30 OptionsPage.prototype.initializePage.call(this);
32 } 31
32 var serifFontRange = $('serif-font-size');
33 serifFontRange.valueMap = $('fixed-font-size').valueMap = [9, 10, 11, 12,
34 13, 14, 15, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 44,
35 48, 56, 64, 72];
36 serifFontRange.continuous = false;
37 serifFontRange.fontSampleEl = $('serif-font-sample');
38 serifFontRange.notifyChange = this.rangeChanged_.bind(this);
39
40 var minimumFontRange = $('minimum-font-size');
41 minimumFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20,
42 22, 24];
43 minimumFontRange.continuous = false;
44 minimumFontRange.fontSampleEl = $('minimum-font-sample');
45 minimumFontRange.notifyChange = this.rangeChanged_.bind(this);
46 },
47
48 /**
49 * @inheritDoc
50 */
51 rangeChanged_: function(el, value) {
52 this.setupFontSample_(
53 el.fontSampleEl, value, el.fontSampleEl.style.fontFamily);
54 },
55
56 /**
57 * Sets the text, font size and font family of the sample text.
58 * @param {Element} el The div containing the sample text.
59 * @param {number} size The font size of the sample text.
60 * @param {string} font The font family of the sample text.
61 * @private
62 */
63 setupFontSample_: function(el, size, font) {
64 el.textContent =
65 size + "pt: " + localStrings.getString('fontSettingsLoremIpsum');
66 el.style.fontSize = size + "pt";
67 if (font)
68 el.style.fontFamily = font;
69 },
33 }; 70 };
34 71
35 FontSettings.setupFontPreview = function(id, font, size) { 72 // Chrome callbacks
36 $(id).textContent = font + " " + size; 73 FontSettings.setupSerifFontSample = function(font, size) {
37 $(id).style.fontFamily = font; 74 FontSettings.getInstance().setupFontSample_(
38 $(id).style.fontSize = size + "pt"; 75 $('serif-font-sample'), size, font);
39 } 76 };
40 77
41 // Chrome callbacks 78 FontSettings.setupFixedFontSample = function(font, size) {
42 FontSettings.setupSerifFontPreview = function(text, size) { 79 FontSettings.getInstance().setupFontSample_(
43 this.setupFontPreview('fontSettingsSerifPreview', text, size); 80 $('fixed-font-sample'), size, font);
44 } 81 };
45 82
46 FontSettings.setupSansSerifFontPreview = function(text, size) { 83 FontSettings.setupMinimumFontSample = function(size) {
47 this.setupFontPreview('fontSettingsSansSerifPreview', text, size); 84 FontSettings.getInstance().setupFontSample_(
48 } 85 $('minimum-font-sample'), size);
49 86 };
50 FontSettings.setupFixedFontPreview = function(text, size) {
51 this.setupFontPreview('fontSettingsFixedWidthPreview', text, size);
52 }
53 87
54 // Export 88 // Export
55 return { 89 return {
56 FontSettings: FontSettings 90 FontSettings: FontSettings
57 }; 91 };
58
59 }); 92 });
60 93
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/font_settings.html ('k') | chrome/browser/resources/options/font_settings_ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698