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

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

Issue 353833003: [DevTools] Hide popover on window resize. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 this._popupArrowElement = document.createElement("div"); 43 this._popupArrowElement = document.createElement("div");
44 this._popupArrowElement.className = "arrow"; 44 this._popupArrowElement.className = "arrow";
45 this.element.appendChild(this._popupArrowElement); 45 this.element.appendChild(this._popupArrowElement);
46 46
47 this._contentDiv = document.createElement("div"); 47 this._contentDiv = document.createElement("div");
48 this._contentDiv.className = "content"; 48 this._contentDiv.className = "content";
49 this.element.appendChild(this._contentDiv); 49 this.element.appendChild(this._contentDiv);
50 50
51 this._popoverHelper = popoverHelper; 51 this._popoverHelper = popoverHelper;
52 this._hideBound = this.hide.bind(this);
52 } 53 }
53 54
54 WebInspector.Popover.prototype = { 55 WebInspector.Popover.prototype = {
55 /** 56 /**
56 * @param {!Element} element 57 * @param {!Element} element
57 * @param {!Element|!AnchorBox} anchor 58 * @param {!Element|!AnchorBox} anchor
58 * @param {?number=} preferredWidth 59 * @param {?number=} preferredWidth
59 * @param {?number=} preferredHeight 60 * @param {?number=} preferredHeight
60 * @param {?WebInspector.Popover.Orientation=} arrowDirection 61 * @param {?WebInspector.Popover.Orientation=} arrowDirection
61 */ 62 */
(...skipping 30 matching lines...) Expand all
92 // This should not happen, but we hide previous popup to be on the safe side. 93 // This should not happen, but we hide previous popup to be on the safe side.
93 if (WebInspector.Popover._popover) 94 if (WebInspector.Popover._popover)
94 WebInspector.Popover._popover.hide(); 95 WebInspector.Popover._popover.hide();
95 WebInspector.Popover._popover = this; 96 WebInspector.Popover._popover = this;
96 97
97 // Temporarily attach in order to measure preferred dimensions. 98 // Temporarily attach in order to measure preferred dimensions.
98 var preferredSize = view ? view.measurePreferredSize() : this.contentEle ment.measurePreferredSize(); 99 var preferredSize = view ? view.measurePreferredSize() : this.contentEle ment.measurePreferredSize();
99 preferredWidth = preferredWidth || preferredSize.width; 100 preferredWidth = preferredWidth || preferredSize.width;
100 preferredHeight = preferredHeight || preferredSize.height; 101 preferredHeight = preferredHeight || preferredSize.height;
101 102
103 window.addEventListener("resize", this._hideBound, false);
102 document.body.appendChild(this._containerElement); 104 document.body.appendChild(this._containerElement);
103 WebInspector.View.prototype.show.call(this, this._containerElement); 105 WebInspector.View.prototype.show.call(this, this._containerElement);
104 106
105 if (view) 107 if (view)
106 view.show(this._contentDiv); 108 view.show(this._contentDiv);
107 else 109 else
108 this._contentDiv.appendChild(this.contentElement); 110 this._contentDiv.appendChild(this.contentElement);
109 111
110 this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire ction); 112 this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire ction);
111 113
112 if (this._popoverHelper) { 114 if (this._popoverHelper) {
113 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true); 115 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true);
114 this.element.addEventListener("mouseout", this._popoverHelper._popov erMouseOut.bind(this._popoverHelper), true); 116 this.element.addEventListener("mouseout", this._popoverHelper._popov erMouseOut.bind(this._popoverHelper), true);
115 } 117 }
116 }, 118 },
117 119
118 hide: function() 120 hide: function()
119 { 121 {
122 window.removeEventListener("resize", this._hideBound, false);
120 this.detach(); 123 this.detach();
121 this._containerElement.remove(); 124 this._containerElement.remove();
122 delete WebInspector.Popover._popover; 125 delete WebInspector.Popover._popover;
123 }, 126 },
124 127
125 get disposed() 128 get disposed()
126 { 129 {
127 return this._disposed; 130 return this._disposed;
128 }, 131 },
129 132
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 this._resetHoverTimer(); 392 this._resetHoverTimer();
390 } 393 }
391 } 394 }
392 } 395 }
393 396
394 /** @enum {string} */ 397 /** @enum {string} */
395 WebInspector.Popover.Orientation = { 398 WebInspector.Popover.Orientation = {
396 Top: "top", 399 Top: "top",
397 Bottom: "bottom" 400 Bottom: "bottom"
398 } 401 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698