summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options/font_settings.js
blob: e82863516f1b3a8099128350ff28cedeaaa4d05d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2010 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.

cr.define('options', function() {

  var OptionsPage = options.OptionsPage;

  /**
   * FontSettings class
   * Encapsulated handling of the 'Font Settings' page.
   * @class
   */
  function FontSettings() {
    OptionsPage.call(this,
                     'fontSettings',
                     templateData.fontSettingsTitle,
                     'font-settings');
  }

  cr.addSingletonGetter(FontSettings);

  FontSettings.prototype = {
    __proto__: OptionsPage.prototype,

    /**
     * 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";
  }

  // Chrome callbacks
  FontSettings.setupSerifFontPreview = function(text, size) {
    this.setupFontPreview('fontSettingsSerifPreview', text, size);
  }

  FontSettings.setupSansSerifFontPreview = function(text, size) {
    this.setupFontPreview('fontSettingsSansSerifPreview', text, size);
  }

  FontSettings.setupFixedFontPreview = function(text, size) {
    this.setupFontPreview('fontSettingsFixedWidthPreview', text, size);
  }

  // Export
  return {
    FontSettings: FontSettings
  };

});