WebInspector.HelpScreen = function(title)
{
this._element = document.createElement("div");
this._element.className = "help-window-outer";
this._element.addEventListener("keydown", this._onKeyDown.bind(this), false);
var mainWindow = this._element.createChild("div", "help-window-main");
var captionWindow = mainWindow.createChild("div", "help-window-caption");
var closeButton = captionWindow.createChild("button", "help-close-button");
this.contentElement = mainWindow.createChild("div", "help-content");
this.contentElement.tabIndex = 0;
this.contentElement.addEventListener("blur", this._onBlur.bind(this), false);
captionWindow.createChild("h1", "help-window-title").textContent = title;
closeButton.textContent = "\u2716"; closeButton.addEventListener("click", this._hide.bind(this), false);
this._closeKeys = [
WebInspector.KeyboardShortcut.Keys.Enter.code,
WebInspector.KeyboardShortcut.Keys.Esc.code,
WebInspector.KeyboardShortcut.Keys.Space.code,
];
document.body.appendChild(this._element);
}
WebInspector.HelpScreen.prototype = {
show: function()
{
if (this._isShown)
return;
this._element.style.visibility = "visible";
this._isShown = true;
this._previousFocusElement = WebInspector.currentFocusElement;
WebInspector.currentFocusElement = this.contentElement;
},
_hide: function()
{
this._isShown = false;
this._element.style.visibility = "hidden";
WebInspector.currentFocusElement = this._previousFocusElement;
},
_onKeyDown: function(event)
{
if (this._isShown && this._closeKeys.indexOf(event.keyCode) >= 0) {
this._hide();
event.stopPropagation();
}
},
_onBlur: function()
{
if (this._isShown)
WebInspector.currentFocusElement = this.contentElement;
}
}