Permalink
Browse files

refactor bindings

  • Loading branch information...
tj committed Jun 27, 2013
1 parent b092faf commit 900f7a67e9255f25acef0f903b29d4b69161dcaf
Showing with 9 additions and 6 deletions.
  1. +9 −6 index.js
View
@@ -22,6 +22,9 @@ module.exports = Clipboard;
function Clipboard(el) {
Emitter.call(this);
this.el = el;
this.onpaste = this.onpaste.bind(this);
this.oncopy = this.oncopy.bind(this);
this.oncut = this.oncut.bind(this);
this.bind();
}
@@ -38,9 +41,9 @@ Emitter(Clipboard.prototype);
*/
Clipboard.prototype.bind = function(){
this.el.addEventListener('paste', this._paste = this.onpaste.bind(this), false);
this.el.addEventListener('copy', this._copy = this.oncopy.bind(this), false);
this.el.addEventListener('cut', this._cut = this.oncut.bind(this), false);
this.el.addEventListener('paste', this.onpaste, false);
this.el.addEventListener('copy', this.oncopy, false);
this.el.addEventListener('cut', this.oncut, false);
};
/**
@@ -50,9 +53,9 @@ Clipboard.prototype.bind = function(){
*/
Clipboard.prototype.unbind = function(arg){
this.el.removeEventListener('paste', this._paste);
this.el.removeEventListener('copy', this._copy);
this.el.removeEventListener('cut', this._cut);
this.el.removeEventListener('paste', this.onpaste);
this.el.removeEventListener('copy', this.oncopy);
this.el.removeEventListener('cut', this.oncut);
};
/**

0 comments on commit 900f7a6

Please sign in to comment.