Permalink
Browse files

update to latest Spine

  • Loading branch information...
1 parent ef942cc commit 5f29591e4a1c089fbe6147a94041533a42fabab4 @maccman committed Apr 13, 2011
@@ -4,7 +4,7 @@
(function($){
window.Assets = Spine.Controller.create({
- scoped: ["drop"],
+ proxied: ["drop"],
handle: $("meta[name=handle]").attr("content"),
@@ -3,7 +3,7 @@
window.MessagesItem = Spine.Controller.create({
tag: "li",
- scoped: ["render", "remove"],
+ proxied: ["render", "remove"],
template: function(data){
return $("#messageTemplate").tmpl(data);
@@ -40,7 +40,7 @@ window.Messages = Spine.Controller.create({
"keydown .new textarea": "checkCreate",
},
- scoped: ["changeChannel", "addNew", "addOne", "render"],
+ proxied: ["changeChannel", "addNew", "addOne", "render"],
handle: $("meta[name=handle]").attr("content"),
@@ -10,7 +10,7 @@ window.Searches = Spine.Controller.create({
"click .item": "click"
},
- scoped: ["render", "query", "checkActive"],
+ proxied: ["render", "query", "checkActive"],
template: function(data){
return $("#searchTemplate").tmpl(data);
@@ -3,7 +3,7 @@
var Channels = Spine.Controller.create({
tag: "li",
- scoped: ["render", "remove"],
+ proxied: ["render", "remove"],
events: {
"click .destroy": "destroy",
@@ -64,7 +64,7 @@ window.Settings = Spine.Controller.create({
"submit .createChannel form": "create"
},
- scoped: ["addAll", "addOne", "active"],
+ proxied: ["addAll", "addOne", "active"],
init: function(){
Channel.bind("refresh", this.addAll);
@@ -9,7 +9,7 @@ window.Sidebar = Spine.Controller.create({
"#channels": "channels"
},
- scoped: ["change", "render"],
+ proxied: ["change", "render"],
template: function(item){
return $("#channelsTemplate").tmpl(item);
@@ -3,7 +3,7 @@
jQuery(function($){
if (typeof Juggernaut == "undefined") return;
- var JuggernautApp = Spine.Klass.create({
+ var JuggernautApp = Spine.Class.create({
init: function(){
this.socket = new Juggernaut;
this.offline = $("<div></div>")
@@ -1,6 +1,6 @@
(function(Spine, $){
-var Manager = Spine.Controller.Manager = Spine.Klass.create();
+var Manager = Spine.Controller.Manager = Spine.Class.create();
Manager.include(Spine.Events);
Manager.include({
@@ -94,7 +94,7 @@
var moduleKeywords = ["included", "extended", "setup"];
- var Klass = Spine.Klass = {
+ var Class = Spine.Class = {
initializer: function(){},
init: function(){},
@@ -159,8 +159,8 @@
}
};
- Klass.prototype.proxy = Klass.proxy;
- Klass.prototype.proxyAll = Klass.proxyAll;
+ Class.prototype.proxy = Class.proxy;
+ Class.prototype.proxyAll = Class.proxyAll;
// Models
@@ -171,7 +171,7 @@
}).toUpperCase();
};
- var Model = Spine.Model = Klass.create();
+ var Model = Spine.Model = Class.create();
Model.extend(Events);
@@ -400,6 +400,10 @@
toJSON: function(){
return(this.attributes());
},
+
+ exists: function(){
+ return(this.id && this.id in this.parent.records);
+ },
// Private
@@ -433,7 +437,7 @@
// Controllers
- var Controller = Spine.Controller = Klass.create({
+ var Controller = Spine.Controller = Class.create({
tag: "div",
initializer: function(options){
@@ -450,7 +454,7 @@
if (this.events) this.delegateEvents();
if (this.elements) this.refreshElements();
- if (this.scoped) this.proxyAll.apply(this, this.scoped);
+ if (this.proxied) this.proxyAll.apply(this, this.proxied);
},
render: function(){},
@@ -26,20 +26,24 @@ var ajaxSync = function(method, record){
};
if (Spine.Model._noSync) return;
-
- params.url = getUrl(record);
+
+ if (method == "create" && record.model)
+ params.url = getUrl(record.parent);
+ else
+ params.url = getUrl(record);
+
if (!params.url) throw("Invalid URL");
if (method == "create" || method == "update")
- params.data = JSON.stringify(record);
+ params.data = JSON.stringify(record);
if (method == "read")
params.success = function(data){
(record.refresh || record.load).call(record, data);
};
- params.error = function(e){
- record.trigger("error", e);
+ params.error = function(xhr, s, e){
+ record.trigger("ajaxError", xhr, s, e);
};
$.ajax(params);
@@ -1,4 +1,4 @@
-var Search = Spine.Klass.create();
+var Search = Spine.Class.create();
Search.include(Spine.Events);
Search.models = [];
@@ -9,7 +9,7 @@ Search.Model = {
}
};
-Search.Record = Spine.Klass.create({
+Search.Record = Spine.Class.create({
init: function(value, record){
this.value = value;
this.record = record;
View
@@ -56,21 +56,11 @@
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
- resources :messages do
- member do
- post "create"
- end
- end
-
- resources :channels do
- member do
- post "create"
- end
- end
-
- resources :assets
-
+ resources :messages
+ resources :channels
+ resources :assets
resources :app
+
match "/assets/*:id" => "assets#show"
match "/auth/twitter/callback" => "authorize#create"

0 comments on commit 5f29591

Please sign in to comment.