diff options
author | Mike Rennie <Michael_Rennie@ca.ibm.com> | 2016-11-29 16:04:47 -0500 |
---|---|---|
committer | Mike Rennie <Michael_Rennie@ca.ibm.com> | 2016-11-29 16:04:47 -0500 |
commit | bf1b9ea43a77c43aecac427f479a1f590f21bd91 (patch) | |
tree | 63e6d82d25c766e11c5515933c8f2502a991d399 | |
parent | 2d96da7d6b0dd69845a7f7767f23fe65f8027fad (diff) | |
download | org.eclipse.orion.client-bf1b9ea43a77c43aecac427f479a1f590f21bd91.zip org.eclipse.orion.client-bf1b9ea43a77c43aecac427f479a1f590f21bd91.tar.gz org.eclipse.orion.client-bf1b9ea43a77c43aecac427f479a1f590f21bd91.tar.bz2 |
[nobug] Format source / remove bad whitespace / unused NLS comments
-rw-r--r-- | bundles/org.eclipse.orion.client.ui/web/orion/folderView.js | 154 |
1 files changed, 84 insertions, 70 deletions
diff --git a/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js b/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js index 0da8902..1b118cb 100644 --- a/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js +++ b/bundles/org.eclipse.orion.client.ui/web/orion/folderView.js @@ -1,20 +1,20 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials are made - * available under the terms of the Eclipse Public License v1.0 - * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution - * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). - * + * Copyright (c) 2013, 2016 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials are made + * available under the terms of the Eclipse Public License v1.0 + * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution + * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). + * * Contributors: IBM Corporation - initial API and implementation ******************************************************************************/ - + /*eslint-env browser, amd*/ define([ 'orion/globalCommands', 'orion/explorers/explorer-table', 'orion/explorers/navigatorRenderer', 'orion/fileCommands', - 'orion/markdownView', + 'orion/markdownView', 'orion/projects/projectEditor', 'orion/PageUtil', 'orion/URITemplate', @@ -25,12 +25,12 @@ define([ 'orion/projects/projectView', 'orion/section' ], function(mGlobalCommands, mExplorerTable, mNavigatorRenderer, FileCommands, mMarkdownView, mProjectEditor, PageUtil, URITemplate, lib, objects, util, Deferred, mProjectView, mSection) { - + var ID_COUNT = 0; - + var FileExplorer = mExplorerTable.FileExplorer; var NavigatorRenderer = mNavigatorRenderer.NavigatorRenderer; - + var uriTemplate = new URITemplate("#{,resource,params*}"); //$NON-NLS-0$ function FolderNavRenderer() { NavigatorRenderer.apply(this, arguments); @@ -43,8 +43,10 @@ define([ */ createFolderNode: function(folder) { var folderNode = mNavigatorRenderer.NavigatorRenderer.prototype.createFolderNode.call(this, folder); - if (this.showFolderLinks && folderNode.tagName === "A") { //$NON-NLS-0$ - folderNode.href = uriTemplate.expand({resource: folder.Location}); //$NON-NLS-0$ + if (this.showFolderLinks && folderNode.tagName === "A") { + folderNode.href = uriTemplate.expand({ + resource: folder.Location + }); } folderNode.classList.add("folderNavFolder"); //$NON-NLS-0$ folderNode.classList.add("navlink"); //$NON-NLS-0$ @@ -58,7 +60,7 @@ define([ getCellHeaderElement: function(col_no) { var td; if (col_no === 0) { - td = document.createElement("th"); //$NON-NLS-0$ + td = document.createElement("th"); td.colSpan = 1; var root = this.explorer.treeRoot; td.appendChild(document.createTextNode(root.Parents || util.isElectron ? root.Name : this.explorer.fileClient.fileServiceName(root.Location))); @@ -73,9 +75,9 @@ define([ return null; } }); - + function FolderNavExplorer(options) { - options.setFocus = false; // do not steal focus on load + options.setFocus = false; // do not steal focus on load options.cachePrefix = null; // do not persist table state options.dragAndDrop = FileCommands.uploadFile; options.modelEventDispatcher = FileCommands.getModelEventDispatcher(); @@ -94,7 +96,7 @@ define([ this.contentTypeRegistry = options.contentTypeRegistry; this.editorInputManager = options.editorInputManager; this.treeRoot = {}; - this.parent = lib.node(options.parentId); + this.parent = lib.node(options.parentId); } FolderNavExplorer.prototype = Object.create(FileExplorer.prototype); objects.mixin(FolderNavExplorer.prototype, /** @lends orion.FolderNavExplorer.prototype */ { @@ -116,14 +118,16 @@ define([ return true; }, scope: function(childrenLocation) { - window.location.href = uriTemplate.expand({resource: childrenLocation}); + window.location.href = uriTemplate.expand({ + resource: childrenLocation + }); }, scopeUp: function() { var navigate; var root = this.treeRoot; - var parent = root.Parents && root.Parents[0]; - if (parent) { - navigate = parent.ChildrenLocation; + var prnt = root.Parents && root.Parents[0]; + if (prnt) { + navigate = prnt.ChildrenLocation; } else { navigate = this.fileClient.fileServiceRootURL(root.Location); } @@ -139,6 +143,9 @@ define([ getTreeRoot: function() { return this.treeRoot; }, + /** + * @callback + */ updateCommands: function(selections) { if (this.menuBar) { this.menuBar.setActiveExplorer(this); @@ -146,11 +153,11 @@ define([ } } }); - - /** + + /** * Constructs a new FolderView object. - * - * @class + * + * @class * @name orion.FolderView */ function FolderView(options) { @@ -170,30 +177,30 @@ define([ this._init(); } FolderView.prototype = /** @lends orion.FolderView.prototype */ { - _init: function(){ + _init: function() { this.markdownView = new mMarkdownView.MarkdownView({ - fileClient : this.fileClient, + fileClient: this.fileClient, canHide: true, - progress : this.progress + progress: this.progress }); - if(this.showProjectView){ + if (this.showProjectView) { this.projectEditor = new mProjectEditor.ProjectEditor({ - fileClient : this.fileClient, - progress : this.progress, + fileClient: this.fileClient, + progress: this.progress, serviceRegistry: this.serviceRegistry, commandRegistry: this.commandRegistry, preferences: this.preferences }); this.projectView = new mProjectView.ProjectView({ - fileClient : this.fileClient, - progress : this.progress, + fileClient: this.fileClient, + progress: this.progress, serviceRegistry: this.serviceRegistry, commandRegistry: this.commandRegistry }); } var mainSplitter = mGlobalCommands.getMainSplitter(); - if(mainSplitter) { - mGlobalCommands.getMainSplitter().splitter.addEventListener("toggle", this._splitterToggleListener = function(e) { //$NON-NLS-0$ + if (mainSplitter) { + mGlobalCommands.getMainSplitter().splitter.addEventListener("toggle", this._splitterToggleListener = function(e) { [this.markdownView, this.projectEditor, this.projectView, this.folderNavExplorer].forEach(function(view) { if (view && view.setCommandsVisible) { view.setCommandsVisible(e.closed); @@ -204,47 +211,52 @@ define([ }, _isCommandsVisible: function() { var mainSplitter = mGlobalCommands.getMainSplitter(); - if(mainSplitter) { + if (mainSplitter) { return mainSplitter.splitter.isClosed(); } return true; }, - displayFolderView: function(root){ + displayFolderView: function(root) { var children = root.Children; var projectJson; var readmeMd; - if(children) { - for (var i=0; i<children.length; i++) { + if (children) { + for (var i = 0; i < children.length; i++) { var child = children[i]; - if (!child.Directory && child.Name === "project.json") { //$NON-NLS-0$ + if (!child.Directory && child.Name === "project.json") { projectJson = child; } - if (!child.Directory && child.Name && child.Name.toLowerCase() === "readme.md") { //$NON-NLS-0$ + if (!child.Directory && child.Name && child.Name.toLowerCase() === "readme.md") { readmeMd = child; } - + } } var div; - if(!this._node){ - this._node = document.createElement("div"); //$NON-NLS-0$ + if (!this._node) { + this._node = document.createElement("div"); } this._parent.appendChild(this._node); - - function renderSections(sectionsOrder, sectionNames){ - sectionsOrder.forEach(function(sectionName){ - if(sectionName === "project"){ //$NON-NLS-0$ - if(projectJson && this.showProjectView){ - div = document.createElement("div"); //$NON-NLS-0$ + + function renderSections(sectionsOrder, sectionNames) { + sectionsOrder.forEach(function(sectionName) { + if (sectionName === "project") { + if (projectJson && this.showProjectView) { + div = document.createElement("div"); this.projectEditor.displayContents(div, this._metadata); this._node.appendChild(div); } - } else if(sectionName === "folderNav") { //$NON-NLS-0$ + } else if (sectionName === "folderNav") { if (this.showFolderNav) { - var navNode = document.createElement("div"); //$NON-NLS-0$ + var navNode = document.createElement("div"); navNode.id = "folderNavNode" + this.idCount; //$NON-NLS-0$ var title = sectionNames[sectionName] || "Files"; - var foldersSection = new mSection.Section(this._node, {id: "folderNavSection" + this.idCount, headerClass: ["sectionTreeTableHeader"], title: title, canHide: true}); //$NON-NLS-1$ //$NON-NLS-0$ + var foldersSection = new mSection.Section(this._node, { + id: "folderNavSection" + this.idCount, + headerClass: ["sectionTreeTableHeader"], + title: title, + canHide: true + }); this.folderNavExplorer = new FolderNavExplorer({ parentId: navNode, view: this, @@ -259,24 +271,24 @@ define([ this.folderNavExplorer.setCommandsVisible(this._isCommandsVisible()); this.folderNavExplorer.loadRoot(this._metadata); } - } else if(sectionName === "readme"){ //$NON-NLS-0$ + } else if (sectionName === "readme") { if (readmeMd) { - div = document.createElement("div"); //$NON-NLS-0$ + div = document.createElement("div"); this.markdownView.displayInFrame(div, readmeMd, ["sectionTreeTableHeader"], null, sectionNames[sectionName]); //$NON-NLS-0$ this._node.appendChild(div); } } }.bind(this)); } - + var sectionsOrder = ["project", "folderNav", "readme"]; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$ - var sectionNames = {}; - if(this.preferences) { - this.preferences.get("/sectionsOrder").then(function(sectionsOrderPrefs){ //$NON-NLS-0$ - sectionNames = sectionsOrderPrefs["folderViewNames"] || sectionNames; //$NON-NLS-0$ - sectionsOrder = sectionsOrderPrefs["folderView"] || sectionsOrder; //$NON-NLS-0$ + var sectionNames = {}; + if (this.preferences) { + this.preferences.get("/sectionsOrder").then(function(sectionsOrderPrefs) { //$NON-NLS-0$ + sectionNames = sectionsOrderPrefs["folderViewNames"] || sectionNames; + sectionsOrder = sectionsOrderPrefs["folderView"] || sectionsOrder; renderSections.apply(this, [sectionsOrder, sectionNames]); - }.bind(this), function(error){ + }.bind(this), function(error) { renderSections.apply(this, [sectionsOrder, sectionNames]); window.console.error(error); }.bind(this)); @@ -285,9 +297,9 @@ define([ } }, create: function() { - if(this._metadata.Children){ + if (this._metadata.Children) { this.displayFolderView(this._metadata); - } else if(this._metadata.ChildrenLocation){ + } else if (this._metadata.ChildrenLocation) { this.progress.progress(this.fileClient.fetchChildren(this._metadata.ChildrenLocation), "Fetching children of " + this._metadata.Name).then(function(children) { this._metadata.Children = children; this.displayFolderView(this._metadata); @@ -296,8 +308,8 @@ define([ }, destroy: function() { var mainSplitter = mGlobalCommands.getMainSplitter(); - if(mainSplitter) { - mainSplitter.splitter.removeEventListener("toggle", this._splitterToggleListener); //$NON-NLS-0$ + if (mainSplitter) { + mainSplitter.splitter.removeEventListener("toggle", this._splitterToggleListener); } if (this.folderNavExplorer) { this.folderNavExplorer.destroy(); @@ -306,14 +318,16 @@ define([ if (this._node && this._node.parentNode) { this._node.parentNode.removeChild(this._node); } - if(this.projectView) { + if (this.projectView) { this.projectView.destroy(); } - if(this.projectEditor){ + if (this.projectEditor) { this.projectEditor.destroy(); } this._node = null; } }; - return {FolderView: FolderView}; -}); + return { + FolderView: FolderView + }; +});
\ No newline at end of file |