From ab1fb2f217aa94cac98105316c7f164bfb6251bd Mon Sep 17 00:00:00 2001 From: Mikhail Fesenko Date: Sun, 5 Mar 2017 21:59:07 +0300 Subject: [PATCH 01/27] Fix path on macOS link --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index e9b6ff120..c555306b5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -10,7 +10,7 @@ In this directory you can only find very specific build and API level documentat Instructions for building Atom on various platforms from source. -* [macOS](./build-instructions/macos.md) +* [macOS](./build-instructions/macOS.md) * [Windows](./build-instructions/windows.md) * [Linux](./build-instructions/linux.md) * [FreeBSD](./build-instructions/freebsd.md) From d64d99d2f74ecfd4db0c059055ba05ac40dab8ac Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 6 Mar 2017 11:47:09 -0500 Subject: [PATCH 02/27] :arrow_up: autocomplete-css@0.15.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 97d523fa4..f3fd9d9cd 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "about": "1.7.5", "archive-view": "0.63.0", "autocomplete-atom-api": "0.10.0", - "autocomplete-css": "0.15.0", + "autocomplete-css": "0.15.1", "autocomplete-html": "0.7.2", "autocomplete-plus": "2.34.2", "autocomplete-snippets": "1.11.0", From 273dd5405ee61380a19c756e805812d522c2a032 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:49:51 -0500 Subject: [PATCH 03/27] :arrow_up: language-xml@0.35.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f3fd9d9cd..0cceb8760 100644 --- a/package.json +++ b/package.json @@ -171,7 +171,7 @@ "language-text": "0.7.1", "language-todo": "0.29.1", "language-toml": "0.18.1", - "language-xml": "0.34.16", + "language-xml": "0.35.0", "language-yaml": "0.28.0" }, "private": true, From 5d6cd1e54291ea10fd62e837e2d401374ccb01ad Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:51:00 -0500 Subject: [PATCH 04/27] :arrow_up: language-property-list@0.9.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0cceb8760..f1a429063 100644 --- a/package.json +++ b/package.json @@ -160,7 +160,7 @@ "language-objective-c": "0.15.1", "language-perl": "0.37.0", "language-php": "0.37.4", - "language-property-list": "0.9.0", + "language-property-list": "0.9.1", "language-python": "0.45.2", "language-ruby": "0.70.5", "language-ruby-on-rails": "0.25.2", From e97c8f8e6b673f6ae070cafaec142997a89b656d Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:51:54 -0500 Subject: [PATCH 05/27] :arrow_up: language-sass@0.58.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f1a429063..e2bd39671 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,7 @@ "language-python": "0.45.2", "language-ruby": "0.70.5", "language-ruby-on-rails": "0.25.2", - "language-sass": "0.57.1", + "language-sass": "0.58.0", "language-shellscript": "0.25.0", "language-source": "0.9.0", "language-sql": "0.25.3", From eb9cf0330a04db8062a74c775d0406c458402c80 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:53:02 -0500 Subject: [PATCH 06/27] :arrow_up: language-java@0.27.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e2bd39671..c6be559f9 100644 --- a/package.json +++ b/package.json @@ -151,10 +151,10 @@ "language-go": "0.43.1", "language-html": "0.47.2", "language-hyperlink": "0.16.1", - "language-java": "0.26.0", + "language-java": "0.27.0", "language-javascript": "0.126.1", "language-json": "0.18.3", - "language-less": "0.30.1", + "language-less": "0.31.0", "language-make": "0.22.3", "language-mustache": "0.13.1", "language-objective-c": "0.15.1", From 4e8ac61e54f426808378a09da76e7ed65192308e Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:53:42 -0500 Subject: [PATCH 07/27] :arrow_up: language-php@0.37.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6be559f9..9ecbfac5b 100644 --- a/package.json +++ b/package.json @@ -159,7 +159,7 @@ "language-mustache": "0.13.1", "language-objective-c": "0.15.1", "language-perl": "0.37.0", - "language-php": "0.37.4", + "language-php": "0.37.5", "language-property-list": "0.9.1", "language-python": "0.45.2", "language-ruby": "0.70.5", From a58f732b0ad1f0c92b0354a7f74d5b06f87ac786 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:54:30 -0500 Subject: [PATCH 08/27] :arrow_up: language-json@0.19.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ecbfac5b..a6ac8f639 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "language-hyperlink": "0.16.1", "language-java": "0.27.0", "language-javascript": "0.126.1", - "language-json": "0.18.3", + "language-json": "0.19.0", "language-less": "0.31.0", "language-make": "0.22.3", "language-mustache": "0.13.1", From 6c70984b29ecd85bc2719624f7063df496d58a03 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:55:14 -0500 Subject: [PATCH 09/27] :arrow_up: language-yaml@0.29.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a6ac8f639..d1afaac99 100644 --- a/package.json +++ b/package.json @@ -172,7 +172,7 @@ "language-todo": "0.29.1", "language-toml": "0.18.1", "language-xml": "0.35.0", - "language-yaml": "0.28.0" + "language-yaml": "0.29.0" }, "private": true, "scripts": { From d298a4e7c6f8d456460895b235784c2b6ee7b4d3 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 6 Mar 2017 11:56:19 -0500 Subject: [PATCH 10/27] :arrow_up: language-text@0.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d1afaac99..fa571aa88 100644 --- a/package.json +++ b/package.json @@ -168,7 +168,7 @@ "language-shellscript": "0.25.0", "language-source": "0.9.0", "language-sql": "0.25.3", - "language-text": "0.7.1", + "language-text": "0.7.2", "language-todo": "0.29.1", "language-toml": "0.18.1", "language-xml": "0.35.0", From 59c20484aa222af436040f022e0bb44cdee8d7e9 Mon Sep 17 00:00:00 2001 From: Damien Guard Date: Mon, 6 Mar 2017 09:41:14 -0800 Subject: [PATCH 11/27] Always restore Reopen Project menu, fixes #13758 --- src/atom-environment.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index dc4318bec..d7fab1924 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -237,7 +237,7 @@ class AtomEnvironment extends Model @applicationDelegate.didChangeHistoryManager() unless e.reloaded @disposables.add @applicationDelegate.onDidChangeHistoryManager(=> @history.loadState()) - new ReopenProjectMenuManager({@menu, @commands, @history, @config, open: (paths) => @open(pathsToOpen: paths)}) + (new ReopenProjectMenuManager({@menu, @commands, @history, @config, open: (paths) => @open(pathsToOpen: paths)})).update() attachSaveStateListeners: -> saveState = _.debounce((=> From 24503806d7eb77c62c1da45398b2ad00a8178d27 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Mon, 6 Mar 2017 17:30:43 -0500 Subject: [PATCH 12/27] :arrow_up: language-c@0.57.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fa571aa88..ed3756a38 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "welcome": "0.36.2", "whitespace": "0.36.2", "wrap-guide": "0.40.0", - "language-c": "0.56.0", + "language-c": "0.57.0", "language-clojure": "0.22.2", "language-coffee-script": "0.48.5", "language-csharp": "0.14.2", From 6f9a536aca8f64346bda55624553c55845fc0e80 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Tue, 7 Mar 2017 11:04:45 -0500 Subject: [PATCH 13/27] :arrow_up: language-css@0.42.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ed3756a38..8207d3307 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,7 @@ "language-clojure": "0.22.2", "language-coffee-script": "0.48.5", "language-csharp": "0.14.2", - "language-css": "0.42.0", + "language-css": "0.42.1", "language-gfm": "0.88.1", "language-git": "0.19.0", "language-go": "0.43.1", From 228b24b68bacfecd810910b5c06383c74390f2ef Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Tue, 7 Mar 2017 14:20:27 -0800 Subject: [PATCH 14/27] Convert panel container to JS: Decaffeinate --- spec/panel-container-element-spec.coffee | 137 -------------------- spec/panel-container-element-spec.js | 154 +++++++++++++++++++++++ spec/panel-container-spec.coffee | 113 ----------------- spec/panel-container-spec.js | 139 ++++++++++++++++++++ src/panel-container-element.coffee | 45 ------- src/panel-container-element.js | 59 +++++++++ src/panel-container.coffee | 71 ----------- src/panel-container.js | 92 ++++++++++++++ 8 files changed, 444 insertions(+), 366 deletions(-) delete mode 100644 spec/panel-container-element-spec.coffee create mode 100644 spec/panel-container-element-spec.js delete mode 100644 spec/panel-container-spec.coffee create mode 100644 spec/panel-container-spec.js delete mode 100644 src/panel-container-element.coffee create mode 100644 src/panel-container-element.js delete mode 100644 src/panel-container.coffee create mode 100644 src/panel-container.js diff --git a/spec/panel-container-element-spec.coffee b/spec/panel-container-element-spec.coffee deleted file mode 100644 index 55e6f7133..000000000 --- a/spec/panel-container-element-spec.coffee +++ /dev/null @@ -1,137 +0,0 @@ -Panel = require '../src/panel' -PanelContainer = require '../src/panel-container' - -describe "PanelContainerElement", -> - [jasmineContent, element, container] = [] - - class TestPanelContainerItem - constructior: -> - - class TestPanelContainerItemElement extends HTMLElement - createdCallback: -> - @classList.add('test-root') - initialize: (@model) -> - this - - TestPanelContainerItemElement = document.registerElement 'atom-test-container-item-element', prototype: TestPanelContainerItemElement.prototype - - beforeEach -> - jasmineContent = document.body.querySelector('#jasmine-content') - - atom.views.addViewProvider TestPanelContainerItem, (model) -> - new TestPanelContainerItemElement().initialize(model) - - container = new PanelContainer({location: 'left'}) - element = atom.views.getView(container) - jasmineContent.appendChild(element) - - it 'has a location class with value from the model', -> - expect(element).toHaveClass 'left' - - it 'removes the element when the container is destroyed', -> - expect(element.parentNode).toBe jasmineContent - container.destroy() - expect(element.parentNode).not.toBe jasmineContent - - describe "adding and removing panels", -> - it "allows panels to be inserted at any position", -> - panel1 = new Panel({item: new TestPanelContainerItem(), priority: 10}) - panel2 = new Panel({item: new TestPanelContainerItem(), priority: 5}) - panel3 = new Panel({item: new TestPanelContainerItem(), priority: 8}) - - container.addPanel(panel1) - container.addPanel(panel2) - container.addPanel(panel3) - - expect(element.childNodes[2].getModel()).toBe(panel1) - expect(element.childNodes[1].getModel()).toBe(panel3) - expect(element.childNodes[0].getModel()).toBe(panel2) - - describe "when the container is at the left location", -> - it "adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", -> - expect(element.childNodes.length).toBe 0 - - panel1 = new Panel({item: new TestPanelContainerItem()}) - container.addPanel(panel1) - expect(element.childNodes.length).toBe 1 - expect(element.childNodes[0]).toHaveClass 'left' - expect(element.childNodes[0]).toHaveClass 'tool-panel' # legacy selector support - expect(element.childNodes[0]).toHaveClass 'panel-left' # legacy selector support - - expect(element.childNodes[0].tagName).toBe 'ATOM-PANEL' - - panel2 = new Panel({item: new TestPanelContainerItem()}) - container.addPanel(panel2) - expect(element.childNodes.length).toBe 2 - - expect(atom.views.getView(panel1).style.display).not.toBe 'none' - expect(atom.views.getView(panel2).style.display).not.toBe 'none' - - panel1.destroy() - expect(element.childNodes.length).toBe 1 - - panel2.destroy() - expect(element.childNodes.length).toBe 0 - - describe "when the container is at the bottom location", -> - beforeEach -> - container = new PanelContainer({location: 'bottom'}) - element = atom.views.getView(container) - jasmineContent.appendChild(element) - - it "adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", -> - expect(element.childNodes.length).toBe 0 - - panel1 = new Panel({item: new TestPanelContainerItem(), className: 'one'}) - container.addPanel(panel1) - expect(element.childNodes.length).toBe 1 - expect(element.childNodes[0]).toHaveClass 'bottom' - expect(element.childNodes[0]).toHaveClass 'tool-panel' # legacy selector support - expect(element.childNodes[0]).toHaveClass 'panel-bottom' # legacy selector support - expect(element.childNodes[0].tagName).toBe 'ATOM-PANEL' - expect(atom.views.getView(panel1)).toHaveClass 'one' - - panel2 = new Panel({item: new TestPanelContainerItem(), className: 'two'}) - container.addPanel(panel2) - expect(element.childNodes.length).toBe 2 - expect(atom.views.getView(panel2)).toHaveClass 'two' - - panel1.destroy() - expect(element.childNodes.length).toBe 1 - - panel2.destroy() - expect(element.childNodes.length).toBe 0 - - describe "when the container is modal", -> - beforeEach -> - container = new PanelContainer({location: 'modal'}) - element = atom.views.getView(container) - jasmineContent.appendChild(element) - - it "allows only one panel to be visible at a time", -> - panel1 = new Panel({item: new TestPanelContainerItem()}) - container.addPanel(panel1) - - expect(atom.views.getView(panel1).style.display).not.toBe 'none' - - panel2 = new Panel({item: new TestPanelContainerItem()}) - container.addPanel(panel2) - - expect(atom.views.getView(panel1).style.display).toBe 'none' - expect(atom.views.getView(panel2).style.display).not.toBe 'none' - - panel1.show() - - expect(atom.views.getView(panel1).style.display).not.toBe 'none' - expect(atom.views.getView(panel2).style.display).toBe 'none' - - it "adds the 'modal' class to panels", -> - panel1 = new Panel({item: new TestPanelContainerItem()}) - container.addPanel(panel1) - - expect(atom.views.getView(panel1)).toHaveClass 'modal' - - # legacy selector support - expect(atom.views.getView(panel1)).not.toHaveClass 'tool-panel' - expect(atom.views.getView(panel1)).toHaveClass 'overlay' - expect(atom.views.getView(panel1)).toHaveClass 'from-top' diff --git a/spec/panel-container-element-spec.js b/spec/panel-container-element-spec.js new file mode 100644 index 000000000..167fd92ed --- /dev/null +++ b/spec/panel-container-element-spec.js @@ -0,0 +1,154 @@ +const Panel = require('../src/panel'); +const PanelContainer = require('../src/panel-container'); + +describe("PanelContainerElement", function() { + let [jasmineContent, element, container] = Array.from([]); + + class TestPanelContainerItem { + constructior() {} + } + + class TestPanelContainerItemElement extends HTMLElement { + createdCallback() { + return this.classList.add('test-root'); + } + initialize(model) { + this.model = model; + return this; + } + } + + TestPanelContainerItemElement = document.registerElement('atom-test-container-item-element', {prototype: TestPanelContainerItemElement.prototype}); + + beforeEach(function() { + jasmineContent = document.body.querySelector('#jasmine-content'); + + atom.views.addViewProvider(TestPanelContainerItem, model => new TestPanelContainerItemElement().initialize(model)); + + container = new PanelContainer({location: 'left'}); + element = atom.views.getView(container); + return jasmineContent.appendChild(element); + }); + + it('has a location class with value from the model', () => expect(element).toHaveClass('left')); + + it('removes the element when the container is destroyed', function() { + expect(element.parentNode).toBe(jasmineContent); + container.destroy(); + return expect(element.parentNode).not.toBe(jasmineContent); + }); + + describe("adding and removing panels", function() { + it("allows panels to be inserted at any position", function() { + const panel1 = new Panel({item: new TestPanelContainerItem(), priority: 10}); + const panel2 = new Panel({item: new TestPanelContainerItem(), priority: 5}); + const panel3 = new Panel({item: new TestPanelContainerItem(), priority: 8}); + + container.addPanel(panel1); + container.addPanel(panel2); + container.addPanel(panel3); + + expect(element.childNodes[2].getModel()).toBe(panel1); + expect(element.childNodes[1].getModel()).toBe(panel3); + return expect(element.childNodes[0].getModel()).toBe(panel2); + }); + + describe("when the container is at the left location", () => + it("adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", function() { + expect(element.childNodes.length).toBe(0); + + const panel1 = new Panel({item: new TestPanelContainerItem()}); + container.addPanel(panel1); + expect(element.childNodes.length).toBe(1); + expect(element.childNodes[0]).toHaveClass('left'); + expect(element.childNodes[0]).toHaveClass('tool-panel'); // legacy selector support + expect(element.childNodes[0]).toHaveClass('panel-left'); // legacy selector support + + expect(element.childNodes[0].tagName).toBe('ATOM-PANEL'); + + const panel2 = new Panel({item: new TestPanelContainerItem()}); + container.addPanel(panel2); + expect(element.childNodes.length).toBe(2); + + expect(atom.views.getView(panel1).style.display).not.toBe('none'); + expect(atom.views.getView(panel2).style.display).not.toBe('none'); + + panel1.destroy(); + expect(element.childNodes.length).toBe(1); + + panel2.destroy(); + return expect(element.childNodes.length).toBe(0); + }) + ); + + return describe("when the container is at the bottom location", function() { + beforeEach(function() { + container = new PanelContainer({location: 'bottom'}); + element = atom.views.getView(container); + return jasmineContent.appendChild(element); + }); + + return it("adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", function() { + expect(element.childNodes.length).toBe(0); + + const panel1 = new Panel({item: new TestPanelContainerItem(), className: 'one'}); + container.addPanel(panel1); + expect(element.childNodes.length).toBe(1); + expect(element.childNodes[0]).toHaveClass('bottom'); + expect(element.childNodes[0]).toHaveClass('tool-panel'); // legacy selector support + expect(element.childNodes[0]).toHaveClass('panel-bottom'); // legacy selector support + expect(element.childNodes[0].tagName).toBe('ATOM-PANEL'); + expect(atom.views.getView(panel1)).toHaveClass('one'); + + const panel2 = new Panel({item: new TestPanelContainerItem(), className: 'two'}); + container.addPanel(panel2); + expect(element.childNodes.length).toBe(2); + expect(atom.views.getView(panel2)).toHaveClass('two'); + + panel1.destroy(); + expect(element.childNodes.length).toBe(1); + + panel2.destroy(); + return expect(element.childNodes.length).toBe(0); + }); + }); + }); + + return describe("when the container is modal", function() { + beforeEach(function() { + container = new PanelContainer({location: 'modal'}); + element = atom.views.getView(container); + return jasmineContent.appendChild(element); + }); + + it("allows only one panel to be visible at a time", function() { + const panel1 = new Panel({item: new TestPanelContainerItem()}); + container.addPanel(panel1); + + expect(atom.views.getView(panel1).style.display).not.toBe('none'); + + const panel2 = new Panel({item: new TestPanelContainerItem()}); + container.addPanel(panel2); + + expect(atom.views.getView(panel1).style.display).toBe('none'); + expect(atom.views.getView(panel2).style.display).not.toBe('none'); + + panel1.show(); + + expect(atom.views.getView(panel1).style.display).not.toBe('none'); + return expect(atom.views.getView(panel2).style.display).toBe('none'); + }); + + return it("adds the 'modal' class to panels", function() { + const panel1 = new Panel({item: new TestPanelContainerItem()}); + container.addPanel(panel1); + + expect(atom.views.getView(panel1)).toHaveClass('modal'); + + // legacy selector support + expect(atom.views.getView(panel1)).not.toHaveClass('tool-panel'); + expect(atom.views.getView(panel1)).toHaveClass('overlay'); + return expect(atom.views.getView(panel1)).toHaveClass('from-top'); + }); + }); +}); diff --git a/spec/panel-container-spec.coffee b/spec/panel-container-spec.coffee deleted file mode 100644 index fbf1c3446..000000000 --- a/spec/panel-container-spec.coffee +++ /dev/null @@ -1,113 +0,0 @@ -Panel = require '../src/panel' -PanelContainer = require '../src/panel-container' - -describe "PanelContainer", -> - [container] = [] - - class TestPanelItem - constructor: -> - - beforeEach -> - container = new PanelContainer - - describe "::addPanel(panel)", -> - it 'emits an onDidAddPanel event with the index the panel was inserted at', -> - container.onDidAddPanel addPanelSpy = jasmine.createSpy() - - panel1 = new Panel(item: new TestPanelItem()) - container.addPanel(panel1) - expect(addPanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}) - - panel2 = new Panel(item: new TestPanelItem()) - container.addPanel(panel2) - expect(addPanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}) - - describe "when a panel is destroyed", -> - it 'emits an onDidRemovePanel event with the index of the removed item', -> - container.onDidRemovePanel removePanelSpy = jasmine.createSpy() - - panel1 = new Panel(item: new TestPanelItem()) - container.addPanel(panel1) - panel2 = new Panel(item: new TestPanelItem()) - container.addPanel(panel2) - - expect(removePanelSpy).not.toHaveBeenCalled() - - panel2.destroy() - expect(removePanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}) - - panel1.destroy() - expect(removePanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}) - - describe "::destroy()", -> - it "destroys the container and all of its panels", -> - destroyedPanels = [] - - panel1 = new Panel(item: new TestPanelItem()) - panel1.onDidDestroy -> destroyedPanels.push(panel1) - container.addPanel(panel1) - - panel2 = new Panel(item: new TestPanelItem()) - panel2.onDidDestroy -> destroyedPanels.push(panel2) - container.addPanel(panel2) - - container.destroy() - - expect(container.getPanels().length).toBe(0) - expect(destroyedPanels).toEqual([panel1, panel2]) - - describe "panel priority", -> - describe 'left / top panel container', -> - [initialPanel] = [] - beforeEach -> - # 'left' logic is the same as 'top' - container = new PanelContainer({location: 'left'}) - initialPanel = new Panel(item: new TestPanelItem()) - container.addPanel(initialPanel) - - describe 'when a panel with low priority is added', -> - it 'is inserted at the beginning of the list', -> - container.onDidAddPanel addPanelSpy = jasmine.createSpy() - panel = new Panel(item: new TestPanelItem(), priority: 0) - container.addPanel(panel) - - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - expect(container.getPanels()[0]).toBe panel - - describe 'when a panel with priority between two other panels is added', -> - it 'is inserted at the between the two panels', -> - panel = new Panel(item: new TestPanelItem(), priority: 1000) - container.addPanel(panel) - - container.onDidAddPanel addPanelSpy = jasmine.createSpy() - panel = new Panel(item: new TestPanelItem(), priority: 101) - container.addPanel(panel) - - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}) - expect(container.getPanels()[1]).toBe panel - - describe 'right / bottom panel container', -> - [initialPanel] = [] - beforeEach -> - # 'bottom' logic is the same as 'right' - container = new PanelContainer({location: 'right'}) - initialPanel = new Panel(item: new TestPanelItem()) - container.addPanel(initialPanel) - - describe 'when a panel with high priority is added', -> - it 'is inserted at the beginning of the list', -> - container.onDidAddPanel addPanelSpy = jasmine.createSpy() - panel = new Panel(item: new TestPanelItem(), priority: 1000) - container.addPanel(panel) - - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - expect(container.getPanels()[0]).toBe panel - - describe 'when a panel with low priority is added', -> - it 'is inserted at the end of the list', -> - container.onDidAddPanel addPanelSpy = jasmine.createSpy() - panel = new Panel(item: new TestPanelItem(), priority: 0) - container.addPanel(panel) - - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}) - expect(container.getPanels()[1]).toBe panel diff --git a/spec/panel-container-spec.js b/spec/panel-container-spec.js new file mode 100644 index 000000000..db155b3cb --- /dev/null +++ b/spec/panel-container-spec.js @@ -0,0 +1,139 @@ +const Panel = require('../src/panel'); +const PanelContainer = require('../src/panel-container'); + +describe("PanelContainer", function() { + let [container] = Array.from([]); + + class TestPanelItem { + constructor() {} + } + + beforeEach(() => container = new PanelContainer); + + describe("::addPanel(panel)", () => + it('emits an onDidAddPanel event with the index the panel was inserted at', function() { + let addPanelSpy; + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); + + const panel1 = new Panel({item: new TestPanelItem()}); + container.addPanel(panel1); + expect(addPanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}); + + const panel2 = new Panel({item: new TestPanelItem()}); + container.addPanel(panel2); + return expect(addPanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}); + }) + ); + + describe("when a panel is destroyed", () => + it('emits an onDidRemovePanel event with the index of the removed item', function() { + let removePanelSpy; + container.onDidRemovePanel(removePanelSpy = jasmine.createSpy()); + + const panel1 = new Panel({item: new TestPanelItem()}); + container.addPanel(panel1); + const panel2 = new Panel({item: new TestPanelItem()}); + container.addPanel(panel2); + + expect(removePanelSpy).not.toHaveBeenCalled(); + + panel2.destroy(); + expect(removePanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}); + + panel1.destroy(); + return expect(removePanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}); + }) + ); + + describe("::destroy()", () => + it("destroys the container and all of its panels", function() { + const destroyedPanels = []; + + const panel1 = new Panel({item: new TestPanelItem()}); + panel1.onDidDestroy(() => destroyedPanels.push(panel1)); + container.addPanel(panel1); + + const panel2 = new Panel({item: new TestPanelItem()}); + panel2.onDidDestroy(() => destroyedPanels.push(panel2)); + container.addPanel(panel2); + + container.destroy(); + + expect(container.getPanels().length).toBe(0); + return expect(destroyedPanels).toEqual([panel1, panel2]); + }) + ); + + return describe("panel priority", function() { + describe('left / top panel container', function() { + let [initialPanel] = Array.from([]); + beforeEach(function() { + // 'left' logic is the same as 'top' + container = new PanelContainer({location: 'left'}); + initialPanel = new Panel({item: new TestPanelItem()}); + return container.addPanel(initialPanel); + }); + + describe('when a panel with low priority is added', () => + it('is inserted at the beginning of the list', function() { + let addPanelSpy; + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); + const panel = new Panel({item: new TestPanelItem(), priority: 0}); + container.addPanel(panel); + + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}); + return expect(container.getPanels()[0]).toBe(panel); + }) + ); + + return describe('when a panel with priority between two other panels is added', () => + it('is inserted at the between the two panels', function() { + let addPanelSpy; + let panel = new Panel({item: new TestPanelItem(), priority: 1000}); + container.addPanel(panel); + + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); + panel = new Panel({item: new TestPanelItem(), priority: 101}); + container.addPanel(panel); + + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}); + return expect(container.getPanels()[1]).toBe(panel); + }) + ); + }); + + return describe('right / bottom panel container', function() { + let [initialPanel] = Array.from([]); + beforeEach(function() { + // 'bottom' logic is the same as 'right' + container = new PanelContainer({location: 'right'}); + initialPanel = new Panel({item: new TestPanelItem()}); + return container.addPanel(initialPanel); + }); + + describe('when a panel with high priority is added', () => + it('is inserted at the beginning of the list', function() { + let addPanelSpy; + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); + const panel = new Panel({item: new TestPanelItem(), priority: 1000}); + container.addPanel(panel); + + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}); + return expect(container.getPanels()[0]).toBe(panel); + }) + ); + + return describe('when a panel with low priority is added', () => + it('is inserted at the end of the list', function() { + let addPanelSpy; + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); + const panel = new Panel({item: new TestPanelItem(), priority: 0}); + container.addPanel(panel); + + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}); + return expect(container.getPanels()[1]).toBe(panel); + }) + ); + }); + }); +}); diff --git a/src/panel-container-element.coffee b/src/panel-container-element.coffee deleted file mode 100644 index b66a0cd90..000000000 --- a/src/panel-container-element.coffee +++ /dev/null @@ -1,45 +0,0 @@ -{CompositeDisposable} = require 'event-kit' - -class PanelContainerElement extends HTMLElement - createdCallback: -> - @subscriptions = new CompositeDisposable - - initialize: (@model, {@views}) -> - throw new Error("Must pass a views parameter when initializing PanelContainerElements") unless @views? - - @subscriptions.add @model.onDidAddPanel(@panelAdded.bind(this)) - @subscriptions.add @model.onDidDestroy(@destroyed.bind(this)) - @classList.add(@model.getLocation()) - this - - getModel: -> @model - - panelAdded: ({panel, index}) -> - panelElement = @views.getView(panel) - panelElement.classList.add(@model.getLocation()) - if @model.isModal() - panelElement.classList.add("overlay", "from-top") - else - panelElement.classList.add("tool-panel", "panel-#{@model.getLocation()}") - - if index >= @childNodes.length - @appendChild(panelElement) - else - referenceItem = @childNodes[index] - @insertBefore(panelElement, referenceItem) - - if @model.isModal() - @hideAllPanelsExcept(panel) - @subscriptions.add panel.onDidChangeVisible (visible) => - @hideAllPanelsExcept(panel) if visible - - destroyed: -> - @subscriptions.dispose() - @parentNode?.removeChild(this) - - hideAllPanelsExcept: (excludedPanel) -> - for panel in @model.getPanels() - panel.hide() unless panel is excludedPanel - return - -module.exports = PanelContainerElement = document.registerElement 'atom-panel-container', prototype: PanelContainerElement.prototype diff --git a/src/panel-container-element.js b/src/panel-container-element.js new file mode 100644 index 000000000..a6c133764 --- /dev/null +++ b/src/panel-container-element.js @@ -0,0 +1,59 @@ +const {CompositeDisposable} = require('event-kit'); + +class PanelContainerElement extends HTMLElement { + createdCallback() { + return this.subscriptions = new CompositeDisposable; + } + + initialize(model, {views}) { + this.model = model; + this.views = views; + if (this.views == null) { throw new Error("Must pass a views parameter when initializing PanelContainerElements"); } + + this.subscriptions.add(this.model.onDidAddPanel(this.panelAdded.bind(this))); + this.subscriptions.add(this.model.onDidDestroy(this.destroyed.bind(this))); + this.classList.add(this.model.getLocation()); + return this; + } + + getModel() { return this.model; } + + panelAdded({panel, index}) { + const panelElement = this.views.getView(panel); + panelElement.classList.add(this.model.getLocation()); + if (this.model.isModal()) { + panelElement.classList.add("overlay", "from-top"); + } else { + panelElement.classList.add("tool-panel", `panel-${this.model.getLocation()}`); + } + + if (index >= this.childNodes.length) { + this.appendChild(panelElement); + } else { + const referenceItem = this.childNodes[index]; + this.insertBefore(panelElement, referenceItem); + } + + if (this.model.isModal()) { + this.hideAllPanelsExcept(panel); + return this.subscriptions.add(panel.onDidChangeVisible(visible => { + if (visible) { return this.hideAllPanelsExcept(panel); } + } + ) + ); + } + } + + destroyed() { + this.subscriptions.dispose(); + return (this.parentNode != null ? this.parentNode.removeChild(this) : undefined); + } + + hideAllPanelsExcept(excludedPanel) { + for (let panel of this.model.getPanels()) { + if (panel !== excludedPanel) { panel.hide(); } + } + } +} + +module.exports = PanelContainerElement = document.registerElement('atom-panel-container', {prototype: PanelContainerElement.prototype}); diff --git a/src/panel-container.coffee b/src/panel-container.coffee deleted file mode 100644 index d109210a7..000000000 --- a/src/panel-container.coffee +++ /dev/null @@ -1,71 +0,0 @@ -{Emitter, CompositeDisposable} = require 'event-kit' - -module.exports = -class PanelContainer - constructor: ({@location}={}) -> - @emitter = new Emitter - @subscriptions = new CompositeDisposable - @panels = [] - - destroy: -> - panel.destroy() for panel in @getPanels() - @subscriptions.dispose() - @emitter.emit 'did-destroy', this - @emitter.dispose() - - ### - Section: Event Subscription - ### - - onDidAddPanel: (callback) -> - @emitter.on 'did-add-panel', callback - - onDidRemovePanel: (callback) -> - @emitter.on 'did-remove-panel', callback - - onDidDestroy: (callback) -> - @emitter.on 'did-destroy', callback - - ### - Section: Panels - ### - - getLocation: -> @location - - isModal: -> @location is 'modal' - - getPanels: -> @panels.slice() - - addPanel: (panel) -> - @subscriptions.add panel.onDidDestroy(@panelDestroyed.bind(this)) - - index = @getPanelIndex(panel) - if index is @panels.length - @panels.push(panel) - else - @panels.splice(index, 0, panel) - - @emitter.emit 'did-add-panel', {panel, index} - panel - - panelForItem: (item) -> - for panel in @panels - return panel if panel.getItem() is item - null - - panelDestroyed: (panel) -> - index = @panels.indexOf(panel) - if index > -1 - @panels.splice(index, 1) - @emitter.emit 'did-remove-panel', {panel, index} - - getPanelIndex: (panel) -> - priority = panel.getPriority() - if @location in ['bottom', 'right'] - for p, i in @panels by -1 - return i + 1 if priority < p.getPriority() - 0 - else - for p, i in @panels - return i if priority < p.getPriority() - @panels.length diff --git a/src/panel-container.js b/src/panel-container.js new file mode 100644 index 000000000..bfcf14bbd --- /dev/null +++ b/src/panel-container.js @@ -0,0 +1,92 @@ +let PanelContainer; +const {Emitter, CompositeDisposable} = require('event-kit'); + +module.exports = +PanelContainer = class PanelContainer { + constructor({location}={}) { + this.location = location; + this.emitter = new Emitter; + this.subscriptions = new CompositeDisposable; + this.panels = []; + } + + destroy() { + for (let panel of this.getPanels()) { panel.destroy(); } + this.subscriptions.dispose(); + this.emitter.emit('did-destroy', this); + return this.emitter.dispose(); + } + + /* + Section: Event Subscription + */ + + onDidAddPanel(callback) { + return this.emitter.on('did-add-panel', callback); + } + + onDidRemovePanel(callback) { + return this.emitter.on('did-remove-panel', callback); + } + + onDidDestroy(callback) { + return this.emitter.on('did-destroy', callback); + } + + /* + Section: Panels + */ + + getLocation() { return this.location; } + + isModal() { return this.location === 'modal'; } + + getPanels() { return this.panels.slice(); } + + addPanel(panel) { + this.subscriptions.add(panel.onDidDestroy(this.panelDestroyed.bind(this))); + + const index = this.getPanelIndex(panel); + if (index === this.panels.length) { + this.panels.push(panel); + } else { + this.panels.splice(index, 0, panel); + } + + this.emitter.emit('did-add-panel', {panel, index}); + return panel; + } + + panelForItem(item) { + for (let panel of this.panels) { + if (panel.getItem() === item) { return panel; } + } + return null; + } + + panelDestroyed(panel) { + const index = this.panels.indexOf(panel); + if (index > -1) { + this.panels.splice(index, 1); + return this.emitter.emit('did-remove-panel', {panel, index}); + } + } + + getPanelIndex(panel) { + let i, p; + const priority = panel.getPriority(); + if (['bottom', 'right'].includes(this.location)) { + for (i = this.panels.length - 1; i >= 0; i--) { + p = this.panels[i]; + if (priority < p.getPriority()) { return i + 1; } + } + return 0; + } else { + for (i = 0; i < this.panels.length; i++) { + p = this.panels[i]; + if (priority < p.getPriority()) { return i; } + } + return this.panels.length; + } + } +}; From f56865b6f81cc62246c83afceb11c1f36f8c2ed8 Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Tue, 7 Mar 2017 14:30:33 -0800 Subject: [PATCH 15/27] Convert panel container to JS: Lint --- spec/panel-container-element-spec.js | 226 ++++++++++++++------------- spec/panel-container-spec.js | 193 ++++++++++++----------- src/panel-container-element.js | 60 +++---- src/panel-container.js | 92 ++++++----- 4 files changed, 286 insertions(+), 285 deletions(-) diff --git a/spec/panel-container-element-spec.js b/spec/panel-container-element-spec.js index 167fd92ed..9bc779ba8 100644 --- a/spec/panel-container-element-spec.js +++ b/spec/panel-container-element-spec.js @@ -1,154 +1,156 @@ -const Panel = require('../src/panel'); -const PanelContainer = require('../src/panel-container'); +/* global HTMLElement */ -describe("PanelContainerElement", function() { - let [jasmineContent, element, container] = Array.from([]); +const Panel = require('../src/panel') +const PanelContainer = require('../src/panel-container') + +describe('PanelContainerElement', function () { + let [jasmineContent, element, container] = Array.from([]) class TestPanelContainerItem { - constructior() {} + constructior () {} } - class TestPanelContainerItemElement extends HTMLElement { - createdCallback() { - return this.classList.add('test-root'); + class TestPanelContainerItemElement_ extends HTMLElement { + createdCallback () { + return this.classList.add('test-root') } - initialize(model) { - this.model = model; - return this; + initialize (model) { + this.model = model + return this } } - TestPanelContainerItemElement = document.registerElement('atom-test-container-item-element', {prototype: TestPanelContainerItemElement.prototype}); + const TestPanelContainerItemElement = document.registerElement('atom-test-container-item-element', {prototype: TestPanelContainerItemElement_.prototype}) - beforeEach(function() { - jasmineContent = document.body.querySelector('#jasmine-content'); + beforeEach(function () { + jasmineContent = document.body.querySelector('#jasmine-content') - atom.views.addViewProvider(TestPanelContainerItem, model => new TestPanelContainerItemElement().initialize(model)); + atom.views.addViewProvider(TestPanelContainerItem, model => new TestPanelContainerItemElement().initialize(model)) - container = new PanelContainer({location: 'left'}); - element = atom.views.getView(container); - return jasmineContent.appendChild(element); - }); + container = new PanelContainer({location: 'left'}) + element = atom.views.getView(container) + return jasmineContent.appendChild(element) + }) - it('has a location class with value from the model', () => expect(element).toHaveClass('left')); + it('has a location class with value from the model', () => expect(element).toHaveClass('left')) - it('removes the element when the container is destroyed', function() { - expect(element.parentNode).toBe(jasmineContent); - container.destroy(); - return expect(element.parentNode).not.toBe(jasmineContent); - }); + it('removes the element when the container is destroyed', function () { + expect(element.parentNode).toBe(jasmineContent) + container.destroy() + return expect(element.parentNode).not.toBe(jasmineContent) + }) - describe("adding and removing panels", function() { - it("allows panels to be inserted at any position", function() { - const panel1 = new Panel({item: new TestPanelContainerItem(), priority: 10}); - const panel2 = new Panel({item: new TestPanelContainerItem(), priority: 5}); - const panel3 = new Panel({item: new TestPanelContainerItem(), priority: 8}); + describe('adding and removing panels', function () { + it('allows panels to be inserted at any position', function () { + const panel1 = new Panel({item: new TestPanelContainerItem(), priority: 10}) + const panel2 = new Panel({item: new TestPanelContainerItem(), priority: 5}) + const panel3 = new Panel({item: new TestPanelContainerItem(), priority: 8}) - container.addPanel(panel1); - container.addPanel(panel2); - container.addPanel(panel3); + container.addPanel(panel1) + container.addPanel(panel2) + container.addPanel(panel3) - expect(element.childNodes[2].getModel()).toBe(panel1); - expect(element.childNodes[1].getModel()).toBe(panel3); - return expect(element.childNodes[0].getModel()).toBe(panel2); - }); + expect(element.childNodes[2].getModel()).toBe(panel1) + expect(element.childNodes[1].getModel()).toBe(panel3) + return expect(element.childNodes[0].getModel()).toBe(panel2) + }) - describe("when the container is at the left location", () => - it("adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", function() { - expect(element.childNodes.length).toBe(0); + describe('when the container is at the left location', () => + it('adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed', function () { + expect(element.childNodes.length).toBe(0) - const panel1 = new Panel({item: new TestPanelContainerItem()}); - container.addPanel(panel1); - expect(element.childNodes.length).toBe(1); - expect(element.childNodes[0]).toHaveClass('left'); - expect(element.childNodes[0]).toHaveClass('tool-panel'); // legacy selector support - expect(element.childNodes[0]).toHaveClass('panel-left'); // legacy selector support + const panel1 = new Panel({item: new TestPanelContainerItem()}) + container.addPanel(panel1) + expect(element.childNodes.length).toBe(1) + expect(element.childNodes[0]).toHaveClass('left') + expect(element.childNodes[0]).toHaveClass('tool-panel') // legacy selector support + expect(element.childNodes[0]).toHaveClass('panel-left') // legacy selector support - expect(element.childNodes[0].tagName).toBe('ATOM-PANEL'); + expect(element.childNodes[0].tagName).toBe('ATOM-PANEL') - const panel2 = new Panel({item: new TestPanelContainerItem()}); - container.addPanel(panel2); - expect(element.childNodes.length).toBe(2); + const panel2 = new Panel({item: new TestPanelContainerItem()}) + container.addPanel(panel2) + expect(element.childNodes.length).toBe(2) - expect(atom.views.getView(panel1).style.display).not.toBe('none'); - expect(atom.views.getView(panel2).style.display).not.toBe('none'); + expect(atom.views.getView(panel1).style.display).not.toBe('none') + expect(atom.views.getView(panel2).style.display).not.toBe('none') - panel1.destroy(); - expect(element.childNodes.length).toBe(1); + panel1.destroy() + expect(element.childNodes.length).toBe(1) - panel2.destroy(); - return expect(element.childNodes.length).toBe(0); + panel2.destroy() + return expect(element.childNodes.length).toBe(0) }) - ); + ) - return describe("when the container is at the bottom location", function() { - beforeEach(function() { - container = new PanelContainer({location: 'bottom'}); - element = atom.views.getView(container); - return jasmineContent.appendChild(element); - }); + return describe('when the container is at the bottom location', function () { + beforeEach(function () { + container = new PanelContainer({location: 'bottom'}) + element = atom.views.getView(container) + return jasmineContent.appendChild(element) + }) - return it("adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed", function() { - expect(element.childNodes.length).toBe(0); + return it('adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed', function () { + expect(element.childNodes.length).toBe(0) - const panel1 = new Panel({item: new TestPanelContainerItem(), className: 'one'}); - container.addPanel(panel1); - expect(element.childNodes.length).toBe(1); - expect(element.childNodes[0]).toHaveClass('bottom'); - expect(element.childNodes[0]).toHaveClass('tool-panel'); // legacy selector support - expect(element.childNodes[0]).toHaveClass('panel-bottom'); // legacy selector support - expect(element.childNodes[0].tagName).toBe('ATOM-PANEL'); - expect(atom.views.getView(panel1)).toHaveClass('one'); + const panel1 = new Panel({item: new TestPanelContainerItem(), className: 'one'}) + container.addPanel(panel1) + expect(element.childNodes.length).toBe(1) + expect(element.childNodes[0]).toHaveClass('bottom') + expect(element.childNodes[0]).toHaveClass('tool-panel') // legacy selector support + expect(element.childNodes[0]).toHaveClass('panel-bottom') // legacy selector support + expect(element.childNodes[0].tagName).toBe('ATOM-PANEL') + expect(atom.views.getView(panel1)).toHaveClass('one') - const panel2 = new Panel({item: new TestPanelContainerItem(), className: 'two'}); - container.addPanel(panel2); - expect(element.childNodes.length).toBe(2); - expect(atom.views.getView(panel2)).toHaveClass('two'); + const panel2 = new Panel({item: new TestPanelContainerItem(), className: 'two'}) + container.addPanel(panel2) + expect(element.childNodes.length).toBe(2) + expect(atom.views.getView(panel2)).toHaveClass('two') - panel1.destroy(); - expect(element.childNodes.length).toBe(1); + panel1.destroy() + expect(element.childNodes.length).toBe(1) - panel2.destroy(); - return expect(element.childNodes.length).toBe(0); - }); - }); - }); + panel2.destroy() + return expect(element.childNodes.length).toBe(0) + }) + }) + }) - return describe("when the container is modal", function() { - beforeEach(function() { - container = new PanelContainer({location: 'modal'}); - element = atom.views.getView(container); - return jasmineContent.appendChild(element); - }); + return describe('when the container is modal', function () { + beforeEach(function () { + container = new PanelContainer({location: 'modal'}) + element = atom.views.getView(container) + return jasmineContent.appendChild(element) + }) - it("allows only one panel to be visible at a time", function() { - const panel1 = new Panel({item: new TestPanelContainerItem()}); - container.addPanel(panel1); + it('allows only one panel to be visible at a time', function () { + const panel1 = new Panel({item: new TestPanelContainerItem()}) + container.addPanel(panel1) - expect(atom.views.getView(panel1).style.display).not.toBe('none'); + expect(atom.views.getView(panel1).style.display).not.toBe('none') - const panel2 = new Panel({item: new TestPanelContainerItem()}); - container.addPanel(panel2); + const panel2 = new Panel({item: new TestPanelContainerItem()}) + container.addPanel(panel2) - expect(atom.views.getView(panel1).style.display).toBe('none'); - expect(atom.views.getView(panel2).style.display).not.toBe('none'); + expect(atom.views.getView(panel1).style.display).toBe('none') + expect(atom.views.getView(panel2).style.display).not.toBe('none') - panel1.show(); + panel1.show() - expect(atom.views.getView(panel1).style.display).not.toBe('none'); - return expect(atom.views.getView(panel2).style.display).toBe('none'); - }); + expect(atom.views.getView(panel1).style.display).not.toBe('none') + return expect(atom.views.getView(panel2).style.display).toBe('none') + }) - return it("adds the 'modal' class to panels", function() { - const panel1 = new Panel({item: new TestPanelContainerItem()}); - container.addPanel(panel1); + return it("adds the 'modal' class to panels", function () { + const panel1 = new Panel({item: new TestPanelContainerItem()}) + container.addPanel(panel1) - expect(atom.views.getView(panel1)).toHaveClass('modal'); + expect(atom.views.getView(panel1)).toHaveClass('modal') // legacy selector support - expect(atom.views.getView(panel1)).not.toHaveClass('tool-panel'); - expect(atom.views.getView(panel1)).toHaveClass('overlay'); - return expect(atom.views.getView(panel1)).toHaveClass('from-top'); - }); - }); -}); + expect(atom.views.getView(panel1)).not.toHaveClass('tool-panel') + expect(atom.views.getView(panel1)).toHaveClass('overlay') + return expect(atom.views.getView(panel1)).toHaveClass('from-top') + }) + }) +}) diff --git a/spec/panel-container-spec.js b/spec/panel-container-spec.js index db155b3cb..4f22b7552 100644 --- a/spec/panel-container-spec.js +++ b/spec/panel-container-spec.js @@ -1,139 +1,138 @@ -const Panel = require('../src/panel'); -const PanelContainer = require('../src/panel-container'); +const Panel = require('../src/panel') +const PanelContainer = require('../src/panel-container') -describe("PanelContainer", function() { - let [container] = Array.from([]); +describe('PanelContainer', function () { + let [container] = Array.from([]) class TestPanelItem { - constructor() {} } - beforeEach(() => container = new PanelContainer); + beforeEach(() => (container = new PanelContainer())) - describe("::addPanel(panel)", () => - it('emits an onDidAddPanel event with the index the panel was inserted at', function() { - let addPanelSpy; - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); + describe('::addPanel(panel)', () => + it('emits an onDidAddPanel event with the index the panel was inserted at', function () { + let addPanelSpy + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) - const panel1 = new Panel({item: new TestPanelItem()}); - container.addPanel(panel1); - expect(addPanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}); + const panel1 = new Panel({item: new TestPanelItem()}) + container.addPanel(panel1) + expect(addPanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}) - const panel2 = new Panel({item: new TestPanelItem()}); - container.addPanel(panel2); - return expect(addPanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}); + const panel2 = new Panel({item: new TestPanelItem()}) + container.addPanel(panel2) + return expect(addPanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}) }) - ); + ) - describe("when a panel is destroyed", () => - it('emits an onDidRemovePanel event with the index of the removed item', function() { - let removePanelSpy; - container.onDidRemovePanel(removePanelSpy = jasmine.createSpy()); + describe('when a panel is destroyed', () => + it('emits an onDidRemovePanel event with the index of the removed item', function () { + let removePanelSpy + container.onDidRemovePanel(removePanelSpy = jasmine.createSpy()) - const panel1 = new Panel({item: new TestPanelItem()}); - container.addPanel(panel1); - const panel2 = new Panel({item: new TestPanelItem()}); - container.addPanel(panel2); + const panel1 = new Panel({item: new TestPanelItem()}) + container.addPanel(panel1) + const panel2 = new Panel({item: new TestPanelItem()}) + container.addPanel(panel2) - expect(removePanelSpy).not.toHaveBeenCalled(); + expect(removePanelSpy).not.toHaveBeenCalled() - panel2.destroy(); - expect(removePanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}); + panel2.destroy() + expect(removePanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}) - panel1.destroy(); - return expect(removePanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}); + panel1.destroy() + return expect(removePanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}) }) - ); + ) - describe("::destroy()", () => - it("destroys the container and all of its panels", function() { - const destroyedPanels = []; + describe('::destroy()', () => + it('destroys the container and all of its panels', function () { + const destroyedPanels = [] - const panel1 = new Panel({item: new TestPanelItem()}); - panel1.onDidDestroy(() => destroyedPanels.push(panel1)); - container.addPanel(panel1); + const panel1 = new Panel({item: new TestPanelItem()}) + panel1.onDidDestroy(() => destroyedPanels.push(panel1)) + container.addPanel(panel1) - const panel2 = new Panel({item: new TestPanelItem()}); - panel2.onDidDestroy(() => destroyedPanels.push(panel2)); - container.addPanel(panel2); + const panel2 = new Panel({item: new TestPanelItem()}) + panel2.onDidDestroy(() => destroyedPanels.push(panel2)) + container.addPanel(panel2) - container.destroy(); + container.destroy() - expect(container.getPanels().length).toBe(0); - return expect(destroyedPanels).toEqual([panel1, panel2]); + expect(container.getPanels().length).toBe(0) + return expect(destroyedPanels).toEqual([panel1, panel2]) }) - ); + ) - return describe("panel priority", function() { - describe('left / top panel container', function() { - let [initialPanel] = Array.from([]); - beforeEach(function() { + return describe('panel priority', function () { + describe('left / top panel container', function () { + let [initialPanel] = Array.from([]) + beforeEach(function () { // 'left' logic is the same as 'top' - container = new PanelContainer({location: 'left'}); - initialPanel = new Panel({item: new TestPanelItem()}); - return container.addPanel(initialPanel); - }); + container = new PanelContainer({location: 'left'}) + initialPanel = new Panel({item: new TestPanelItem()}) + return container.addPanel(initialPanel) + }) describe('when a panel with low priority is added', () => - it('is inserted at the beginning of the list', function() { - let addPanelSpy; - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); - const panel = new Panel({item: new TestPanelItem(), priority: 0}); - container.addPanel(panel); + it('is inserted at the beginning of the list', function () { + let addPanelSpy + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + const panel = new Panel({item: new TestPanelItem(), priority: 0}) + container.addPanel(panel) - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}); - return expect(container.getPanels()[0]).toBe(panel); + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) + return expect(container.getPanels()[0]).toBe(panel) }) - ); + ) return describe('when a panel with priority between two other panels is added', () => - it('is inserted at the between the two panels', function() { - let addPanelSpy; - let panel = new Panel({item: new TestPanelItem(), priority: 1000}); - container.addPanel(panel); + it('is inserted at the between the two panels', function () { + let addPanelSpy + let panel = new Panel({item: new TestPanelItem(), priority: 1000}) + container.addPanel(panel) - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); - panel = new Panel({item: new TestPanelItem(), priority: 101}); - container.addPanel(panel); + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + panel = new Panel({item: new TestPanelItem(), priority: 101}) + container.addPanel(panel) - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}); - return expect(container.getPanels()[1]).toBe(panel); + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}) + return expect(container.getPanels()[1]).toBe(panel) }) - ); - }); + ) + }) - return describe('right / bottom panel container', function() { - let [initialPanel] = Array.from([]); - beforeEach(function() { + return describe('right / bottom panel container', function () { + let [initialPanel] = Array.from([]) + beforeEach(function () { // 'bottom' logic is the same as 'right' - container = new PanelContainer({location: 'right'}); - initialPanel = new Panel({item: new TestPanelItem()}); - return container.addPanel(initialPanel); - }); + container = new PanelContainer({location: 'right'}) + initialPanel = new Panel({item: new TestPanelItem()}) + return container.addPanel(initialPanel) + }) describe('when a panel with high priority is added', () => - it('is inserted at the beginning of the list', function() { - let addPanelSpy; - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); - const panel = new Panel({item: new TestPanelItem(), priority: 1000}); - container.addPanel(panel); + it('is inserted at the beginning of the list', function () { + let addPanelSpy + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + const panel = new Panel({item: new TestPanelItem(), priority: 1000}) + container.addPanel(panel) - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}); - return expect(container.getPanels()[0]).toBe(panel); + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) + return expect(container.getPanels()[0]).toBe(panel) }) - ); + ) return describe('when a panel with low priority is added', () => - it('is inserted at the end of the list', function() { - let addPanelSpy; - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()); - const panel = new Panel({item: new TestPanelItem(), priority: 0}); - container.addPanel(panel); + it('is inserted at the end of the list', function () { + let addPanelSpy + container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + const panel = new Panel({item: new TestPanelItem(), priority: 0}) + container.addPanel(panel) - expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}); - return expect(container.getPanels()[1]).toBe(panel); + expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}) + return expect(container.getPanels()[1]).toBe(panel) }) - ); - }); - }); -}); + ) + }) + }) +}) diff --git a/src/panel-container-element.js b/src/panel-container-element.js index a6c133764..1609b2bef 100644 --- a/src/panel-container-element.js +++ b/src/panel-container-element.js @@ -1,59 +1,61 @@ -const {CompositeDisposable} = require('event-kit'); +/* global HTMLElement */ + +const {CompositeDisposable} = require('event-kit') class PanelContainerElement extends HTMLElement { - createdCallback() { - return this.subscriptions = new CompositeDisposable; + createdCallback () { + return (this.subscriptions = new CompositeDisposable()) } - initialize(model, {views}) { - this.model = model; - this.views = views; - if (this.views == null) { throw new Error("Must pass a views parameter when initializing PanelContainerElements"); } + initialize (model, {views}) { + this.model = model + this.views = views + if (this.views == null) { throw new Error('Must pass a views parameter when initializing PanelContainerElements') } - this.subscriptions.add(this.model.onDidAddPanel(this.panelAdded.bind(this))); - this.subscriptions.add(this.model.onDidDestroy(this.destroyed.bind(this))); - this.classList.add(this.model.getLocation()); - return this; + this.subscriptions.add(this.model.onDidAddPanel(this.panelAdded.bind(this))) + this.subscriptions.add(this.model.onDidDestroy(this.destroyed.bind(this))) + this.classList.add(this.model.getLocation()) + return this } - getModel() { return this.model; } + getModel () { return this.model } - panelAdded({panel, index}) { - const panelElement = this.views.getView(panel); - panelElement.classList.add(this.model.getLocation()); + panelAdded ({panel, index}) { + const panelElement = this.views.getView(panel) + panelElement.classList.add(this.model.getLocation()) if (this.model.isModal()) { - panelElement.classList.add("overlay", "from-top"); + panelElement.classList.add('overlay', 'from-top') } else { - panelElement.classList.add("tool-panel", `panel-${this.model.getLocation()}`); + panelElement.classList.add('tool-panel', `panel-${this.model.getLocation()}`) } if (index >= this.childNodes.length) { - this.appendChild(panelElement); + this.appendChild(panelElement) } else { - const referenceItem = this.childNodes[index]; - this.insertBefore(panelElement, referenceItem); + const referenceItem = this.childNodes[index] + this.insertBefore(panelElement, referenceItem) } if (this.model.isModal()) { - this.hideAllPanelsExcept(panel); + this.hideAllPanelsExcept(panel) return this.subscriptions.add(panel.onDidChangeVisible(visible => { - if (visible) { return this.hideAllPanelsExcept(panel); } + if (visible) { return this.hideAllPanelsExcept(panel) } } ) - ); + ) } } - destroyed() { - this.subscriptions.dispose(); - return (this.parentNode != null ? this.parentNode.removeChild(this) : undefined); + destroyed () { + this.subscriptions.dispose() + return (this.parentNode != null ? this.parentNode.removeChild(this) : undefined) } - hideAllPanelsExcept(excludedPanel) { + hideAllPanelsExcept (excludedPanel) { for (let panel of this.model.getPanels()) { - if (panel !== excludedPanel) { panel.hide(); } + if (panel !== excludedPanel) { panel.hide() } } } } -module.exports = PanelContainerElement = document.registerElement('atom-panel-container', {prototype: PanelContainerElement.prototype}); +module.exports = document.registerElement('atom-panel-container', {prototype: PanelContainerElement.prototype}) diff --git a/src/panel-container.js b/src/panel-container.js index bfcf14bbd..cc473b189 100644 --- a/src/panel-container.js +++ b/src/panel-container.js @@ -1,92 +1,90 @@ -let PanelContainer; -const {Emitter, CompositeDisposable} = require('event-kit'); +const {Emitter, CompositeDisposable} = require('event-kit') -module.exports = -PanelContainer = class PanelContainer { - constructor({location}={}) { - this.location = location; - this.emitter = new Emitter; - this.subscriptions = new CompositeDisposable; - this.panels = []; +module.exports = class PanelContainer { + constructor ({location} = {}) { + this.location = location + this.emitter = new Emitter() + this.subscriptions = new CompositeDisposable() + this.panels = [] } - destroy() { - for (let panel of this.getPanels()) { panel.destroy(); } - this.subscriptions.dispose(); - this.emitter.emit('did-destroy', this); - return this.emitter.dispose(); + destroy () { + for (let panel of this.getPanels()) { panel.destroy() } + this.subscriptions.dispose() + this.emitter.emit('did-destroy', this) + return this.emitter.dispose() } /* Section: Event Subscription */ - onDidAddPanel(callback) { - return this.emitter.on('did-add-panel', callback); + onDidAddPanel (callback) { + return this.emitter.on('did-add-panel', callback) } - onDidRemovePanel(callback) { - return this.emitter.on('did-remove-panel', callback); + onDidRemovePanel (callback) { + return this.emitter.on('did-remove-panel', callback) } - onDidDestroy(callback) { - return this.emitter.on('did-destroy', callback); + onDidDestroy (callback) { + return this.emitter.on('did-destroy', callback) } /* Section: Panels */ - getLocation() { return this.location; } + getLocation () { return this.location } - isModal() { return this.location === 'modal'; } + isModal () { return this.location === 'modal' } - getPanels() { return this.panels.slice(); } + getPanels () { return this.panels.slice() } - addPanel(panel) { - this.subscriptions.add(panel.onDidDestroy(this.panelDestroyed.bind(this))); + addPanel (panel) { + this.subscriptions.add(panel.onDidDestroy(this.panelDestroyed.bind(this))) - const index = this.getPanelIndex(panel); + const index = this.getPanelIndex(panel) if (index === this.panels.length) { - this.panels.push(panel); + this.panels.push(panel) } else { - this.panels.splice(index, 0, panel); + this.panels.splice(index, 0, panel) } - this.emitter.emit('did-add-panel', {panel, index}); - return panel; + this.emitter.emit('did-add-panel', {panel, index}) + return panel } - panelForItem(item) { + panelForItem (item) { for (let panel of this.panels) { - if (panel.getItem() === item) { return panel; } + if (panel.getItem() === item) { return panel } } - return null; + return null } - panelDestroyed(panel) { - const index = this.panels.indexOf(panel); + panelDestroyed (panel) { + const index = this.panels.indexOf(panel) if (index > -1) { - this.panels.splice(index, 1); - return this.emitter.emit('did-remove-panel', {panel, index}); + this.panels.splice(index, 1) + return this.emitter.emit('did-remove-panel', {panel, index}) } } - getPanelIndex(panel) { - let i, p; - const priority = panel.getPriority(); + getPanelIndex (panel) { + let i, p + const priority = panel.getPriority() if (['bottom', 'right'].includes(this.location)) { for (i = this.panels.length - 1; i >= 0; i--) { - p = this.panels[i]; - if (priority < p.getPriority()) { return i + 1; } + p = this.panels[i] + if (priority < p.getPriority()) { return i + 1 } } - return 0; + return 0 } else { for (i = 0; i < this.panels.length; i++) { - p = this.panels[i]; - if (priority < p.getPriority()) { return i; } + p = this.panels[i] + if (priority < p.getPriority()) { return i } } - return this.panels.length; + return this.panels.length } } -}; +} From d6a354d6ba807822583f6e07c36d26c481266c8d Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Tue, 7 Mar 2017 14:52:32 -0800 Subject: [PATCH 16/27] Convert panel container to JS: Cleanup --- spec/panel-container-element-spec.js | 65 +++++++++------- spec/panel-container-spec.js | 112 ++++++++++++++------------- src/panel-container-element.js | 20 +++-- src/panel-container.js | 15 ++-- 4 files changed, 115 insertions(+), 97 deletions(-) diff --git a/spec/panel-container-element-spec.js b/spec/panel-container-element-spec.js index 9bc779ba8..23da47663 100644 --- a/spec/panel-container-element-spec.js +++ b/spec/panel-container-element-spec.js @@ -1,18 +1,19 @@ +'use strict' + /* global HTMLElement */ const Panel = require('../src/panel') const PanelContainer = require('../src/panel-container') -describe('PanelContainerElement', function () { - let [jasmineContent, element, container] = Array.from([]) +describe('PanelContainerElement', () => { + let jasmineContent, element, container class TestPanelContainerItem { - constructior () {} } class TestPanelContainerItemElement_ extends HTMLElement { createdCallback () { - return this.classList.add('test-root') + this.classList.add('test-root') } initialize (model) { this.model = model @@ -20,28 +21,36 @@ describe('PanelContainerElement', function () { } } - const TestPanelContainerItemElement = document.registerElement('atom-test-container-item-element', {prototype: TestPanelContainerItemElement_.prototype}) + const TestPanelContainerItemElement = document.registerElement( + 'atom-test-container-item-element', + {prototype: TestPanelContainerItemElement_.prototype} + ) - beforeEach(function () { + beforeEach(() => { jasmineContent = document.body.querySelector('#jasmine-content') - atom.views.addViewProvider(TestPanelContainerItem, model => new TestPanelContainerItemElement().initialize(model)) + atom.views.addViewProvider( + TestPanelContainerItem, + model => new TestPanelContainerItemElement().initialize(model) + ) container = new PanelContainer({location: 'left'}) element = atom.views.getView(container) - return jasmineContent.appendChild(element) + jasmineContent.appendChild(element) }) - it('has a location class with value from the model', () => expect(element).toHaveClass('left')) + it('has a location class with value from the model', () => { + expect(element).toHaveClass('left') + }) - it('removes the element when the container is destroyed', function () { + it('removes the element when the container is destroyed', () => { expect(element.parentNode).toBe(jasmineContent) container.destroy() - return expect(element.parentNode).not.toBe(jasmineContent) + expect(element.parentNode).not.toBe(jasmineContent) }) - describe('adding and removing panels', function () { - it('allows panels to be inserted at any position', function () { + describe('adding and removing panels', () => { + it('allows panels to be inserted at any position', () => { const panel1 = new Panel({item: new TestPanelContainerItem(), priority: 10}) const panel2 = new Panel({item: new TestPanelContainerItem(), priority: 5}) const panel3 = new Panel({item: new TestPanelContainerItem(), priority: 8}) @@ -52,11 +61,11 @@ describe('PanelContainerElement', function () { expect(element.childNodes[2].getModel()).toBe(panel1) expect(element.childNodes[1].getModel()).toBe(panel3) - return expect(element.childNodes[0].getModel()).toBe(panel2) + expect(element.childNodes[0].getModel()).toBe(panel2) }) describe('when the container is at the left location', () => - it('adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed', function () { + it('adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed', () => { expect(element.childNodes.length).toBe(0) const panel1 = new Panel({item: new TestPanelContainerItem()}) @@ -79,18 +88,18 @@ describe('PanelContainerElement', function () { expect(element.childNodes.length).toBe(1) panel2.destroy() - return expect(element.childNodes.length).toBe(0) + expect(element.childNodes.length).toBe(0) }) ) - return describe('when the container is at the bottom location', function () { - beforeEach(function () { + describe('when the container is at the bottom location', () => { + beforeEach(() => { container = new PanelContainer({location: 'bottom'}) element = atom.views.getView(container) - return jasmineContent.appendChild(element) + jasmineContent.appendChild(element) }) - return it('adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed', function () { + it('adds atom-panel elements when a new panel is added to the container; removes them when the panels are destroyed', () => { expect(element.childNodes.length).toBe(0) const panel1 = new Panel({item: new TestPanelContainerItem(), className: 'one'}) @@ -111,19 +120,19 @@ describe('PanelContainerElement', function () { expect(element.childNodes.length).toBe(1) panel2.destroy() - return expect(element.childNodes.length).toBe(0) + expect(element.childNodes.length).toBe(0) }) }) }) - return describe('when the container is modal', function () { - beforeEach(function () { + describe('when the container is modal', () => { + beforeEach(() => { container = new PanelContainer({location: 'modal'}) element = atom.views.getView(container) - return jasmineContent.appendChild(element) + jasmineContent.appendChild(element) }) - it('allows only one panel to be visible at a time', function () { + it('allows only one panel to be visible at a time', () => { const panel1 = new Panel({item: new TestPanelContainerItem()}) container.addPanel(panel1) @@ -138,10 +147,10 @@ describe('PanelContainerElement', function () { panel1.show() expect(atom.views.getView(panel1).style.display).not.toBe('none') - return expect(atom.views.getView(panel2).style.display).toBe('none') + expect(atom.views.getView(panel2).style.display).toBe('none') }) - return it("adds the 'modal' class to panels", function () { + it("adds the 'modal' class to panels", () => { const panel1 = new Panel({item: new TestPanelContainerItem()}) container.addPanel(panel1) @@ -150,7 +159,7 @@ describe('PanelContainerElement', function () { // legacy selector support expect(atom.views.getView(panel1)).not.toHaveClass('tool-panel') expect(atom.views.getView(panel1)).toHaveClass('overlay') - return expect(atom.views.getView(panel1)).toHaveClass('from-top') + expect(atom.views.getView(panel1)).toHaveClass('from-top') }) }) }) diff --git a/spec/panel-container-spec.js b/spec/panel-container-spec.js index 4f22b7552..628904256 100644 --- a/spec/panel-container-spec.js +++ b/spec/panel-container-spec.js @@ -1,18 +1,22 @@ +'use strict' + const Panel = require('../src/panel') const PanelContainer = require('../src/panel-container') -describe('PanelContainer', function () { - let [container] = Array.from([]) +describe('PanelContainer', () => { + let container class TestPanelItem { } - beforeEach(() => (container = new PanelContainer())) + beforeEach(() => { + container = new PanelContainer() + }) - describe('::addPanel(panel)', () => - it('emits an onDidAddPanel event with the index the panel was inserted at', function () { - let addPanelSpy - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + describe('::addPanel(panel)', () => { + it('emits an onDidAddPanel event with the index the panel was inserted at', () => { + const addPanelSpy = jasmine.createSpy() + container.onDidAddPanel(addPanelSpy) const panel1 = new Panel({item: new TestPanelItem()}) container.addPanel(panel1) @@ -20,14 +24,14 @@ describe('PanelContainer', function () { const panel2 = new Panel({item: new TestPanelItem()}) container.addPanel(panel2) - return expect(addPanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}) + expect(addPanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}) }) - ) + }) - describe('when a panel is destroyed', () => - it('emits an onDidRemovePanel event with the index of the removed item', function () { - let removePanelSpy - container.onDidRemovePanel(removePanelSpy = jasmine.createSpy()) + describe('when a panel is destroyed', () => { + it('emits an onDidRemovePanel event with the index of the removed item', () => { + const removePanelSpy = jasmine.createSpy() + container.onDidRemovePanel(removePanelSpy) const panel1 = new Panel({item: new TestPanelItem()}) container.addPanel(panel1) @@ -40,99 +44,99 @@ describe('PanelContainer', function () { expect(removePanelSpy).toHaveBeenCalledWith({panel: panel2, index: 1}) panel1.destroy() - return expect(removePanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}) + expect(removePanelSpy).toHaveBeenCalledWith({panel: panel1, index: 0}) }) - ) + }) - describe('::destroy()', () => - it('destroys the container and all of its panels', function () { + describe('::destroy()', () => { + it('destroys the container and all of its panels', () => { const destroyedPanels = [] const panel1 = new Panel({item: new TestPanelItem()}) - panel1.onDidDestroy(() => destroyedPanels.push(panel1)) + panel1.onDidDestroy(() => { destroyedPanels.push(panel1) }) container.addPanel(panel1) const panel2 = new Panel({item: new TestPanelItem()}) - panel2.onDidDestroy(() => destroyedPanels.push(panel2)) + panel2.onDidDestroy(() => { destroyedPanels.push(panel2) }) container.addPanel(panel2) container.destroy() expect(container.getPanels().length).toBe(0) - return expect(destroyedPanels).toEqual([panel1, panel2]) + expect(destroyedPanels).toEqual([panel1, panel2]) }) - ) + }) - return describe('panel priority', function () { - describe('left / top panel container', function () { - let [initialPanel] = Array.from([]) - beforeEach(function () { + describe('panel priority', () => { + describe('left / top panel container', () => { + let initialPanel + beforeEach(() => { // 'left' logic is the same as 'top' container = new PanelContainer({location: 'left'}) initialPanel = new Panel({item: new TestPanelItem()}) - return container.addPanel(initialPanel) + container.addPanel(initialPanel) }) - describe('when a panel with low priority is added', () => - it('is inserted at the beginning of the list', function () { - let addPanelSpy - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + describe('when a panel with low priority is added', () => { + it('is inserted at the beginning of the list', () => { + const addPanelSpy = jasmine.createSpy() + container.onDidAddPanel(addPanelSpy) const panel = new Panel({item: new TestPanelItem(), priority: 0}) container.addPanel(panel) expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - return expect(container.getPanels()[0]).toBe(panel) + expect(container.getPanels()[0]).toBe(panel) }) - ) + }) - return describe('when a panel with priority between two other panels is added', () => - it('is inserted at the between the two panels', function () { - let addPanelSpy + describe('when a panel with priority between two other panels is added', () => { + it('is inserted at the between the two panels', () => { + const addPanelSpy = jasmine.createSpy() let panel = new Panel({item: new TestPanelItem(), priority: 1000}) container.addPanel(panel) - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + container.onDidAddPanel(addPanelSpy) panel = new Panel({item: new TestPanelItem(), priority: 101}) container.addPanel(panel) expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}) - return expect(container.getPanels()[1]).toBe(panel) + expect(container.getPanels()[1]).toBe(panel) }) - ) + }) }) - return describe('right / bottom panel container', function () { - let [initialPanel] = Array.from([]) - beforeEach(function () { + describe('right / bottom panel container', () => { + let initialPanel + beforeEach(() => { // 'bottom' logic is the same as 'right' container = new PanelContainer({location: 'right'}) initialPanel = new Panel({item: new TestPanelItem()}) - return container.addPanel(initialPanel) + container.addPanel(initialPanel) }) - describe('when a panel with high priority is added', () => - it('is inserted at the beginning of the list', function () { - let addPanelSpy - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + describe('when a panel with high priority is added', () => { + it('is inserted at the beginning of the list', () => { + const addPanelSpy = jasmine.createSpy() + container.onDidAddPanel(addPanelSpy) const panel = new Panel({item: new TestPanelItem(), priority: 1000}) container.addPanel(panel) expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 0}) - return expect(container.getPanels()[0]).toBe(panel) + expect(container.getPanels()[0]).toBe(panel) }) - ) + }) - return describe('when a panel with low priority is added', () => - it('is inserted at the end of the list', function () { - let addPanelSpy - container.onDidAddPanel(addPanelSpy = jasmine.createSpy()) + describe('when a panel with low priority is added', () => { + it('is inserted at the end of the list', () => { + const addPanelSpy = jasmine.createSpy() + container.onDidAddPanel(addPanelSpy) const panel = new Panel({item: new TestPanelItem(), priority: 0}) container.addPanel(panel) expect(addPanelSpy).toHaveBeenCalledWith({panel, index: 1}) - return expect(container.getPanels()[1]).toBe(panel) + expect(container.getPanels()[1]).toBe(panel) }) - ) + }) }) }) }) diff --git a/src/panel-container-element.js b/src/panel-container-element.js index 1609b2bef..dbc595186 100644 --- a/src/panel-container-element.js +++ b/src/panel-container-element.js @@ -1,16 +1,20 @@ +'use strict' + /* global HTMLElement */ const {CompositeDisposable} = require('event-kit') class PanelContainerElement extends HTMLElement { createdCallback () { - return (this.subscriptions = new CompositeDisposable()) + this.subscriptions = new CompositeDisposable() } initialize (model, {views}) { this.model = model this.views = views - if (this.views == null) { throw new Error('Must pass a views parameter when initializing PanelContainerElements') } + if (this.views == null) { + throw new Error('Must pass a views parameter when initializing PanelContainerElements') + } this.subscriptions.add(this.model.onDidAddPanel(this.panelAdded.bind(this))) this.subscriptions.add(this.model.onDidDestroy(this.destroyed.bind(this))) @@ -38,17 +42,17 @@ class PanelContainerElement extends HTMLElement { if (this.model.isModal()) { this.hideAllPanelsExcept(panel) - return this.subscriptions.add(panel.onDidChangeVisible(visible => { - if (visible) { return this.hideAllPanelsExcept(panel) } - } - ) - ) + this.subscriptions.add(panel.onDidChangeVisible(visible => { + if (visible) { this.hideAllPanelsExcept(panel) } + })) } } destroyed () { this.subscriptions.dispose() - return (this.parentNode != null ? this.parentNode.removeChild(this) : undefined) + if (this.parentNode != null) { + this.parentNode.removeChild(this) + } } hideAllPanelsExcept (excludedPanel) { diff --git a/src/panel-container.js b/src/panel-container.js index cc473b189..377b4cd97 100644 --- a/src/panel-container.js +++ b/src/panel-container.js @@ -1,3 +1,5 @@ +'use strict' + const {Emitter, CompositeDisposable} = require('event-kit') module.exports = class PanelContainer { @@ -12,7 +14,7 @@ module.exports = class PanelContainer { for (let panel of this.getPanels()) { panel.destroy() } this.subscriptions.dispose() this.emitter.emit('did-destroy', this) - return this.emitter.dispose() + this.emitter.dispose() } /* @@ -66,22 +68,21 @@ module.exports = class PanelContainer { const index = this.panels.indexOf(panel) if (index > -1) { this.panels.splice(index, 1) - return this.emitter.emit('did-remove-panel', {panel, index}) + this.emitter.emit('did-remove-panel', {panel, index}) } } getPanelIndex (panel) { - let i, p const priority = panel.getPriority() if (['bottom', 'right'].includes(this.location)) { - for (i = this.panels.length - 1; i >= 0; i--) { - p = this.panels[i] + for (let i = this.panels.length - 1; i >= 0; i--) { + const p = this.panels[i] if (priority < p.getPriority()) { return i + 1 } } return 0 } else { - for (i = 0; i < this.panels.length; i++) { - p = this.panels[i] + for (let i = 0; i < this.panels.length; i++) { + const p = this.panels[i] if (priority < p.getPriority()) { return i } } return this.panels.length From ede4a2972a859f7508cb98ce77e08bd48cf22639 Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Tue, 7 Mar 2017 15:49:22 -0800 Subject: [PATCH 17/27] Convert workspace element to JS: Decaffeinate --- spec/workspace-element-spec.coffee | 208 -------------------------- spec/workspace-element-spec.js | 228 +++++++++++++++++++++++++++++ src/workspace-element.coffee | 149 ------------------- src/workspace-element.js | 196 +++++++++++++++++++++++++ 4 files changed, 424 insertions(+), 357 deletions(-) delete mode 100644 spec/workspace-element-spec.coffee create mode 100644 spec/workspace-element-spec.js delete mode 100644 src/workspace-element.coffee create mode 100644 src/workspace-element.js diff --git a/spec/workspace-element-spec.coffee b/spec/workspace-element-spec.coffee deleted file mode 100644 index ec24242ac..000000000 --- a/spec/workspace-element-spec.coffee +++ /dev/null @@ -1,208 +0,0 @@ -{ipcRenderer} = require 'electron' -path = require 'path' -temp = require('temp').track() -{Disposable} = require 'event-kit' - -describe "WorkspaceElement", -> - afterEach -> - temp.cleanupSync() - - describe "when the workspace element is focused", -> - it "transfers focus to the active pane", -> - workspaceElement = atom.views.getView(atom.workspace) - jasmine.attachToDOM(workspaceElement) - activePaneElement = atom.views.getView(atom.workspace.getActivePane()) - document.body.focus() - expect(document.activeElement).not.toBe(activePaneElement) - workspaceElement.focus() - expect(document.activeElement).toBe(activePaneElement) - - describe "the scrollbar visibility class", -> - it "has a class based on the style of the scrollbar", -> - observeCallback = null - scrollbarStyle = require 'scrollbar-style' - spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake (cb) -> - observeCallback = cb - new Disposable(->) - - workspaceElement = atom.views.getView(atom.workspace) - observeCallback('legacy') - expect(workspaceElement.className).toMatch 'scrollbars-visible-always' - - observeCallback('overlay') - expect(workspaceElement).toHaveClass 'scrollbars-visible-when-scrolling' - - describe "editor font styling", -> - [editor, editorElement, workspaceElement] = [] - - beforeEach -> - waitsForPromise -> atom.workspace.open('sample.js') - - runs -> - workspaceElement = atom.views.getView(atom.workspace) - jasmine.attachToDOM(workspaceElement) - editor = atom.workspace.getActiveTextEditor() - editorElement = atom.views.getView(editor) - - it "updates the font-size based on the 'editor.fontSize' config value", -> - initialCharWidth = editor.getDefaultCharWidth() - expect(getComputedStyle(editorElement).fontSize).toBe atom.config.get('editor.fontSize') + 'px' - atom.config.set('editor.fontSize', atom.config.get('editor.fontSize') + 5) - expect(getComputedStyle(editorElement).fontSize).toBe atom.config.get('editor.fontSize') + 'px' - expect(editor.getDefaultCharWidth()).toBeGreaterThan initialCharWidth - - it "updates the font-family based on the 'editor.fontFamily' config value", -> - initialCharWidth = editor.getDefaultCharWidth() - fontFamily = atom.config.get('editor.fontFamily') - expect(getComputedStyle(editorElement).fontFamily).toBe fontFamily - - atom.config.set('editor.fontFamily', 'sans-serif') - fontFamily = atom.config.get('editor.fontFamily') - expect(getComputedStyle(editorElement).fontFamily).toBe fontFamily - expect(editor.getDefaultCharWidth()).not.toBe initialCharWidth - - it "updates the line-height based on the 'editor.lineHeight' config value", -> - initialLineHeight = editor.getLineHeightInPixels() - atom.config.set('editor.lineHeight', '30px') - expect(getComputedStyle(editorElement).lineHeight).toBe atom.config.get('editor.lineHeight') - expect(editor.getLineHeightInPixels()).not.toBe initialLineHeight - - it "increases or decreases the font size when a ctrl-mousewheel event occurs", -> - atom.config.set('editor.zoomFontWhenCtrlScrolling', true) - atom.config.set('editor.fontSize', 12) - - # Zoom out - editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { - wheelDeltaY: -10, - ctrlKey: true - })) - expect(atom.config.get('editor.fontSize')).toBe(11) - - # Zoom in - editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { - wheelDeltaY: 10, - ctrlKey: true - })) - expect(atom.config.get('editor.fontSize')).toBe(12) - - # Not on an atom-text-editor - workspaceElement.dispatchEvent(new WheelEvent('mousewheel', { - wheelDeltaY: 10, - ctrlKey: true - })) - expect(atom.config.get('editor.fontSize')).toBe(12) - - # No ctrl key - editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { - wheelDeltaY: 10, - })) - expect(atom.config.get('editor.fontSize')).toBe(12) - - atom.config.set('editor.zoomFontWhenCtrlScrolling', false) - editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { - wheelDeltaY: 10, - ctrlKey: true - })) - expect(atom.config.get('editor.fontSize')).toBe(12) - - describe 'panel containers', -> - it 'inserts panel container elements in the correct places in the DOM', -> - workspaceElement = atom.views.getView(atom.workspace) - - leftContainer = workspaceElement.querySelector('atom-panel-container.left') - rightContainer = workspaceElement.querySelector('atom-panel-container.right') - expect(leftContainer.nextSibling).toBe workspaceElement.verticalAxis - expect(rightContainer.previousSibling).toBe workspaceElement.verticalAxis - - topContainer = workspaceElement.querySelector('atom-panel-container.top') - bottomContainer = workspaceElement.querySelector('atom-panel-container.bottom') - expect(topContainer.nextSibling).toBe workspaceElement.paneContainer - expect(bottomContainer.previousSibling).toBe workspaceElement.paneContainer - - headerContainer = workspaceElement.querySelector('atom-panel-container.header') - footerContainer = workspaceElement.querySelector('atom-panel-container.footer') - expect(headerContainer.nextSibling).toBe workspaceElement.horizontalAxis - expect(footerContainer.previousSibling).toBe workspaceElement.horizontalAxis - - modalContainer = workspaceElement.querySelector('atom-panel-container.modal') - expect(modalContainer.parentNode).toBe workspaceElement - - it 'stretches header/footer panels to the workspace width', -> - workspaceElement = atom.views.getView(atom.workspace) - jasmine.attachToDOM(workspaceElement) - expect(workspaceElement.offsetWidth).toBeGreaterThan(0) - - headerItem = document.createElement('div') - atom.workspace.addHeaderPanel({item: headerItem}) - expect(headerItem.offsetWidth).toEqual(workspaceElement.offsetWidth) - - footerItem = document.createElement('div') - atom.workspace.addFooterPanel({item: footerItem}) - expect(footerItem.offsetWidth).toEqual(workspaceElement.offsetWidth) - - it 'shrinks horizontal axis according to header/footer panels height', -> - workspaceElement = atom.views.getView(atom.workspace) - workspaceElement.style.height = '100px' - horizontalAxisElement = workspaceElement.querySelector('atom-workspace-axis.horizontal') - jasmine.attachToDOM(workspaceElement) - - originalHorizontalAxisHeight = horizontalAxisElement.offsetHeight - expect(workspaceElement.offsetHeight).toBeGreaterThan(0) - expect(originalHorizontalAxisHeight).toBeGreaterThan(0) - - headerItem = document.createElement('div') - headerItem.style.height = '10px' - atom.workspace.addHeaderPanel({item: headerItem}) - expect(headerItem.offsetHeight).toBeGreaterThan(0) - - footerItem = document.createElement('div') - footerItem.style.height = '15px' - atom.workspace.addFooterPanel({item: footerItem}) - expect(footerItem.offsetHeight).toBeGreaterThan(0) - - expect(horizontalAxisElement.offsetHeight).toEqual(originalHorizontalAxisHeight - headerItem.offsetHeight - footerItem.offsetHeight) - - describe "the 'window:toggle-invisibles' command", -> - it "shows/hides invisibles in all open and future editors", -> - workspaceElement = atom.views.getView(atom.workspace) - expect(atom.config.get('editor.showInvisibles')).toBe false - atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles') - expect(atom.config.get('editor.showInvisibles')).toBe true - atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles') - expect(atom.config.get('editor.showInvisibles')).toBe false - - describe "the 'window:run-package-specs' command", -> - it "runs the package specs for the active item's project path, or the first project path", -> - workspaceElement = atom.views.getView(atom.workspace) - spyOn(ipcRenderer, 'send') - - # No project paths. Don't try to run specs. - atom.commands.dispatch(workspaceElement, "window:run-package-specs") - expect(ipcRenderer.send).not.toHaveBeenCalledWith("run-package-specs") - - projectPaths = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")] - atom.project.setPaths(projectPaths) - - # No active item. Use first project directory. - atom.commands.dispatch(workspaceElement, "window:run-package-specs") - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")) - ipcRenderer.send.reset() - - # Active item doesn't implement ::getPath(). Use first project directory. - item = document.createElement("div") - atom.workspace.getActivePane().activateItem(item) - atom.commands.dispatch(workspaceElement, "window:run-package-specs") - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")) - ipcRenderer.send.reset() - - # Active item has no path. Use first project directory. - item.getPath = -> null - atom.commands.dispatch(workspaceElement, "window:run-package-specs") - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")) - ipcRenderer.send.reset() - - # Active item has path. Use project path for item path. - item.getPath = -> path.join(projectPaths[1], "a-file.txt") - atom.commands.dispatch(workspaceElement, "window:run-package-specs") - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[1], "spec")) - ipcRenderer.send.reset() diff --git a/spec/workspace-element-spec.js b/spec/workspace-element-spec.js new file mode 100644 index 000000000..f81276796 --- /dev/null +++ b/spec/workspace-element-spec.js @@ -0,0 +1,228 @@ +const {ipcRenderer} = require('electron'); +const path = require('path'); +const temp = require('temp').track(); +const {Disposable} = require('event-kit'); + +describe("WorkspaceElement", function() { + afterEach(() => temp.cleanupSync()); + + describe("when the workspace element is focused", () => + it("transfers focus to the active pane", function() { + const workspaceElement = atom.views.getView(atom.workspace); + jasmine.attachToDOM(workspaceElement); + const activePaneElement = atom.views.getView(atom.workspace.getActivePane()); + document.body.focus(); + expect(document.activeElement).not.toBe(activePaneElement); + workspaceElement.focus(); + return expect(document.activeElement).toBe(activePaneElement); + }) + ); + + describe("the scrollbar visibility class", () => + it("has a class based on the style of the scrollbar", function() { + let observeCallback = null; + const scrollbarStyle = require('scrollbar-style'); + spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake(function(cb) { + observeCallback = cb; + return new Disposable(function() {}); + }); + + const workspaceElement = atom.views.getView(atom.workspace); + observeCallback('legacy'); + expect(workspaceElement.className).toMatch('scrollbars-visible-always'); + + observeCallback('overlay'); + return expect(workspaceElement).toHaveClass('scrollbars-visible-when-scrolling'); + }) + ); + + describe("editor font styling", function() { + let [editor, editorElement, workspaceElement] = Array.from([]); + + beforeEach(function() { + waitsForPromise(() => atom.workspace.open('sample.js')); + + return runs(function() { + workspaceElement = atom.views.getView(atom.workspace); + jasmine.attachToDOM(workspaceElement); + editor = atom.workspace.getActiveTextEditor(); + return editorElement = atom.views.getView(editor); + }); + }); + + it("updates the font-size based on the 'editor.fontSize' config value", function() { + const initialCharWidth = editor.getDefaultCharWidth(); + expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px'); + atom.config.set('editor.fontSize', atom.config.get('editor.fontSize') + 5); + expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px'); + return expect(editor.getDefaultCharWidth()).toBeGreaterThan(initialCharWidth); + }); + + it("updates the font-family based on the 'editor.fontFamily' config value", function() { + const initialCharWidth = editor.getDefaultCharWidth(); + let fontFamily = atom.config.get('editor.fontFamily'); + expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily); + + atom.config.set('editor.fontFamily', 'sans-serif'); + fontFamily = atom.config.get('editor.fontFamily'); + expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily); + return expect(editor.getDefaultCharWidth()).not.toBe(initialCharWidth); + }); + + it("updates the line-height based on the 'editor.lineHeight' config value", function() { + const initialLineHeight = editor.getLineHeightInPixels(); + atom.config.set('editor.lineHeight', '30px'); + expect(getComputedStyle(editorElement).lineHeight).toBe(atom.config.get('editor.lineHeight')); + return expect(editor.getLineHeightInPixels()).not.toBe(initialLineHeight); + }); + + return it("increases or decreases the font size when a ctrl-mousewheel event occurs", function() { + atom.config.set('editor.zoomFontWhenCtrlScrolling', true); + atom.config.set('editor.fontSize', 12); + + // Zoom out + editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { + wheelDeltaY: -10, + ctrlKey: true + })); + expect(atom.config.get('editor.fontSize')).toBe(11); + + // Zoom in + editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { + wheelDeltaY: 10, + ctrlKey: true + })); + expect(atom.config.get('editor.fontSize')).toBe(12); + + // Not on an atom-text-editor + workspaceElement.dispatchEvent(new WheelEvent('mousewheel', { + wheelDeltaY: 10, + ctrlKey: true + })); + expect(atom.config.get('editor.fontSize')).toBe(12); + + // No ctrl key + editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { + wheelDeltaY: 10, + })); + expect(atom.config.get('editor.fontSize')).toBe(12); + + atom.config.set('editor.zoomFontWhenCtrlScrolling', false); + editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { + wheelDeltaY: 10, + ctrlKey: true + })); + return expect(atom.config.get('editor.fontSize')).toBe(12); + }); + }); + + describe('panel containers', function() { + it('inserts panel container elements in the correct places in the DOM', function() { + const workspaceElement = atom.views.getView(atom.workspace); + + const leftContainer = workspaceElement.querySelector('atom-panel-container.left'); + const rightContainer = workspaceElement.querySelector('atom-panel-container.right'); + expect(leftContainer.nextSibling).toBe(workspaceElement.verticalAxis); + expect(rightContainer.previousSibling).toBe(workspaceElement.verticalAxis); + + const topContainer = workspaceElement.querySelector('atom-panel-container.top'); + const bottomContainer = workspaceElement.querySelector('atom-panel-container.bottom'); + expect(topContainer.nextSibling).toBe(workspaceElement.paneContainer); + expect(bottomContainer.previousSibling).toBe(workspaceElement.paneContainer); + + const headerContainer = workspaceElement.querySelector('atom-panel-container.header'); + const footerContainer = workspaceElement.querySelector('atom-panel-container.footer'); + expect(headerContainer.nextSibling).toBe(workspaceElement.horizontalAxis); + expect(footerContainer.previousSibling).toBe(workspaceElement.horizontalAxis); + + const modalContainer = workspaceElement.querySelector('atom-panel-container.modal'); + return expect(modalContainer.parentNode).toBe(workspaceElement); + }); + + it('stretches header/footer panels to the workspace width', function() { + const workspaceElement = atom.views.getView(atom.workspace); + jasmine.attachToDOM(workspaceElement); + expect(workspaceElement.offsetWidth).toBeGreaterThan(0); + + const headerItem = document.createElement('div'); + atom.workspace.addHeaderPanel({item: headerItem}); + expect(headerItem.offsetWidth).toEqual(workspaceElement.offsetWidth); + + const footerItem = document.createElement('div'); + atom.workspace.addFooterPanel({item: footerItem}); + return expect(footerItem.offsetWidth).toEqual(workspaceElement.offsetWidth); + }); + + return it('shrinks horizontal axis according to header/footer panels height', function() { + const workspaceElement = atom.views.getView(atom.workspace); + workspaceElement.style.height = '100px'; + const horizontalAxisElement = workspaceElement.querySelector('atom-workspace-axis.horizontal'); + jasmine.attachToDOM(workspaceElement); + + const originalHorizontalAxisHeight = horizontalAxisElement.offsetHeight; + expect(workspaceElement.offsetHeight).toBeGreaterThan(0); + expect(originalHorizontalAxisHeight).toBeGreaterThan(0); + + const headerItem = document.createElement('div'); + headerItem.style.height = '10px'; + atom.workspace.addHeaderPanel({item: headerItem}); + expect(headerItem.offsetHeight).toBeGreaterThan(0); + + const footerItem = document.createElement('div'); + footerItem.style.height = '15px'; + atom.workspace.addFooterPanel({item: footerItem}); + expect(footerItem.offsetHeight).toBeGreaterThan(0); + + return expect(horizontalAxisElement.offsetHeight).toEqual(originalHorizontalAxisHeight - headerItem.offsetHeight - footerItem.offsetHeight); + }); + }); + + describe("the 'window:toggle-invisibles' command", () => + it("shows/hides invisibles in all open and future editors", function() { + const workspaceElement = atom.views.getView(atom.workspace); + expect(atom.config.get('editor.showInvisibles')).toBe(false); + atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles'); + expect(atom.config.get('editor.showInvisibles')).toBe(true); + atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles'); + return expect(atom.config.get('editor.showInvisibles')).toBe(false); + }) + ); + + return describe("the 'window:run-package-specs' command", () => + it("runs the package specs for the active item's project path, or the first project path", function() { + const workspaceElement = atom.views.getView(atom.workspace); + spyOn(ipcRenderer, 'send'); + + // No project paths. Don't try to run specs. + atom.commands.dispatch(workspaceElement, "window:run-package-specs"); + expect(ipcRenderer.send).not.toHaveBeenCalledWith("run-package-specs"); + + const projectPaths = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")]; + atom.project.setPaths(projectPaths); + + // No active item. Use first project directory. + atom.commands.dispatch(workspaceElement, "window:run-package-specs"); + expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")); + ipcRenderer.send.reset(); + + // Active item doesn't implement ::getPath(). Use first project directory. + const item = document.createElement("div"); + atom.workspace.getActivePane().activateItem(item); + atom.commands.dispatch(workspaceElement, "window:run-package-specs"); + expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")); + ipcRenderer.send.reset(); + + // Active item has no path. Use first project directory. + item.getPath = () => null; + atom.commands.dispatch(workspaceElement, "window:run-package-specs"); + expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")); + ipcRenderer.send.reset(); + + // Active item has path. Use project path for item path. + item.getPath = () => path.join(projectPaths[1], "a-file.txt"); + atom.commands.dispatch(workspaceElement, "window:run-package-specs"); + expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[1], "spec")); + return ipcRenderer.send.reset(); + }) + ); +}); diff --git a/src/workspace-element.coffee b/src/workspace-element.coffee deleted file mode 100644 index 6defe33da..000000000 --- a/src/workspace-element.coffee +++ /dev/null @@ -1,149 +0,0 @@ -{ipcRenderer} = require 'electron' -path = require 'path' -fs = require 'fs-plus' -{CompositeDisposable} = require 'event-kit' -scrollbarStyle = require 'scrollbar-style' - -module.exports = -class WorkspaceElement extends HTMLElement - globalTextEditorStyleSheet: null - - attachedCallback: -> - @focus() - - detachedCallback: -> - @subscriptions.dispose() - - initializeContent: -> - @classList.add 'workspace' - @setAttribute 'tabindex', -1 - - @verticalAxis = document.createElement('atom-workspace-axis') - @verticalAxis.classList.add('vertical') - - @horizontalAxis = document.createElement('atom-workspace-axis') - @horizontalAxis.classList.add('horizontal') - @horizontalAxis.appendChild(@verticalAxis) - - @appendChild(@horizontalAxis) - - observeScrollbarStyle: -> - @subscriptions.add scrollbarStyle.observePreferredScrollbarStyle (style) => - switch style - when 'legacy' - @classList.remove('scrollbars-visible-when-scrolling') - @classList.add("scrollbars-visible-always") - when 'overlay' - @classList.remove('scrollbars-visible-always') - @classList.add("scrollbars-visible-when-scrolling") - - observeTextEditorFontConfig: -> - @updateGlobalTextEditorStyleSheet() - @subscriptions.add @config.onDidChange 'editor.fontSize', @updateGlobalTextEditorStyleSheet.bind(this) - @subscriptions.add @config.onDidChange 'editor.fontFamily', @updateGlobalTextEditorStyleSheet.bind(this) - @subscriptions.add @config.onDidChange 'editor.lineHeight', @updateGlobalTextEditorStyleSheet.bind(this) - - updateGlobalTextEditorStyleSheet: -> - styleSheetSource = """ - atom-text-editor { - font-size: #{@config.get('editor.fontSize')}px; - font-family: #{@config.get('editor.fontFamily')}; - line-height: #{@config.get('editor.lineHeight')}; - } - """ - @styles.addStyleSheet(styleSheetSource, sourcePath: 'global-text-editor-styles') - @views.performDocumentPoll() - - initialize: (@model, {@views, @workspace, @project, @config, @styles}) -> - throw new Error("Must pass a views parameter when initializing WorskpaceElements") unless @views? - throw new Error("Must pass a workspace parameter when initializing WorskpaceElements") unless @workspace? - throw new Error("Must pass a project parameter when initializing WorskpaceElements") unless @project? - throw new Error("Must pass a config parameter when initializing WorskpaceElements") unless @config? - throw new Error("Must pass a styles parameter when initializing WorskpaceElements") unless @styles? - - @subscriptions = new CompositeDisposable - @initializeContent() - @observeScrollbarStyle() - @observeTextEditorFontConfig() - - @paneContainer = @views.getView(@model.paneContainer) - @verticalAxis.appendChild(@paneContainer) - @addEventListener 'focus', @handleFocus.bind(this) - - @addEventListener 'mousewheel', @handleMousewheel.bind(this), true - - @panelContainers = - top: @views.getView(@model.panelContainers.top) - left: @views.getView(@model.panelContainers.left) - right: @views.getView(@model.panelContainers.right) - bottom: @views.getView(@model.panelContainers.bottom) - header: @views.getView(@model.panelContainers.header) - footer: @views.getView(@model.panelContainers.footer) - modal: @views.getView(@model.panelContainers.modal) - - @horizontalAxis.insertBefore(@panelContainers.left, @verticalAxis) - @horizontalAxis.appendChild(@panelContainers.right) - - @verticalAxis.insertBefore(@panelContainers.top, @paneContainer) - @verticalAxis.appendChild(@panelContainers.bottom) - - @insertBefore(@panelContainers.header, @horizontalAxis) - @appendChild(@panelContainers.footer) - - @appendChild(@panelContainers.modal) - - this - - getModel: -> @model - - handleMousewheel: (event) -> - if event.ctrlKey and @config.get('editor.zoomFontWhenCtrlScrolling') and event.target.closest('atom-text-editor')? - if event.wheelDeltaY > 0 - @model.increaseFontSize() - else if event.wheelDeltaY < 0 - @model.decreaseFontSize() - event.preventDefault() - event.stopPropagation() - - handleFocus: (event) -> - @model.getActivePane().activate() - - focusPaneViewAbove: -> @paneContainer.focusPaneViewAbove() - - focusPaneViewBelow: -> @paneContainer.focusPaneViewBelow() - - focusPaneViewOnLeft: -> @paneContainer.focusPaneViewOnLeft() - - focusPaneViewOnRight: -> @paneContainer.focusPaneViewOnRight() - - moveActiveItemToPaneAbove: (params) -> @paneContainer.moveActiveItemToPaneAbove(params) - - moveActiveItemToPaneBelow: (params) -> @paneContainer.moveActiveItemToPaneBelow(params) - - moveActiveItemToPaneOnLeft: (params) -> @paneContainer.moveActiveItemToPaneOnLeft(params) - - moveActiveItemToPaneOnRight: (params) -> @paneContainer.moveActiveItemToPaneOnRight(params) - - runPackageSpecs: -> - if activePath = @workspace.getActivePaneItem()?.getPath?() - [projectPath] = @project.relativizePath(activePath) - else - [projectPath] = @project.getPaths() - if projectPath - specPath = path.join(projectPath, 'spec') - testPath = path.join(projectPath, 'test') - if not fs.existsSync(specPath) and fs.existsSync(testPath) - specPath = testPath - - ipcRenderer.send('run-package-specs', specPath) - - runBenchmarks: -> - if activePath = @workspace.getActivePaneItem()?.getPath?() - [projectPath] = @project.relativizePath(activePath) - else - [projectPath] = @project.getPaths() - - if projectPath - ipcRenderer.send('run-benchmarks', path.join(projectPath, 'benchmarks')) - -module.exports = WorkspaceElement = document.registerElement 'atom-workspace', prototype: WorkspaceElement.prototype diff --git a/src/workspace-element.js b/src/workspace-element.js new file mode 100644 index 000000000..b24bb80f6 --- /dev/null +++ b/src/workspace-element.js @@ -0,0 +1,196 @@ +let WorkspaceElement; +const {ipcRenderer} = require('electron'); +const path = require('path'); +const fs = require('fs-plus'); +const {CompositeDisposable} = require('event-kit'); +const scrollbarStyle = require('scrollbar-style'); + +module.exports = +__initClass__(WorkspaceElement = class WorkspaceElement extends HTMLElement { + static initClass() { + this.prototype.globalTextEditorStyleSheet = null; + } + + attachedCallback() { + return this.focus(); + } + + detachedCallback() { + return this.subscriptions.dispose(); + } + + initializeContent() { + this.classList.add('workspace'); + this.setAttribute('tabindex', -1); + + this.verticalAxis = document.createElement('atom-workspace-axis'); + this.verticalAxis.classList.add('vertical'); + + this.horizontalAxis = document.createElement('atom-workspace-axis'); + this.horizontalAxis.classList.add('horizontal'); + this.horizontalAxis.appendChild(this.verticalAxis); + + return this.appendChild(this.horizontalAxis); + } + + observeScrollbarStyle() { + return this.subscriptions.add(scrollbarStyle.observePreferredScrollbarStyle(style => { + switch (style) { + case 'legacy': + this.classList.remove('scrollbars-visible-when-scrolling'); + return this.classList.add("scrollbars-visible-always"); + case 'overlay': + this.classList.remove('scrollbars-visible-always'); + return this.classList.add("scrollbars-visible-when-scrolling"); + } + } + ) + ); + } + + observeTextEditorFontConfig() { + this.updateGlobalTextEditorStyleSheet(); + this.subscriptions.add(this.config.onDidChange('editor.fontSize', this.updateGlobalTextEditorStyleSheet.bind(this))); + this.subscriptions.add(this.config.onDidChange('editor.fontFamily', this.updateGlobalTextEditorStyleSheet.bind(this))); + return this.subscriptions.add(this.config.onDidChange('editor.lineHeight', this.updateGlobalTextEditorStyleSheet.bind(this))); + } + + updateGlobalTextEditorStyleSheet() { + const styleSheetSource = `\ +atom-text-editor { + font-size: ${this.config.get('editor.fontSize')}px; + font-family: ${this.config.get('editor.fontFamily')}; + line-height: ${this.config.get('editor.lineHeight')}; +}\ +`; + this.styles.addStyleSheet(styleSheetSource, {sourcePath: 'global-text-editor-styles'}); + return this.views.performDocumentPoll(); + } + + initialize(model, {views, workspace, project, config, styles}) { + this.model = model; + this.views = views; + this.workspace = workspace; + this.project = project; + this.config = config; + this.styles = styles; + if (this.views == null) { throw new Error("Must pass a views parameter when initializing WorskpaceElements"); } + if (this.workspace == null) { throw new Error("Must pass a workspace parameter when initializing WorskpaceElements"); } + if (this.project == null) { throw new Error("Must pass a project parameter when initializing WorskpaceElements"); } + if (this.config == null) { throw new Error("Must pass a config parameter when initializing WorskpaceElements"); } + if (this.styles == null) { throw new Error("Must pass a styles parameter when initializing WorskpaceElements"); } + + this.subscriptions = new CompositeDisposable; + this.initializeContent(); + this.observeScrollbarStyle(); + this.observeTextEditorFontConfig(); + + this.paneContainer = this.views.getView(this.model.paneContainer); + this.verticalAxis.appendChild(this.paneContainer); + this.addEventListener('focus', this.handleFocus.bind(this)); + + this.addEventListener('mousewheel', this.handleMousewheel.bind(this), true); + + this.panelContainers = { + top: this.views.getView(this.model.panelContainers.top), + left: this.views.getView(this.model.panelContainers.left), + right: this.views.getView(this.model.panelContainers.right), + bottom: this.views.getView(this.model.panelContainers.bottom), + header: this.views.getView(this.model.panelContainers.header), + footer: this.views.getView(this.model.panelContainers.footer), + modal: this.views.getView(this.model.panelContainers.modal) + }; + + this.horizontalAxis.insertBefore(this.panelContainers.left, this.verticalAxis); + this.horizontalAxis.appendChild(this.panelContainers.right); + + this.verticalAxis.insertBefore(this.panelContainers.top, this.paneContainer); + this.verticalAxis.appendChild(this.panelContainers.bottom); + + this.insertBefore(this.panelContainers.header, this.horizontalAxis); + this.appendChild(this.panelContainers.footer); + + this.appendChild(this.panelContainers.modal); + + return this; + } + + getModel() { return this.model; } + + handleMousewheel(event) { + if (event.ctrlKey && this.config.get('editor.zoomFontWhenCtrlScrolling') && (event.target.closest('atom-text-editor') != null)) { + if (event.wheelDeltaY > 0) { + this.model.increaseFontSize(); + } else if (event.wheelDeltaY < 0) { + this.model.decreaseFontSize(); + } + event.preventDefault(); + return event.stopPropagation(); + } + } + + handleFocus(event) { + return this.model.getActivePane().activate(); + } + + focusPaneViewAbove() { return this.paneContainer.focusPaneViewAbove(); } + + focusPaneViewBelow() { return this.paneContainer.focusPaneViewBelow(); } + + focusPaneViewOnLeft() { return this.paneContainer.focusPaneViewOnLeft(); } + + focusPaneViewOnRight() { return this.paneContainer.focusPaneViewOnRight(); } + + moveActiveItemToPaneAbove(params) { return this.paneContainer.moveActiveItemToPaneAbove(params); } + + moveActiveItemToPaneBelow(params) { return this.paneContainer.moveActiveItemToPaneBelow(params); } + + moveActiveItemToPaneOnLeft(params) { return this.paneContainer.moveActiveItemToPaneOnLeft(params); } + + moveActiveItemToPaneOnRight(params) { return this.paneContainer.moveActiveItemToPaneOnRight(params); } + + runPackageSpecs() { + let activePath, projectPath; + if (activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath())) { + [projectPath] = Array.from(this.project.relativizePath(activePath)); + } else { + [projectPath] = Array.from(this.project.getPaths()); + } + if (projectPath) { + let specPath = path.join(projectPath, 'spec'); + const testPath = path.join(projectPath, 'test'); + if (!fs.existsSync(specPath) && fs.existsSync(testPath)) { + specPath = testPath; + } + + return ipcRenderer.send('run-package-specs', specPath); + } + } + + runBenchmarks() { + let activePath, projectPath; + if (activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath())) { + [projectPath] = Array.from(this.project.relativizePath(activePath)); + } else { + [projectPath] = Array.from(this.project.getPaths()); + } + + if (projectPath) { + return ipcRenderer.send('run-benchmarks', path.join(projectPath, 'benchmarks')); + } + } +}); + +module.exports = WorkspaceElement = document.registerElement('atom-workspace', {prototype: WorkspaceElement.prototype}); + +function __initClass__(c) { + c.initClass(); + return c; +} +function __guardMethod__(obj, methodName, transform) { + if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') { + return transform(obj, methodName); + } else { + return undefined; + } +} \ No newline at end of file From ca4d55954b4b82dd96b76f8fef676ffed17cfbf5 Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Tue, 7 Mar 2017 15:56:57 -0800 Subject: [PATCH 18/27] Convert workspace element to JS: Lint --- spec/workspace-element-spec.js | 324 +++++++++++++++++---------------- src/workspace-element.js | 218 +++++++++++----------- 2 files changed, 273 insertions(+), 269 deletions(-) diff --git a/spec/workspace-element-spec.js b/spec/workspace-element-spec.js index f81276796..2a7fc0cab 100644 --- a/spec/workspace-element-spec.js +++ b/spec/workspace-element-spec.js @@ -1,228 +1,230 @@ -const {ipcRenderer} = require('electron'); -const path = require('path'); -const temp = require('temp').track(); -const {Disposable} = require('event-kit'); +/* global getComputedStyle, WheelEvent */ -describe("WorkspaceElement", function() { - afterEach(() => temp.cleanupSync()); +const {ipcRenderer} = require('electron') +const path = require('path') +const temp = require('temp').track() +const {Disposable} = require('event-kit') - describe("when the workspace element is focused", () => - it("transfers focus to the active pane", function() { - const workspaceElement = atom.views.getView(atom.workspace); - jasmine.attachToDOM(workspaceElement); - const activePaneElement = atom.views.getView(atom.workspace.getActivePane()); - document.body.focus(); - expect(document.activeElement).not.toBe(activePaneElement); - workspaceElement.focus(); - return expect(document.activeElement).toBe(activePaneElement); +describe('WorkspaceElement', function () { + afterEach(() => temp.cleanupSync()) + + describe('when the workspace element is focused', () => + it('transfers focus to the active pane', function () { + const workspaceElement = atom.views.getView(atom.workspace) + jasmine.attachToDOM(workspaceElement) + const activePaneElement = atom.views.getView(atom.workspace.getActivePane()) + document.body.focus() + expect(document.activeElement).not.toBe(activePaneElement) + workspaceElement.focus() + return expect(document.activeElement).toBe(activePaneElement) }) - ); + ) - describe("the scrollbar visibility class", () => - it("has a class based on the style of the scrollbar", function() { - let observeCallback = null; - const scrollbarStyle = require('scrollbar-style'); - spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake(function(cb) { - observeCallback = cb; - return new Disposable(function() {}); - }); + describe('the scrollbar visibility class', () => + it('has a class based on the style of the scrollbar', function () { + let observeCallback = null + const scrollbarStyle = require('scrollbar-style') + spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake(function (cb) { + observeCallback = cb + return new Disposable(function () {}) + }) - const workspaceElement = atom.views.getView(atom.workspace); - observeCallback('legacy'); - expect(workspaceElement.className).toMatch('scrollbars-visible-always'); + const workspaceElement = atom.views.getView(atom.workspace) + observeCallback('legacy') + expect(workspaceElement.className).toMatch('scrollbars-visible-always') - observeCallback('overlay'); - return expect(workspaceElement).toHaveClass('scrollbars-visible-when-scrolling'); + observeCallback('overlay') + return expect(workspaceElement).toHaveClass('scrollbars-visible-when-scrolling') }) - ); + ) - describe("editor font styling", function() { - let [editor, editorElement, workspaceElement] = Array.from([]); + describe('editor font styling', function () { + let [editor, editorElement, workspaceElement] = Array.from([]) - beforeEach(function() { - waitsForPromise(() => atom.workspace.open('sample.js')); + beforeEach(function () { + waitsForPromise(() => atom.workspace.open('sample.js')) - return runs(function() { - workspaceElement = atom.views.getView(atom.workspace); - jasmine.attachToDOM(workspaceElement); - editor = atom.workspace.getActiveTextEditor(); - return editorElement = atom.views.getView(editor); - }); - }); + return runs(function () { + workspaceElement = atom.views.getView(atom.workspace) + jasmine.attachToDOM(workspaceElement) + editor = atom.workspace.getActiveTextEditor() + return (editorElement = atom.views.getView(editor)) + }) + }) - it("updates the font-size based on the 'editor.fontSize' config value", function() { - const initialCharWidth = editor.getDefaultCharWidth(); - expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px'); - atom.config.set('editor.fontSize', atom.config.get('editor.fontSize') + 5); - expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px'); - return expect(editor.getDefaultCharWidth()).toBeGreaterThan(initialCharWidth); - }); + it("updates the font-size based on the 'editor.fontSize' config value", function () { + const initialCharWidth = editor.getDefaultCharWidth() + expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px') + atom.config.set('editor.fontSize', atom.config.get('editor.fontSize') + 5) + expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px') + return expect(editor.getDefaultCharWidth()).toBeGreaterThan(initialCharWidth) + }) - it("updates the font-family based on the 'editor.fontFamily' config value", function() { - const initialCharWidth = editor.getDefaultCharWidth(); - let fontFamily = atom.config.get('editor.fontFamily'); - expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily); + it("updates the font-family based on the 'editor.fontFamily' config value", function () { + const initialCharWidth = editor.getDefaultCharWidth() + let fontFamily = atom.config.get('editor.fontFamily') + expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily) - atom.config.set('editor.fontFamily', 'sans-serif'); - fontFamily = atom.config.get('editor.fontFamily'); - expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily); - return expect(editor.getDefaultCharWidth()).not.toBe(initialCharWidth); - }); + atom.config.set('editor.fontFamily', 'sans-serif') + fontFamily = atom.config.get('editor.fontFamily') + expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily) + return expect(editor.getDefaultCharWidth()).not.toBe(initialCharWidth) + }) - it("updates the line-height based on the 'editor.lineHeight' config value", function() { - const initialLineHeight = editor.getLineHeightInPixels(); - atom.config.set('editor.lineHeight', '30px'); - expect(getComputedStyle(editorElement).lineHeight).toBe(atom.config.get('editor.lineHeight')); - return expect(editor.getLineHeightInPixels()).not.toBe(initialLineHeight); - }); + it("updates the line-height based on the 'editor.lineHeight' config value", function () { + const initialLineHeight = editor.getLineHeightInPixels() + atom.config.set('editor.lineHeight', '30px') + expect(getComputedStyle(editorElement).lineHeight).toBe(atom.config.get('editor.lineHeight')) + return expect(editor.getLineHeightInPixels()).not.toBe(initialLineHeight) + }) - return it("increases or decreases the font size when a ctrl-mousewheel event occurs", function() { - atom.config.set('editor.zoomFontWhenCtrlScrolling', true); - atom.config.set('editor.fontSize', 12); + return it('increases or decreases the font size when a ctrl-mousewheel event occurs', function () { + atom.config.set('editor.zoomFontWhenCtrlScrolling', true) + atom.config.set('editor.fontSize', 12) // Zoom out editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { wheelDeltaY: -10, ctrlKey: true - })); - expect(atom.config.get('editor.fontSize')).toBe(11); + })) + expect(atom.config.get('editor.fontSize')).toBe(11) // Zoom in editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { wheelDeltaY: 10, ctrlKey: true - })); - expect(atom.config.get('editor.fontSize')).toBe(12); + })) + expect(atom.config.get('editor.fontSize')).toBe(12) // Not on an atom-text-editor workspaceElement.dispatchEvent(new WheelEvent('mousewheel', { wheelDeltaY: 10, ctrlKey: true - })); - expect(atom.config.get('editor.fontSize')).toBe(12); + })) + expect(atom.config.get('editor.fontSize')).toBe(12) // No ctrl key editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { - wheelDeltaY: 10, - })); - expect(atom.config.get('editor.fontSize')).toBe(12); + wheelDeltaY: 10 + })) + expect(atom.config.get('editor.fontSize')).toBe(12) - atom.config.set('editor.zoomFontWhenCtrlScrolling', false); + atom.config.set('editor.zoomFontWhenCtrlScrolling', false) editorElement.querySelector('span').dispatchEvent(new WheelEvent('mousewheel', { wheelDeltaY: 10, ctrlKey: true - })); - return expect(atom.config.get('editor.fontSize')).toBe(12); - }); - }); + })) + return expect(atom.config.get('editor.fontSize')).toBe(12) + }) + }) - describe('panel containers', function() { - it('inserts panel container elements in the correct places in the DOM', function() { - const workspaceElement = atom.views.getView(atom.workspace); + describe('panel containers', function () { + it('inserts panel container elements in the correct places in the DOM', function () { + const workspaceElement = atom.views.getView(atom.workspace) - const leftContainer = workspaceElement.querySelector('atom-panel-container.left'); - const rightContainer = workspaceElement.querySelector('atom-panel-container.right'); - expect(leftContainer.nextSibling).toBe(workspaceElement.verticalAxis); - expect(rightContainer.previousSibling).toBe(workspaceElement.verticalAxis); + const leftContainer = workspaceElement.querySelector('atom-panel-container.left') + const rightContainer = workspaceElement.querySelector('atom-panel-container.right') + expect(leftContainer.nextSibling).toBe(workspaceElement.verticalAxis) + expect(rightContainer.previousSibling).toBe(workspaceElement.verticalAxis) - const topContainer = workspaceElement.querySelector('atom-panel-container.top'); - const bottomContainer = workspaceElement.querySelector('atom-panel-container.bottom'); - expect(topContainer.nextSibling).toBe(workspaceElement.paneContainer); - expect(bottomContainer.previousSibling).toBe(workspaceElement.paneContainer); + const topContainer = workspaceElement.querySelector('atom-panel-container.top') + const bottomContainer = workspaceElement.querySelector('atom-panel-container.bottom') + expect(topContainer.nextSibling).toBe(workspaceElement.paneContainer) + expect(bottomContainer.previousSibling).toBe(workspaceElement.paneContainer) - const headerContainer = workspaceElement.querySelector('atom-panel-container.header'); - const footerContainer = workspaceElement.querySelector('atom-panel-container.footer'); - expect(headerContainer.nextSibling).toBe(workspaceElement.horizontalAxis); - expect(footerContainer.previousSibling).toBe(workspaceElement.horizontalAxis); + const headerContainer = workspaceElement.querySelector('atom-panel-container.header') + const footerContainer = workspaceElement.querySelector('atom-panel-container.footer') + expect(headerContainer.nextSibling).toBe(workspaceElement.horizontalAxis) + expect(footerContainer.previousSibling).toBe(workspaceElement.horizontalAxis) - const modalContainer = workspaceElement.querySelector('atom-panel-container.modal'); - return expect(modalContainer.parentNode).toBe(workspaceElement); - }); + const modalContainer = workspaceElement.querySelector('atom-panel-container.modal') + return expect(modalContainer.parentNode).toBe(workspaceElement) + }) - it('stretches header/footer panels to the workspace width', function() { - const workspaceElement = atom.views.getView(atom.workspace); - jasmine.attachToDOM(workspaceElement); - expect(workspaceElement.offsetWidth).toBeGreaterThan(0); + it('stretches header/footer panels to the workspace width', function () { + const workspaceElement = atom.views.getView(atom.workspace) + jasmine.attachToDOM(workspaceElement) + expect(workspaceElement.offsetWidth).toBeGreaterThan(0) - const headerItem = document.createElement('div'); - atom.workspace.addHeaderPanel({item: headerItem}); - expect(headerItem.offsetWidth).toEqual(workspaceElement.offsetWidth); + const headerItem = document.createElement('div') + atom.workspace.addHeaderPanel({item: headerItem}) + expect(headerItem.offsetWidth).toEqual(workspaceElement.offsetWidth) - const footerItem = document.createElement('div'); - atom.workspace.addFooterPanel({item: footerItem}); - return expect(footerItem.offsetWidth).toEqual(workspaceElement.offsetWidth); - }); + const footerItem = document.createElement('div') + atom.workspace.addFooterPanel({item: footerItem}) + return expect(footerItem.offsetWidth).toEqual(workspaceElement.offsetWidth) + }) - return it('shrinks horizontal axis according to header/footer panels height', function() { - const workspaceElement = atom.views.getView(atom.workspace); - workspaceElement.style.height = '100px'; - const horizontalAxisElement = workspaceElement.querySelector('atom-workspace-axis.horizontal'); - jasmine.attachToDOM(workspaceElement); + return it('shrinks horizontal axis according to header/footer panels height', function () { + const workspaceElement = atom.views.getView(atom.workspace) + workspaceElement.style.height = '100px' + const horizontalAxisElement = workspaceElement.querySelector('atom-workspace-axis.horizontal') + jasmine.attachToDOM(workspaceElement) - const originalHorizontalAxisHeight = horizontalAxisElement.offsetHeight; - expect(workspaceElement.offsetHeight).toBeGreaterThan(0); - expect(originalHorizontalAxisHeight).toBeGreaterThan(0); + const originalHorizontalAxisHeight = horizontalAxisElement.offsetHeight + expect(workspaceElement.offsetHeight).toBeGreaterThan(0) + expect(originalHorizontalAxisHeight).toBeGreaterThan(0) - const headerItem = document.createElement('div'); - headerItem.style.height = '10px'; - atom.workspace.addHeaderPanel({item: headerItem}); - expect(headerItem.offsetHeight).toBeGreaterThan(0); + const headerItem = document.createElement('div') + headerItem.style.height = '10px' + atom.workspace.addHeaderPanel({item: headerItem}) + expect(headerItem.offsetHeight).toBeGreaterThan(0) - const footerItem = document.createElement('div'); - footerItem.style.height = '15px'; - atom.workspace.addFooterPanel({item: footerItem}); - expect(footerItem.offsetHeight).toBeGreaterThan(0); + const footerItem = document.createElement('div') + footerItem.style.height = '15px' + atom.workspace.addFooterPanel({item: footerItem}) + expect(footerItem.offsetHeight).toBeGreaterThan(0) - return expect(horizontalAxisElement.offsetHeight).toEqual(originalHorizontalAxisHeight - headerItem.offsetHeight - footerItem.offsetHeight); - }); - }); + return expect(horizontalAxisElement.offsetHeight).toEqual(originalHorizontalAxisHeight - headerItem.offsetHeight - footerItem.offsetHeight) + }) + }) describe("the 'window:toggle-invisibles' command", () => - it("shows/hides invisibles in all open and future editors", function() { - const workspaceElement = atom.views.getView(atom.workspace); - expect(atom.config.get('editor.showInvisibles')).toBe(false); - atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles'); - expect(atom.config.get('editor.showInvisibles')).toBe(true); - atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles'); - return expect(atom.config.get('editor.showInvisibles')).toBe(false); + it('shows/hides invisibles in all open and future editors', function () { + const workspaceElement = atom.views.getView(atom.workspace) + expect(atom.config.get('editor.showInvisibles')).toBe(false) + atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles') + expect(atom.config.get('editor.showInvisibles')).toBe(true) + atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles') + return expect(atom.config.get('editor.showInvisibles')).toBe(false) }) - ); + ) return describe("the 'window:run-package-specs' command", () => - it("runs the package specs for the active item's project path, or the first project path", function() { - const workspaceElement = atom.views.getView(atom.workspace); - spyOn(ipcRenderer, 'send'); + it("runs the package specs for the active item's project path, or the first project path", function () { + const workspaceElement = atom.views.getView(atom.workspace) + spyOn(ipcRenderer, 'send') // No project paths. Don't try to run specs. - atom.commands.dispatch(workspaceElement, "window:run-package-specs"); - expect(ipcRenderer.send).not.toHaveBeenCalledWith("run-package-specs"); + atom.commands.dispatch(workspaceElement, 'window:run-package-specs') + expect(ipcRenderer.send).not.toHaveBeenCalledWith('run-package-specs') - const projectPaths = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")]; - atom.project.setPaths(projectPaths); + const projectPaths = [temp.mkdirSync('dir1-'), temp.mkdirSync('dir2-')] + atom.project.setPaths(projectPaths) // No active item. Use first project directory. - atom.commands.dispatch(workspaceElement, "window:run-package-specs"); - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")); - ipcRenderer.send.reset(); + atom.commands.dispatch(workspaceElement, 'window:run-package-specs') + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec')) + ipcRenderer.send.reset() // Active item doesn't implement ::getPath(). Use first project directory. - const item = document.createElement("div"); - atom.workspace.getActivePane().activateItem(item); - atom.commands.dispatch(workspaceElement, "window:run-package-specs"); - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")); - ipcRenderer.send.reset(); + const item = document.createElement('div') + atom.workspace.getActivePane().activateItem(item) + atom.commands.dispatch(workspaceElement, 'window:run-package-specs') + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec')) + ipcRenderer.send.reset() // Active item has no path. Use first project directory. - item.getPath = () => null; - atom.commands.dispatch(workspaceElement, "window:run-package-specs"); - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[0], "spec")); - ipcRenderer.send.reset(); + item.getPath = () => null + atom.commands.dispatch(workspaceElement, 'window:run-package-specs') + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[0], 'spec')) + ipcRenderer.send.reset() // Active item has path. Use project path for item path. - item.getPath = () => path.join(projectPaths[1], "a-file.txt"); - atom.commands.dispatch(workspaceElement, "window:run-package-specs"); - expect(ipcRenderer.send).toHaveBeenCalledWith("run-package-specs", path.join(projectPaths[1], "spec")); - return ipcRenderer.send.reset(); + item.getPath = () => path.join(projectPaths[1], 'a-file.txt') + atom.commands.dispatch(workspaceElement, 'window:run-package-specs') + expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[1], 'spec')) + return ipcRenderer.send.reset() }) - ); -}); + ) +}) diff --git a/src/workspace-element.js b/src/workspace-element.js index b24bb80f6..465c4be34 100644 --- a/src/workspace-element.js +++ b/src/workspace-element.js @@ -1,95 +1,97 @@ -let WorkspaceElement; -const {ipcRenderer} = require('electron'); -const path = require('path'); -const fs = require('fs-plus'); -const {CompositeDisposable} = require('event-kit'); -const scrollbarStyle = require('scrollbar-style'); +/* global HTMLElement */ + +let WorkspaceElement +const {ipcRenderer} = require('electron') +const path = require('path') +const fs = require('fs-plus') +const {CompositeDisposable} = require('event-kit') +const scrollbarStyle = require('scrollbar-style') module.exports = __initClass__(WorkspaceElement = class WorkspaceElement extends HTMLElement { - static initClass() { - this.prototype.globalTextEditorStyleSheet = null; + static initClass () { + this.prototype.globalTextEditorStyleSheet = null } - attachedCallback() { - return this.focus(); + attachedCallback () { + return this.focus() } - detachedCallback() { - return this.subscriptions.dispose(); + detachedCallback () { + return this.subscriptions.dispose() } - initializeContent() { - this.classList.add('workspace'); - this.setAttribute('tabindex', -1); + initializeContent () { + this.classList.add('workspace') + this.setAttribute('tabindex', -1) - this.verticalAxis = document.createElement('atom-workspace-axis'); - this.verticalAxis.classList.add('vertical'); + this.verticalAxis = document.createElement('atom-workspace-axis') + this.verticalAxis.classList.add('vertical') - this.horizontalAxis = document.createElement('atom-workspace-axis'); - this.horizontalAxis.classList.add('horizontal'); - this.horizontalAxis.appendChild(this.verticalAxis); + this.horizontalAxis = document.createElement('atom-workspace-axis') + this.horizontalAxis.classList.add('horizontal') + this.horizontalAxis.appendChild(this.verticalAxis) - return this.appendChild(this.horizontalAxis); + return this.appendChild(this.horizontalAxis) } - observeScrollbarStyle() { + observeScrollbarStyle () { return this.subscriptions.add(scrollbarStyle.observePreferredScrollbarStyle(style => { switch (style) { case 'legacy': - this.classList.remove('scrollbars-visible-when-scrolling'); - return this.classList.add("scrollbars-visible-always"); + this.classList.remove('scrollbars-visible-when-scrolling') + return this.classList.add('scrollbars-visible-always') case 'overlay': - this.classList.remove('scrollbars-visible-always'); - return this.classList.add("scrollbars-visible-when-scrolling"); + this.classList.remove('scrollbars-visible-always') + return this.classList.add('scrollbars-visible-when-scrolling') } } ) - ); + ) } - observeTextEditorFontConfig() { - this.updateGlobalTextEditorStyleSheet(); - this.subscriptions.add(this.config.onDidChange('editor.fontSize', this.updateGlobalTextEditorStyleSheet.bind(this))); - this.subscriptions.add(this.config.onDidChange('editor.fontFamily', this.updateGlobalTextEditorStyleSheet.bind(this))); - return this.subscriptions.add(this.config.onDidChange('editor.lineHeight', this.updateGlobalTextEditorStyleSheet.bind(this))); + observeTextEditorFontConfig () { + this.updateGlobalTextEditorStyleSheet() + this.subscriptions.add(this.config.onDidChange('editor.fontSize', this.updateGlobalTextEditorStyleSheet.bind(this))) + this.subscriptions.add(this.config.onDidChange('editor.fontFamily', this.updateGlobalTextEditorStyleSheet.bind(this))) + return this.subscriptions.add(this.config.onDidChange('editor.lineHeight', this.updateGlobalTextEditorStyleSheet.bind(this))) } - updateGlobalTextEditorStyleSheet() { + updateGlobalTextEditorStyleSheet () { const styleSheetSource = `\ atom-text-editor { - font-size: ${this.config.get('editor.fontSize')}px; - font-family: ${this.config.get('editor.fontFamily')}; - line-height: ${this.config.get('editor.lineHeight')}; + font-size: ${this.config.get('editor.fontSize')}px + font-family: ${this.config.get('editor.fontFamily')} + line-height: ${this.config.get('editor.lineHeight')} }\ -`; - this.styles.addStyleSheet(styleSheetSource, {sourcePath: 'global-text-editor-styles'}); - return this.views.performDocumentPoll(); +` + this.styles.addStyleSheet(styleSheetSource, {sourcePath: 'global-text-editor-styles'}) + return this.views.performDocumentPoll() } - initialize(model, {views, workspace, project, config, styles}) { - this.model = model; - this.views = views; - this.workspace = workspace; - this.project = project; - this.config = config; - this.styles = styles; - if (this.views == null) { throw new Error("Must pass a views parameter when initializing WorskpaceElements"); } - if (this.workspace == null) { throw new Error("Must pass a workspace parameter when initializing WorskpaceElements"); } - if (this.project == null) { throw new Error("Must pass a project parameter when initializing WorskpaceElements"); } - if (this.config == null) { throw new Error("Must pass a config parameter when initializing WorskpaceElements"); } - if (this.styles == null) { throw new Error("Must pass a styles parameter when initializing WorskpaceElements"); } + initialize (model, {views, workspace, project, config, styles}) { + this.model = model + this.views = views + this.workspace = workspace + this.project = project + this.config = config + this.styles = styles + if (this.views == null) { throw new Error('Must pass a views parameter when initializing WorskpaceElements') } + if (this.workspace == null) { throw new Error('Must pass a workspace parameter when initializing WorskpaceElements') } + if (this.project == null) { throw new Error('Must pass a project parameter when initializing WorskpaceElements') } + if (this.config == null) { throw new Error('Must pass a config parameter when initializing WorskpaceElements') } + if (this.styles == null) { throw new Error('Must pass a styles parameter when initializing WorskpaceElements') } - this.subscriptions = new CompositeDisposable; - this.initializeContent(); - this.observeScrollbarStyle(); - this.observeTextEditorFontConfig(); + this.subscriptions = new CompositeDisposable() + this.initializeContent() + this.observeScrollbarStyle() + this.observeTextEditorFontConfig() - this.paneContainer = this.views.getView(this.model.paneContainer); - this.verticalAxis.appendChild(this.paneContainer); - this.addEventListener('focus', this.handleFocus.bind(this)); + this.paneContainer = this.views.getView(this.model.paneContainer) + this.verticalAxis.appendChild(this.paneContainer) + this.addEventListener('focus', this.handleFocus.bind(this)) - this.addEventListener('mousewheel', this.handleMousewheel.bind(this), true); + this.addEventListener('mousewheel', this.handleMousewheel.bind(this), true) this.panelContainers = { top: this.views.getView(this.model.panelContainers.top), @@ -99,98 +101,98 @@ atom-text-editor { header: this.views.getView(this.model.panelContainers.header), footer: this.views.getView(this.model.panelContainers.footer), modal: this.views.getView(this.model.panelContainers.modal) - }; + } - this.horizontalAxis.insertBefore(this.panelContainers.left, this.verticalAxis); - this.horizontalAxis.appendChild(this.panelContainers.right); + this.horizontalAxis.insertBefore(this.panelContainers.left, this.verticalAxis) + this.horizontalAxis.appendChild(this.panelContainers.right) - this.verticalAxis.insertBefore(this.panelContainers.top, this.paneContainer); - this.verticalAxis.appendChild(this.panelContainers.bottom); + this.verticalAxis.insertBefore(this.panelContainers.top, this.paneContainer) + this.verticalAxis.appendChild(this.panelContainers.bottom) - this.insertBefore(this.panelContainers.header, this.horizontalAxis); - this.appendChild(this.panelContainers.footer); + this.insertBefore(this.panelContainers.header, this.horizontalAxis) + this.appendChild(this.panelContainers.footer) - this.appendChild(this.panelContainers.modal); + this.appendChild(this.panelContainers.modal) - return this; + return this } - getModel() { return this.model; } + getModel () { return this.model } - handleMousewheel(event) { + handleMousewheel (event) { if (event.ctrlKey && this.config.get('editor.zoomFontWhenCtrlScrolling') && (event.target.closest('atom-text-editor') != null)) { if (event.wheelDeltaY > 0) { - this.model.increaseFontSize(); + this.model.increaseFontSize() } else if (event.wheelDeltaY < 0) { - this.model.decreaseFontSize(); + this.model.decreaseFontSize() } - event.preventDefault(); - return event.stopPropagation(); + event.preventDefault() + return event.stopPropagation() } } - handleFocus(event) { - return this.model.getActivePane().activate(); + handleFocus (event) { + return this.model.getActivePane().activate() } - focusPaneViewAbove() { return this.paneContainer.focusPaneViewAbove(); } + focusPaneViewAbove () { return this.paneContainer.focusPaneViewAbove() } - focusPaneViewBelow() { return this.paneContainer.focusPaneViewBelow(); } + focusPaneViewBelow () { return this.paneContainer.focusPaneViewBelow() } - focusPaneViewOnLeft() { return this.paneContainer.focusPaneViewOnLeft(); } + focusPaneViewOnLeft () { return this.paneContainer.focusPaneViewOnLeft() } - focusPaneViewOnRight() { return this.paneContainer.focusPaneViewOnRight(); } + focusPaneViewOnRight () { return this.paneContainer.focusPaneViewOnRight() } - moveActiveItemToPaneAbove(params) { return this.paneContainer.moveActiveItemToPaneAbove(params); } + moveActiveItemToPaneAbove (params) { return this.paneContainer.moveActiveItemToPaneAbove(params) } - moveActiveItemToPaneBelow(params) { return this.paneContainer.moveActiveItemToPaneBelow(params); } + moveActiveItemToPaneBelow (params) { return this.paneContainer.moveActiveItemToPaneBelow(params) } - moveActiveItemToPaneOnLeft(params) { return this.paneContainer.moveActiveItemToPaneOnLeft(params); } + moveActiveItemToPaneOnLeft (params) { return this.paneContainer.moveActiveItemToPaneOnLeft(params) } - moveActiveItemToPaneOnRight(params) { return this.paneContainer.moveActiveItemToPaneOnRight(params); } + moveActiveItemToPaneOnRight (params) { return this.paneContainer.moveActiveItemToPaneOnRight(params) } - runPackageSpecs() { - let activePath, projectPath; - if (activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath())) { - [projectPath] = Array.from(this.project.relativizePath(activePath)); + runPackageSpecs () { + let activePath, projectPath + if ((activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath()))) { + [projectPath] = Array.from(this.project.relativizePath(activePath)) } else { - [projectPath] = Array.from(this.project.getPaths()); + [projectPath] = Array.from(this.project.getPaths()) } if (projectPath) { - let specPath = path.join(projectPath, 'spec'); - const testPath = path.join(projectPath, 'test'); + let specPath = path.join(projectPath, 'spec') + const testPath = path.join(projectPath, 'test') if (!fs.existsSync(specPath) && fs.existsSync(testPath)) { - specPath = testPath; + specPath = testPath } - return ipcRenderer.send('run-package-specs', specPath); + return ipcRenderer.send('run-package-specs', specPath) } } - runBenchmarks() { - let activePath, projectPath; - if (activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath())) { - [projectPath] = Array.from(this.project.relativizePath(activePath)); + runBenchmarks () { + let activePath, projectPath + if ((activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath()))) { + [projectPath] = Array.from(this.project.relativizePath(activePath)) } else { - [projectPath] = Array.from(this.project.getPaths()); + [projectPath] = Array.from(this.project.getPaths()) } if (projectPath) { - return ipcRenderer.send('run-benchmarks', path.join(projectPath, 'benchmarks')); + return ipcRenderer.send('run-benchmarks', path.join(projectPath, 'benchmarks')) } } -}); +}) -module.exports = WorkspaceElement = document.registerElement('atom-workspace', {prototype: WorkspaceElement.prototype}); +module.exports = WorkspaceElement = document.registerElement('atom-workspace', {prototype: WorkspaceElement.prototype}) -function __initClass__(c) { - c.initClass(); - return c; +function __initClass__ (c) { + c.initClass() + return c } -function __guardMethod__(obj, methodName, transform) { +function __guardMethod__ (obj, methodName, transform) { if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') { - return transform(obj, methodName); + return transform(obj, methodName) } else { - return undefined; + return undefined } -} \ No newline at end of file +} From 3017b28ef7bb4a411e0a3de4802cce2f8b197532 Mon Sep 17 00:00:00 2001 From: Matthew Dapena-Tretter Date: Tue, 7 Mar 2017 16:31:00 -0800 Subject: [PATCH 19/27] Convert workspace element to JS: Cleanup --- spec/workspace-element-spec.js | 84 +++++++++++++------------- src/workspace-element.js | 104 ++++++++++++++------------------- 2 files changed, 88 insertions(+), 100 deletions(-) diff --git a/spec/workspace-element-spec.js b/spec/workspace-element-spec.js index 2a7fc0cab..a7f6957a0 100644 --- a/spec/workspace-element-spec.js +++ b/spec/workspace-element-spec.js @@ -1,3 +1,5 @@ +'use strict' + /* global getComputedStyle, WheelEvent */ const {ipcRenderer} = require('electron') @@ -5,28 +7,28 @@ const path = require('path') const temp = require('temp').track() const {Disposable} = require('event-kit') -describe('WorkspaceElement', function () { - afterEach(() => temp.cleanupSync()) +describe('WorkspaceElement', () => { + afterEach(() => { temp.cleanupSync() }) - describe('when the workspace element is focused', () => - it('transfers focus to the active pane', function () { + describe('when the workspace element is focused', () => { + it('transfers focus to the active pane', () => { const workspaceElement = atom.views.getView(atom.workspace) jasmine.attachToDOM(workspaceElement) const activePaneElement = atom.views.getView(atom.workspace.getActivePane()) document.body.focus() expect(document.activeElement).not.toBe(activePaneElement) workspaceElement.focus() - return expect(document.activeElement).toBe(activePaneElement) + expect(document.activeElement).toBe(activePaneElement) }) - ) + }) - describe('the scrollbar visibility class', () => - it('has a class based on the style of the scrollbar', function () { - let observeCallback = null + describe('the scrollbar visibility class', () => { + it('has a class based on the style of the scrollbar', () => { + let observeCallback const scrollbarStyle = require('scrollbar-style') - spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake(function (cb) { + spyOn(scrollbarStyle, 'observePreferredScrollbarStyle').andCallFake(cb => { observeCallback = cb - return new Disposable(function () {}) + return new Disposable(() => {}) }) const workspaceElement = atom.views.getView(atom.workspace) @@ -34,33 +36,33 @@ describe('WorkspaceElement', function () { expect(workspaceElement.className).toMatch('scrollbars-visible-always') observeCallback('overlay') - return expect(workspaceElement).toHaveClass('scrollbars-visible-when-scrolling') + expect(workspaceElement).toHaveClass('scrollbars-visible-when-scrolling') }) - ) + }) - describe('editor font styling', function () { - let [editor, editorElement, workspaceElement] = Array.from([]) + describe('editor font styling', () => { + let editor, editorElement, workspaceElement - beforeEach(function () { + beforeEach(() => { waitsForPromise(() => atom.workspace.open('sample.js')) - return runs(function () { + runs(() => { workspaceElement = atom.views.getView(atom.workspace) jasmine.attachToDOM(workspaceElement) editor = atom.workspace.getActiveTextEditor() - return (editorElement = atom.views.getView(editor)) + editorElement = atom.views.getView(editor) }) }) - it("updates the font-size based on the 'editor.fontSize' config value", function () { + it("updates the font-size based on the 'editor.fontSize' config value", () => { const initialCharWidth = editor.getDefaultCharWidth() expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px') atom.config.set('editor.fontSize', atom.config.get('editor.fontSize') + 5) expect(getComputedStyle(editorElement).fontSize).toBe(atom.config.get('editor.fontSize') + 'px') - return expect(editor.getDefaultCharWidth()).toBeGreaterThan(initialCharWidth) + expect(editor.getDefaultCharWidth()).toBeGreaterThan(initialCharWidth) }) - it("updates the font-family based on the 'editor.fontFamily' config value", function () { + it("updates the font-family based on the 'editor.fontFamily' config value", () => { const initialCharWidth = editor.getDefaultCharWidth() let fontFamily = atom.config.get('editor.fontFamily') expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily) @@ -68,17 +70,17 @@ describe('WorkspaceElement', function () { atom.config.set('editor.fontFamily', 'sans-serif') fontFamily = atom.config.get('editor.fontFamily') expect(getComputedStyle(editorElement).fontFamily).toBe(fontFamily) - return expect(editor.getDefaultCharWidth()).not.toBe(initialCharWidth) + expect(editor.getDefaultCharWidth()).not.toBe(initialCharWidth) }) - it("updates the line-height based on the 'editor.lineHeight' config value", function () { + it("updates the line-height based on the 'editor.lineHeight' config value", () => { const initialLineHeight = editor.getLineHeightInPixels() atom.config.set('editor.lineHeight', '30px') expect(getComputedStyle(editorElement).lineHeight).toBe(atom.config.get('editor.lineHeight')) - return expect(editor.getLineHeightInPixels()).not.toBe(initialLineHeight) + expect(editor.getLineHeightInPixels()).not.toBe(initialLineHeight) }) - return it('increases or decreases the font size when a ctrl-mousewheel event occurs', function () { + it('increases or decreases the font size when a ctrl-mousewheel event occurs', () => { atom.config.set('editor.zoomFontWhenCtrlScrolling', true) atom.config.set('editor.fontSize', 12) @@ -114,12 +116,12 @@ describe('WorkspaceElement', function () { wheelDeltaY: 10, ctrlKey: true })) - return expect(atom.config.get('editor.fontSize')).toBe(12) + expect(atom.config.get('editor.fontSize')).toBe(12) }) }) - describe('panel containers', function () { - it('inserts panel container elements in the correct places in the DOM', function () { + describe('panel containers', () => { + it('inserts panel container elements in the correct places in the DOM', () => { const workspaceElement = atom.views.getView(atom.workspace) const leftContainer = workspaceElement.querySelector('atom-panel-container.left') @@ -138,10 +140,10 @@ describe('WorkspaceElement', function () { expect(footerContainer.previousSibling).toBe(workspaceElement.horizontalAxis) const modalContainer = workspaceElement.querySelector('atom-panel-container.modal') - return expect(modalContainer.parentNode).toBe(workspaceElement) + expect(modalContainer.parentNode).toBe(workspaceElement) }) - it('stretches header/footer panels to the workspace width', function () { + it('stretches header/footer panels to the workspace width', () => { const workspaceElement = atom.views.getView(atom.workspace) jasmine.attachToDOM(workspaceElement) expect(workspaceElement.offsetWidth).toBeGreaterThan(0) @@ -152,10 +154,10 @@ describe('WorkspaceElement', function () { const footerItem = document.createElement('div') atom.workspace.addFooterPanel({item: footerItem}) - return expect(footerItem.offsetWidth).toEqual(workspaceElement.offsetWidth) + expect(footerItem.offsetWidth).toEqual(workspaceElement.offsetWidth) }) - return it('shrinks horizontal axis according to header/footer panels height', function () { + it('shrinks horizontal axis according to header/footer panels height', () => { const workspaceElement = atom.views.getView(atom.workspace) workspaceElement.style.height = '100px' const horizontalAxisElement = workspaceElement.querySelector('atom-workspace-axis.horizontal') @@ -175,23 +177,23 @@ describe('WorkspaceElement', function () { atom.workspace.addFooterPanel({item: footerItem}) expect(footerItem.offsetHeight).toBeGreaterThan(0) - return expect(horizontalAxisElement.offsetHeight).toEqual(originalHorizontalAxisHeight - headerItem.offsetHeight - footerItem.offsetHeight) + expect(horizontalAxisElement.offsetHeight).toEqual(originalHorizontalAxisHeight - headerItem.offsetHeight - footerItem.offsetHeight) }) }) - describe("the 'window:toggle-invisibles' command", () => - it('shows/hides invisibles in all open and future editors', function () { + describe("the 'window:toggle-invisibles' command", () => { + it('shows/hides invisibles in all open and future editors', () => { const workspaceElement = atom.views.getView(atom.workspace) expect(atom.config.get('editor.showInvisibles')).toBe(false) atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles') expect(atom.config.get('editor.showInvisibles')).toBe(true) atom.commands.dispatch(workspaceElement, 'window:toggle-invisibles') - return expect(atom.config.get('editor.showInvisibles')).toBe(false) + expect(atom.config.get('editor.showInvisibles')).toBe(false) }) - ) + }) - return describe("the 'window:run-package-specs' command", () => - it("runs the package specs for the active item's project path, or the first project path", function () { + describe("the 'window:run-package-specs' command", () => { + it("runs the package specs for the active item's project path, or the first project path", () => { const workspaceElement = atom.views.getView(atom.workspace) spyOn(ipcRenderer, 'send') @@ -224,7 +226,7 @@ describe('WorkspaceElement', function () { item.getPath = () => path.join(projectPaths[1], 'a-file.txt') atom.commands.dispatch(workspaceElement, 'window:run-package-specs') expect(ipcRenderer.send).toHaveBeenCalledWith('run-package-specs', path.join(projectPaths[1], 'spec')) - return ipcRenderer.send.reset() + ipcRenderer.send.reset() }) - ) + }) }) diff --git a/src/workspace-element.js b/src/workspace-element.js index 465c4be34..65333e7d3 100644 --- a/src/workspace-element.js +++ b/src/workspace-element.js @@ -1,24 +1,20 @@ +'use strict' + /* global HTMLElement */ -let WorkspaceElement const {ipcRenderer} = require('electron') const path = require('path') const fs = require('fs-plus') const {CompositeDisposable} = require('event-kit') const scrollbarStyle = require('scrollbar-style') -module.exports = -__initClass__(WorkspaceElement = class WorkspaceElement extends HTMLElement { - static initClass () { - this.prototype.globalTextEditorStyleSheet = null - } - +class WorkspaceElement extends HTMLElement { attachedCallback () { - return this.focus() + this.focus() } detachedCallback () { - return this.subscriptions.dispose() + this.subscriptions.dispose() } initializeContent () { @@ -32,41 +28,39 @@ __initClass__(WorkspaceElement = class WorkspaceElement extends HTMLElement { this.horizontalAxis.classList.add('horizontal') this.horizontalAxis.appendChild(this.verticalAxis) - return this.appendChild(this.horizontalAxis) + this.appendChild(this.horizontalAxis) } observeScrollbarStyle () { - return this.subscriptions.add(scrollbarStyle.observePreferredScrollbarStyle(style => { + this.subscriptions.add(scrollbarStyle.observePreferredScrollbarStyle(style => { switch (style) { case 'legacy': this.classList.remove('scrollbars-visible-when-scrolling') - return this.classList.add('scrollbars-visible-always') + this.classList.add('scrollbars-visible-always') + break case 'overlay': this.classList.remove('scrollbars-visible-always') - return this.classList.add('scrollbars-visible-when-scrolling') + this.classList.add('scrollbars-visible-when-scrolling') + break } - } - ) - ) + })) } observeTextEditorFontConfig () { this.updateGlobalTextEditorStyleSheet() this.subscriptions.add(this.config.onDidChange('editor.fontSize', this.updateGlobalTextEditorStyleSheet.bind(this))) this.subscriptions.add(this.config.onDidChange('editor.fontFamily', this.updateGlobalTextEditorStyleSheet.bind(this))) - return this.subscriptions.add(this.config.onDidChange('editor.lineHeight', this.updateGlobalTextEditorStyleSheet.bind(this))) + this.subscriptions.add(this.config.onDidChange('editor.lineHeight', this.updateGlobalTextEditorStyleSheet.bind(this))) } updateGlobalTextEditorStyleSheet () { - const styleSheetSource = `\ -atom-text-editor { - font-size: ${this.config.get('editor.fontSize')}px - font-family: ${this.config.get('editor.fontFamily')} - line-height: ${this.config.get('editor.lineHeight')} -}\ -` + const styleSheetSource = `atom-text-editor { + font-size: ${this.config.get('editor.fontSize')}px; + font-family: ${this.config.get('editor.fontFamily')}; + line-height: ${this.config.get('editor.lineHeight')}; +}` this.styles.addStyleSheet(styleSheetSource, {sourcePath: 'global-text-editor-styles'}) - return this.views.performDocumentPoll() + this.views.performDocumentPoll() } initialize (model, {views, workspace, project, config, styles}) { @@ -127,36 +121,38 @@ atom-text-editor { this.model.decreaseFontSize() } event.preventDefault() - return event.stopPropagation() + event.stopPropagation() } } handleFocus (event) { - return this.model.getActivePane().activate() + this.model.getActivePane().activate() } - focusPaneViewAbove () { return this.paneContainer.focusPaneViewAbove() } + focusPaneViewAbove () { this.paneContainer.focusPaneViewAbove() } - focusPaneViewBelow () { return this.paneContainer.focusPaneViewBelow() } + focusPaneViewBelow () { this.paneContainer.focusPaneViewBelow() } - focusPaneViewOnLeft () { return this.paneContainer.focusPaneViewOnLeft() } + focusPaneViewOnLeft () { this.paneContainer.focusPaneViewOnLeft() } - focusPaneViewOnRight () { return this.paneContainer.focusPaneViewOnRight() } + focusPaneViewOnRight () { this.paneContainer.focusPaneViewOnRight() } - moveActiveItemToPaneAbove (params) { return this.paneContainer.moveActiveItemToPaneAbove(params) } + moveActiveItemToPaneAbove (params) { this.paneContainer.moveActiveItemToPaneAbove(params) } - moveActiveItemToPaneBelow (params) { return this.paneContainer.moveActiveItemToPaneBelow(params) } + moveActiveItemToPaneBelow (params) { this.paneContainer.moveActiveItemToPaneBelow(params) } - moveActiveItemToPaneOnLeft (params) { return this.paneContainer.moveActiveItemToPaneOnLeft(params) } + moveActiveItemToPaneOnLeft (params) { this.paneContainer.moveActiveItemToPaneOnLeft(params) } - moveActiveItemToPaneOnRight (params) { return this.paneContainer.moveActiveItemToPaneOnRight(params) } + moveActiveItemToPaneOnRight (params) { this.paneContainer.moveActiveItemToPaneOnRight(params) } runPackageSpecs () { - let activePath, projectPath - if ((activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath()))) { - [projectPath] = Array.from(this.project.relativizePath(activePath)) + const activePaneItem = this.workspace.getActivePaneItem() + const activePath = activePaneItem && typeof activePaneItem.getPath === 'function' ? activePaneItem.getPath() : null + let projectPath + if (activePath != null) { + [projectPath] = this.project.relativizePath(activePath) } else { - [projectPath] = Array.from(this.project.getPaths()) + [projectPath] = this.project.getPaths() } if (projectPath) { let specPath = path.join(projectPath, 'spec') @@ -165,34 +161,24 @@ atom-text-editor { specPath = testPath } - return ipcRenderer.send('run-package-specs', specPath) + ipcRenderer.send('run-package-specs', specPath) } } runBenchmarks () { - let activePath, projectPath - if ((activePath = __guardMethod__(this.workspace.getActivePaneItem(), 'getPath', o => o.getPath()))) { - [projectPath] = Array.from(this.project.relativizePath(activePath)) + const activePaneItem = this.workspace.getActivePaneItem() + const activePath = activePaneItem && typeof activePaneItem.getPath === 'function' ? activePaneItem.getPath() : null + let projectPath + if (activePath) { + [projectPath] = this.project.relativizePath(activePath) } else { - [projectPath] = Array.from(this.project.getPaths()) + [projectPath] = this.project.getPaths() } if (projectPath) { - return ipcRenderer.send('run-benchmarks', path.join(projectPath, 'benchmarks')) + ipcRenderer.send('run-benchmarks', path.join(projectPath, 'benchmarks')) } } -}) - -module.exports = WorkspaceElement = document.registerElement('atom-workspace', {prototype: WorkspaceElement.prototype}) - -function __initClass__ (c) { - c.initClass() - return c -} -function __guardMethod__ (obj, methodName, transform) { - if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') { - return transform(obj, methodName) - } else { - return undefined - } } + +module.exports = document.registerElement('atom-workspace', {prototype: WorkspaceElement.prototype}) From 5858a22fe4205e64c0180f9d0c4fea10a6423530 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 7 Mar 2017 19:37:25 -0700 Subject: [PATCH 20/27] :arrow_up: find-and-replace --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8207d3307..0059bdbf6 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "dev-live-reload": "0.47.0", "encoding-selector": "0.23.2", "exception-reporting": "0.41.2", - "find-and-replace": "0.207.0", + "find-and-replace": "0.207.2", "fuzzy-finder": "1.5.0", "git-diff": "1.3.3", "go-to-line": "0.32.0", From 80dd64c14906fc425b8227bdf356f6af095d0388 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Tue, 7 Mar 2017 22:32:04 -0500 Subject: [PATCH 21/27] :arrow_up: language-sql@0.25.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0059bdbf6..841cfc1be 100644 --- a/package.json +++ b/package.json @@ -167,7 +167,7 @@ "language-sass": "0.58.0", "language-shellscript": "0.25.0", "language-source": "0.9.0", - "language-sql": "0.25.3", + "language-sql": "0.25.4", "language-text": "0.7.2", "language-todo": "0.29.1", "language-toml": "0.18.1", From 414ad13b0977e6497319a855263bcb163de5e02b Mon Sep 17 00:00:00 2001 From: simurai Date: Wed, 8 Mar 2017 13:41:29 +0900 Subject: [PATCH 22/27] :arrow_up: atom-package-manager@v1.16.1 --- apm/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm/package.json b/apm/package.json index 07931700d..e57d07aee 100644 --- a/apm/package.json +++ b/apm/package.json @@ -6,6 +6,6 @@ "url": "https://github.com/atom/atom.git" }, "dependencies": { - "atom-package-manager": "1.16.0" + "atom-package-manager": "1.16.1" } } From 43868bb939781037e33fa67922c8454b05189bcc Mon Sep 17 00:00:00 2001 From: simurai Date: Wed, 8 Mar 2017 15:36:41 +0900 Subject: [PATCH 23/27] Revert ":arrow_up: atom-package-manager@v1.16.1" This reverts commit 414ad13b0977e6497319a855263bcb163de5e02b. --- apm/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm/package.json b/apm/package.json index e57d07aee..07931700d 100644 --- a/apm/package.json +++ b/apm/package.json @@ -6,6 +6,6 @@ "url": "https://github.com/atom/atom.git" }, "dependencies": { - "atom-package-manager": "1.16.1" + "atom-package-manager": "1.16.0" } } From 40071265cb70e5a76093e902c5449ac0c80a1eed Mon Sep 17 00:00:00 2001 From: simurai Date: Wed, 8 Mar 2017 22:27:09 +0900 Subject: [PATCH 24/27] :arrow_up: apm, take II --- apm/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm/package.json b/apm/package.json index 07931700d..e57d07aee 100644 --- a/apm/package.json +++ b/apm/package.json @@ -6,6 +6,6 @@ "url": "https://github.com/atom/atom.git" }, "dependencies": { - "atom-package-manager": "1.16.0" + "atom-package-manager": "1.16.1" } } From 982074061e675ab607186f3173c426eafa2a0035 Mon Sep 17 00:00:00 2001 From: Hubot Date: Wed, 8 Mar 2017 14:18:49 -0600 Subject: [PATCH 25/27] 1.17.0-dev --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 841cfc1be..96864fd81 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "atom", "productName": "Atom", - "version": "1.16.0-dev", + "version": "1.17.0-dev", "description": "A hackable text editor for the 21st Century.", "main": "./src/main-process/main.js", "repository": { From 4a1f98cb6ccd59fc89399ebb45b2f8a0a1778727 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 8 Mar 2017 15:50:08 -0800 Subject: [PATCH 26/27] Create autoUpdateManager in AtomApplication constructor --- src/main-process/atom-application.coffee | 9 ++++++--- src/main-process/auto-update-manager.coffee | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main-process/atom-application.coffee b/src/main-process/atom-application.coffee index 93e9e3395..d21ebae45 100644 --- a/src/main-process/atom-application.coffee +++ b/src/main-process/atom-application.coffee @@ -73,6 +73,11 @@ class AtomApplication @config.load() @fileRecoveryService = new FileRecoveryService(path.join(process.env.ATOM_HOME, "recovery")) @storageFolder = new StorageFolder(process.env.ATOM_HOME) + @autoUpdateManager = new AutoUpdateManager( + @version, + options.test or options.benchmark or options.benchmarkTest, + @config + ) @disposable = new CompositeDisposable @handleEvents() @@ -92,9 +97,7 @@ class AtomApplication @config.onDidChange 'core.titleBar', @promptForRestart.bind(this) - @autoUpdateManager = new AutoUpdateManager( - @version, options.test or options.benchmark or options.benchmarkTest, @resourcePath, @config - ) + process.nextTick => @autoUpdateManager.initialize() @applicationMenu = new ApplicationMenu(@version, @autoUpdateManager) @atomProtocolHandler = new AtomProtocolHandler(@resourcePath, @safeMode) diff --git a/src/main-process/auto-update-manager.coffee b/src/main-process/auto-update-manager.coffee index ff29dd3d6..2ff2852cb 100644 --- a/src/main-process/auto-update-manager.coffee +++ b/src/main-process/auto-update-manager.coffee @@ -14,12 +14,11 @@ module.exports = class AutoUpdateManager Object.assign @prototype, EventEmitter.prototype - constructor: (@version, @testMode, resourcePath, @config) -> + constructor: (@version, @testMode, @config) -> @state = IdleState @iconPath = path.resolve(__dirname, '..', '..', 'resources', 'atom.png') - process.nextTick => @setupAutoUpdater() - setupAutoUpdater: -> + initialize: -> if process.platform is 'win32' archSuffix = if process.arch is 'ia32' then '' else '-' + process.arch @feedUrl = "https://atom.io/api/updates#{archSuffix}?version=#{@version}" From 82c49001f4c3e043ae43575190eed0ae40263b9d Mon Sep 17 00:00:00 2001 From: Michelle Tilley Date: Wed, 8 Mar 2017 17:21:58 -0800 Subject: [PATCH 27/27] :arrow_up: legal-eagle@0.14.0 --- script/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/package.json b/script/package.json index 87c43f261..89beaa492 100644 --- a/script/package.json +++ b/script/package.json @@ -13,7 +13,7 @@ "fs-extra": "0.30.0", "glob": "7.0.3", "joanna": "0.0.8", - "legal-eagle": "0.13.0", + "legal-eagle": "0.14.0", "lodash.template": "4.4.0", "minidump": "0.9.0", "mkdirp": "0.5.1",