Created
June 13, 2012 05:23
-
-
Save davidmarble/2922029 to your computer and use it in GitHub Desktop.
javascript version of https://github.com/documentcloud/backbone/issues/1402
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Feed, FeedItem, FeedItems, Feeds, | |
__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; }; | |
Feeds = (function(_super) { | |
__extends(Feeds, _super); | |
Feeds.prototype.model = Feed; | |
Feeds.prototype.url = '/feeds/'; | |
function Feeds(models, options) { | |
if (true) { | |
this.params = _.extend({}, options.params); | |
} else { | |
this.params = {}; | |
} | |
Feeds.__super__.constructor.apply(this, arguments); | |
} | |
return Feeds; | |
})(Collection); | |
Feed = (function(_super) { | |
__extends(Feed, _super); | |
function Feed(attrs, options) { | |
this.add_nested = false; | |
Feed.__super__.constructor.apply(this, arguments); | |
} | |
Feed.prototype.parse = function(response, xhr) { | |
var opts; | |
if (!this.spurs) { | |
opts = { | |
params: _.extend(this.collection.params, { | |
some_param: overridden | |
}) | |
}; | |
this.feed_items = new FeedItems(null, opts); | |
} | |
this.feed_items[this.add_nested ? 'add' : 'reset'](this.feed_items.parse(response.items, xhr)); | |
delete response.items; | |
return response; | |
}; | |
return Feed; | |
})(Model); | |
FeedItems = (function(_super) { | |
__extends(FeedItems, _super); | |
function FeedItems() { | |
return FeedItems.__super__.constructor.apply(this, arguments); | |
} | |
FeedItems.prototype.model = FeedItem; | |
FeedItems.prototype.url = '/feed/'; | |
return FeedItems; | |
})(Collection); | |
FeedItem = (function(_super) { | |
__extends(FeedItem, _super); | |
function FeedItem() { | |
return FeedItem.__super__.constructor.apply(this, arguments); | |
} | |
return FeedItem; | |
})(Model); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment