1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 * @param {!WebInspector.Infobar.Type} type
8 * @param {!WebInspector.Setting=} disableSetting
10 WebInspector
.Infobar = function(type
, disableSetting
)
12 this.element
= createElementWithClass("div");
13 this._shadowRoot
= WebInspector
.createShadowRootWithCoreStyles(this.element
);
14 this._shadowRoot
.appendChild(WebInspector
.Widget
.createStyleElement("ui/infobar.css"));
15 this._contentElement
= this._shadowRoot
.createChild("div", "infobar infobar-" + type
);
17 this._contentElement
.createChild("label", "icon", "dt-icon-label").type
= type
+ "-icon";
18 this._contentElement
.createChild("div", "content").createChild("content");
20 /** @type {?WebInspector.Setting} */
21 this._disableSetting
= null;
24 this._disableSetting
= disableSetting
;
25 disableSetting
.addChangeListener(this._updateVisibility
, this);
26 var disableButton
= this._contentElement
.createChild("div", "disable-button");
27 disableButton
.textContent
= WebInspector
.UIString("Never show");
28 disableButton
.addEventListener("click", disableSetting
.set.bind(disableSetting
, true), false);
31 this._closeButton
= this._contentElement
.createChild("div", "close-button", "dt-close-button");
32 this._closeButton
.addEventListener("click", this.close
.bind(this), false);
33 /** @type {?function()} */
34 this._closeCallback
= null;
36 this.setVisible(false);
40 WebInspector
.Infobar
.Type
= {
45 WebInspector
.Infobar
.prototype = {
47 * @param {boolean} visible
49 setVisible: function(visible
)
51 this._visible
= visible
;
52 if (this._disableSetting
)
53 visible
= visible
&& !this._disableSetting
.get();
54 this.element
.classList
.toggle("hidden", !visible
);
57 _updateVisibility: function()
59 this.setVisible(this._visible
);
64 this.setVisible(false);
65 if (this._closeCallback
)
66 this._closeCallback
.call(null);
70 * @param {?function()} callback
72 setCloseCallback: function(callback
)
74 this._closeCallback
= callback
;