summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options/font_settings_overlay.js
blob: af445dce11d29da8043ed8218b34197c52d97898 (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
// 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;

  /**
   * FontSettingsOverlay class
   * Encapsulated handling of the 'Font Settings' overlay page.
   * @class
   */
  function FontSettingsOverlay() {
    OptionsPage.call(this, 'fontSettingsOverlay',
                     templateData.fontSettingsOverlayTitle,
                     'fontSettingsOverlay');
  }

  cr.addSingletonGetter(FontSettingsOverlay);

  FontSettingsOverlay.prototype = {
    // Inherit FontSettingsOverlay 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)
      $('fontSettingsEncodingSelector').initializeValues(
          templateData.fontSettingsEncodingList)
    }
  };

  FontSettingsOverlay.setupFontPreview = function(id, font, size) {
    $(id).textContent = font + " " + size;
    $(id).style.fontFamily = font;
    $(id).style.fontSize = size + "pt";
  }

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

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

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

  // Export
  return {
    FontSettingsOverlay: FontSettingsOverlay
  };

});