commandz 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +3 -3
- data/commandz.min.js +3 -3
- data/lib/assets/javascripts/commandz.coffee +2 -2
- data/lib/commandz/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 183bfa031cc7ddcd92e5d751f0076f7f8039b552
|
4
|
+
data.tar.gz: de872e50f6ec7f0da196656e344075ece62d39c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d23f010558fab213cdd722745972e8c49a984313d540a1b596b3a7e43eba8992be11c688548859628eb06184a269d5a6cefb91676f71853b002451c9cf0bfee
|
7
|
+
data.tar.gz: a7dbe78ceb7821709096489af35411099150d4e21b986aea7b55088729d5faa81147a75e81f84a55ae9ac620fb0febe32670a8c1e895b5402f7c0c4fbce6529c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## [v0.1.1](https://github.com/EtienneLem/commandz/tree/v0.1.1)
|
2
|
+
- Add `CTRL+Z` & `CTRL+SHIFT+Z` keyboard shortcuts
|
3
|
+
|
1
4
|
## [v0.1.0](https://github.com/EtienneLem/commandz/tree/v0.1.0)
|
2
5
|
- Rename `CommandZ.commands` -> `CommandZ.history`
|
3
6
|
- Rename `CommandZ.onChange` -> `CommandZ.onStatusChange`
|
data/README.md
CHANGED
@@ -154,7 +154,7 @@ console.log(CommandZ.index) // => -1
|
|
154
154
|
|
155
155
|
CommandZ.store({ width: 100, height: 100 })
|
156
156
|
CommandZ.store({ width: 200, height: 200 })
|
157
|
-
CommandZ.undo()
|
157
|
+
CommandZ.undo() // => { width: 100, height: 100 }
|
158
158
|
|
159
159
|
console.log(CommandZ.commands.length) // => 2
|
160
160
|
console.log(CommandZ.index) // => 0
|
@@ -170,8 +170,8 @@ CommandZ.onStorageChange(function(data) {
|
|
170
170
|
|
171
171
|
CommandZ.store({ width: 100, height: 100 })
|
172
172
|
CommandZ.store({ width: 200, height: 200 })
|
173
|
-
CommandZ.undo()
|
174
|
-
CommandZ.redo()
|
173
|
+
CommandZ.undo() // => { width: 100, height: 100 }
|
174
|
+
CommandZ.redo() // => { width: 200, height: 200 }
|
175
175
|
|
176
176
|
console.log(CommandZ.commands.length) // => 2
|
177
177
|
console.log(CommandZ.index) // => 1
|
data/commandz.min.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
/*
|
2
|
-
* CommandZ v0.1.
|
2
|
+
* CommandZ v0.1.1
|
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-02
|
8
|
+
* Date: 2013-09-02 15:44:16 -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.1",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]("keypress",this.handleKeypress)},t.prototype.handleKeypress=function(t){return"INPUT"!==document.activeElement.nodeName&&(122===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.1'
|
5
5
|
|
6
6
|
this.reset()
|
7
7
|
this.keyboardShortcuts(true)
|
@@ -24,7 +24,7 @@ class CommandZ
|
|
24
24
|
|
25
25
|
handleKeypress: (e) =>
|
26
26
|
return if document.activeElement.nodeName is 'INPUT'
|
27
|
-
return unless e.
|
27
|
+
return unless (e.which is 122 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