diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ade14b9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +npm-debug.log +node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c3d858c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 - First Release +* Every feature added +* Every bug fixed diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..40a0eeb --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2015 + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d7987d --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# autocomplete-xml package + +A short description of your package. + +![A screenshot of your package](https://f.cloud.github.com/assets/69169/2290250/c35d867a-a017-11e3-86be-cd7c5bf3ff9b.gif) diff --git a/keymaps/autocomplete-xml.cson b/keymaps/autocomplete-xml.cson new file mode 100644 index 0000000..79d1b4a --- /dev/null +++ b/keymaps/autocomplete-xml.cson @@ -0,0 +1,11 @@ +# Keybindings require three things to be fully defined: A selector that is +# matched against the focused element, the keystroke and the command to +# execute. +# +# Below is a basic keybinding which registers on all platforms by applying to +# the root workspace element. + +# For more detailed documentation see +# https://atom.io/docs/latest/behind-atom-keymaps-in-depth +'atom-workspace': + 'ctrl-alt-o': 'autocomplete-xml:toggle' diff --git a/lib/autocomplete-xml-view.coffee b/lib/autocomplete-xml-view.coffee new file mode 100644 index 0000000..2dbd33f --- /dev/null +++ b/lib/autocomplete-xml-view.coffee @@ -0,0 +1,22 @@ +module.exports = +class AutocompleteXmlView + constructor: (serializedState) -> + # Create root element + @element = document.createElement('div') + @element.classList.add('autocomplete-xml') + + # Create message element + message = document.createElement('div') + message.textContent = "The AutocompleteXml package is Alive! It's ALIVE!" + message.classList.add('message') + @element.appendChild(message) + + # Returns an object that can be retrieved when package is activated + serialize: -> + + # Tear down any state and detach + destroy: -> + @element.remove() + + getElement: -> + @element diff --git a/lib/autocomplete-xml.coffee b/lib/autocomplete-xml.coffee new file mode 100644 index 0000000..ed4d132 --- /dev/null +++ b/lib/autocomplete-xml.coffee @@ -0,0 +1,33 @@ +AutocompleteXmlView = require './autocomplete-xml-view' +{CompositeDisposable} = require 'atom' + +module.exports = AutocompleteXml = + autocompleteXmlView: null + modalPanel: null + subscriptions: null + + activate: (state) -> + @autocompleteXmlView = new AutocompleteXmlView(state.autocompleteXmlViewState) + @modalPanel = atom.workspace.addModalPanel(item: @autocompleteXmlView.getElement(), visible: false) + + # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable + @subscriptions = new CompositeDisposable + + # Register command that toggles this view + @subscriptions.add atom.commands.add 'atom-workspace', 'autocomplete-xml:toggle': => @toggle() + + deactivate: -> + @modalPanel.destroy() + @subscriptions.dispose() + @autocompleteXmlView.destroy() + + serialize: -> + autocompleteXmlViewState: @autocompleteXmlView.serialize() + + toggle: -> + console.log 'AutocompleteXml was toggled!' + + if @modalPanel.isVisible() + @modalPanel.hide() + else + @modalPanel.show() diff --git a/menus/autocomplete-xml.cson b/menus/autocomplete-xml.cson new file mode 100644 index 0000000..cd4c25a --- /dev/null +++ b/menus/autocomplete-xml.cson @@ -0,0 +1,22 @@ +# See https://atom.io/docs/latest/hacking-atom-package-word-count#menus for more details +'context-menu': + 'atom-text-editor': [ + { + 'label': 'Toggle autocomplete-xml' + 'command': 'autocomplete-xml:toggle' + } + ] +'menu': [ + { + 'label': 'Packages' + 'submenu': [ + 'label': 'autocomplete-xml' + 'submenu': [ + { + 'label': 'Toggle' + 'command': 'autocomplete-xml:toggle' + } + ] + ] + } +] diff --git a/package.json b/package.json new file mode 100644 index 0000000..d2b7fef --- /dev/null +++ b/package.json @@ -0,0 +1,18 @@ +{ + "name": "autocomplete-xml", + "main": "./lib/autocomplete-xml", + "version": "0.0.0", + "description": "A short description of your package", + "keywords": [ + ], + "activationCommands": { + "atom-workspace": "autocomplete-xml:toggle" + }, + "repository": "https://github.com/atom/autocomplete-xml", + "license": "MIT", + "engines": { + "atom": ">=1.0.0 <2.0.0" + }, + "dependencies": { + } +} diff --git a/spec/autocomplete-xml-spec.coffee b/spec/autocomplete-xml-spec.coffee new file mode 100644 index 0000000..6499165 --- /dev/null +++ b/spec/autocomplete-xml-spec.coffee @@ -0,0 +1,62 @@ +AutocompleteXml = require '../lib/autocomplete-xml' + +# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs. +# +# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit` +# or `fdescribe`). Remove the `f` to unfocus the block. + +describe "AutocompleteXml", -> + [workspaceElement, activationPromise] = [] + + beforeEach -> + workspaceElement = atom.views.getView(atom.workspace) + activationPromise = atom.packages.activatePackage('autocomplete-xml') + + describe "when the autocomplete-xml:toggle event is triggered", -> + it "hides and shows the modal panel", -> + # Before the activation event the view is not on the DOM, and no panel + # has been created + expect(workspaceElement.querySelector('.autocomplete-xml')).not.toExist() + + # This is an activation event, triggering it will cause the package to be + # activated. + atom.commands.dispatch workspaceElement, 'autocomplete-xml:toggle' + + waitsForPromise -> + activationPromise + + runs -> + expect(workspaceElement.querySelector('.autocomplete-xml')).toExist() + + autocompleteXmlElement = workspaceElement.querySelector('.autocomplete-xml') + expect(autocompleteXmlElement).toExist() + + autocompleteXmlPanel = atom.workspace.panelForItem(autocompleteXmlElement) + expect(autocompleteXmlPanel.isVisible()).toBe true + atom.commands.dispatch workspaceElement, 'autocomplete-xml:toggle' + expect(autocompleteXmlPanel.isVisible()).toBe false + + it "hides and shows the view", -> + # This test shows you an integration test testing at the view level. + + # Attaching the workspaceElement to the DOM is required to allow the + # `toBeVisible()` matchers to work. Anything testing visibility or focus + # requires that the workspaceElement is on the DOM. Tests that attach the + # workspaceElement to the DOM are generally slower than those off DOM. + jasmine.attachToDOM(workspaceElement) + + expect(workspaceElement.querySelector('.autocomplete-xml')).not.toExist() + + # This is an activation event, triggering it causes the package to be + # activated. + atom.commands.dispatch workspaceElement, 'autocomplete-xml:toggle' + + waitsForPromise -> + activationPromise + + runs -> + # Now we can test for view visibility + autocompleteXmlElement = workspaceElement.querySelector('.autocomplete-xml') + expect(autocompleteXmlElement).toBeVisible() + atom.commands.dispatch workspaceElement, 'autocomplete-xml:toggle' + expect(autocompleteXmlElement).not.toBeVisible() diff --git a/spec/autocomplete-xml-view-spec.coffee b/spec/autocomplete-xml-view-spec.coffee new file mode 100644 index 0000000..f1f41d0 --- /dev/null +++ b/spec/autocomplete-xml-view-spec.coffee @@ -0,0 +1,5 @@ +AutocompleteXmlView = require '../lib/autocomplete-xml-view' + +describe "AutocompleteXmlView", -> + it "has one valid test", -> + expect("life").toBe "easy" diff --git a/styles/autocomplete-xml.less b/styles/autocomplete-xml.less new file mode 100644 index 0000000..811b054 --- /dev/null +++ b/styles/autocomplete-xml.less @@ -0,0 +1,8 @@ +// The ui-variables file is provided by base themes provided by Atom. +// +// See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less +// for a full listing of what's available. +@import "ui-variables"; + +.autocomplete-xml { +}