commandz 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +10 -0
- data/README.md +1 -0
- data/Rakefile +4 -1
- data/commandz.gemspec +2 -2
- data/commandz.min.js +3 -3
- data/lib/assets/javascripts/commandz.coffee +2 -1
- data/lib/commandz/version.rb +1 -1
- data/spec/commandz_spec.coffee +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f2704f6b71bfb108f4089d4539879479a1f5e6c9
|
|
4
|
+
data.tar.gz: a7511dae7fbb4fa5b5d499947f1712718a3bc2c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c650267d1bac2d6e1525a1f77a044cfd5929a9baed475f8b53a6bd51430b000731031a4182f196f3611d180f7bc2fe162a8c11fb4e07fc0d0f63dc9cec4b1b2
|
|
7
|
+
data.tar.gz: 076c76e6f4e9ba0dbfe2efaea07317a63eb902382ccf9ec0dfce6f7cf8dca245e039cf5e232cfd7fb4dee0ca92322ae05284de2e617ff03c907f498f865986c3
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## [v0.0.3](https://github.com/EtienneLem/commandz/tree/v0.0.3)
|
|
2
|
+
- Fix a bug where `handleChange` wouldn’t be called after `CommandZ.execute()`
|
|
3
|
+
|
|
4
|
+
## [v0.0.2](https://github.com/EtienneLem/commandz/tree/v0.0.2)
|
|
5
|
+
- Make `CommandZ.status()` return `canUndo` and `canRedo` states
|
|
6
|
+
- Add `CommandZ.onChange()` status callback
|
|
7
|
+
- Add `CMD+Z` & `CMD+SHIFT+Z` keyboard shortcuts
|
|
8
|
+
|
|
9
|
+
## [v0.0.1](https://github.com/EtienneLem/commandz/tree/v0.0.1)
|
|
10
|
+
Initial release
|
data/README.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
13
13
|
<a href="http://badge.fury.io/rb/commandz"><img src="https://badge.fury.io/rb/commandz@2x.png" alt="Gem Version" height="18"></a>
|
|
14
|
+
<a href="https://travis-ci.org/EtienneLem/commandz"><img src="https://travis-ci.org/EtienneLem/commandz.png" alt="Travis build"></a>
|
|
14
15
|
</p>
|
|
15
16
|
|
|
16
17
|
## Table of contents
|
data/Rakefile
CHANGED
|
@@ -9,6 +9,7 @@ Bundler::GemHelper.install_tasks
|
|
|
9
9
|
require 'uglifier'
|
|
10
10
|
require 'commandz'
|
|
11
11
|
require 'sprockets'
|
|
12
|
+
require 'jasmine-headless-webkit'
|
|
12
13
|
|
|
13
14
|
# Tasks
|
|
14
15
|
desc 'Merge, compiles and minify CoffeeScript files'
|
|
@@ -20,9 +21,11 @@ task :compile do
|
|
|
20
21
|
compile('commandz.js')
|
|
21
22
|
end
|
|
22
23
|
|
|
24
|
+
Jasmine::Headless::Task.new
|
|
25
|
+
|
|
23
26
|
desc 'run Jasmine specs'
|
|
24
27
|
task :spec do
|
|
25
|
-
|
|
28
|
+
Rake::Task['jasmine:headless'].invoke
|
|
26
29
|
end
|
|
27
30
|
|
|
28
31
|
# Helpers
|
data/commandz.gemspec
CHANGED
|
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
|
|
|
5
5
|
s.version = CommandZ::VERSION
|
|
6
6
|
s.authors = ['Etienne Lemay']
|
|
7
7
|
s.email = ['etienne@heliom.ca']
|
|
8
|
-
s.homepage = '
|
|
9
|
-
s.summary = '
|
|
8
|
+
s.homepage = 'http://etiennelem.github.io/commandz'
|
|
9
|
+
s.summary = '⌘Z add commands history support to your web app'
|
|
10
10
|
s.license = 'MIT'
|
|
11
11
|
|
|
12
12
|
s.files = `git ls-files`.split($/)
|
data/commandz.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* CommandZ v0.0.
|
|
2
|
+
* CommandZ v0.0.3
|
|
3
3
|
* https://github.com/EtienneLem/commandz
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2013, Etienne Lemay http://heliom.ca
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
*
|
|
8
|
-
* Date: 2013-08-29
|
|
8
|
+
* Date: 2013-08-29 16:12:59 -0400
|
|
9
9
|
*/
|
|
10
|
-
(function(){var t,n=function(t,n){return function(){return t.apply(n,arguments)}};t=function(){function t(){this.handleKeyboard=n(this.handleKeyboard,this),this.VERSION="0.0.
|
|
10
|
+
(function(){var t,n=function(t,n){return function(){return t.apply(n,arguments)}};t=function(){function t(){this.handleKeyboard=n(this.handleKeyboard,this),this.VERSION="0.0.3",this.changeCallback=null,this.clear(),this.keyboardShortcuts(!0)}return t.prototype.clear=function(){return this.commands=[],this.index=-1},t.prototype.keyboardShortcuts=function(t){var n;return null==t&&(t=!0),n=t?"addEventListener":"removeEventListener",document[n]("keypress",this.handleKeyboard)},t.prototype.handleKeyboard=function(t){return"INPUT"!==document.activeElement.nodeName&&122===t.keyCode&&t.metaKey===!0?(t.preventDefault(),t.shiftKey?this.redo():this.undo()):void 0},t.prototype.execute=function(t){var n;return this.up(t),this.index<this.commands.length-1&&(n=this.commands.length-this.index-1,this.commands.splice(-n)),this.commands.push(t),this.index=this.commands.length-1,this.handleChange()},t.prototype.undo=function(t){var n,e;if(null==t&&(t=1),this.status().canUndo)for(n=e=1;t>=1?t>=e:e>=t;n=t>=1?++e:--e){if(!this.commands[this.index])return;this.down(this.commands[this.index]),this.index--,this.handleChange()}},t.prototype.redo=function(t){var n,e;if(null==t&&(t=1),this.status().canRedo)for(n=e=1;t>=1?t>=e:e>=t;n=t>=1?++e:--e){if(!this.commands[this.index+1])return;this.index++,this.up(this.commands[this.index]),this.handleChange()}},t.prototype.exec=function(t,n){var e,i,o,s;if(!(n instanceof Array))return n[t]();for(s=[],i=0,o=n.length;o>i;i++)e=n[i],s.push(e[t]());return s},t.prototype.up=function(t){return this.exec("up",t)},t.prototype.down=function(t){return this.exec("down",t)},t.prototype.onChange=function(t){return this.changeCallback=t,this.handleChange()},t.prototype.handleChange=function(){return this.changeCallback?this.changeCallback(this.status()):void 0},t.prototype.status=function(){return{canUndo:this.index>-1,canRedo:this.index<this.commands.length-1}},t}(),this.CommandZ=new t}).call(this);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class CommandZ
|
|
2
2
|
|
|
3
3
|
constructor: ->
|
|
4
|
-
@VERSION = '0.0.
|
|
4
|
+
@VERSION = '0.0.3'
|
|
5
5
|
@changeCallback = null
|
|
6
6
|
|
|
7
7
|
this.clear()
|
|
@@ -33,6 +33,7 @@ class CommandZ
|
|
|
33
33
|
# Push new command
|
|
34
34
|
@commands.push(command)
|
|
35
35
|
@index = @commands.length - 1
|
|
36
|
+
this.handleChange()
|
|
36
37
|
|
|
37
38
|
undo: (times=1) ->
|
|
38
39
|
return unless this.status().canUndo
|
data/lib/commandz/version.rb
CHANGED
data/spec/commandz_spec.coffee
CHANGED
|
@@ -74,8 +74,9 @@ describe 'CommandZ', ->
|
|
|
74
74
|
|
|
75
75
|
CommandZ.undo(3)
|
|
76
76
|
CommandZ.redo(2)
|
|
77
|
+
CommandZ.execute({up: (->), down: (->)})
|
|
77
78
|
|
|
78
|
-
expect(onChangeCallback.calls.length).toBe(
|
|
79
|
+
expect(onChangeCallback.calls.length).toBe(7)
|
|
79
80
|
CommandZ.onChange(null)
|
|
80
81
|
|
|
81
82
|
describe 'integration', ->
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: commandz
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Etienne Lemay
|
|
@@ -103,6 +103,8 @@ extra_rdoc_files: []
|
|
|
103
103
|
files:
|
|
104
104
|
- .gitignore
|
|
105
105
|
- .jasmine-headless-webkit
|
|
106
|
+
- .travis.yml
|
|
107
|
+
- CHANGELOG.md
|
|
106
108
|
- Gemfile
|
|
107
109
|
- Guardfile
|
|
108
110
|
- MIT-LICENSE
|
|
@@ -121,7 +123,7 @@ files:
|
|
|
121
123
|
- spec/helpers/spec_helper.coffee
|
|
122
124
|
- vendor/jasmine-jquery.js
|
|
123
125
|
- vendor/jquery.js
|
|
124
|
-
homepage:
|
|
126
|
+
homepage: http://etiennelem.github.io/commandz
|
|
125
127
|
licenses:
|
|
126
128
|
- MIT
|
|
127
129
|
metadata: {}
|
|
@@ -144,7 +146,7 @@ rubyforge_project:
|
|
|
144
146
|
rubygems_version: 2.0.0
|
|
145
147
|
signing_key:
|
|
146
148
|
specification_version: 4
|
|
147
|
-
summary:
|
|
149
|
+
summary: ⌘Z add commands history support to your web app
|
|
148
150
|
test_files:
|
|
149
151
|
- spec/commandz_spec.coffee
|
|
150
152
|
- spec/fixtures/spec_container.html
|