| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (this._proxyElement) | 102 if (this._proxyElement) |
| 103 throw 'Cannot attach an attached TextPrompt'; | 103 throw 'Cannot attach an attached TextPrompt'; |
| 104 this._element = element; | 104 this._element = element; |
| 105 | 105 |
| 106 this._boundOnKeyDown = this.onKeyDown.bind(this); | 106 this._boundOnKeyDown = this.onKeyDown.bind(this); |
| 107 this._boundOnInput = this.onInput.bind(this); | 107 this._boundOnInput = this.onInput.bind(this); |
| 108 this._boundOnMouseWheel = this.onMouseWheel.bind(this); | 108 this._boundOnMouseWheel = this.onMouseWheel.bind(this); |
| 109 this._boundClearAutocomplete = this.clearAutocomplete.bind(this); | 109 this._boundClearAutocomplete = this.clearAutocomplete.bind(this); |
| 110 this._proxyElement = element.ownerDocument.createElement('span'); | 110 this._proxyElement = element.ownerDocument.createElement('span'); |
| 111 var shadowRoot = UI.createShadowRootWithCoreStyles(this._proxyElement, 'ui/t
extPrompt.css'); | 111 var shadowRoot = UI.createShadowRootWithCoreStyles(this._proxyElement, 'ui/t
extPrompt.css'); |
| 112 this._contentElement = shadowRoot.createChild('div'); | 112 this._contentElement = shadowRoot.createChild('div', 'text-prompt-root'); |
| 113 this._contentElement.createChild('content'); | 113 this._contentElement.createChild('content'); |
| 114 this._proxyElement.style.display = this._proxyElementDisplay; | 114 this._proxyElement.style.display = this._proxyElementDisplay; |
| 115 element.parentElement.insertBefore(this._proxyElement, element); | 115 element.parentElement.insertBefore(this._proxyElement, element); |
| 116 this._proxyElement.appendChild(element); | 116 this._proxyElement.appendChild(element); |
| 117 this._element.classList.add('text-prompt'); | 117 this._element.classList.add('text-prompt'); |
| 118 this._element.addEventListener('keydown', this._boundOnKeyDown, false); | 118 this._element.addEventListener('keydown', this._boundOnKeyDown, false); |
| 119 this._element.addEventListener('input', this._boundOnInput, false); | 119 this._element.addEventListener('input', this._boundOnInput, false); |
| 120 this._element.addEventListener('mousewheel', this._boundOnMouseWheel, false)
; | 120 this._element.addEventListener('mousewheel', this._boundOnMouseWheel, false)
; |
| 121 this._element.addEventListener('selectstart', this._boundClearAutocomplete,
false); | 121 this._element.addEventListener('selectstart', this._boundClearAutocomplete,
false); |
| 122 this._element.addEventListener('blur', this._boundClearAutocomplete, false); | 122 this._element.addEventListener('blur', this._boundClearAutocomplete, false); |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 } | 636 } |
| 637 }; | 637 }; |
| 638 | 638 |
| 639 UI.TextPrompt.DefaultAutocompletionTimeout = 250; | 639 UI.TextPrompt.DefaultAutocompletionTimeout = 250; |
| 640 | 640 |
| 641 /** @enum {symbol} */ | 641 /** @enum {symbol} */ |
| 642 UI.TextPrompt.Events = { | 642 UI.TextPrompt.Events = { |
| 643 ItemApplied: Symbol('text-prompt-item-applied'), | 643 ItemApplied: Symbol('text-prompt-item-applied'), |
| 644 ItemAccepted: Symbol('text-prompt-item-accepted') | 644 ItemAccepted: Symbol('text-prompt-item-accepted') |
| 645 }; | 645 }; |
| OLD | NEW |