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

Unified Diff: chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js

Issue 2256773005: MD Settings: Bluetooth: Use CrScrollableBehavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_638377_scrollable_behavior
Patch Set: Improve item focus and fix tests Created 4 years, 4 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: chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
index d003d9981089cffb38c6552d0740819ee97d502f..e6a6e6d173a0239b65b9840f83315b5f322a5874 100644
--- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
+++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js
@@ -32,9 +32,7 @@ var bluetoothPage = bluetoothPage || {
Polymer({
is: 'settings-bluetooth-page',
- behaviors: [
- I18nBehavior,
- ],
+ behaviors: [I18nBehavior, CrScrollableBehavior],
properties: {
/** Whether bluetooth is enabled. */
@@ -62,7 +60,18 @@ Polymer({
*/
deviceList: {
type: Array,
- value: function() { return []; },
+ value: function() {
+ return [];
+ },
+ },
+
+ /**
+ * Reflects the iron-list selecteditem property.
+ * @type {!chrome.bluetooth.Device}
+ */
+ selectedItem: {
+ type: Object,
+ observer: 'selectedItemChanged_',
},
/**
@@ -191,12 +200,19 @@ Polymer({
}
},
+ /** @private */
bluetoothEnabledChanged_: function() {
// When bluetooth is enabled, auto-expand the device list.
if (this.bluetoothEnabled)
this.deviceListExpanded = true;
},
+ /** @private */
+ selectedItemChanged_: function() {
+ if (this.selectedItem)
+ this.connectDevice_(this.selectedItem);
+ },
+
/**
* @param {boolean} bluetoothEnabled
* @param {boolean} deviceListExpanded
@@ -219,6 +235,7 @@ Polymer({
}
this.bluetooth.getDevices(function(devices) {
this.deviceList = devices;
+ this.updateScrollableContents();
}.bind(this));
},
@@ -261,9 +278,7 @@ Polymer({
}
var index = this.getDeviceIndex_(address);
if (index >= 0) {
- // Use splice to update the item in order to update the dom-repeat lists.
- // See https://github.com/Polymer/polymer/issues/3254.
- this.splice('deviceList', index, 1, device);
+ this.set('deviceList.' + index, device);
return;
}
this.push('deviceList', device);
@@ -346,7 +361,9 @@ Polymer({
},
/** @private */
- onAddDeviceTap_: function() { this.openDialog_('addDevice'); },
+ onAddDeviceTap_: function() {
+ this.openDialog_('addDevice');
+ },
/**
* @param {!{detail: {action: string, device: !chrome.bluetooth.Device}}} e
@@ -406,15 +423,18 @@ Polymer({
* @return {string} The text to display for |device| in the device list.
* @private
*/
- getDeviceName_: function(device) { return device.name || device.address; },
+ getDeviceName_: function(device) {
+ return device.name || device.address;
+ },
/**
- * @param {!chrome.bluetooth.Device} device
- * @return {boolean}
+ * @return {!Array<!chrome.bluetooth.Device>}
* @private
*/
- deviceIsPairedOrConnecting_: function(device) {
- return !!device.paired || !!device.connecting;
+ getPairedOrConnecting_: function() {
+ return this.deviceList.filter(function(device) {
+ return !!device.paired || !!device.connecting;
+ });
},
/**
@@ -423,7 +443,9 @@ Polymer({
* @private
*/
haveDevices_: function(deviceListChanges) {
- return this.deviceList.findIndex(function(d) { return !!d.paired; }) != -1;
+ return this.deviceList.findIndex(function(d) {
+ return !!d.paired;
+ }) != -1;
},
/**
@@ -508,7 +530,9 @@ Polymer({
* @return {boolean}
* @private
*/
- dialogIsVisible_(dialogId, dialogToShow) { return dialogToShow == dialogId; },
+ dialogIsVisible_(dialogId, dialogToShow) {
+ return dialogToShow == dialogId;
+ },
/**
* @param {string} dialogId

Powered by Google App Engine
This is Rietveld 408576698