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

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: Split cr-network-list into two dom-repeat objects/. Removed list_item_base. 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..8b0115e676cf158d29b648469f058e6a03ee17d4
--- /dev/null
+++ b/ui/webui/resources/cr_elements/network/cr_network_list_custom_item.js
@@ -0,0 +1,85 @@
+// 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';
+
+/**
+ * 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.
+ */
+function getText(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;
+}
+
+/**
+ * Polymer class definition for 'cr-network-list-custom-item'.
+ */
+Polymer({
+ is: 'cr-network-list-custom-item',
+
+ properties: {
+ /**
+ * Custom entry properties:
+ * customItemName - item name
+ * polymerIcon - item polymer icon
+ * onTapEvent - Event to send onTap
+ * (see <cr-network-select/> for details).
+ * @type {!Object}
stevenjb 2016/06/24 22:33:08 Instead of commenting the properties like this, us
Alexander Alekseev 2016/06/25 06:04:43 Done.
+ */
+ itemState: {
+ type: Object,
+ value: null,
+ observer: 'itemStateChanged_'
+ },
+ },
+
+ /**
+ * Polymer listeners.
+ */
stevenjb 2016/06/24 22:33:08 nit: Comment not needed
Alexander Alekseev 2016/06/25 06:04:43 Done.
+ listeners: {
+ 'tap' : 'onTap_'
+ },
+
+ /**
+ * Polymer |itemState| changed method.
+ */
+ itemStateChanged_: function() {
+ if (!this.itemState)
+ return;
+
+ if (this.itemState.customItemName) {
+ this.$.itemName.textContent =
+ getText(this.itemState.customItemName);
+ }
stevenjb 2016/06/24 22:33:08 This shouldn't be necessary, you can just use [[ge
Alexander Alekseev 2016/06/25 06:04:43 Done.
+ },
+
stevenjb 2016/06/24 22:33:08 provide @param doc for |e|
Alexander Alekseev 2016/06/25 06:04:43 Done.
+ onTap_: function(e) {
+ if (!this.itemState)
+ return;
+
+ if (this.itemState.onTapEvent)
+ this.fire(this.itemState.onTapEvent, this.itemState);
stevenjb 2016/06/24 22:33:08 Instead of using a custom event, just fire e.g. 'n
Alexander Alekseev 2016/06/25 06:04:43 Done.
+ },
+});
+})();

Powered by Google App Engine
This is Rietveld 408576698