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

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 2. 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 typeof values == 'string' ? element.appendChild(new Option(values)) :
arv (Not doing code reviews) 2011/01/08 00:08:53 This was not what I had in mind... Either: var o
James Hawkins 2011/01/08 00:15:51 Done.
48 element.appendChild(new Option(values[1], values[0]));
49 });
50 },
51
52 /**
42 * This is used to set HTML attributes and DOM properties,. The syntax is: 53 * This is used to set HTML attributes and DOM properties,. The syntax is:
43 * attributename:key; 54 * attributename:key;
44 * .domProperty:key; 55 * .domProperty:key;
45 * .nested.dom.property:key 56 * .nested.dom.property:key
46 */ 57 */
47 'i18n-values': function(element, attributeValue, obj) { 58 'i18n-values': function(element, attributeValue, obj) {
48 var parts = attributeValue.replace(/\s/g, '').split(/;/); 59 var parts = attributeValue.replace(/\s/g, '').split(/;/);
49 for (var j = 0; j < parts.length; j++) { 60 for (var j = 0; j < parts.length; j++) {
50 var a = parts[j].match(/^([^:]+):(.+)$/); 61 var a = parts[j].match(/^([^:]+):(.+)$/);
51 if (a) { 62 if (a) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 handlers[name](element, att, obj); 110 handlers[name](element, att, obj);
100 } 111 }
101 } 112 }
102 } 113 }
103 } 114 }
104 115
105 return { 116 return {
106 process: process 117 process: process
107 }; 118 };
108 })(); 119 })();
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