Comparing version 0.0.3 to 0.1.0
var Keyconfig, Shortcuts, events, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -13,4 +13,4 @@ Keyconfig = require('keyconfig'); | ||
module.exports = Shortcuts = (function(_super) { | ||
__extends(Shortcuts, _super); | ||
module.exports = Shortcuts = (function(superClass) { | ||
extend(Shortcuts, superClass); | ||
@@ -33,4 +33,4 @@ function Shortcuts(defaults) { | ||
return function(event) { | ||
var collection, collectionName, eventName, _ref; | ||
_ref = event.split(':'), eventName = _ref[0], collectionName = _ref[1]; | ||
var collection, collectionName, eventName, ref; | ||
ref = event.split(':'), eventName = ref[0], collectionName = ref[1]; | ||
if (eventName !== 'key' || !(collection = _this.get(collectionName))) { | ||
@@ -67,17 +67,27 @@ return void 0; | ||
Shortcuts.prototype.removeAllListeners = function(type) { | ||
if (!type) { | ||
throw new Error('missing type'); | ||
} | ||
return Shortcuts.__super__.removeAllListeners.call(this, type); | ||
}; | ||
Shortcuts._osIndex = /(Mac|iPhone|iPod|iPad)/i.test(window.navigator.platform) ? 1 : 0; | ||
Shortcuts.prototype._bind = function(collection) { | ||
var index, _base, _name; | ||
index = ((_base = this._listeners)[_name = collection.name] || (_base[_name] = {})); | ||
var base, index, name; | ||
index = ((base = this._listeners)[name = collection.name] || (base[name] = {})); | ||
return collection.each((function(_this) { | ||
return function(model) { | ||
var bindings, cb, listeners, sequence, _i, _len, _name1, _ref; | ||
var bindings, cb, i, len, listeners, name1, ref, sequence; | ||
bindings = [].concat(model.binding[Shortcuts._osIndex]).filter(Boolean); | ||
if (bindings.length) { | ||
listeners = (index[_name1 = model.name] || (index[_name1] = [])); | ||
for (_i = 0, _len = bindings.length; _i < _len; _i++) { | ||
sequence = bindings[_i]; | ||
listeners = (index[name1 = model.name] || (index[name1] = [])); | ||
for (i = 0, len = bindings.length; i < len; i++) { | ||
sequence = bindings[i]; | ||
cb = function(e) { | ||
return _this.emit("key:" + collection.name, e, collection, model); | ||
e.collection = collection; | ||
e.model = model; | ||
e.sequence = sequence; | ||
return _this.emit("key:" + collection.name, e); | ||
}; | ||
@@ -88,3 +98,3 @@ listeners.push({ | ||
}); | ||
if (((_ref = model.options) != null ? _ref.global : void 0) === true) { | ||
if (((ref = model.options) != null ? ref.global : void 0) === true) { | ||
Mousetrap.bindGlobal(sequence, cb); | ||
@@ -91,0 +101,0 @@ } else { |
{ | ||
"name": "shortcuts", | ||
"version": "0.0.3", | ||
"description": "manages keyboard shortcuts", | ||
"version": "0.1.0", | ||
"description": "manages keyboard shortcuts in browser", | ||
"main": "build/lib/index.js", | ||
@@ -12,9 +12,9 @@ "scripts": { | ||
"type": "git", | ||
"url": "https://github.com/koding/keyhub.git" | ||
"url": "https://github.com/koding/shortcuts.git" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/koding/keyhub/issues" | ||
"url": "https://github.com/koding/shortcuts/issues" | ||
}, | ||
"homepage": "https://github.com/koding/keyhub", | ||
"homepage": "https://github.com/koding/shortcuts", | ||
"dependencies": { | ||
@@ -21,0 +21,0 @@ "keyconfig": "^0.3.0", |
# shortcuts | ||
manages keyboard shortcuts in browser. | ||
# license | ||
mit |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
12026
9
123
1
1
7