Chromium Code Reviews| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 this._element.removeChildren(); | 182 this._element.removeChildren(); |
| 183 this._element.createChild("br"); | 183 this._element.createChild("br"); |
| 184 } else { | 184 } else { |
| 185 this._element.textContent = x; | 185 this._element.textContent = x; |
| 186 } | 186 } |
| 187 | 187 |
| 188 this.moveCaretToEndOfPrompt(); | 188 this.moveCaretToEndOfPrompt(); |
| 189 this._element.scrollIntoView(); | 189 this._element.scrollIntoView(); |
| 190 }, | 190 }, |
| 191 | 191 |
| 192 /** | |
| 193 * @return {string} | |
| 194 */ | |
| 195 title: function() | |
| 196 { | |
| 197 return this._element.title; | |
|
lushnikov
2016/03/25 18:48:32
In order to make methods title() and setTitle() in
| |
| 198 }, | |
| 199 | |
| 200 /** | |
| 201 * @param {string} title | |
| 202 */ | |
| 203 setTitle: function(title) | |
| 204 { | |
| 205 this._element.title = title; | |
|
lushnikov
2016/03/25 18:48:32
I think it would be better to use this._proxyEleme
| |
| 206 }, | |
| 207 | |
| 192 _removeFromElement: function() | 208 _removeFromElement: function() |
| 193 { | 209 { |
| 194 this.clearAutoComplete(true); | 210 this.clearAutoComplete(true); |
| 195 this._element.removeEventListener("keydown", this._boundOnKeyDown, false ); | 211 this._element.removeEventListener("keydown", this._boundOnKeyDown, false ); |
| 196 this._element.removeEventListener("input", this._boundOnInput, false); | 212 this._element.removeEventListener("input", this._boundOnInput, false); |
| 197 this._element.removeEventListener("selectstart", this._boundSelectStart, false); | 213 this._element.removeEventListener("selectstart", this._boundSelectStart, false); |
| 198 this._element.removeEventListener("blur", this._boundRemoveSuggestionAid s, false); | 214 this._element.removeEventListener("blur", this._boundRemoveSuggestionAid s, false); |
| 199 this._element.ownerDocument.defaultView.removeEventListener("resize", th is._boundRemoveSuggestionAids, false); | 215 this._element.ownerDocument.defaultView.removeEventListener("resize", th is._boundRemoveSuggestionAids, false); |
| 200 if (this._isEditing) | 216 if (this._isEditing) |
| 201 this._stopEditing(); | 217 this._stopEditing(); |
| 202 if (this._suggestBox) | 218 if (this._suggestBox) |
| 203 this._suggestBox.removeFromElement(); | 219 this._suggestBox.removeFromElement(); |
| 204 }, | 220 }, |
| 205 | 221 |
| 222 onEditStart: function() | |
| 223 { | |
| 224 // Subclasses can implement. | |
| 225 }, | |
| 226 | |
| 227 onEditDone: function() | |
| 228 { | |
| 229 // Subclasses can implement. | |
| 230 }, | |
| 231 | |
| 206 /** | 232 /** |
| 207 * @param {function(!Event)=} blurListener | 233 * @param {function(!Event)=} blurListener |
| 208 */ | 234 */ |
| 209 _startEditing: function(blurListener) | 235 _startEditing: function(blurListener) |
| 210 { | 236 { |
| 211 this._isEditing = true; | 237 this._isEditing = true; |
| 212 this._contentElement.classList.add("text-prompt-editing"); | 238 this._contentElement.classList.add("text-prompt-editing"); |
| 213 if (blurListener) { | 239 if (blurListener) { |
| 214 this._blurListener = blurListener; | 240 this._blurListener = blurListener; |
| 215 this._element.addEventListener("blur", this._blurListener, false); | 241 this._element.addEventListener("blur", this._blurListener, false); |
| 216 } | 242 } |
| 217 this._oldTabIndex = this._element.tabIndex; | 243 this._oldTabIndex = this._element.tabIndex; |
| 218 if (this._element.tabIndex < 0) | 244 if (this._element.tabIndex < 0) |
| 219 this._element.tabIndex = 0; | 245 this._element.tabIndex = 0; |
| 220 WebInspector.setCurrentFocusElement(this._element); | 246 WebInspector.setCurrentFocusElement(this._element); |
| 221 if (!this.text()) | 247 if (!this.text()) |
| 222 this._updateAutoComplete(); | 248 this._updateAutoComplete(); |
| 249 this.onEditStart(); | |
| 223 }, | 250 }, |
| 224 | 251 |
| 225 _stopEditing: function() | 252 _stopEditing: function() |
| 226 { | 253 { |
| 227 this._element.tabIndex = this._oldTabIndex; | 254 this._element.tabIndex = this._oldTabIndex; |
| 228 if (this._blurListener) | 255 if (this._blurListener) |
| 229 this._element.removeEventListener("blur", this._blurListener, false) ; | 256 this._element.removeEventListener("blur", this._blurListener, false) ; |
| 230 this._contentElement.classList.remove("text-prompt-editing"); | 257 this._contentElement.classList.remove("text-prompt-editing"); |
| 231 delete this._isEditing; | 258 delete this._isEditing; |
| 259 this.onEditDone(); | |
| 232 }, | 260 }, |
| 233 | 261 |
| 234 _removeSuggestionAids: function() | 262 _removeSuggestionAids: function() |
| 235 { | 263 { |
| 236 this.clearAutoComplete(); | 264 this.clearAutoComplete(); |
| 237 this.hideSuggestBox(); | 265 this.hideSuggestBox(); |
| 238 }, | 266 }, |
| 239 | 267 |
| 240 _selectStart: function() | 268 _selectStart: function() |
| 241 { | 269 { |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 | 996 |
| 969 return; | 997 return; |
| 970 } | 998 } |
| 971 | 999 |
| 972 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); | 1000 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); |
| 973 }, | 1001 }, |
| 974 | 1002 |
| 975 __proto__: WebInspector.TextPrompt.prototype | 1003 __proto__: WebInspector.TextPrompt.prototype |
| 976 } | 1004 } |
| 977 | 1005 |
| OLD | NEW |