Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/common/extensions/docs/examples/api/fontSettings/popup.js

Issue 9836036: Add getDefaultFontSize and setDefaultFontSize to Font Settings Extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 var scriptList; 5 var scriptList;
6 6
7 // Mapping between font list ids and the generic family setting they 7 // Mapping between font list ids and the generic family setting they
8 // represent. 8 // represent.
9 var genericFamilies = [ 9 var genericFamilies = [
10 { fontList: 'standardFontList', name: 'standard' }, 10 { fontList: 'standardFontList', name: 'standard' },
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 var details = {}; 100 var details = {};
101 details.genericFamily = family; 101 details.genericFamily = family;
102 if (script != DEFAULT_SCRIPT) 102 if (script != DEFAULT_SCRIPT)
103 details.script = script; 103 details.script = script;
104 104
105 chrome.experimental.fontSettings.getFontName(details, 105 chrome.experimental.fontSettings.getFontName(details,
106 getFontNameHandler(list)); 106 getFontNameHandler(list));
107 } 107 }
108 } 108 }
109 109
110 function defaultFontSizeChanged() {
111 var defaultFontSizeInput = document.getElementById('defaultFontSize');
112 var pixelSize = parseInt(defaultFontSizeInput.value);
113 if (!isNaN(pixelSize)) {
114 chrome.experimental.fontSettings.setDefaultFontSize({
115 pixelSize: pixelSize
116 });
117 }
118 }
119
110 function init() { 120 function init() {
111 scriptList = document.getElementById('scriptList'); 121 scriptList = document.getElementById('scriptList');
112 scriptList.addEventListener('change', updateListSelections); 122 scriptList.addEventListener('change', updateListSelections);
113 123
114 // Populate the font lists. 124 // Populate the font lists.
115 chrome.experimental.fontSettings.getFontList(populateLists); 125 chrome.experimental.fontSettings.getFontList(populateLists);
116 126
117 // Add change handlers to the font lists. 127 // Add change handlers to the font lists.
118 for (var i = 0; i < genericFamilies.length; i++) { 128 for (var i = 0; i < genericFamilies.length; i++) {
119 var list = document.getElementById(genericFamilies[i].fontList); 129 var list = document.getElementById(genericFamilies[i].fontList);
120 var handler = getFontChangeHandler(list, genericFamilies[i].name); 130 var handler = getFontChangeHandler(list, genericFamilies[i].name);
121 list.addEventListener('change', handler); 131 list.addEventListener('change', handler);
122 } 132 }
133
134 var defaultFontSizeInput = document.getElementById('defaultFontSize');
135 chrome.experimental.fontSettings.getDefaultFontSize({}, function(details) {
136 defaultFontSizeInput.value = details.pixelSize;
137 });
138 defaultFontSizeInput.addEventListener('change', defaultFontSizeChanged);
123 } 139 }
124 140
125 document.addEventListener('DOMContentLoaded', init); 141 document.addEventListener('DOMContentLoaded', init);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698