ScriptsNavigator.js [plain text]
WebInspector.ScriptsNavigator = function()
{
WebInspector.Object.call(this);
this._tabbedPane = new WebInspector.TabbedPane();
this._tabbedPane.shrinkableTabs = true;
this._tabbedPane.element.addStyleClass("navigator-tabbed-pane");
this._scriptsView = new WebInspector.NavigatorView();
this._scriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected, this._scriptSelected, this);
this._contentScriptsView = new WebInspector.NavigatorView();
this._contentScriptsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected, this._scriptSelected, this);
this._snippetsView = new WebInspector.SnippetsNavigatorView();
this._snippetsView.addEventListener(WebInspector.NavigatorView.Events.ItemSelected, this._scriptSelected, this);
this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ScriptsTab, WebInspector.UIString("Scripts"), this._scriptsView);
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab);
this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.ContentScriptsTab, WebInspector.UIString("Content scripts"), this._contentScriptsView);
if (WebInspector.experimentsSettings.snippetsSupport.isEnabled())
this._tabbedPane.appendTab(WebInspector.ScriptsNavigator.SnippetsTab, WebInspector.UIString("Snippets"), this._snippetsView);
}
WebInspector.ScriptsNavigator.Events = {
ScriptSelected: "ScriptSelected"
}
WebInspector.ScriptsNavigator.ScriptsTab = "scripts";
WebInspector.ScriptsNavigator.ContentScriptsTab = "contentScripts";
WebInspector.ScriptsNavigator.SnippetsTab = "snippets";
WebInspector.ScriptsNavigator.prototype = {
get view()
{
return this._tabbedPane;
},
addUISourceCode: function(uiSourceCode)
{
if (uiSourceCode.isContentScript)
this._contentScriptsView.addUISourceCode(uiSourceCode);
else if (uiSourceCode.isSnippet || uiSourceCode.isSnippetEvaluation)
this._snippetsView.addUISourceCode(uiSourceCode);
else
this._scriptsView.addUISourceCode(uiSourceCode);
},
isScriptSourceAdded: function(uiSourceCode)
{
if (uiSourceCode.isContentScript)
return this._contentScriptsView.isScriptSourceAdded(uiSourceCode);
if (uiSourceCode.isSnippet || uiSourceCode.isSnippetEvaluation)
return this._snippetsView.isScriptSourceAdded(uiSourceCode);
return this._scriptsView.isScriptSourceAdded(uiSourceCode);
},
revealUISourceCode: function(uiSourceCode)
{
if (uiSourceCode.isContentScript) {
this._contentScriptsView.revealUISourceCode(uiSourceCode);
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ContentScriptsTab);
} else if (uiSourceCode.isSnippet || uiSourceCode.isSnippetEvaluation) {
this._snippetsView.revealUISourceCode(uiSourceCode);
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.SnippetsTab);
} else {
this._scriptsView.revealUISourceCode(uiSourceCode);
this._tabbedPane.selectTab(WebInspector.ScriptsNavigator.ScriptsTab);
}
},
setScriptSourceIsDirty: function(uiSourceCode, isDirty)
{
},
replaceUISourceCodes: function(oldUISourceCodeList, uiSourceCodeList)
{
this._scriptsView.replaceUISourceCodes(oldUISourceCodeList, uiSourceCodeList);
this._contentScriptsView.replaceUISourceCodes(oldUISourceCodeList, uiSourceCodeList);
this._snippetsView.replaceUISourceCodes(oldUISourceCodeList, uiSourceCodeList);
},
_scriptSelected: function(event)
{
this.dispatchEventToListeners(WebInspector.ScriptsNavigator.Events.ScriptSelected, event.data);
},
reset: function()
{
this._scriptsView.reset();
this._contentScriptsView.reset();
this._snippetsView.reset();
}
}
WebInspector.ScriptsNavigator.prototype.__proto__ = WebInspector.Object.prototype;
WebInspector.SnippetsNavigatorView = function()
{
WebInspector.NavigatorView.call(this);
this.element.addEventListener("contextmenu", this.handleContextMenu.bind(this), false);
}
WebInspector.SnippetsNavigatorView.prototype = {
getOrCreateFolderTreeElement: function(uiSourceCode)
{
if (uiSourceCode.isSnippet)
return this._scriptsTree;
if (uiSourceCode.isSnippetEvaluation)
return this._getOrCreateSnippetEvaluationsFolderTreeElement();
return WebInspector.NavigatorView.prototype.getOrCreateFolderTreeElement.call(this, uiSourceCode);
},
_getOrCreateSnippetEvaluationsFolderTreeElement: function()
{
const snippetEvaluationsFolderIdentifier = "snippetEvaluationsFolder";
var folderTreeElement = this._folderTreeElements[snippetEvaluationsFolderIdentifier];
if (folderTreeElement)
return folderTreeElement;
return this.createFolderTreeElement(this._scriptsTree, snippetEvaluationsFolderIdentifier, "", WebInspector.UIString("Evaluated snippets"));
},
handleContextMenu: function(event, uiSourceCode)
{
var contextMenu = new WebInspector.ContextMenu();
if (uiSourceCode) {
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate snippet" : "Evaluate Snippet"), this._handleEvaluateSnippet.bind(this, uiSourceCode));
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Rename snippet" : "Rename Snippet"), this._handleRenameSnippet.bind(this, uiSourceCode));
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove snippet" : "Remove Snippet"), this._handleRemoveSnippet.bind(this, uiSourceCode));
contextMenu.appendSeparator();
}
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Create snippet" : "Create Snippet"), this._handleCreateSnippet.bind(this));
contextMenu.show(event);
},
_handleEvaluateSnippet: function(uiSourceCode, event)
{
},
_handleRenameSnippet: function(uiSourceCode, event)
{
this.rename(uiSourceCode);
},
_handleRemoveSnippet: function(uiSourceCode, event)
{
},
_handleCreateSnippet: function(event)
{
}
}
WebInspector.SnippetsNavigatorView.prototype.__proto__ = WebInspector.NavigatorView.prototype;