| 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 /** | 9 /** |
| 10 * FontSettings class | 10 * FontSettings class |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 serifFontRange.continuous = false; | 36 serifFontRange.continuous = false; |
| 37 serifFontRange.fontSampleEl = $('serif-font-sample'); | 37 serifFontRange.fontSampleEl = $('serif-font-sample'); |
| 38 serifFontRange.notifyChange = this.rangeChanged_.bind(this); | 38 serifFontRange.notifyChange = this.rangeChanged_.bind(this); |
| 39 | 39 |
| 40 var minimumFontRange = $('minimum-font-size'); | 40 var minimumFontRange = $('minimum-font-size'); |
| 41 minimumFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, | 41 minimumFontRange.valueMap = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, |
| 42 22, 24]; | 42 22, 24]; |
| 43 minimumFontRange.continuous = false; | 43 minimumFontRange.continuous = false; |
| 44 minimumFontRange.fontSampleEl = $('minimum-font-sample'); | 44 minimumFontRange.fontSampleEl = $('minimum-font-sample'); |
| 45 minimumFontRange.notifyChange = this.rangeChanged_.bind(this); | 45 minimumFontRange.notifyChange = this.rangeChanged_.bind(this); |
| 46 minimumFontRange.notifyPrefChange = |
| 47 this.minimumFontSizeChanged_.bind(this); |
| 48 |
| 49 // Add an additional listener to the font select menu for the |
| 50 // 'sansserif_font_family' preference. |
| 51 $('serif-font-family').addEventListener('change', |
| 52 function(e) { |
| 53 Preferences.setStringPref('webkit.webprefs.sansserif_font_family', |
| 54 this.options[this.selectedIndex].value, ''); |
| 55 }); |
| 46 }, | 56 }, |
| 47 | 57 |
| 48 /** | 58 /** |
| 49 * @inheritDoc | 59 * Called as the user changes a non-continuous slider. This allows for |
| 60 * reflecting the change in the UI before the preference has been changed. |
| 61 * @param {Element} el The slider input element. |
| 62 * @param {number} value The mapped value currently set by the slider. |
| 63 * @private |
| 50 */ | 64 */ |
| 51 rangeChanged_: function(el, value) { | 65 rangeChanged_: function(el, value) { |
| 52 this.setupFontSample_( | 66 this.setupFontSample_( |
| 53 el.fontSampleEl, value, el.fontSampleEl.style.fontFamily); | 67 el.fontSampleEl, value, el.fontSampleEl.style.fontFamily); |
| 54 }, | 68 }, |
| 55 | 69 |
| 56 /** | 70 /** |
| 71 * Sets the 'minimum_logical_font_size' preference when the minimum font |
| 72 * size has been changed by the user. |
| 73 * @param {Element} el The slider input element. |
| 74 * @param {number} value The mapped value that has been saved. |
| 75 * @private |
| 76 */ |
| 77 minimumFontSizeChanged_: function(el, value) { |
| 78 Preferences.setIntegerPref('webkit.webprefs.minimum_logical_font_size', |
| 79 value, ''); |
| 80 }, |
| 81 |
| 82 /** |
| 57 * Sets the text, font size and font family of the sample text. | 83 * Sets the text, font size and font family of the sample text. |
| 58 * @param {Element} el The div containing the sample text. | 84 * @param {Element} el The div containing the sample text. |
| 59 * @param {number} size The font size of the sample text. | 85 * @param {number} size The font size of the sample text. |
| 60 * @param {string} font The font family of the sample text. | 86 * @param {string} font The font family of the sample text. |
| 61 * @private | 87 * @private |
| 62 */ | 88 */ |
| 63 setupFontSample_: function(el, size, font) { | 89 setupFontSample_: function(el, size, font) { |
| 64 el.textContent = | 90 el.textContent = |
| 65 size + "pt: " + localStrings.getString('fontSettingsLoremIpsum'); | 91 size + "pt: " + localStrings.getString('fontSettingsLoremIpsum'); |
| 66 el.style.fontSize = size + "pt"; | 92 el.style.fontSize = size + "pt"; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 84 FontSettings.getInstance().setupFontSample_( | 110 FontSettings.getInstance().setupFontSample_( |
| 85 $('minimum-font-sample'), size); | 111 $('minimum-font-sample'), size); |
| 86 }; | 112 }; |
| 87 | 113 |
| 88 // Export | 114 // Export |
| 89 return { | 115 return { |
| 90 FontSettings: FontSettings | 116 FontSettings: FontSettings |
| 91 }; | 117 }; |
| 92 }); | 118 }); |
| 93 | 119 |
| OLD | NEW |