Comparing version 0.0.3 to 0.1.0
{ | ||
"author": "Brian M. Carlson", | ||
"name": "xo", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"repository": { | ||
@@ -9,5 +9,4 @@ "url": "https://github.com/brianc/xo.git" | ||
"scripts": { | ||
"compile": "node_modules/.bin/coffee -j xo.js -c src/index.coffee", | ||
"compile": "./node_modules/.bin/coffee -j xo.js -c src/index.coffee", | ||
"prepublish": "npm run-script compile", | ||
"postpublish": "rm -r package", | ||
"pretest": "npm run-script compile", | ||
@@ -27,4 +26,4 @@ "test": "mocha", | ||
"filed": "*", | ||
"jquery-browser": "*", | ||
"uglify-js": "*" | ||
"uglify-js": "*", | ||
"jquery": "*" | ||
}, | ||
@@ -31,0 +30,0 @@ "engines": { |
94
xo.js
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.3.3 | ||
// Generated by CoffeeScript 1.4.0 | ||
(function() { | ||
var xo, | ||
var $, xo, | ||
__slice = [].slice, | ||
@@ -9,7 +9,10 @@ __hasProp = {}.hasOwnProperty, | ||
xo = { | ||
handlers: {}, | ||
on: function(name, handler) { | ||
_handlers: {}, | ||
handlers: function(name) { | ||
var _base; | ||
return !((_base = xo.handlers)[name] || (_base[name] = [])).push(handler); | ||
return (_base = xo._handlers)[name] || (_base[name] = []); | ||
}, | ||
on: function(name, handler) { | ||
return !xo.handlers(name).push(handler); | ||
}, | ||
emit: function() { | ||
@@ -20,3 +23,3 @@ var args, handler, name; | ||
var _i, _len, _ref, _results; | ||
_ref = xo.handlers[name] || []; | ||
_ref = xo.handlers(name); | ||
_results = []; | ||
@@ -30,33 +33,32 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
}, | ||
removeListener: function(name, listener) { | ||
var handler, _i, _len, _ref, _results; | ||
_ref = xo.handlers[name]; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
handler = _ref[_i]; | ||
if (listener === handler) { | ||
_results.push(delete xo.handlers[name]); | ||
} else { | ||
_results.push(void 0); | ||
} | ||
removeListener: function(name, handler) { | ||
var t, _ref; | ||
if ((t = xo.handlers(name).indexOf(handler)) > -1) { | ||
return ([].splice.apply(xo.handlers(name), [t, t - t + 1].concat(_ref = [])), _ref); | ||
} | ||
return _results; | ||
} | ||
}; | ||
if ((typeof module !== "undefined" && module !== null ? module.exports : void 0) != null) { | ||
module.exports = xo; | ||
$ = require('jquery'); | ||
} else { | ||
window.xo = xo; | ||
$ = window.$; | ||
} | ||
xo.Agent = (function() { | ||
function Agent(config) { | ||
var handler, key, name, val, _ref, _ref1; | ||
this.config = config; | ||
_ref = this.config; | ||
for (key in _ref) { | ||
val = _ref[key]; | ||
var handler, key, name, val, _ref; | ||
for (key in config) { | ||
val = config[key]; | ||
this[key] = val; | ||
} | ||
_ref1 = this.on; | ||
for (name in _ref1) { | ||
handler = _ref1[name]; | ||
this.__handlers || (this.__handlers = {}); | ||
xo.on(name, this.__handlers[name] = handler.bind(this)); | ||
this.__handlers = {}; | ||
_ref = this.on; | ||
for (name in _ref) { | ||
handler = _ref[name]; | ||
this.__handlers[name] = handler.bind(this); | ||
xo.on(name, this.__handlers[name]); | ||
} | ||
@@ -86,6 +88,8 @@ } | ||
var handler, name, _ref; | ||
this.config = config; | ||
View.__super__.constructor.call(this, this.config); | ||
if (this.$) { | ||
this.children = []; | ||
View.__super__.constructor.call(this, config); | ||
if (typeof this.$ === "string") { | ||
this.el = $(this.$); | ||
} else if (typeof this.$ === "function") { | ||
this.el = $(this.$.call(this)); | ||
} | ||
@@ -99,2 +103,24 @@ _ref = this.bind; | ||
View.prototype.append = function(selector, child) { | ||
var el; | ||
if (child != null) { | ||
el = this.el.find(selector); | ||
} else { | ||
el = this.el; | ||
child = selector; | ||
} | ||
this.children.push(child); | ||
return el.append(child.el); | ||
}; | ||
View.prototype.destroy = function() { | ||
var child, _i, _len, _ref; | ||
_ref = this.children; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
child = _ref[_i]; | ||
child.destroy(); | ||
} | ||
return View.__super__.destroy.call(this); | ||
}; | ||
return View; | ||
@@ -104,8 +130,2 @@ | ||
if ((typeof module !== "undefined" && module !== null ? module.exports : void 0) != null) { | ||
module.exports = xo; | ||
} else { | ||
window.xo = xo; | ||
} | ||
}).call(this); |
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
4177
110
0