commandz 0.1.1 → 0.1.2
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/CHANGELOG.md +3 -0
- data/README.md +1 -1
- data/commandz.min.js +3 -3
- data/lib/assets/javascripts/commandz.coffee +3 -3
- data/lib/commandz/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 206adc5178d437e2e6cdce0614dc97c7e851369c
|
|
4
|
+
data.tar.gz: dadc06107948a25686061ce921006d8b37fe56e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2592d44cdae768177814295410ad5a6b26e0bd8936ba27406830084737abf5b6615674de82b0eb9e6b09b41a759e51966aa2fd127d79fc1bf623197ec77fbc6
|
|
7
|
+
data.tar.gz: e20a309436c00946a57b89d39ea3a66ce1f35ce45d5615c2edaa2dfb12a9e48a1d1f2a1bb302ac874999571632ee0f8bd47f04c6ac7907542aba0ebcd94fbf6f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -360,7 +360,7 @@ console.log(img.width) // => 300
|
|
|
360
360
|
3. Restart your server and `CMD+Z` - `CMD+SHIFT+Z` away!
|
|
361
361
|
|
|
362
362
|
### Other
|
|
363
|
-
Download and include [commandz.min.js](https://raw.github.com/EtienneLem/commandz/master/commandz.min.js) in your HTML pages.
|
|
363
|
+
Download and include [commandz.min.js](https://raw.github.com/EtienneLem/commandz/master/commandz.min.js) in your HTML pages. CommandZ is also hosted on [cdnjs.com](http://cdnjs.com).
|
|
364
364
|
|
|
365
365
|
## Tests
|
|
366
366
|
Run the `rake spec` task or `bundle exec guard` for continuous testing.
|
data/commandz.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* CommandZ v0.1.
|
|
2
|
+
* CommandZ v0.1.2
|
|
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-09-
|
|
8
|
+
* Date: 2013-09-27 15:56:22 -0400
|
|
9
9
|
*/
|
|
10
|
-
(function(){var t,e=function(t,e){return function(){return t.apply(e,arguments)}};t=function(){function t(){this.handleKeypress=e(this.handleKeypress,this),this.VERSION="0.1.
|
|
10
|
+
(function(){var t,e=function(t,e){return function(){return t.apply(e,arguments)}};t=function(){function t(){this.handleKeypress=e(this.handleKeypress,this),this.VERSION="0.1.2",this.reset(),this.keyboardShortcuts(!0)}return t.prototype.reset=function(){return this.clear(),this.statusChangeCallback=null,this.storageChangeCallback=null,this.thresholdTimer=null,this.threshold=0},t.prototype.clear=function(){return this.history=[],this.index=-1},t.prototype.keyboardShortcuts=function(t){var e;return null==t&&(t=!0),e=t?"addEventListener":"removeEventListener",document[e]("keydown",this.handleKeypress)},t.prototype.handleKeypress=function(t){return"INPUT"!==document.activeElement.nodeName&&(90===t.which&&t.metaKey===!0||26===t.which&&t.ctrlKey===!0)?(t.preventDefault(),t.shiftKey?this.redo():this.undo()):void 0},t.prototype.execute=function(t){var e;return e={},e.command=t,this.up(t),this.addToHistory(e)},t.prototype.store=function(t){var e;return e={},e.data=t,this.addToHistory(e)},t.prototype.addToHistory=function(t){var e;return this.index<this.history.length-1&&(e=this.history.length-this.index-1,this.history.splice(-e)),this.history.push(t),this.index=this.history.length-1,this.handleStatusChange()},t.prototype.undo=function(t){var e,n,s,i,h;if(null==t&&(t=1),this.status().canUndo)for(i=h=1;t>=1?t>=h:h>=t;i=t>=1?++h:--h){if(!this.history[this.index])return;s=this.history[this.index],(e=s.command)&&this.down(e),this.index--,(s=this.history[this.index])&&(n=s.data)&&this.handleData(n),this.handleStatusChange()}},t.prototype.redo=function(t){var e,n,s,i,h;if(null==t&&(t=1),this.status().canRedo)for(i=h=1;t>=1?t>=h:h>=t;i=t>=1?++h:--h){if(!this.history[this.index+1])return;this.index++,s=this.history[this.index],(e=s.command)&&this.up(e),(n=s.data)&&this.handleData(n),this.handleStatusChange()}},t.prototype.exec=function(t,e){var n,s,i,h;if(!(e instanceof Array))return e[t]();for(h=[],s=0,i=e.length;i>s;s++)n=e[s],h.push(n[t]());return h},t.prototype.up=function(t){return this.exec("up",t)},t.prototype.down=function(t){return this.exec("down",t)},t.prototype.handleData=function(t){var e=this;return this.threshold>0?(clearTimeout(this.thresholdTimer),this.thresholdTimer=setTimeout(function(){return e.sendData(t)},this.threshold)):this.sendData(t)},t.prototype.sendData=function(t){return this.storageChangeCallback?this.storageChangeCallback(t):void 0},t.prototype.onStorageChange=function(t){return this.storageChangeCallback=t},t.prototype.setThreshold=function(t){return this.threshold=t},t.prototype.onStatusChange=function(t){return this.statusChangeCallback=t,this.handleStatusChange()},t.prototype.handleStatusChange=function(){return this.statusChangeCallback?this.statusChangeCallback(this.status()):void 0},t.prototype.status=function(){return{canUndo:this.index>-1,canRedo:this.index<this.history.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.1.
|
|
4
|
+
@VERSION = '0.1.2'
|
|
5
5
|
|
|
6
6
|
this.reset()
|
|
7
7
|
this.keyboardShortcuts(true)
|
|
@@ -20,11 +20,11 @@ class CommandZ
|
|
|
20
20
|
|
|
21
21
|
keyboardShortcuts: (enable=true) ->
|
|
22
22
|
addOrRemove = if enable then 'addEventListener' else 'removeEventListener'
|
|
23
|
-
document[addOrRemove]('
|
|
23
|
+
document[addOrRemove]('keydown', this.handleKeypress)
|
|
24
24
|
|
|
25
25
|
handleKeypress: (e) =>
|
|
26
26
|
return if document.activeElement.nodeName is 'INPUT'
|
|
27
|
-
return unless (e.which is
|
|
27
|
+
return unless (e.which is 90 and e.metaKey is true || e.which is 26 and e.ctrlKey is true)
|
|
28
28
|
|
|
29
29
|
e.preventDefault()
|
|
30
30
|
if e.shiftKey then this.redo() else this.undo()
|
data/lib/commandz/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: commandz
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Etienne Lemay
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-09-
|
|
11
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|