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

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

Issue 1113813002: [DevTools] Rename View to Widget. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased Created 5 years, 7 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) 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.View} 33 * @extends {WebInspector.Widget}
34 * @param {!WebInspector.PopoverHelper=} popoverHelper 34 * @param {!WebInspector.PopoverHelper=} popoverHelper
35 */ 35 */
36 WebInspector.Popover = function(popoverHelper) 36 WebInspector.Popover = function(popoverHelper)
37 { 37 {
38 WebInspector.View.call(this); 38 WebInspector.Widget.call(this);
39 this.markAsRoot(); 39 this.markAsRoot();
40 this.element.className = WebInspector.Popover._classNamePrefix; // Override 40 this.element.className = WebInspector.Popover._classNamePrefix; // Override
41 WebInspector.installComponentRootStyles(this.element); 41 WebInspector.installComponentRootStyles(this.element);
42 this._containerElement = createElementWithClass("div", "fill popover-contain er"); 42 this._containerElement = createElementWithClass("div", "fill popover-contain er");
43 43
44 this._popupArrowElement = this.element.createChild("div", "arrow"); 44 this._popupArrowElement = this.element.createChild("div", "arrow");
45 this._contentDiv = this.element.createChild("div", "content"); 45 this._contentDiv = this.element.createChild("div", "content");
46 46
47 this._popoverHelper = popoverHelper; 47 this._popoverHelper = popoverHelper;
48 this._hideBound = this.hide.bind(this); 48 this._hideBound = this.hide.bind(this);
49 } 49 }
50 50
51 WebInspector.Popover._classNamePrefix = "popover custom-popup-vertical-scroll cu stom-popup-horizontal-scroll"; 51 WebInspector.Popover._classNamePrefix = "popover custom-popup-vertical-scroll cu stom-popup-horizontal-scroll";
52 52
53 WebInspector.Popover.prototype = { 53 WebInspector.Popover.prototype = {
54 /** 54 /**
55 * @param {!Element} element 55 * @param {!Element} element
56 * @param {!Element|!AnchorBox} anchor 56 * @param {!Element|!AnchorBox} anchor
57 * @param {?number=} preferredWidth 57 * @param {?number=} preferredWidth
58 * @param {?number=} preferredHeight 58 * @param {?number=} preferredHeight
59 * @param {?WebInspector.Popover.Orientation=} arrowDirection 59 * @param {?WebInspector.Popover.Orientation=} arrowDirection
60 */ 60 */
61 showForAnchor: function(element, anchor, preferredWidth, preferredHeight, ar rowDirection) 61 showForAnchor: function(element, anchor, preferredWidth, preferredHeight, ar rowDirection)
62 { 62 {
63 this._innerShow(null, element, anchor, preferredWidth, preferredHeight, arrowDirection); 63 this._innerShow(null, element, anchor, preferredWidth, preferredHeight, arrowDirection);
64 }, 64 },
65 65
66 /** 66 /**
67 * @param {!WebInspector.View} view 67 * @param {!WebInspector.Widget} view
68 * @param {!Element|!AnchorBox} anchor 68 * @param {!Element|!AnchorBox} anchor
69 * @param {?number=} preferredWidth 69 * @param {?number=} preferredWidth
70 * @param {?number=} preferredHeight 70 * @param {?number=} preferredHeight
71 */ 71 */
72 showView: function(view, anchor, preferredWidth, preferredHeight) 72 showView: function(view, anchor, preferredWidth, preferredHeight)
73 { 73 {
74 this._innerShow(view, view.element, anchor, preferredWidth, preferredHei ght); 74 this._innerShow(view, view.element, anchor, preferredWidth, preferredHei ght);
75 }, 75 },
76 76
77 /** 77 /**
78 * @param {?WebInspector.View} view 78 * @param {?WebInspector.Widget} view
79 * @param {!Element} contentElement 79 * @param {!Element} contentElement
80 * @param {!Element|!AnchorBox} anchor 80 * @param {!Element|!AnchorBox} anchor
81 * @param {?number=} preferredWidth 81 * @param {?number=} preferredWidth
82 * @param {?number=} preferredHeight 82 * @param {?number=} preferredHeight
83 * @param {?WebInspector.Popover.Orientation=} arrowDirection 83 * @param {?WebInspector.Popover.Orientation=} arrowDirection
84 */ 84 */
85 _innerShow: function(view, contentElement, anchor, preferredWidth, preferred Height, arrowDirection) 85 _innerShow: function(view, contentElement, anchor, preferredWidth, preferred Height, arrowDirection)
86 { 86 {
87 if (this._disposed) 87 if (this._disposed)
88 return; 88 return;
89 this._contentElement = contentElement; 89 this._contentElement = contentElement;
90 90
91 // This should not happen, but we hide previous popup to be on the safe side. 91 // This should not happen, but we hide previous popup to be on the safe side.
92 if (WebInspector.Popover._popover) 92 if (WebInspector.Popover._popover)
93 WebInspector.Popover._popover.hide(); 93 WebInspector.Popover._popover.hide();
94 WebInspector.Popover._popover = this; 94 WebInspector.Popover._popover = this;
95 95
96 var document = anchor instanceof Element ? anchor.ownerDocument : conten tElement.ownerDocument; 96 var document = anchor instanceof Element ? anchor.ownerDocument : conten tElement.ownerDocument;
97 var window = document.defaultView; 97 var window = document.defaultView;
98 98
99 // Temporarily attach in order to measure preferred dimensions. 99 // Temporarily attach in order to measure preferred dimensions.
100 var preferredSize = view ? view.measurePreferredSize() : WebInspector.me asurePreferredSize(this._contentElement); 100 var preferredSize = view ? view.measurePreferredSize() : WebInspector.me asurePreferredSize(this._contentElement);
101 preferredWidth = preferredWidth || preferredSize.width; 101 preferredWidth = preferredWidth || preferredSize.width;
102 preferredHeight = preferredHeight || preferredSize.height; 102 preferredHeight = preferredHeight || preferredSize.height;
103 103
104 window.addEventListener("resize", this._hideBound, false); 104 window.addEventListener("resize", this._hideBound, false);
105 document.body.appendChild(this._containerElement); 105 document.body.appendChild(this._containerElement);
106 WebInspector.View.prototype.show.call(this, this._containerElement); 106 WebInspector.Widget.prototype.show.call(this, this._containerElement);
107 107
108 if (view) 108 if (view)
109 view.show(this._contentDiv); 109 view.show(this._contentDiv);
110 else 110 else
111 this._contentDiv.appendChild(this._contentElement); 111 this._contentDiv.appendChild(this._contentElement);
112 112
113 this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire ction); 113 this._positionElement(anchor, preferredWidth, preferredHeight, arrowDire ction);
114 114
115 if (this._popoverHelper) { 115 if (this._popoverHelper) {
116 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true); 116 this._contentDiv.addEventListener("mousemove", this._popoverHelper._ killHidePopoverTimer.bind(this._popoverHelper), true);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 this._popupArrowElement.style.left = Math.max(0, anchorBox.x - newEl ementPosition.x - borderRadius - arrowRadius + anchorBox.width / 2) + "px"; 238 this._popupArrowElement.style.left = Math.max(0, anchorBox.x - newEl ementPosition.x - borderRadius - arrowRadius + anchorBox.width / 2) + "px";
239 } 239 }
240 240
241 this.element.className = WebInspector.Popover._classNamePrefix + " " + v erticalAlignment + "-" + horizontalAlignment + "-arrow"; 241 this.element.className = WebInspector.Popover._classNamePrefix + " " + v erticalAlignment + "-" + horizontalAlignment + "-arrow";
242 WebInspector.installComponentRootStyles(this.element); 242 WebInspector.installComponentRootStyles(this.element);
243 this.element.positionAt(newElementPosition.x, newElementPosition.y - bor derWidth, container); 243 this.element.positionAt(newElementPosition.x, newElementPosition.y - bor derWidth, container);
244 this.element.style.width = newElementPosition.width + borderWidth * 2 + "px"; 244 this.element.style.width = newElementPosition.width + borderWidth * 2 + "px";
245 this.element.style.height = newElementPosition.height + borderWidth * 2 + "px"; 245 this.element.style.height = newElementPosition.height + borderWidth * 2 + "px";
246 }, 246 },
247 247
248 __proto__: WebInspector.View.prototype 248 __proto__: WebInspector.Widget.prototype
249 } 249 }
250 250
251 /** 251 /**
252 * @constructor 252 * @constructor
253 * @param {!Element} panelElement 253 * @param {!Element} panelElement
254 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnchor 254 * @param {function(!Element, !Event):(!Element|!AnchorBox|undefined)} getAnchor
255 * @param {function(!Element, !WebInspector.Popover):undefined} showPopover 255 * @param {function(!Element, !WebInspector.Popover):undefined} showPopover
256 * @param {function()=} onHide 256 * @param {function()=} onHide
257 * @param {boolean=} disableOnClick 257 * @param {boolean=} disableOnClick
258 */ 258 */
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 this._resetHoverTimer(); 415 this._resetHoverTimer();
416 } 416 }
417 } 417 }
418 } 418 }
419 419
420 /** @enum {string} */ 420 /** @enum {string} */
421 WebInspector.Popover.Orientation = { 421 WebInspector.Popover.Orientation = {
422 Top: "top", 422 Top: "top",
423 Bottom: "bottom" 423 Bottom: "bottom"
424 } 424 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ui/Panel.js ('k') | Source/devtools/front_end/ui/ProgressIndicator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698