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

Unified Diff: ui/webui/resources/cr_elements/network/cr_network_list_custom_item.js

Issue 2069323002: Add support for custom entries in <cr_network_select/>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@604119--Implement-Chrome-OS-out-of-box-flow-in-Material-Design--ImplementNetworkSelectionScreen
Patch Set: Fix compile. Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/webui/resources/cr_elements/network/cr_network_list_custom_item.js
diff --git a/ui/webui/resources/cr_elements/network/cr_network_list_custom_item.js b/ui/webui/resources/cr_elements/network/cr_network_list_custom_item.js
new file mode 100644
index 0000000000000000000000000000000000000000..13af5194eb4279bbb537f0da68656736f71eeb25
--- /dev/null
+++ b/ui/webui/resources/cr_elements/network/cr_network_list_custom_item.js
@@ -0,0 +1,69 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Polymer element for displaying information about a network
+ * in a list or summary based on ONC state properties.
+ */
+(function() {
+'use strict';
+
+/**
+ * Polymer class definition for 'cr-network-list-custom-item'.
+ * Note: on-tapaction on this item fires "custom-item-selected" event
+ * with |itemState| as data.
+ */
+Polymer({
+ is: 'cr-network-list-custom-item',
+
+ properties: {
+ /**
+ * Custom entry properties.
+ * @type {?CrNetworkList.CustomItemState}
+ */
+ itemState: {
+ type: Object,
+ value: null,
+ },
+ },
+
+ listeners: {
+ 'tap' : 'onTap_'
+ },
+
+ /**
+ * @param {!Event} event
+ */
+ onTap_: function(event) {
+ if (!this.itemState)
+ return;
+
+ this.fire("custom-item-selected", this.itemState);
+ },
+
+ /**
+ * TODO(stevenjb): Replace getText with a proper localization function that
+ * handles string substitution.
+ * Performs argument substitution, replacing $1, $2, etc in 'text' with
+ * corresponding entries in |args|.
+ * @param {string} text The string to perform the substitution on.
+ * @param {?Array<string>=} opt_args The arguments to replace $1, $2, etc
+ * with.
+ */
+ getText_: function(text, opt_args) {
+ var res;
+ if (loadTimeData && loadTimeData.data_)
+ res = loadTimeData.getString(text) || text;
+ else
+ res = text;
+ if (!opt_args)
+ return res;
+ for (let i = 0; i < opt_args.length; ++i) {
+ let key = '$' + (i + 1);
+ res = res.replace(key, opt_args[i]);
+ }
+ return res;
+ },
+});
+})();

Powered by Google App Engine
This is Rietveld 408576698