| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * A bluetooth device. | 6 * A bluetooth device. |
| 7 * @constructor | 7 * @constructor |
| 8 */ | 8 */ |
| 9 var BluetoothDevice = function() { | 9 var BluetoothDevice = function() { |
| 10 // The device's address (MAC format, must be unique). | 10 // The device's address (MAC format, must be unique). |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 */ | 166 */ |
| 167 currentEditableObjectChanged: function(obj) { | 167 currentEditableObjectChanged: function(obj) { |
| 168 if (this.currentEditIndex >= 0) { | 168 if (this.currentEditIndex >= 0) { |
| 169 var prop = obj.path.split('.')[1]; | 169 var prop = obj.path.split('.')[1]; |
| 170 this.set( | 170 this.set( |
| 171 'devices.' + this.currentEditIndex.toString() + '.' + prop, | 171 'devices.' + this.currentEditIndex.toString() + '.' + prop, |
| 172 obj.value); | 172 obj.value); |
| 173 } | 173 } |
| 174 }, | 174 }, |
| 175 | 175 |
| 176 /** | |
| 177 * Called when the device edit dialog is opened. Re-validates necessary input | |
| 178 * fields. | |
| 179 */ | |
| 180 editDialogOpened: function() { | |
| 181 this.validateAddress(); | |
| 182 this.validatePath(); | |
| 183 }, | |
| 184 | |
| 185 handleAddressInput: function() { | 176 handleAddressInput: function() { |
| 186 this.autoFormatAddress(); | 177 this.autoFormatAddress(); |
| 187 this.validateAddress(); | 178 this.validateAddress(); |
| 188 }, | 179 }, |
| 189 | 180 |
| 190 autoFormatAddress: function() { | 181 autoFormatAddress: function() { |
| 191 var input = this.$.deviceAddressInput; | 182 var input = this.$.deviceAddressInput; |
| 192 var regex = /([a-f0-9]{2})([a-f0-9]{2})/i; | 183 var regex = /([a-f0-9]{2})([a-f0-9]{2})/i; |
| 193 // Remove things that aren't hex characters from the string. | 184 // Remove things that aren't hex characters from the string. |
| 194 var val = input.value.replace(/[^a-f0-9]/ig, ''); | 185 var val = input.value.replace(/[^a-f0-9]/ig, ''); |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 464 |
| 474 /** | 465 /** |
| 475 * Shows a dialog to edit the selected device's properties. | 466 * Shows a dialog to edit the selected device's properties. |
| 476 * @param {Event} event Contains event data. |event.model.index| is the index | 467 * @param {Event} event Contains event data. |event.model.index| is the index |
| 477 * of the item which the target is contained in. | 468 * of the item which the target is contained in. |
| 478 */ | 469 */ |
| 479 showEditDialog: function(event) { | 470 showEditDialog: function(event) { |
| 480 var index = event.model.index; | 471 var index = event.model.index; |
| 481 this.currentEditIndex = index; | 472 this.currentEditIndex = index; |
| 482 this.currentEditableObject = this.devices[index]; | 473 this.currentEditableObject = this.devices[index]; |
| 483 this.$.editDialog.toggle(); | 474 this.$.editDialog.showModal(); |
| 475 this.validateAddress(); |
| 476 this.validatePath(); |
| 477 }, |
| 478 |
| 479 /** @private */ |
| 480 onCloseTap_: function() { |
| 481 this.$.editDialog.close(); |
| 484 }, | 482 }, |
| 485 | 483 |
| 486 /** | 484 /** |
| 487 * A click handler for the delete button on bluetooth devices. | 485 * A click handler for the delete button on bluetooth devices. |
| 488 * @param {Event} event Contains event data. |event.model.index| is the index | 486 * @param {Event} event Contains event data. |event.model.index| is the index |
| 489 * of the item which the target is contained in. | 487 * of the item which the target is contained in. |
| 490 */ | 488 */ |
| 491 deleteDevice: function(event) { | 489 deleteDevice: function(event) { |
| 492 var index = event.model.index; | 490 var index = event.model.index; |
| 493 var device = this.devices[index]; | 491 var device = this.devices[index]; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 * @return {number} The value which |classText| represents. | 532 * @return {number} The value which |classText| represents. |
| 535 */ | 533 */ |
| 536 getValueForDeviceClass: function(classText) { | 534 getValueForDeviceClass: function(classText) { |
| 537 for (var i = 0; i < this.deviceClassOptions.length; ++i) { | 535 for (var i = 0; i < this.deviceClassOptions.length; ++i) { |
| 538 if (this.deviceClassOptions[i].text == classText) | 536 if (this.deviceClassOptions[i].text == classText) |
| 539 return this.deviceClassOptions[i].value; | 537 return this.deviceClassOptions[i].value; |
| 540 } | 538 } |
| 541 return 0; | 539 return 0; |
| 542 }, | 540 }, |
| 543 }); | 541 }); |
| OLD | NEW |