summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options/font_settings.js
blob: 50445ce5ad2983e54e7e075de8836f557841b5f2 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 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,
                     'fontSettings');
  }

  cr.addSingletonGetter(FontSettings);

  FontSettings.prototype = {
    // Inherit FontSettings from OptionsPage.
    __proto__: OptionsPage.prototype,

    /**
     * Initialize the page.
     */
    initializePage: function() {
      // Call base class implementation to starts preference initialization.
      OptionsPage.prototype.initializePage.call(this);

      // Initialize values for selector controls.
      $('fontSettingsSerifSelector').initializeValues(
          templateData.fontSettingsFontList)
      $('fontSettingsSerifSizeSelector').initializeValues(
          templateData.fontSettingsFontSizeList)
      $('fontSettingsSansSerifSelector').initializeValues(
          templateData.fontSettingsFontList)
      $('fontSettingsSansSerifSizeSelector').initializeValues(
          templateData.fontSettingsFontSizeList)
      $('fontSettingsFixedWidthSelector').initializeValues(
          templateData.fontSettingsFontList)
      $('fontSettingsFixedWidthSizeSelector').initializeValues(
          templateData.fontSettingsFontSizeList)
      $('fontSettingsMinimumSizeSelector').initializeValues(
          templateData.fontSettingsMinimumFontSizeList)
      $('fontSettingsEncodingSelector').initializeValues(
          templateData.fontSettingsEncodingList)
    }
  };

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

});