Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 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 const SizeDifferenceFixedStandard = 3; | |
|
Peter Kasting
2011/11/04 16:22:33
Nit: I suggest adding some comments on what this m
groby-ooo-7-16
2011/11/08 19:05:17
nit: Please uppercase simple primitive constants.
rosen.dash
2011/11/09 07:04:02
Done.
rosen.dash
2011/11/09 07:04:02
Done.
| |
| 10 | |
| 9 /** | 11 /** |
| 10 * FontSettings class | 12 * FontSettings class |
| 11 * Encapsulated handling of the 'Fonts and Encoding' page. | 13 * Encapsulated handling of the 'Fonts and Encoding' page. |
| 12 * @class | 14 * @class |
| 13 */ | 15 */ |
| 14 function FontSettings() { | 16 function FontSettings() { |
| 15 OptionsPage.call(this, | 17 OptionsPage.call(this, |
| 16 'fonts', | 18 'fonts', |
| 17 templateData.fontSettingsPageTabTitle, | 19 templateData.fontSettingsPageTabTitle, |
| 18 'font-settings'); | 20 'font-settings'); |
| 19 } | 21 } |
| 20 | 22 |
| 21 cr.addSingletonGetter(FontSettings); | 23 cr.addSingletonGetter(FontSettings); |
| 22 | 24 |
| 23 FontSettings.prototype = { | 25 FontSettings.prototype = { |
| 24 __proto__: OptionsPage.prototype, | 26 __proto__: OptionsPage.prototype, |
| 25 | 27 |
| 26 /** | 28 /** |
| 27 * Initialize the page. | 29 * Initialize the page. |
| 28 */ | 30 */ |
| 29 initializePage: function() { | 31 initializePage: function() { |
| 30 OptionsPage.prototype.initializePage.call(this); | 32 OptionsPage.prototype.initializePage.call(this); |
| 31 | 33 |
| 32 var standardFontRange = $('standard-font-size'); | 34 var standardFontRange = $('standard-font-size'); |
| 33 standardFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, | 35 standardFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, |
| 34 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 56, 64, 72]; | 36 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 56, 64, 72]; |
| 35 standardFontRange.continuous = false; | 37 standardFontRange.continuous = false; |
| 36 standardFontRange.notifyChange = this.standardRangeChanged_.bind(this); | 38 standardFontRange.notifyChange = this.standardRangeChanged_.bind(this); |
| 39 standardFontRange.notifyPrefChange = | |
| 40 this.standardFontSizeChanged_.bind(this); | |
| 37 | 41 |
| 38 var minimumFontRange = $('minimum-font-size'); | 42 var minimumFontRange = $('minimum-font-size'); |
| 39 minimumFontRange.valueMap = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, | 43 minimumFontRange.valueMap = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, |
| 40 18, 20, 22, 24]; | 44 18, 20, 22, 24]; |
| 41 minimumFontRange.continuous = false; | 45 minimumFontRange.continuous = false; |
| 42 minimumFontRange.notifyChange = this.minimumRangeChanged_.bind(this); | 46 minimumFontRange.notifyChange = this.minimumRangeChanged_.bind(this); |
| 43 minimumFontRange.notifyPrefChange = | 47 minimumFontRange.notifyPrefChange = |
| 44 this.minimumFontSizeChanged_.bind(this); | 48 this.minimumFontSizeChanged_.bind(this); |
| 45 | 49 |
| 46 var placeholder = localStrings.getString('fontSettingsPlaceholder'); | 50 var placeholder = localStrings.getString('fontSettingsPlaceholder'); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 83 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, |
| 80 true); | 84 true); |
| 81 | 85 |
| 82 fontSampleEl = $('serif-font-sample'); | 86 fontSampleEl = $('serif-font-sample'); |
| 83 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 87 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, |
| 84 true); | 88 true); |
| 85 | 89 |
| 86 fontSampleEl = $('sans-serif-font-sample'); | 90 fontSampleEl = $('sans-serif-font-sample'); |
| 87 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 91 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, |
| 88 true); | 92 true); |
| 93 | |
| 94 fontSampleEl = $('fixed-font-sample'); | |
| 95 this.setUpFontSample_(fontSampleEl, value - SizeDifferenceFixedStandard, | |
|
Peter Kasting
2011/11/04 16:22:33
Nit: Should someone somewhere assert that this wil
groby-ooo-7-16
2011/11/08 19:05:17
Technically, standardRange has a minimum of '9', s
rosen.dash
2011/11/09 07:04:02
I think that it's not necessary to add an assert.
| |
| 96 fontSampleEl.style.fontFamily, false); | |
| 89 }, | 97 }, |
| 90 | 98 |
| 91 /** | 99 /** |
| 100 * Sets the 'default_fixed_font_size' preference when the standard font | |
| 101 * size has been changed by the user. | |
| 102 * @param {Element} el The slider input element. | |
| 103 * @param {number} value The mapped value that has been saved. | |
| 104 * @private | |
| 105 */ | |
| 106 standardFontSizeChanged_: function(el, value) { | |
| 107 Preferences.setIntegerPref('webkit.webprefs.default_fixed_font_size', | |
| 108 value - SizeDifferenceFixedStandard, ''); | |
| 109 }, | |
| 110 | |
| 111 /** | |
| 92 * Called as the user changes the miniumum font size. This allows for | 112 * Called as the user changes the miniumum font size. This allows for |
| 93 * reflecting the change in the UI before the preference has been changed. | 113 * reflecting the change in the UI before the preference has been changed. |
| 94 * @param {Element} el The slider input element. | 114 * @param {Element} el The slider input element. |
| 95 * @param {number} value The mapped value currently set by the slider. | 115 * @param {number} value The mapped value currently set by the slider. |
| 96 * @private | 116 * @private |
| 97 */ | 117 */ |
| 98 minimumRangeChanged_: function(el, value) { | 118 minimumRangeChanged_: function(el, value) { |
| 99 var fontSampleEl = $('minimum-font-sample'); | 119 var fontSampleEl = $('minimum-font-sample'); |
| 100 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 120 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, |
| 101 true); | 121 true); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 FontSettings.getInstance().setUpFontSample_($('minimum-font-sample'), size, | 220 FontSettings.getInstance().setUpFontSample_($('minimum-font-sample'), size, |
| 201 null, true); | 221 null, true); |
| 202 }; | 222 }; |
| 203 | 223 |
| 204 // Export | 224 // Export |
| 205 return { | 225 return { |
| 206 FontSettings: FontSettings | 226 FontSettings: FontSettings |
| 207 }; | 227 }; |
| 208 }); | 228 }); |
| 209 | 229 |
| OLD | NEW |