commandz 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 706f3e28800a1bd1c1e659a2fcf7a355c8b03fab
4
- data.tar.gz: 4b3451066e237bbf6e4c75e8245f9ac1e528a490
3
+ metadata.gz: 183bfa031cc7ddcd92e5d751f0076f7f8039b552
4
+ data.tar.gz: de872e50f6ec7f0da196656e344075ece62d39c1
5
5
  SHA512:
6
- metadata.gz: e2caf799f9bab92f94978984affae1337d23acb9dba7f4476d3a55637a5ed810e60d08ce08ba4c708b7251f0d5df24e65c2b6ea61f4bf43d69891bf9850ecb35
7
- data.tar.gz: aa1ddb7d6a90db28f177d10b24eac586e94dfc16eea054ed29aa372d30d3d9dbdf609e8a9a5c42f03ee44079991efa6737f6840372f185814d858d5b011951aa
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() # => { width: 100, height: 100 }
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() # => { width: 100, height: 100 }
174
- CommandZ.redo() # => { width: 200, height: 200 }
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.0
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 11:47:04 -0400
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.0",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.keyCode&&t.metaKey===!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);
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.0'
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.keyCode is 122 and e.metaKey is true
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()
@@ -1,3 +1,3 @@
1
1
  module CommandZ
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Etienne Lemay