| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * @fileoverview | 6 * @fileoverview |
| 7 * Class representing an entry in the host-list portion of the home screen. | 7 * Class representing an entry in the host-list portion of the home screen. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 'use strict'; | 10 'use strict'; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 /** @type {function():void?} @private */ | 50 /** @type {function():void?} @private */ |
| 51 this.onConnectReference_ = null; | 51 this.onConnectReference_ = null; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Create the HTML elements for this entry and set up event handlers. | 55 * Create the HTML elements for this entry and set up event handlers. |
| 56 * @return {void} Nothing. | 56 * @return {void} Nothing. |
| 57 */ | 57 */ |
| 58 remoting.HostTableEntry.prototype.createDom = function() { | 58 remoting.HostTableEntry.prototype.createDom = function() { |
| 59 // Create the top-level <div> | 59 // Create the top-level <div> |
| 60 var tableRow = /** @type {HTMLElement} */ document.createElement('div'); | 60 var tableRow = /** @type {HTMLElement} */ (document.createElement('div')); |
| 61 tableRow.classList.add('section-row'); | 61 tableRow.classList.add('section-row'); |
| 62 // Create the host icon cell. | 62 // Create the host icon cell. |
| 63 var hostIconDiv = /** @type {HTMLElement} */ document.createElement('div'); | 63 var hostIconDiv = /** @type {HTMLElement} */ (document.createElement('div')); |
| 64 hostIconDiv.classList.add('host-list-main-icon'); | 64 hostIconDiv.classList.add('host-list-main-icon'); |
| 65 var warningOverlay = | 65 var warningOverlay = |
| 66 /** @type {HTMLElement} */ document.createElement('span'); | 66 /** @type {HTMLElement} */ (document.createElement('span')); |
| 67 hostIconDiv.appendChild(warningOverlay); | 67 hostIconDiv.appendChild(warningOverlay); |
| 68 var hostIcon = /** @type {HTMLElement} */ document.createElement('img'); | 68 var hostIcon = /** @type {HTMLElement} */ (document.createElement('img')); |
| 69 hostIcon.src = 'icon_host.webp'; | 69 hostIcon.src = 'icon_host.webp'; |
| 70 hostIconDiv.appendChild(hostIcon); | 70 hostIconDiv.appendChild(hostIcon); |
| 71 tableRow.appendChild(hostIconDiv); | 71 tableRow.appendChild(hostIconDiv); |
| 72 // Create the host name cell. | 72 // Create the host name cell. |
| 73 var hostNameCell = /** @type {HTMLElement} */ document.createElement('div'); | 73 var hostNameCell = /** @type {HTMLElement} */ (document.createElement('div')); |
| 74 hostNameCell.classList.add('box-spacer'); | 74 hostNameCell.classList.add('box-spacer'); |
| 75 hostNameCell.id = 'host_' + this.host.hostId; | 75 hostNameCell.id = 'host_' + this.host.hostId; |
| 76 tableRow.appendChild(hostNameCell); | 76 tableRow.appendChild(hostNameCell); |
| 77 // Create the host rename cell. | 77 // Create the host rename cell. |
| 78 var editButton = /** @type {HTMLElement} */ document.createElement('span'); | 78 var editButton = /** @type {HTMLElement} */ (document.createElement('span')); |
| 79 var editButtonImg = /** @type {HTMLElement} */ document.createElement('img'); | 79 var editButtonImg = |
| 80 /** @type {HTMLElement} */ (document.createElement('img')); |
| 80 editButtonImg.title = chrome.i18n.getMessage( | 81 editButtonImg.title = chrome.i18n.getMessage( |
| 81 /*i18n-content*/'TOOLTIP_RENAME'); | 82 /*i18n-content*/'TOOLTIP_RENAME'); |
| 82 editButtonImg.src = 'icon_pencil.webp'; | 83 editButtonImg.src = 'icon_pencil.webp'; |
| 83 editButton.tabIndex = 0; | 84 editButton.tabIndex = 0; |
| 84 editButton.classList.add('clickable'); | 85 editButton.classList.add('clickable'); |
| 85 editButton.classList.add('host-list-edit'); | 86 editButton.classList.add('host-list-edit'); |
| 86 editButtonImg.classList.add('host-list-rename-icon'); | 87 editButtonImg.classList.add('host-list-rename-icon'); |
| 87 editButton.appendChild(editButtonImg); | 88 editButton.appendChild(editButtonImg); |
| 88 tableRow.appendChild(editButton); | 89 tableRow.appendChild(editButton); |
| 89 // Create the host delete cell. | 90 // Create the host delete cell. |
| 90 var deleteButton = /** @type {HTMLElement} */ document.createElement('span'); | 91 var deleteButton = |
| 92 /** @type {HTMLElement} */ (document.createElement('span')); |
| 91 var deleteButtonImg = | 93 var deleteButtonImg = |
| 92 /** @type {HTMLElement} */ document.createElement('img'); | 94 /** @type {HTMLElement} */ (document.createElement('img')); |
| 93 deleteButtonImg.title = | 95 deleteButtonImg.title = |
| 94 chrome.i18n.getMessage(/*i18n-content*/'TOOLTIP_DELETE'); | 96 chrome.i18n.getMessage(/*i18n-content*/'TOOLTIP_DELETE'); |
| 95 deleteButtonImg.src = 'icon_cross.webp'; | 97 deleteButtonImg.src = 'icon_cross.webp'; |
| 96 deleteButton.tabIndex = 0; | 98 deleteButton.tabIndex = 0; |
| 97 deleteButton.classList.add('clickable'); | 99 deleteButton.classList.add('clickable'); |
| 98 deleteButton.classList.add('host-list-edit'); | 100 deleteButton.classList.add('host-list-edit'); |
| 99 deleteButtonImg.classList.add('host-list-remove-icon'); | 101 deleteButtonImg.classList.add('host-list-remove-icon'); |
| 100 deleteButton.appendChild(deleteButtonImg); | 102 deleteButton.appendChild(deleteButtonImg); |
| 101 tableRow.appendChild(deleteButton); | 103 tableRow.appendChild(deleteButton); |
| 102 | 104 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 this.warningOverlay_.hidden = !remoting.Host.needsUpdate( | 206 this.warningOverlay_.hidden = !remoting.Host.needsUpdate( |
| 205 this.host, this.webappMajorVersion_); | 207 this.host, this.webappMajorVersion_); |
| 206 }; | 208 }; |
| 207 | 209 |
| 208 /** | 210 /** |
| 209 * Prepare the host for renaming by replacing its name with an edit box. | 211 * Prepare the host for renaming by replacing its name with an edit box. |
| 210 * @return {void} Nothing. | 212 * @return {void} Nothing. |
| 211 * @private | 213 * @private |
| 212 */ | 214 */ |
| 213 remoting.HostTableEntry.prototype.beginRename_ = function() { | 215 remoting.HostTableEntry.prototype.beginRename_ = function() { |
| 214 var editBox = /** @type {HTMLInputElement} */ document.createElement('input'); | 216 var editBox = |
| 217 /** @type {HTMLInputElement} */ (document.createElement('input')); |
| 215 editBox.type = 'text'; | 218 editBox.type = 'text'; |
| 216 editBox.value = this.host.hostName; | 219 editBox.value = this.host.hostName; |
| 217 this.hostNameCell_.innerText = ''; | 220 this.hostNameCell_.innerText = ''; |
| 218 this.hostNameCell_.appendChild(editBox); | 221 this.hostNameCell_.appendChild(editBox); |
| 219 editBox.select(); | 222 editBox.select(); |
| 220 | 223 |
| 221 this.onBlurReference_ = this.commitRename_.bind(this); | 224 this.onBlurReference_ = this.commitRename_.bind(this); |
| 222 editBox.addEventListener('blur', this.onBlurReference_, false); | 225 editBox.addEventListener('blur', this.onBlurReference_, false); |
| 223 | 226 |
| 224 editBox.addEventListener('keydown', this.onKeydown_.bind(this), false); | 227 editBox.addEventListener('keydown', this.onKeydown_.bind(this), false); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 this.updateStatus(); | 312 this.updateStatus(); |
| 310 this.setHostName_(); | 313 this.setHostName_(); |
| 311 }; | 314 }; |
| 312 | 315 |
| 313 /** | 316 /** |
| 314 * Create the DOM nodes and event handlers for the hostname cell. | 317 * Create the DOM nodes and event handlers for the hostname cell. |
| 315 * @return {void} Nothing. | 318 * @return {void} Nothing. |
| 316 * @private | 319 * @private |
| 317 */ | 320 */ |
| 318 remoting.HostTableEntry.prototype.setHostName_ = function() { | 321 remoting.HostTableEntry.prototype.setHostName_ = function() { |
| 319 var hostNameNode = /** @type {HTMLElement} */ document.createElement('a'); | 322 var hostNameNode = /** @type {HTMLElement} */ (document.createElement('a')); |
| 320 if (this.host.status == 'ONLINE') { | 323 if (this.host.status == 'ONLINE') { |
| 321 if (remoting.Host.needsUpdate(this.host, this.webappMajorVersion_)) { | 324 if (remoting.Host.needsUpdate(this.host, this.webappMajorVersion_)) { |
| 322 hostNameNode.innerText = chrome.i18n.getMessage( | 325 hostNameNode.innerText = chrome.i18n.getMessage( |
| 323 /*i18n-content*/'UPDATE_REQUIRED', this.host.hostName); | 326 /*i18n-content*/'UPDATE_REQUIRED', this.host.hostName); |
| 324 } else { | 327 } else { |
| 325 hostNameNode.innerText = this.host.hostName; | 328 hostNameNode.innerText = this.host.hostName; |
| 326 } | 329 } |
| 327 hostNameNode.href = '#'; | 330 hostNameNode.href = '#'; |
| 328 this.registerFocusHandlers_(hostNameNode); | 331 this.registerFocusHandlers_(hostNameNode); |
| 329 /** @type {remoting.HostTableEntry} */ | 332 /** @type {remoting.HostTableEntry} */ |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 var element = document.activeElement; | 402 var element = document.activeElement; |
| 400 while (element) { | 403 while (element) { |
| 401 if (element == this.tableRow) { | 404 if (element == this.tableRow) { |
| 402 this.tableRow.classList.add('child-focused'); | 405 this.tableRow.classList.add('child-focused'); |
| 403 return; | 406 return; |
| 404 } | 407 } |
| 405 element = element.parentNode; | 408 element = element.parentNode; |
| 406 } | 409 } |
| 407 this.tableRow.classList.remove('child-focused'); | 410 this.tableRow.classList.remove('child-focused'); |
| 408 }; | 411 }; |
| OLD | NEW |