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

Side by Side Diff: chrome/browser/resources/shared/js/i18n_template.js

Issue 6150003: DOMUI: Implement the i18n-options attribute that allows the client to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years, 11 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
« no previous file with comments | « chrome/browser/resources/options/pref_ui.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 5 /**
6 * @fileoverview This is a simple template engine inspired by JsTemplates 6 * @fileoverview This is a simple template engine inspired by JsTemplates
7 * optimized for i18n. 7 * optimized for i18n.
8 * 8 *
9 * It currently supports two handlers: 9 * It currently supports two handlers:
10 * 10 *
(...skipping 21 matching lines...) Expand all
32 */ 32 */
33 var handlers = { 33 var handlers = {
34 /** 34 /**
35 * This handler sets the textContent of the element. 35 * This handler sets the textContent of the element.
36 */ 36 */
37 'i18n-content': function(element, attributeValue, obj) { 37 'i18n-content': function(element, attributeValue, obj) {
38 element.textContent = obj[attributeValue]; 38 element.textContent = obj[attributeValue];
39 }, 39 },
40 40
41 /** 41 /**
42 * This handler adds options to a select element.
43 */
44 'i18n-options': function(element, attributeValue, obj) {
45 var options = obj[attributeValue];
46 options.forEach(function(values) {
47 if (typeof values == 'string')
48 element.appendChild(new Option(values));
49 else
50 element.appendChild(new Option(values[1], values[0]));
arv (Not doing code reviews) 2011/01/07 23:54:09 Use a var or ?:
James Hawkins 2011/01/08 00:02:51 Done.
51 });
52 },
53
54 /**
42 * This is used to set HTML attributes and DOM properties,. The syntax is: 55 * This is used to set HTML attributes and DOM properties,. The syntax is:
43 * attributename:key; 56 * attributename:key;
44 * .domProperty:key; 57 * .domProperty:key;
45 * .nested.dom.property:key 58 * .nested.dom.property:key
46 */ 59 */
47 'i18n-values': function(element, attributeValue, obj) { 60 'i18n-values': function(element, attributeValue, obj) {
48 var parts = attributeValue.replace(/\s/g, '').split(/;/); 61 var parts = attributeValue.replace(/\s/g, '').split(/;/);
49 for (var j = 0; j < parts.length; j++) { 62 for (var j = 0; j < parts.length; j++) {
50 var a = parts[j].match(/^([^:]+):(.+)$/); 63 var a = parts[j].match(/^([^:]+):(.+)$/);
51 if (a) { 64 if (a) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 handlers[name](element, att, obj); 112 handlers[name](element, att, obj);
100 } 113 }
101 } 114 }
102 } 115 }
103 } 116 }
104 117
105 return { 118 return {
106 process: process 119 process: process
107 }; 120 };
108 })(); 121 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/pref_ui.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698