OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 /** | 76 /** |
77 * Handler that is called when the user changes the position of the standard | 77 * Handler that is called when the user changes the position of the standard |
78 * font size slider. This allows the UI to show a preview of the change | 78 * font size slider. This allows the UI to show a preview of the change |
79 * before the slider has been released and the associated prefs updated. | 79 * before the slider has been released and the associated prefs updated. |
80 * @param {Element} el The slider input element. | 80 * @param {Element} el The slider input element. |
81 * @param {Event} event Change event. | 81 * @param {Event} event Change event. |
82 * @private | 82 * @private |
83 */ | 83 */ |
84 standardRangeChanged_: function(el, event) { | 84 standardRangeChanged_: function(el, event) { |
85 var value = el.mapValueToRange(el.value); | 85 var size = el.mapPositionToPref(el.value); |
86 var fontSampleEl = $('standard-font-sample'); | 86 var fontSampleEl = $('standard-font-sample'); |
87 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 87 this.setUpFontSample_(fontSampleEl, size, fontSampleEl.style.fontFamily, |
88 true); | 88 true); |
89 | 89 |
90 fontSampleEl = $('serif-font-sample'); | 90 fontSampleEl = $('serif-font-sample'); |
91 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 91 this.setUpFontSample_(fontSampleEl, size, fontSampleEl.style.fontFamily, |
92 true); | 92 true); |
93 | 93 |
94 fontSampleEl = $('sans-serif-font-sample'); | 94 fontSampleEl = $('sans-serif-font-sample'); |
95 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 95 this.setUpFontSample_(fontSampleEl, size, fontSampleEl.style.fontFamily, |
96 true); | 96 true); |
97 | 97 |
98 fontSampleEl = $('fixed-font-sample'); | 98 fontSampleEl = $('fixed-font-sample'); |
99 this.setUpFontSample_(fontSampleEl, | 99 this.setUpFontSample_(fontSampleEl, |
100 value - OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD, | 100 size - OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD, |
101 fontSampleEl.style.fontFamily, false); | 101 fontSampleEl.style.fontFamily, false); |
102 }, | 102 }, |
103 | 103 |
104 /** | 104 /** |
105 * Sets the 'default_fixed_font_size' preference when the user changes the | 105 * Sets the 'default_fixed_font_size' preference when the user changes the |
106 * standard font size. | 106 * standard font size. |
107 * @param {Event} event Change event. | 107 * @param {Event} event Change event. |
108 * @private | 108 * @private |
109 */ | 109 */ |
110 standardFontSizeChanged_: function(event) { | 110 standardFontSizeChanged_: function(event) { |
111 var value = this.mapValueToRange(this.value); | 111 var size = this.mapPositionToPref(this.value); |
112 Preferences.setIntegerPref( | 112 Preferences.setIntegerPref( |
113 'webkit.webprefs.default_fixed_font_size', | 113 'webkit.webprefs.default_fixed_font_size', |
114 value - OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD, true); | 114 size - OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD, true); |
115 return false; | 115 return false; |
116 }, | 116 }, |
117 | 117 |
118 /** | 118 /** |
119 * Handler that is called when the user changes the position of the minimum | 119 * Handler that is called when the user changes the position of the minimum |
120 * font size slider. This allows the UI to show a preview of the change | 120 * font size slider. This allows the UI to show a preview of the change |
121 * before the slider has been released and the associated prefs updated. | 121 * before the slider has been released and the associated prefs updated. |
122 * @param {Element} el The slider input element. | 122 * @param {Element} el The slider input element. |
123 * @param {Event} event Change event. | 123 * @param {Event} event Change event. |
124 * @private | 124 * @private |
125 */ | 125 */ |
126 minimumRangeChanged_: function(el, event) { | 126 minimumRangeChanged_: function(el, event) { |
127 var value = el.mapValueToRange(el.value); | 127 var size = el.mapPositionToPref(el.value); |
128 var fontSampleEl = $('minimum-font-sample'); | 128 var fontSampleEl = $('minimum-font-sample'); |
129 this.setUpFontSample_(fontSampleEl, value, fontSampleEl.style.fontFamily, | 129 this.setUpFontSample_(fontSampleEl, size, fontSampleEl.style.fontFamily, |
130 true); | 130 true); |
131 }, | 131 }, |
132 | 132 |
133 /** | 133 /** |
134 * Sets the 'minimum_logical_font_size' preference when the user changes the | 134 * Sets the 'minimum_logical_font_size' preference when the user changes the |
135 * minimum font size. | 135 * minimum font size. |
136 * @param {Event} event Change event. | 136 * @param {Event} event Change event. |
137 * @private | 137 * @private |
138 */ | 138 */ |
139 minimumFontSizeChanged_: function(event) { | 139 minimumFontSizeChanged_: function(event) { |
140 var value = this.mapValueToRange(this.value); | 140 var size = this.mapPositionToPref(this.value); |
141 Preferences.setIntegerPref( | 141 Preferences.setIntegerPref( |
142 'webkit.webprefs.minimum_logical_font_size', value, true); | 142 'webkit.webprefs.minimum_logical_font_size', size, true); |
143 return false; | 143 return false; |
144 }, | 144 }, |
145 | 145 |
146 /** | 146 /** |
147 * Sets the text, font size and font family of the sample text. | 147 * Sets the text, font size and font family of the sample text. |
148 * @param {Element} el The div containing the sample text. | 148 * @param {Element} el The div containing the sample text. |
149 * @param {number} size The font size of the sample text. | 149 * @param {number} size The font size of the sample text. |
150 * @param {string} font The font family of the sample text. | 150 * @param {string} font The font family of the sample text. |
151 * @param {bool} showSize True if the font size should appear in the sample. | 151 * @param {bool} showSize True if the font size should appear in the sample. |
152 * @private | 152 * @private |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 FontSettings.getInstance().setUpFontSample_($('minimum-font-sample'), size, | 233 FontSettings.getInstance().setUpFontSample_($('minimum-font-sample'), size, |
234 null, true); | 234 null, true); |
235 }; | 235 }; |
236 | 236 |
237 // Export | 237 // Export |
238 return { | 238 return { |
239 FontSettings: FontSettings | 239 FontSettings: FontSettings |
240 }; | 240 }; |
241 }); | 241 }); |
242 | 242 |
OLD | NEW |