Permalink
Browse files

update assets

  • Loading branch information...
1 parent 22453cb commit 4cee17e87d486d95d277a27e147acd0b25158b89 @maccman committed Apr 22, 2011
View
@@ -51,7 +51,10 @@
#tabs li {
float: left;
padding: 10px;
+ cursor: pointer;
}
+
+ #tabs li.active { color: red; }
#main div {
display: none;
View
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <title>Pubsub</title>
+
+ <script src="../lib/jquery.js" type="text/javascript" charset="utf-8"></script>
+ <script type="text/javascript" charset="utf-8">
+ var exports = this;
+
+ (function($){
+
+ exports.Events = {
+ bind: function(ev, callback) {
+ var evs = ev.split(" ");
+ var calls = this._callbacks || (this._callbacks = {});
+
+ for (var i=0; i < evs.length; i++)
+ (this._callbacks[evs[i]] || (this._callbacks[evs[i]] = [])).push(callback);
+
+ return this;
+ },
+
+ trigger: function() {
+ var args = $.makeArray(arguments);
+ var ev = args.shift();
+
+ var list, calls, i, l;
+ if (!(calls = this._callbacks)) return this;
+ if (!(list = this._callbacks[ev])) return this;
+
+ for (i = 0, l = list.length; i < l; i++)
+ if (list[i].apply(this, args) === false)
+ return false;
+ return this;
+ }
+ };
+
+ })(jQuery);
+ </script>
+
+ <script type="text/javascript" charset="utf-8">
+ Events.bind("hail", function(type){
+ alert("Long live the " + type)
+ });
+
+ Events.trigger("hail", "Users");
+ </script>
+</head>
+<body>
+</body>
+</html>
@@ -8,10 +8,10 @@ jQuery(function($){
},
init: function(){
- this.sidebar = Sidebar.inst({el: this.sidebarEl});
- this.contact = Contacts.inst({el: this.contactsEl});
+ this.sidebar = Sidebar.init({el: this.sidebarEl});
+ this.contact = Contacts.init({el: this.contactsEl});
Contact.fetch();
}
- }).inst();
+ }).init();
});
@@ -1,7 +1,7 @@
jQuery(function($){
window.Sidebar = Spine.Controller.create({
- // Create instance variables:
+ // Create initance variables:
// this.items //=> <ul></ul>
// this.input //=> <input />
elements: {
@@ -26,7 +26,7 @@ window.Sidebar = Spine.Controller.create({
},
init: function(){
- this.list = Spine.List.inst({
+ this.list = Spine.List.init({
el: this.items,
template: this.template
});
@@ -7,21 +7,14 @@
Spine = this.Spine = {};
}
- Spine.version = "0.0.2";
+ Spine.version = "0.0.3";
- var $ = this.jQuery || this.Zepto;
+ var $ = Spine.$ = this.jQuery || this.Zepto;
- var makeArray = function(args){
+ var makeArray = Spine.makeArray = function(args){
return Array.prototype.slice.call(args, 0);
};
- var dupHash = function(hash){
- var result = {};
- for(var name in hash)
- result[name] = hash[name];
- return result;
- };
-
var Events = Spine.Events = {
bind: function(ev, callback) {
var evs = ev.split(" ");
@@ -92,12 +85,12 @@
return new F();
};
- var moduleKeywords = ["included", "extended", "setup"];
+ var moduleKeywords = ["included", "extended"];
var Class = Spine.Class = {
- initializer: function(){},
- init: function(){},
-
+ inherited: function(){},
+ created: function(){},
+
prototype: {
initializer: function(){},
init: function(){}
@@ -110,19 +103,19 @@
if (include) object.include(include);
if (extend) object.extend(extend);
-
- object.initializer.apply(object, arguments);
- object.init.apply(object, arguments);
+
+ object.created();
+ this.inherited(object);
return object;
},
- inst: function(){
- var instance = Object.create(this.prototype);
- instance.parent = this;
+ init: function(){
+ var initance = Object.create(this.prototype);
+ initance.parent = this;
- instance.initializer.apply(instance, arguments);
- instance.init.apply(instance, arguments);
- return instance;
+ initance.initializer.apply(initance, arguments);
+ initance.init.apply(initance, arguments);
+ return initance;
},
proxy: function(func){
@@ -143,7 +136,7 @@
if (moduleKeywords.indexOf(key) == -1)
this.fn[key] = obj[key];
- var included = obj.included || obj.setup;
+ var included = obj.included;
if (included) included.apply(this);
return this;
},
@@ -153,14 +146,15 @@
if (moduleKeywords.indexOf(key) == -1)
this[key] = obj[key];
- var extended = obj.extended || obj.setup;
+ var extended = obj.extended;
if (extended) extended.apply(this);
return this;
}
};
Class.prototype.proxy = Class.proxy;
Class.prototype.proxyAll = Class.proxyAll;
+ Class.inst = Class.init;
// Models
@@ -185,7 +179,7 @@
};
Model.extend({
- initializer: function(){
+ created: function(sub){
this.records = {};
this.attributes = [];
@@ -218,7 +212,7 @@
this.records = {};
for (var i=0, il = values.length; i < il; i++) {
- var record = this.inst(values[i]);
+ var record = this.init(values[i]);
record.newRecord = false;
this.records[record.id] = record;
}
@@ -287,7 +281,7 @@
},
create: function(atts){
- var record = this.inst(atts);
+ var record = this.init(atts);
record.save();
return record;
},
@@ -388,7 +382,7 @@
},
dup: function(){
- var result = this.parent.inst(this.attributes());
+ var result = this.parent.init(this.attributes());
result.newRecord = this.newRecord;
return result;
},
@@ -437,6 +431,8 @@
// Controllers
+ var eventSplitter = /^(\w+)\s*(.*)$/;
+
var Controller = Spine.Controller = Class.create({
tag: "div",
@@ -456,21 +452,17 @@
if (this.elements) this.refreshElements();
if (this.proxied) this.proxyAll.apply(this, this.proxied);
},
-
- render: function(){},
-
+
$: function(selector){
return $(selector, this.el);
},
-
- eventSplitter: /^(\w+)\s*(.*)$/,
-
+
delegateEvents: function(){
for (var key in this.events) {
var methodName = this.events[key];
var method = this.proxy(this[methodName]);
- var match = key.match(this.eventSplitter);
+ var match = key.match(eventSplitter);
var eventName = match[1], selector = match[2];
if (selector === '') {
@@ -495,10 +487,11 @@
Controller.include(Events);
Controller.include(Log);
- Spine.App = Spine.Controller.create({
+ Spine.App = Controller.create({
create: function(properties){
this.parent.include(properties);
+ return this;
}
- }).inst();
- Spine.Controller.fn.App = Spine.App;
+ }).init();
+ Controller.fn.App = Spine.App;
})();
@@ -1,4 +1,4 @@
-(function(){
+(function(Spine, $){
Spine.List = Spine.Controller.create({
events: {
@@ -39,4 +39,4 @@
}
});
-})();
+})(Spine, Spine.$);
@@ -25,7 +25,7 @@
};
Spine.Model.Filter = {
- setup: function(){
+ extended: function(){
this.extend(extend);
this.include(include);
}
View
@@ -1 +1,22 @@
-Model
+#Spine Todos
+
+Spine Todos is an example application for the [Spine](http://github.com/maccman/spine) JavaScript library.
+
+#Live Demo
+
+[Checkout the live demo](http://maccman.github.com/spine.todos/) in Safari/Chrome.
+
+#Features
+
+* Todo CRUD
+* Local Storage persistence
+
+#Usage
+
+1. Checkout the Git repository
+1. Open index.html in Safari/Chrome
+1. Check out app/application.js and app/models to see how everything works
+
+#Screenshot
+
+![Todos](https://lh4.googleusercontent.com/_IH1OempnqUc/TZF16JZSTlI/AAAAAAAABKM/ojAu7OBqXp8/s800/Screen%20shot%202011-03-29%20at%2019.01.44.png)
Oops, something went wrong.

0 comments on commit 4cee17e

Please sign in to comment.