WebInspector.HelpScreen = function(title)
{
WebInspector.View.call(this);
this.markAsRoot();
this.registerRequiredCSS("helpScreen.css");
this.element.className = "help-window-outer";
this.element.addEventListener("keydown", this._onKeyDown.bind(this), false);
this.element.tabIndex = 0;
this.element.addEventListener("focus", this._onBlur.bind(this), false);
if (title) {
var mainWindow = this.element.createChild("div", "help-window-main");
var captionWindow = mainWindow.createChild("div", "help-window-caption");
captionWindow.appendChild(this._createCloseButton());
this.contentElement = mainWindow.createChild("div", "help-content");
captionWindow.createChild("h1", "help-window-title").textContent = title;
}
}
WebInspector.HelpScreen._visibleScreen = null;
WebInspector.HelpScreen.prototype = {
_createCloseButton: function()
{
var closeButton = document.createElement("button");
closeButton.className = "help-close-button";
closeButton.textContent = "\u2716"; closeButton.addEventListener("click", this.hide.bind(this), false);
return closeButton;
},
showModal: function()
{
var visibleHelpScreen = WebInspector.HelpScreen._visibleScreen;
if (visibleHelpScreen === this)
return;
if (visibleHelpScreen)
visibleHelpScreen.hide();
WebInspector.HelpScreen._visibleScreen = this;
this.show(document.body);
this.focus();
},
hide: function()
{
if (!this.isShowing())
return;
WebInspector.HelpScreen._visibleScreen = null;
WebInspector.restoreFocusFromElement(this.element);
this.detach();
},
isClosingKey: function(keyCode)
{
return [
WebInspector.KeyboardShortcut.Keys.Enter.code,
WebInspector.KeyboardShortcut.Keys.Esc.code,
WebInspector.KeyboardShortcut.Keys.Space.code,
].indexOf(keyCode) >= 0;
},
_onKeyDown: function(event)
{
if (this.isShowing() && this.isClosingKey(event.keyCode)) {
this.hide();
event.consume();
}
},
_onBlur: function(event)
{
if (this.isShowing() && !this.element.isSelfOrAncestor(event.target))
WebInspector.setCurrentFocusElement(this.element);
},
__proto__: WebInspector.View.prototype
}
WebInspector.HelpScreenUntilReload = function(title, message)
{
WebInspector.HelpScreen.call(this, title);
var p = this.contentElement.createChild("p");
p.addStyleClass("help-section");
p.textContent = message;
WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this.hide, this);
}
WebInspector.HelpScreenUntilReload.prototype = {
willHide: function()
{
WebInspector.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Events.GlobalObjectCleared, this.hide, this);
WebInspector.HelpScreen.prototype.willHide.call(this);
},
__proto__: WebInspector.HelpScreen.prototype
}