Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: Source/devtools/front_end/ui/SuggestBox.js

Issue 662793002: [DevTools] Replace usages of document with custom functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 */ 55 */
56 WebInspector.SuggestBox = function(suggestBoxDelegate, maxItemsHeight) 56 WebInspector.SuggestBox = function(suggestBoxDelegate, maxItemsHeight)
57 { 57 {
58 this._suggestBoxDelegate = suggestBoxDelegate; 58 this._suggestBoxDelegate = suggestBoxDelegate;
59 this._length = 0; 59 this._length = 0;
60 this._selectedIndex = -1; 60 this._selectedIndex = -1;
61 this._selectedElement = null; 61 this._selectedElement = null;
62 this._maxItemsHeight = maxItemsHeight; 62 this._maxItemsHeight = maxItemsHeight;
63 this._bodyElement = document.body; 63 this._bodyElement = document.body;
64 this._maybeHideBound = this._maybeHide.bind(this); 64 this._maybeHideBound = this._maybeHide.bind(this);
65 this._element = document.createElementWithClass("div", "suggest-box"); 65 this._element = createElementWithClass("div", "suggest-box");
66 this._element.addEventListener("mousedown", this._onBoxMouseDown.bind(this), true); 66 this._element.addEventListener("mousedown", this._onBoxMouseDown.bind(this), true);
67 } 67 }
68 68
69 WebInspector.SuggestBox.prototype = { 69 WebInspector.SuggestBox.prototype = {
70 /** 70 /**
71 * @return {boolean} 71 * @return {boolean}
72 */ 72 */
73 visible: function() 73 visible: function()
74 { 74 {
75 return !!this._element.parentElement; 75 return !!this._element.parentElement;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 this.acceptSuggestion(); 236 this.acceptSuggestion();
237 event.consume(true); 237 event.consume(true);
238 }, 238 },
239 239
240 /** 240 /**
241 * @param {string} prefix 241 * @param {string} prefix
242 * @param {string} text 242 * @param {string} text
243 */ 243 */
244 _createItemElement: function(prefix, text) 244 _createItemElement: function(prefix, text)
245 { 245 {
246 var element = document.createElementWithClass("div", "suggest-box-conten t-item source-code"); 246 var element = createElementWithClass("div", "suggest-box-content-item so urce-code");
247 element.tabIndex = -1; 247 element.tabIndex = -1;
248 if (prefix && prefix.length && !text.indexOf(prefix)) { 248 if (prefix && prefix.length && !text.indexOf(prefix)) {
249 element.createChild("span", "prefix").textContent = prefix; 249 element.createChild("span", "prefix").textContent = prefix;
250 element.createChild("span", "suffix").textContent = text.substring(p refix.length); 250 element.createChild("span", "suffix").textContent = text.substring(p refix.length);
251 } else { 251 } else {
252 element.createChild("span", "suffix").textContent = text; 252 element.createChild("span", "suffix").textContent = text;
253 } 253 }
254 element.createChild("span", "spacer"); 254 element.createChild("span", "spacer");
255 element.addEventListener("mousedown", this._onItemMouseDown.bind(this), false); 255 element.addEventListener("mousedown", this._onItemMouseDown.bind(this), false);
256 return element; 256 return element;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // to commit the input or handle it otherwise. 406 // to commit the input or handle it otherwise.
407 return hasSelectedItem; 407 return hasSelectedItem;
408 } 408 }
409 } 409 }
410 410
411 /** 411 /**
412 * @constructor 412 * @constructor
413 */ 413 */
414 WebInspector.SuggestBox.Overlay = function() 414 WebInspector.SuggestBox.Overlay = function()
415 { 415 {
416 this.element = document.createElementWithClass("div", "suggest-box-overlay") ; 416 this.element = createElementWithClass("div", "suggest-box-overlay");
417 this._resize(); 417 this._resize();
418 document.body.appendChild(this.element); 418 document.body.appendChild(this.element);
419 } 419 }
420 420
421 WebInspector.SuggestBox.Overlay.prototype = { 421 WebInspector.SuggestBox.Overlay.prototype = {
422 _resize: function() 422 _resize: function()
423 { 423 {
424 var container = WebInspector.Dialog.modalHostView().element; 424 var container = WebInspector.Dialog.modalHostView().element;
425 var containerBox = container.boxInWindow(container.ownerDocument.default View); 425 var containerBox = container.boxInWindow(container.ownerDocument.default View);
426 426
427 this.element.style.left = containerBox.x + "px"; 427 this.element.style.left = containerBox.x + "px";
428 this.element.style.top = containerBox.y + "px"; 428 this.element.style.top = containerBox.y + "px";
429 this.element.style.height = containerBox.height + "px"; 429 this.element.style.height = containerBox.height + "px";
430 this.element.style.width = containerBox.width + "px"; 430 this.element.style.width = containerBox.width + "px";
431 }, 431 },
432 432
433 dispose: function() 433 dispose: function()
434 { 434 {
435 this.element.remove(); 435 this.element.remove();
436 } 436 }
437 } 437 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ui/StatusBarButton.js ('k') | Source/devtools/front_end/ui/TabbedPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698