| 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 26 matching lines...) Expand all Loading... |
| 37 WebInspector.TextPrompt = function(completions, stopCharacters) | 37 WebInspector.TextPrompt = function(completions, stopCharacters) |
| 38 { | 38 { |
| 39 /** | 39 /** |
| 40 * @type {!Element|undefined} | 40 * @type {!Element|undefined} |
| 41 */ | 41 */ |
| 42 this._proxyElement; | 42 this._proxyElement; |
| 43 this._proxyElementDisplay = "inline-block"; | 43 this._proxyElementDisplay = "inline-block"; |
| 44 this._loadCompletions = completions; | 44 this._loadCompletions = completions; |
| 45 this._completionStopCharacters = stopCharacters || " =:[({;,!+-*/&|^<>."; | 45 this._completionStopCharacters = stopCharacters || " =:[({;,!+-*/&|^<>."; |
| 46 this._autocompletionTimeout = WebInspector.TextPrompt.DefaultAutocompletionT
imeout; | 46 this._autocompletionTimeout = WebInspector.TextPrompt.DefaultAutocompletionT
imeout; |
| 47 this._title = ""; |
| 47 } | 48 } |
| 48 | 49 |
| 49 WebInspector.TextPrompt.DefaultAutocompletionTimeout = 250; | 50 WebInspector.TextPrompt.DefaultAutocompletionTimeout = 250; |
| 50 | 51 |
| 51 WebInspector.TextPrompt.Events = { | 52 WebInspector.TextPrompt.Events = { |
| 52 ItemApplied: "text-prompt-item-applied", | 53 ItemApplied: "text-prompt-item-applied", |
| 53 ItemAccepted: "text-prompt-item-accepted" | 54 ItemAccepted: "text-prompt-item-accepted" |
| 54 }; | 55 }; |
| 55 | 56 |
| 56 WebInspector.TextPrompt.prototype = { | 57 WebInspector.TextPrompt.prototype = { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 this._element.addEventListener("keydown", this._boundOnKeyDown, false); | 131 this._element.addEventListener("keydown", this._boundOnKeyDown, false); |
| 131 this._element.addEventListener("input", this._boundOnInput, false); | 132 this._element.addEventListener("input", this._boundOnInput, false); |
| 132 this._element.addEventListener("mousewheel", this._boundOnMouseWheel, fa
lse); | 133 this._element.addEventListener("mousewheel", this._boundOnMouseWheel, fa
lse); |
| 133 this._element.addEventListener("selectstart", this._boundSelectStart, fa
lse); | 134 this._element.addEventListener("selectstart", this._boundSelectStart, fa
lse); |
| 134 this._element.addEventListener("blur", this._boundRemoveSuggestionAids,
false); | 135 this._element.addEventListener("blur", this._boundRemoveSuggestionAids,
false); |
| 135 this._element.ownerDocument.defaultView.addEventListener("resize", this.
_boundRemoveSuggestionAids, false); | 136 this._element.ownerDocument.defaultView.addEventListener("resize", this.
_boundRemoveSuggestionAids, false); |
| 136 | 137 |
| 137 if (this._suggestBoxEnabled) | 138 if (this._suggestBoxEnabled) |
| 138 this._suggestBox = new WebInspector.SuggestBox(this); | 139 this._suggestBox = new WebInspector.SuggestBox(this); |
| 139 | 140 |
| 141 if (this._title) |
| 142 this._proxyElement.title = this._title; |
| 143 |
| 140 return this._proxyElement; | 144 return this._proxyElement; |
| 141 }, | 145 }, |
| 142 | 146 |
| 143 detach: function() | 147 detach: function() |
| 144 { | 148 { |
| 145 this._removeFromElement(); | 149 this._removeFromElement(); |
| 146 this._proxyElement.parentElement.insertBefore(this._element, this._proxy
Element); | 150 this._proxyElement.parentElement.insertBefore(this._element, this._proxy
Element); |
| 147 this._proxyElement.remove(); | 151 this._proxyElement.remove(); |
| 148 delete this._proxyElement; | 152 delete this._proxyElement; |
| 149 this._element.classList.remove("text-prompt"); | 153 this._element.classList.remove("text-prompt"); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 this._element.removeChildren(); | 186 this._element.removeChildren(); |
| 183 this._element.createChild("br"); | 187 this._element.createChild("br"); |
| 184 } else { | 188 } else { |
| 185 this._element.textContent = x; | 189 this._element.textContent = x; |
| 186 } | 190 } |
| 187 | 191 |
| 188 this.moveCaretToEndOfPrompt(); | 192 this.moveCaretToEndOfPrompt(); |
| 189 this._element.scrollIntoView(); | 193 this._element.scrollIntoView(); |
| 190 }, | 194 }, |
| 191 | 195 |
| 196 /** |
| 197 * @return {string} |
| 198 */ |
| 199 title: function() |
| 200 { |
| 201 return this._title; |
| 202 }, |
| 203 |
| 204 /** |
| 205 * @param {string} title |
| 206 */ |
| 207 setTitle: function(title) |
| 208 { |
| 209 this._title = title; |
| 210 if (this._proxyElement) |
| 211 this.proxyElement.title = title; |
| 212 }, |
| 213 |
| 192 _removeFromElement: function() | 214 _removeFromElement: function() |
| 193 { | 215 { |
| 194 this.clearAutoComplete(true); | 216 this.clearAutoComplete(true); |
| 195 this._element.removeEventListener("keydown", this._boundOnKeyDown, false
); | 217 this._element.removeEventListener("keydown", this._boundOnKeyDown, false
); |
| 196 this._element.removeEventListener("input", this._boundOnInput, false); | 218 this._element.removeEventListener("input", this._boundOnInput, false); |
| 197 this._element.removeEventListener("selectstart", this._boundSelectStart,
false); | 219 this._element.removeEventListener("selectstart", this._boundSelectStart,
false); |
| 198 this._element.removeEventListener("blur", this._boundRemoveSuggestionAid
s, false); | 220 this._element.removeEventListener("blur", this._boundRemoveSuggestionAid
s, false); |
| 199 this._element.ownerDocument.defaultView.removeEventListener("resize", th
is._boundRemoveSuggestionAids, false); | 221 this._element.ownerDocument.defaultView.removeEventListener("resize", th
is._boundRemoveSuggestionAids, false); |
| 200 if (this._isEditing) | 222 if (this._isEditing) |
| 201 this._stopEditing(); | 223 this._stopEditing(); |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 | 1011 |
| 990 return; | 1012 return; |
| 991 } | 1013 } |
| 992 | 1014 |
| 993 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); | 1015 WebInspector.TextPrompt.prototype.onKeyDown.apply(this, arguments); |
| 994 }, | 1016 }, |
| 995 | 1017 |
| 996 __proto__: WebInspector.TextPrompt.prototype | 1018 __proto__: WebInspector.TextPrompt.prototype |
| 997 } | 1019 } |
| 998 | 1020 |
| OLD | NEW |