blank package
This commit is contained in:
commit
ffbe36efec
12 changed files with 210 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
.DS_Store
|
||||||
|
npm-debug.log
|
||||||
|
node_modules
|
||||||
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
## 0.1.0 - First Release
|
||||||
|
* Every feature added
|
||||||
|
* Every bug fixed
|
||||||
20
LICENSE.md
Normal file
20
LICENSE.md
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
Copyright (c) 2014 Loic Nageleisen
|
||||||
|
|
||||||
|
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.
|
||||||
5
README.md
Normal file
5
README.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# ex-mode package
|
||||||
|
|
||||||
|
A short description of your package.
|
||||||
|
|
||||||
|

|
||||||
11
keymaps/ex-mode.cson
Normal file
11
keymaps/ex-mode.cson
Normal file
|
|
@ -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/advanced/keymaps
|
||||||
|
'atom-workspace':
|
||||||
|
'ctrl-alt-o': 'ex-mode:toggle'
|
||||||
22
lib/ex-mode-view.coffee
Normal file
22
lib/ex-mode-view.coffee
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
module.exports =
|
||||||
|
class ExModeView
|
||||||
|
constructor: (serializeState) ->
|
||||||
|
# Create root element
|
||||||
|
@element = document.createElement('div')
|
||||||
|
@element.classList.add('ex-mode')
|
||||||
|
|
||||||
|
# Create message element
|
||||||
|
message = document.createElement('div')
|
||||||
|
message.textContent = "The ExMode 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
|
||||||
33
lib/ex-mode.coffee
Normal file
33
lib/ex-mode.coffee
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
ExModeView = require './ex-mode-view'
|
||||||
|
{CompositeDisposable} = require 'atom'
|
||||||
|
|
||||||
|
module.exports = ExMode =
|
||||||
|
exModeView: null
|
||||||
|
modalPanel: null
|
||||||
|
subscriptions: null
|
||||||
|
|
||||||
|
activate: (state) ->
|
||||||
|
@exModeView = new ExModeView(state.exModeViewState)
|
||||||
|
@modalPanel = atom.workspace.addModalPanel(item: @exModeView.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', 'ex-mode:toggle': => @toggle()
|
||||||
|
|
||||||
|
deactivate: ->
|
||||||
|
@modalPanel.destroy()
|
||||||
|
@subscriptions.dispose()
|
||||||
|
@exModeView.destroy()
|
||||||
|
|
||||||
|
serialize: ->
|
||||||
|
exModeViewState: @exModeView.serialize()
|
||||||
|
|
||||||
|
toggle: ->
|
||||||
|
console.log 'ExMode was toggled!'
|
||||||
|
|
||||||
|
if @modalPanel.isVisible()
|
||||||
|
@modalPanel.hide()
|
||||||
|
else
|
||||||
|
@modalPanel.show()
|
||||||
22
menus/ex-mode.cson
Normal file
22
menus/ex-mode.cson
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# See https://atom.io/docs/latest/creating-a-package#menus for more details
|
||||||
|
'context-menu':
|
||||||
|
'atom-text-editor': [
|
||||||
|
{
|
||||||
|
'label': 'Toggle ex-mode'
|
||||||
|
'command': 'ex-mode:toggle'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
'menu': [
|
||||||
|
{
|
||||||
|
'label': 'Packages'
|
||||||
|
'submenu': [
|
||||||
|
'label': 'ex-mode'
|
||||||
|
'submenu': [
|
||||||
|
{
|
||||||
|
'label': 'Toggle'
|
||||||
|
'command': 'ex-mode:toggle'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
16
package.json
Normal file
16
package.json
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"name": "ex-mode",
|
||||||
|
"main": "./lib/ex-mode",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "A short description of your package",
|
||||||
|
"activationCommands": {
|
||||||
|
"atom-workspace": "ex-mode:toggle"
|
||||||
|
},
|
||||||
|
"repository": "https://github.com/atom/ex-mode",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"atom": ">=0.174.0 <2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
}
|
||||||
|
}
|
||||||
62
spec/ex-mode-spec.coffee
Normal file
62
spec/ex-mode-spec.coffee
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
ExMode = require '../lib/ex-mode'
|
||||||
|
|
||||||
|
# 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 "ExMode", ->
|
||||||
|
[workspaceElement, activationPromise] = []
|
||||||
|
|
||||||
|
beforeEach ->
|
||||||
|
workspaceElement = atom.views.getView(atom.workspace)
|
||||||
|
activationPromise = atom.packages.activatePackage('ex-mode')
|
||||||
|
|
||||||
|
describe "when the ex-mode: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('.ex-mode')).not.toExist()
|
||||||
|
|
||||||
|
# This is an activation event, triggering it will cause the package to be
|
||||||
|
# activated.
|
||||||
|
atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
|
||||||
|
|
||||||
|
waitsForPromise ->
|
||||||
|
activationPromise
|
||||||
|
|
||||||
|
runs ->
|
||||||
|
expect(workspaceElement.querySelector('.ex-mode')).toExist()
|
||||||
|
|
||||||
|
exModeElement = workspaceElement.querySelector('.ex-mode')
|
||||||
|
expect(exModeElement).toExist()
|
||||||
|
|
||||||
|
exModePanel = atom.workspace.panelForItem(exModeElement)
|
||||||
|
expect(exModePanel.isVisible()).toBe true
|
||||||
|
atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
|
||||||
|
expect(exModePanel.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('.ex-mode')).not.toExist()
|
||||||
|
|
||||||
|
# This is an activation event, triggering it causes the package to be
|
||||||
|
# activated.
|
||||||
|
atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
|
||||||
|
|
||||||
|
waitsForPromise ->
|
||||||
|
activationPromise
|
||||||
|
|
||||||
|
runs ->
|
||||||
|
# Now we can test for view visibility
|
||||||
|
exModeElement = workspaceElement.querySelector('.ex-mode')
|
||||||
|
expect(exModeElement).toBeVisible()
|
||||||
|
atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
|
||||||
|
expect(exModeElement).not.toBeVisible()
|
||||||
5
spec/ex-mode-view-spec.coffee
Normal file
5
spec/ex-mode-view-spec.coffee
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
ExModeView = require '../lib/ex-mode-view'
|
||||||
|
|
||||||
|
describe "ExModeView", ->
|
||||||
|
it "has one valid test", ->
|
||||||
|
expect("life").toBe "easy"
|
||||||
8
styles/ex-mode.less
Normal file
8
styles/ex-mode.less
Normal file
|
|
@ -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";
|
||||||
|
|
||||||
|
.ex-mode {
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue