Comparing version 0.7.0 to 0.7.1
@@ -29,3 +29,3 @@ 'use strict'; | ||
return this.getLeft(); | ||
} else if (state === 'complted') { | ||
} else if (state === 'completed') { | ||
return this.getComplete(); | ||
@@ -32,0 +32,0 @@ } |
@@ -37,3 +37,3 @@ 'use strict'; | ||
$('#todo-list').on('dblclick', 'li', function(e) { | ||
this.emit('edittodo', $(e.target).data('id')); | ||
this.emit('edittodo', $(e.target).closest('li').data('id')); | ||
}.bind(this)); | ||
@@ -43,3 +43,3 @@ | ||
if (e.type === 'keyup') { | ||
if (e.which === ENTER_KEY_KEYCODE) { | ||
if (e.which === TodoView.ENTER_KEY_KEYCODE) { | ||
e.preventDefault(); | ||
@@ -51,5 +51,7 @@ } else { | ||
var $li = $(e.target).closest('li'); | ||
this.emit('todoedit', { | ||
id : $(e.target).parents('li').data('id'), | ||
title : $.trim($(this).val()) | ||
id : $li.data('id'), | ||
title : $.trim($li.find('.edit').val()) | ||
}); | ||
@@ -56,0 +58,0 @@ }.bind(this)); |
@@ -28,3 +28,3 @@ 'use strict'; | ||
return this.getLeft(); | ||
} else if (state === 'complted') { | ||
} else if (state === 'completed') { | ||
return this.getComplete(); | ||
@@ -31,0 +31,0 @@ } |
@@ -36,3 +36,3 @@ 'use strict'; | ||
$('#todo-list').on('dblclick', 'li', function(e) { | ||
this.emit('edittodo', $(e.target).data('id')); | ||
this.emit('edittodo', $(e.target).closest('li').data('id')); | ||
}.bind(this)); | ||
@@ -42,3 +42,3 @@ | ||
if (e.type === 'keyup') { | ||
if (e.which === ENTER_KEY_KEYCODE) { | ||
if (e.which === TodoView.ENTER_KEY_KEYCODE) { | ||
e.preventDefault(); | ||
@@ -50,5 +50,7 @@ } else { | ||
var $li = $(e.target).closest('li'); | ||
this.emit('todoedit', { | ||
id : $(e.target).parents('li').data('id'), | ||
title : $.trim($(this).val()) | ||
id : $li.data('id'), | ||
title : $.trim($li.find('.edit').val()) | ||
}); | ||
@@ -55,0 +57,0 @@ }.bind(this)); |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"repository" : { | ||
@@ -13,0 +13,0 @@ "type" : "git", |
@@ -20,3 +20,3 @@ // | ||
var VERSION = "0.7.0"; | ||
var VERSION = "0.7.1"; | ||
@@ -135,3 +135,4 @@ // Global counter for all events in all modules (including mixed in objects) | ||
if (includeEvents) { | ||
// If this class has events add a GUID as well | ||
if (this.on) { | ||
_.addGuid( this, true ); | ||
@@ -184,3 +185,5 @@ } | ||
var handlers = _.eventHandlers[explicitGuid][type]; | ||
// #30: make a local copy of handlers to prevent problems with | ||
// unbinding the event while unwinding the loop | ||
var handlers = slice.call(_.eventHandlers[explicitGuid][type]); | ||
@@ -397,3 +400,6 @@ for (var i = 0, l = handlers.length; i < l; i++) { | ||
_.Module = function(){}; | ||
_.Module = function() { | ||
} | ||
_.Module.prototype = { | ||
@@ -554,3 +560,3 @@ // create() is deprecated from 0.8.0 | ||
"extend" : function() { | ||
return _.extendThis.apply(_.Moduel, arguments); | ||
return _.extendThis.apply(_.Module.prototype, arguments); | ||
}, | ||
@@ -597,2 +603,2 @@ | ||
} | ||
})(); | ||
})(); |
@@ -1,2 +0,2 @@ | ||
/*! Stapes.js v0.7 < http://hay.github.com/stapes > */ | ||
(function(){"use strict";var a="0.7.0",b=1;if(!Object.create)var c=function(){};var d=Array.prototype.slice,e={attributes:{},eventHandlers:{"-1":{}},guid:-1,addEvent:function(a){e.eventHandlers[a.guid][a.type]||(e.eventHandlers[a.guid][a.type]=[]),e.eventHandlers[a.guid][a.type].push({guid:a.guid,handler:a.handler,scope:a.scope,type:a.type})},addEventHandler:function(a,b,c){var d={},f;typeof a=="string"?(f=c||!1,d[a]=b):(f=b||!1,d=a);for(var g in d){var h=d[g],i=g.split(" ");for(var j=0,k=i.length;j<k;j++){var l=i[j];e.addEvent.call(this,{guid:this._guid||this._.guid,handler:h,scope:f,type:l})}}},addGuid:function(a,c){if(!a._guid||!!c)a._guid=b++,e.attributes[a._guid]={},e.eventHandlers[a._guid]={}},attr:function(a){return e.attributes[a]},clone:function(a){return e.extend({},a)},create:function(a){if(Object.create)return Object.create(a);c.prototype=a;return new c},createSubclass:function(a,b){function g(){if(this instanceof g)b&&e.addGuid(this,!0),d.apply(this,arguments);else throw new Error("Please use 'new' when initializing Stapes classes")}a=a||{},b=b||!1;var c=a.superclass.prototype,d=a.hasOwnProperty("constructor")?a.constructor:function(){};b&&e.extend(c,f),g.prototype=e.create(c),g.prototype.constructor=g,e.extend(g,{extend:function(){return e.extendThis.apply(this,arguments)},parent:c,proto:function(){return e.extendThis.apply(this.prototype,arguments)},subclass:function(a){a=a||{},a.superclass=this;return e.createSubclass(a)}});for(var h in a)h!=="constructor"&&h!=="superclass"&&(g.prototype[h]=a[h]);return g},emitEvents:function(a,b,c,d){c=c||!1,d=d||this._guid;var f=e.eventHandlers[d][a];for(var g=0,h=f.length;g<h;g++){var i=e.extend({},f[g]),j=i.scope?i.scope:this;c&&(i.type=c),i.scope=j,i.handler.call(i.scope,b,i)}},extend:function(){var a=d.call(arguments),b=a.shift();for(var c=0,e=a.length;c<e;c++){var f=a[c];for(var g in f)b[g]=f[g]}return b},extendThis:function(){var a=d.call(arguments);a.unshift(this);return e.extend.apply(this,a)},makeUuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=Math.random()*16|0,c=a=="x"?b:b&3|8;return c.toString(16)})},removeAttribute:function(a,b){b=b||!1;var c=e.trim(a).split(" ");for(var d=0,f=c.length;d<f;d++){var g=e.trim(c[d]);g&&(delete e.attr(this._guid)[g],b||(this.emit("change",g),this.emit("change:"+g),this.emit("remove",g),this.emit("remove:"+g)))}},removeEventHandler:function(a,b){var c=e.eventHandlers[this._guid];if(a&&b){c=c[a];if(!c)return;for(var d=0,f=c.length,g;d<f;d++)g=c[d].handler,g&&g===b&&(c.splice(d--,1),f--)}else a?delete c[a]:e.eventHandlers[this._guid]={}},setAttribute:function(a,b,c){c=c||!1;var d=this.has(a),f=e.attr(this._guid)[a];if(b!==f){e.attr(this._guid)[a]=b;if(c)return;this.emit("change",a),this.emit("change:"+a,b);var g={key:a,newValue:b,oldValue:f||null};this.emit("mutate",g),this.emit("mutate:"+a,g);var h=d?"update":"create";this.emit(h,a),this.emit(h+":"+a,b)}},trim:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},typeOf:function(a){return a===null||typeof a=="undefined"?String(a):Object.prototype.toString.call(a).replace(/\[object |\]/g,"").toLowerCase()},updateAttribute:function(a,b,c){var d=this.get(a);e.typeOf(d)==="object"&&(d=e.clone(d));var f=b.call(this,d,a);e.setAttribute.call(this,a,f,c||!1)}},f={emit:function(a,b){b=typeof b=="undefined"?null:b;var c=a.split(" ");for(var d=0,f=c.length;d<f;d++){var g=c[d];e.eventHandlers[-1].all&&e.emitEvents.call(this,"all",b,g,-1),e.eventHandlers[-1][g]&&e.emitEvents.call(this,g,b,g,-1),typeof this._guid=="number"&&(e.eventHandlers[this._guid].all&&e.emitEvents.call(this,"all",b,g),e.eventHandlers[this._guid][g]&&e.emitEvents.call(this,g,b))}},off:function(){e.removeEventHandler.apply(this,arguments)},on:function(){e.addEventHandler.apply(this,arguments)}};e.Module=function(){},e.Module.prototype={create:function(){throw new Error("".concat("create() on Stapes modules no longer works from 0.8.0. ","Check the docs."))},each:function(a,b){var c=e.attr(this._guid);for(var d in c){var f=c[d];a.call(b||this,f,d)}},extend:function(){return e.extendThis.apply(this,arguments)},filter:function(a){var b=[],c=e.attr(this._guid);for(var d in c)a.call(this,c[d],d)&&b.push(c[d]);return b},get:function(a){if(typeof a=="string")return this.has(a)?e.attr(this._guid)[a]:null;if(typeof a=="function"){var b=this.filter(a);return b.length?b[0]:null}},getAll:function(){return e.clone(e.attr(this._guid))},getAllAsArray:function(){var a=[],b=e.attr(this._guid);for(var c in b){var d=b[c];e.typeOf(d)==="object"&&!d.id&&(d.id=c),a.push(d)}return a},has:function(a){return typeof e.attr(this._guid)[a]!="undefined"},map:function(a,b){var c=[];this.each(function(d,e){c.push(a.call(b||this,d,e))},b||this);return c},push:function(a,b){if(e.typeOf(a)==="array")for(var c=0,d=a.length;c<d;c++)e.setAttribute.call(this,e.makeUuid(),a[c]);else e.setAttribute.call(this,e.makeUuid(),a,b||!1);return this},remove:function(a,b){typeof a=="function"?this.each(function(c,d){a(c)&&e.removeAttribute.call(this,d,b)}):e.removeAttribute.call(this,a,b||!1);return this},set:function(a,b,c){if(typeof a=="object")for(var d in a)e.setAttribute.call(this,d,a[d]);else e.setAttribute.call(this,a,b,c||!1);return this},size:function(){var a=0,b=e.attr(this._guid);for(var c in b)a++;return a},update:function(a,b,c){typeof a=="string"?e.updateAttribute.call(this,a,b,c||!1):typeof a=="function"&&this.each(function(b,c){e.updateAttribute.call(this,c,a)});return this}};var g={_:e,create:function(){var a=e.create(e.Module.prototype);e.addGuid(a,!0),g.mixinEvents(a);return a},extend:function(){return e.extendThis.apply(e.Moduel,arguments)},mixinEvents:function(a){a=a||{},e.addGuid(a);return e.extend(a,f)},on:function(){e.addEventHandler.apply(this,arguments)},subclass:function(a,b){b=b||!1,a=a||{},a.superclass=b?function(){}:e.Module;return e.createSubclass(a,!b)},version:a};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=g),exports.Stapes=g):typeof define=="function"&&define.amd?define(function(){return g}):window.Stapes=g})() | ||
/*! Stapes.js v0.7.1 < http://hay.github.com/stapes > */ | ||
(function(){"use strict";var a="0.7.1",b=1;if(!Object.create)var c=function(){};var d=Array.prototype.slice,e={attributes:{},eventHandlers:{"-1":{}},guid:-1,addEvent:function(a){e.eventHandlers[a.guid][a.type]||(e.eventHandlers[a.guid][a.type]=[]),e.eventHandlers[a.guid][a.type].push({guid:a.guid,handler:a.handler,scope:a.scope,type:a.type})},addEventHandler:function(a,b,c){var d={},f;typeof a=="string"?(f=c||!1,d[a]=b):(f=b||!1,d=a);for(var g in d){var h=d[g],i=g.split(" ");for(var j=0,k=i.length;j<k;j++){var l=i[j];e.addEvent.call(this,{guid:this._guid||this._.guid,handler:h,scope:f,type:l})}}},addGuid:function(a,c){if(!a._guid||!!c)a._guid=b++,e.attributes[a._guid]={},e.eventHandlers[a._guid]={}},attr:function(a){return e.attributes[a]},clone:function(a){return e.extend({},a)},create:function(a){if(Object.create)return Object.create(a);c.prototype=a;return new c},createSubclass:function(a,b){function g(){if(this instanceof g)this.on&&e.addGuid(this,!0),d.apply(this,arguments);else throw new Error("Please use 'new' when initializing Stapes classes")}a=a||{},b=b||!1;var c=a.superclass.prototype,d=a.hasOwnProperty("constructor")?a.constructor:function(){};b&&e.extend(c,f),g.prototype=e.create(c),g.prototype.constructor=g,e.extend(g,{extend:function(){return e.extendThis.apply(this,arguments)},parent:c,proto:function(){return e.extendThis.apply(this.prototype,arguments)},subclass:function(a){a=a||{},a.superclass=this;return e.createSubclass(a)}});for(var h in a)h!=="constructor"&&h!=="superclass"&&(g.prototype[h]=a[h]);return g},emitEvents:function(a,b,c,f){c=c||!1,f=f||this._guid;var g=d.call(e.eventHandlers[f][a]);for(var h=0,i=g.length;h<i;h++){var j=e.extend({},g[h]),k=j.scope?j.scope:this;c&&(j.type=c),j.scope=k,j.handler.call(j.scope,b,j)}},extend:function(){var a=d.call(arguments),b=a.shift();for(var c=0,e=a.length;c<e;c++){var f=a[c];for(var g in f)b[g]=f[g]}return b},extendThis:function(){var a=d.call(arguments);a.unshift(this);return e.extend.apply(this,a)},makeUuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=Math.random()*16|0,c=a=="x"?b:b&3|8;return c.toString(16)})},removeAttribute:function(a,b){b=b||!1;var c=e.trim(a).split(" ");for(var d=0,f=c.length;d<f;d++){var g=e.trim(c[d]);g&&(delete e.attr(this._guid)[g],b||(this.emit("change",g),this.emit("change:"+g),this.emit("remove",g),this.emit("remove:"+g)))}},removeEventHandler:function(a,b){var c=e.eventHandlers[this._guid];if(a&&b){c=c[a];if(!c)return;for(var d=0,f=c.length,g;d<f;d++)g=c[d].handler,g&&g===b&&(c.splice(d--,1),f--)}else a?delete c[a]:e.eventHandlers[this._guid]={}},setAttribute:function(a,b,c){c=c||!1;var d=this.has(a),f=e.attr(this._guid)[a];if(b!==f){e.attr(this._guid)[a]=b;if(c)return;this.emit("change",a),this.emit("change:"+a,b);var g={key:a,newValue:b,oldValue:f||null};this.emit("mutate",g),this.emit("mutate:"+a,g);var h=d?"update":"create";this.emit(h,a),this.emit(h+":"+a,b)}},trim:function(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},typeOf:function(a){return a===null||typeof a=="undefined"?String(a):Object.prototype.toString.call(a).replace(/\[object |\]/g,"").toLowerCase()},updateAttribute:function(a,b,c){var d=this.get(a);e.typeOf(d)==="object"&&(d=e.clone(d));var f=b.call(this,d,a);e.setAttribute.call(this,a,f,c||!1)}},f={emit:function(a,b){b=typeof b=="undefined"?null:b;var c=a.split(" ");for(var d=0,f=c.length;d<f;d++){var g=c[d];e.eventHandlers[-1].all&&e.emitEvents.call(this,"all",b,g,-1),e.eventHandlers[-1][g]&&e.emitEvents.call(this,g,b,g,-1),typeof this._guid=="number"&&(e.eventHandlers[this._guid].all&&e.emitEvents.call(this,"all",b,g),e.eventHandlers[this._guid][g]&&e.emitEvents.call(this,g,b))}},off:function(){e.removeEventHandler.apply(this,arguments)},on:function(){e.addEventHandler.apply(this,arguments)}};e.Module=function(){},e.Module.prototype={create:function(){throw new Error("".concat("create() on Stapes modules no longer works from 0.8.0. ","Check the docs."))},each:function(a,b){var c=e.attr(this._guid);for(var d in c){var f=c[d];a.call(b||this,f,d)}},extend:function(){return e.extendThis.apply(this,arguments)},filter:function(a){var b=[],c=e.attr(this._guid);for(var d in c)a.call(this,c[d],d)&&b.push(c[d]);return b},get:function(a){if(typeof a=="string")return this.has(a)?e.attr(this._guid)[a]:null;if(typeof a=="function"){var b=this.filter(a);return b.length?b[0]:null}},getAll:function(){return e.clone(e.attr(this._guid))},getAllAsArray:function(){var a=[],b=e.attr(this._guid);for(var c in b){var d=b[c];e.typeOf(d)==="object"&&!d.id&&(d.id=c),a.push(d)}return a},has:function(a){return typeof e.attr(this._guid)[a]!="undefined"},map:function(a,b){var c=[];this.each(function(d,e){c.push(a.call(b||this,d,e))},b||this);return c},push:function(a,b){if(e.typeOf(a)==="array")for(var c=0,d=a.length;c<d;c++)e.setAttribute.call(this,e.makeUuid(),a[c]);else e.setAttribute.call(this,e.makeUuid(),a,b||!1);return this},remove:function(a,b){typeof a=="function"?this.each(function(c,d){a(c)&&e.removeAttribute.call(this,d,b)}):e.removeAttribute.call(this,a,b||!1);return this},set:function(a,b,c){if(typeof a=="object")for(var d in a)e.setAttribute.call(this,d,a[d]);else e.setAttribute.call(this,a,b,c||!1);return this},size:function(){var a=0,b=e.attr(this._guid);for(var c in b)a++;return a},update:function(a,b,c){typeof a=="string"?e.updateAttribute.call(this,a,b,c||!1):typeof a=="function"&&this.each(function(b,c){e.updateAttribute.call(this,c,a)});return this}};var g={_:e,create:function(){var a=e.create(e.Module.prototype);e.addGuid(a,!0),g.mixinEvents(a);return a},extend:function(){return e.extendThis.apply(e.Module.prototype,arguments)},mixinEvents:function(a){a=a||{},e.addGuid(a);return e.extend(a,f)},on:function(){e.addEventHandler.apply(this,arguments)},subclass:function(a,b){b=b||!1,a=a||{},a.superclass=b?function(){}:e.Module;return e.createSubclass(a,!b)},version:a};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=g),exports.Stapes=g):typeof define=="function"&&define.amd?define(function(){return g}):window.Stapes=g})() |
@@ -352,2 +352,40 @@ var undef; | ||
test("events on subclasses", function() { | ||
expect(3); | ||
var Parent = Stapes.subclass({ | ||
constructor : function(id) { | ||
this.id = id; | ||
}, | ||
getId : function() { | ||
this.emit('id', this.id); | ||
} | ||
}); | ||
var Child = Parent.subclass({ | ||
constructor : Parent.prototype.constructor | ||
}); | ||
var parent = new Parent('parent'); | ||
var parent2 = new Parent('parent2'); | ||
var child = new Child('child'); | ||
parent.on('id', function(id) { | ||
ok(id === 'parent', 'id of parent should be parent'); | ||
}); | ||
parent2.on('id', function(id) { | ||
ok(id === 'parent2', 'id of parent2 should be parent2'); | ||
}); | ||
child.on('id', function(id) { | ||
ok(id === 'child', 'id of child should be child'); | ||
}); | ||
parent.getId(); | ||
parent2.getId(); | ||
child.getId(); | ||
}); | ||
test("chaining", function() { | ||
@@ -362,2 +400,17 @@ var module = Stapes.create().set('foo', true); | ||
ok(!!module.get && module.size() === 1, "push() should return the object"); | ||
}); | ||
test("Extending Stapes (plugins)", function() { | ||
expect(1); | ||
Stapes.extend({ | ||
foo : function() { | ||
ok(true, "New function can be called"); | ||
} | ||
}); | ||
var Module = Stapes.subclass(); | ||
var module = new Module(); | ||
module.foo(); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
432522
43
4249
3