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

Unified Diff: chrome/browser/resources/options2/chromeos/cellular_plan_element.js

Issue 8895023: Options2: Pull the trigger. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DIAF. Created 9 years 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: chrome/browser/resources/options2/chromeos/cellular_plan_element.js
diff --git a/chrome/browser/resources/options2/chromeos/cellular_plan_element.js b/chrome/browser/resources/options2/chromeos/cellular_plan_element.js
new file mode 100644
index 0000000000000000000000000000000000000000..2eaa7d34e18e5f21c5e1db8fca303043ff253c7c
--- /dev/null
+++ b/chrome/browser/resources/options2/chromeos/cellular_plan_element.js
@@ -0,0 +1,132 @@
+// Copyright (c) 2011 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.
+
+cr.define('options.internet', function() {
+ /**
+ * Creates a new network list div.
+ * @param {Object=} opt_propertyBag Optional properties.
+ * @constructor
+ * @extends {HTMLDivElement}
+ */
+ var CellularPlanElement = cr.ui.define('div');
+
+ CellularPlanElement.prototype = {
+ __proto__: HTMLDivElement.prototype,
+
+ /** @inheritDoc */
+ decorate: function() {
+ },
+
+ /**
+ * Loads given network list.
+ * @param {Array} networks An array of network object.
+ */
+ load: function(plans) {
+ this.textContent = '';
+ if (!plans || !plans.length) {
+ var noplansDiv = this.ownerDocument.createElement('div');
+ noplansDiv.textContent = localStrings.getString('noPlansFound');
+ this.appendChild(detailsTable);
+ } else {
+ for (var i = 0; i < plans.length; ++i) {
+ this.appendChild(new CellularPlanItem(i, plans[i]));
+ }
+ }
+ }
+ };
+
+ /**
+ * Creates a new network item.
+ * @param {Object} network The network this represents.
+ * @constructor
+ * @extends {HTMLDivElement}
+ */
+ function CellularPlanItem(idx, plan) {
+ var el = cr.doc.createElement('div');
+ el.data = {
+ idx: idx,
+ planType: plan.planType,
+ name: plan.name,
+ planSummary: plan.planSummary,
+ dataRemaining: plan.dataRemaining,
+ planExpires: plan.planExpires,
+ warning: plan.warning
+ };
+ CellularPlanItem.decorate(el);
+ return el;
+ }
+
+
+ /**
+ * Decorates an element as a network item.
+ * @param {!HTMLElement} el The element to decorate.
+ */
+ CellularPlanItem.decorate = function(el) {
+ el.__proto__ = CellularPlanItem.prototype;
+ el.decorate();
+ };
+
+ CellularPlanItem.prototype = {
+ __proto__: HTMLDivElement.prototype,
+
+ /** @inheritDoc */
+ decorate: function() {
+ this.className = 'cellular-plan';
+ var detailsTable = this.createTable_('details-plan-table',
+ 'option-control-table');
+ this.addRow_(detailsTable, 'plan-details-info',
+ 'option-name', 'planSummary', this.data.planSummary);
+ this.addRow_(detailsTable, 'plan-details-info',
+ 'option-name', null, localStrings.getString('planName'),
+ 'option-value', 'planName', this.data.name);
+ this.addRow_(detailsTable, 'plan-details-info',
+ 'option-name', null, localStrings.getString('dataRemaining'),
+ 'option-value', 'dataRemaining', this.data.dataRemaining);
+ this.addRow_(detailsTable, 'plan-details-info',
+ 'option-name', null, localStrings.getString('planExpires'),
+ 'option-value', 'dataRemaining', this.data.planExpires);
+ if (this.data.warning && this.data.warning != "") {
+ this.addRow_(detailsTable, 'plan-details-info',
+ 'option-name', 'planWarning', this.data.warning);
+ }
+ this.appendChild(detailsTable);
+ this.appendChild(this.ownerDocument.createElement('hr'));
+ },
+
+ createTable_: function(tableId, tableClass) {
+ var table = this.ownerDocument.createElement('table');
+ table.id = tableId;
+ table.className = tableClass;
+ return table;
+ },
+
+ addRow_: function(table, rowClass, col1Class, col1Id, col1Value,
+ col2Class, col2Id, col2Value) {
+ var row = this.ownerDocument.createElement('tr');
+ if (rowClass)
+ row.className = rowClass;
+ var col1 = this.ownerDocument.createElement('td');
+ col1.className = col1Class;
+ if (col1Id)
+ col1.id = col1Id;
+ col1.textContent = col1Value;
+ if (!col2Class)
+ col1.setAttribute('colspan','2');
+ row.appendChild(col1);
+ if (col2Class) {
+ var col2 = this.ownerDocument.createElement('td');
+ col2.className = col2Class;
+ if (col2Id)
+ col2.id = col2Id;
+ col2.textContent = col2Value;
+ row.appendChild(col2);
+ }
+ table.appendChild(row);
+ }
+ };
+
+ return {
+ CellularPlanElement: CellularPlanElement
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698