commandz 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 183bfa031cc7ddcd92e5d751f0076f7f8039b552
4
- data.tar.gz: de872e50f6ec7f0da196656e344075ece62d39c1
3
+ metadata.gz: 206adc5178d437e2e6cdce0614dc97c7e851369c
4
+ data.tar.gz: dadc06107948a25686061ce921006d8b37fe56e6
5
5
  SHA512:
6
- metadata.gz: 7d23f010558fab213cdd722745972e8c49a984313d540a1b596b3a7e43eba8992be11c688548859628eb06184a269d5a6cefb91676f71853b002451c9cf0bfee
7
- data.tar.gz: a7dbe78ceb7821709096489af35411099150d4e21b986aea7b55088729d5faa81147a75e81f84a55ae9ac620fb0febe32670a8c1e895b5402f7c0c4fbce6529c
6
+ metadata.gz: a2592d44cdae768177814295410ad5a6b26e0bd8936ba27406830084737abf5b6615674de82b0eb9e6b09b41a759e51966aa2fd127d79fc1bf623197ec77fbc6
7
+ data.tar.gz: e20a309436c00946a57b89d39ea3a66ce1f35ce45d5615c2edaa2dfb12a9e48a1d1f2a1bb302ac874999571632ee0f8bd47f04c6ac7907542aba0ebcd94fbf6f
@@ -1,3 +1,6 @@
1
+ ## [v0.1.2](https://github.com/EtienneLem/commandz/tree/v0.1.2)
2
+ - Capture keydown instead of keypress. [Fixes Chrome shortcut]
3
+
1
4
  ## [v0.1.1](https://github.com/EtienneLem/commandz/tree/v0.1.1)
2
5
  - Add `CTRL+Z` & `CTRL+SHIFT+Z` keyboard shortcuts
3
6
 
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.
@@ -1,10 +1,10 @@
1
1
  /*
2
- * CommandZ v0.1.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-02 15:44:16 -0400
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.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);
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.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]('keypress', this.handleKeypress)
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 122 and e.metaKey is true || e.which is 26 and e.ctrlKey is true)
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()
@@ -1,3 +1,3 @@
1
1
  module CommandZ
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
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.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-02 00:00:00.000000000 Z
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake