···11+## 0.1.0 - First Release
22+* Every feature added
33+* Every bug fixed
+20
LICENSE.md
···11+Copyright (c) 2015 <Your name here>
22+33+Permission is hereby granted, free of charge, to any person obtaining
44+a copy of this software and associated documentation files (the
55+"Software"), to deal in the Software without restriction, including
66+without limitation the rights to use, copy, modify, merge, publish,
77+distribute, sublicense, and/or sell copies of the Software, and to
88+permit persons to whom the Software is furnished to do so, subject to
99+the following conditions:
1010+1111+The above copyright notice and this permission notice shall be
1212+included in all copies or substantial portions of the Software.
1313+1414+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1515+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1616+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1717+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1818+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1919+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2020+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+5
README.md
···11+# language-mzn package
22+33+A short description of your package.
44+55+
+11
keymaps/language-mzn.cson
···11+# Keybindings require three things to be fully defined: A selector that is
22+# matched against the focused element, the keystroke and the command to
33+# execute.
44+#
55+# Below is a basic keybinding which registers on all platforms by applying to
66+# the root workspace element.
77+88+# For more detailed documentation see
99+# https://atom.io/docs/latest/behind-atom-keymaps-in-depth
1010+'atom-workspace':
1111+ 'ctrl-alt-o': 'language-mzn:toggle'
+22
lib/language-mzn-view.coffee
···11+module.exports =
22+class LanguageMznView
33+ constructor: (serializedState) ->
44+ # Create root element
55+ @element = document.createElement('div')
66+ @element.classList.add('language-mzn')
77+88+ # Create message element
99+ message = document.createElement('div')
1010+ message.textContent = "The LanguageMzn package is Alive! It's ALIVE!"
1111+ message.classList.add('message')
1212+ @element.appendChild(message)
1313+1414+ # Returns an object that can be retrieved when package is activated
1515+ serialize: ->
1616+1717+ # Tear down any state and detach
1818+ destroy: ->
1919+ @element.remove()
2020+2121+ getElement: ->
2222+ @element
+33
lib/language-mzn.coffee
···11+LanguageMznView = require './language-mzn-view'
22+{CompositeDisposable} = require 'atom'
33+44+module.exports = LanguageMzn =
55+ languageMznView: null
66+ modalPanel: null
77+ subscriptions: null
88+99+ activate: (state) ->
1010+ @languageMznView = new LanguageMznView(state.languageMznViewState)
1111+ @modalPanel = atom.workspace.addModalPanel(item: @languageMznView.getElement(), visible: false)
1212+1313+ # Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
1414+ @subscriptions = new CompositeDisposable
1515+1616+ # Register command that toggles this view
1717+ @subscriptions.add atom.commands.add 'atom-workspace', 'language-mzn:toggle': => @toggle()
1818+1919+ deactivate: ->
2020+ @modalPanel.destroy()
2121+ @subscriptions.dispose()
2222+ @languageMznView.destroy()
2323+2424+ serialize: ->
2525+ languageMznViewState: @languageMznView.serialize()
2626+2727+ toggle: ->
2828+ console.log 'LanguageMzn was toggled!'
2929+3030+ if @modalPanel.isVisible()
3131+ @modalPanel.hide()
3232+ else
3333+ @modalPanel.show()
···11+LanguageMzn = require '../lib/language-mzn'
22+33+# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
44+#
55+# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
66+# or `fdescribe`). Remove the `f` to unfocus the block.
77+88+describe "LanguageMzn", ->
99+ [workspaceElement, activationPromise] = []
1010+1111+ beforeEach ->
1212+ workspaceElement = atom.views.getView(atom.workspace)
1313+ activationPromise = atom.packages.activatePackage('language-mzn')
1414+1515+ describe "when the language-mzn:toggle event is triggered", ->
1616+ it "hides and shows the modal panel", ->
1717+ # Before the activation event the view is not on the DOM, and no panel
1818+ # has been created
1919+ expect(workspaceElement.querySelector('.language-mzn')).not.toExist()
2020+2121+ # This is an activation event, triggering it will cause the package to be
2222+ # activated.
2323+ atom.commands.dispatch workspaceElement, 'language-mzn:toggle'
2424+2525+ waitsForPromise ->
2626+ activationPromise
2727+2828+ runs ->
2929+ expect(workspaceElement.querySelector('.language-mzn')).toExist()
3030+3131+ languageMznElement = workspaceElement.querySelector('.language-mzn')
3232+ expect(languageMznElement).toExist()
3333+3434+ languageMznPanel = atom.workspace.panelForItem(languageMznElement)
3535+ expect(languageMznPanel.isVisible()).toBe true
3636+ atom.commands.dispatch workspaceElement, 'language-mzn:toggle'
3737+ expect(languageMznPanel.isVisible()).toBe false
3838+3939+ it "hides and shows the view", ->
4040+ # This test shows you an integration test testing at the view level.
4141+4242+ # Attaching the workspaceElement to the DOM is required to allow the
4343+ # `toBeVisible()` matchers to work. Anything testing visibility or focus
4444+ # requires that the workspaceElement is on the DOM. Tests that attach the
4545+ # workspaceElement to the DOM are generally slower than those off DOM.
4646+ jasmine.attachToDOM(workspaceElement)
4747+4848+ expect(workspaceElement.querySelector('.language-mzn')).not.toExist()
4949+5050+ # This is an activation event, triggering it causes the package to be
5151+ # activated.
5252+ atom.commands.dispatch workspaceElement, 'language-mzn:toggle'
5353+5454+ waitsForPromise ->
5555+ activationPromise
5656+5757+ runs ->
5858+ # Now we can test for view visibility
5959+ languageMznElement = workspaceElement.querySelector('.language-mzn')
6060+ expect(languageMznElement).toBeVisible()
6161+ atom.commands.dispatch workspaceElement, 'language-mzn:toggle'
6262+ expect(languageMznElement).not.toBeVisible()
+5
spec/language-mzn-view-spec.coffee
···11+LanguageMznView = require '../lib/language-mzn-view'
22+33+describe "LanguageMznView", ->
44+ it "has one valid test", ->
55+ expect("life").toBe "easy"
+8
styles/language-mzn.less
···11+// The ui-variables file is provided by base themes provided by Atom.
22+//
33+// See https://github.com/atom/atom-dark-ui/blob/master/styles/ui-variables.less
44+// for a full listing of what's available.
55+@import "ui-variables";
66+77+.language-mzn {
88+}