| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 'Font Settings' page. |
| 12 * @class | 12 * @class |
| 13 */ | 13 */ |
| 14 function FontSettings() { | 14 function FontSettings() { |
| 15 OptionsPage.call(this, 'fontSettings', | 15 OptionsPage.call(this, |
| 16 'fontSettings', |
| 16 templateData.fontSettingsTitle, | 17 templateData.fontSettingsTitle, |
| 17 'fontSettings'); | 18 'font-settings'); |
| 18 } | 19 } |
| 19 | 20 |
| 20 cr.addSingletonGetter(FontSettings); | 21 cr.addSingletonGetter(FontSettings); |
| 21 | 22 |
| 22 FontSettings.prototype = { | 23 FontSettings.prototype = { |
| 23 // Inherit FontSettings from OptionsPage. | |
| 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. | 30 // Call base class implementation to starts preference initialization. |
| 31 OptionsPage.prototype.initializePage.call(this); | 31 OptionsPage.prototype.initializePage.call(this); |
| 32 | |
| 33 // Initialize values for selector controls. | |
| 34 $('fontSettingsSerifSelector').initializeValues( | |
| 35 templateData.fontSettingsFontList) | |
| 36 $('fontSettingsSerifSizeSelector').initializeValues( | |
| 37 templateData.fontSettingsFontSizeList) | |
| 38 $('fontSettingsSansSerifSelector').initializeValues( | |
| 39 templateData.fontSettingsFontList) | |
| 40 $('fontSettingsSansSerifSizeSelector').initializeValues( | |
| 41 templateData.fontSettingsFontSizeList) | |
| 42 $('fontSettingsFixedWidthSelector').initializeValues( | |
| 43 templateData.fontSettingsFontList) | |
| 44 $('fontSettingsFixedWidthSizeSelector').initializeValues( | |
| 45 templateData.fontSettingsFontSizeList) | |
| 46 $('fontSettingsMinimumSizeSelector').initializeValues( | |
| 47 templateData.fontSettingsMinimumFontSizeList) | |
| 48 $('fontSettingsEncodingSelector').initializeValues( | |
| 49 templateData.fontSettingsEncodingList) | |
| 50 } | 32 } |
| 51 }; | 33 }; |
| 52 | 34 |
| 53 FontSettings.setupFontPreview = function(id, font, size) { | 35 FontSettings.setupFontPreview = function(id, font, size) { |
| 54 $(id).textContent = font + " " + size; | 36 $(id).textContent = font + " " + size; |
| 55 $(id).style.fontFamily = font; | 37 $(id).style.fontFamily = font; |
| 56 $(id).style.fontSize = size + "pt"; | 38 $(id).style.fontSize = size + "pt"; |
| 57 } | 39 } |
| 58 | 40 |
| 59 // Chrome callbacks | 41 // Chrome callbacks |
| 60 FontSettings.setupSerifFontPreview = function(text, size) { | 42 FontSettings.setupSerifFontPreview = function(text, size) { |
| 61 this.setupFontPreview('fontSettingsSerifPreview', text, size); | 43 this.setupFontPreview('fontSettingsSerifPreview', text, size); |
| 62 } | 44 } |
| 63 | 45 |
| 64 FontSettings.setupSansSerifFontPreview = function(text, size) { | 46 FontSettings.setupSansSerifFontPreview = function(text, size) { |
| 65 this.setupFontPreview('fontSettingsSansSerifPreview', text, size); | 47 this.setupFontPreview('fontSettingsSansSerifPreview', text, size); |
| 66 } | 48 } |
| 67 | 49 |
| 68 FontSettings.setupFixedFontPreview = function(text, size) { | 50 FontSettings.setupFixedFontPreview = function(text, size) { |
| 69 this.setupFontPreview('fontSettingsFixedWidthPreview', text, size); | 51 this.setupFontPreview('fontSettingsFixedWidthPreview', text, size); |
| 70 } | 52 } |
| 71 | 53 |
| 72 // Export | 54 // Export |
| 73 return { | 55 return { |
| 74 FontSettings: FontSettings | 56 FontSettings: FontSettings |
| 75 }; | 57 }; |
| 76 | 58 |
| 77 }); | 59 }); |
| 78 | 60 |
| OLD | NEW |