/public/js/collections/collections.js
JavaScript | 55 lines | 45 code | 10 blank | 0 comment | 4 complexity | e454cc80c71c232b049077deb5c5c864 MD5 | raw file
- App.collections = {};
- App.collections.SetStore = Backbone.Collection.extend({
- model: App.models.Set,
- fetched: false,
- url: '/set',
- initialize: function() {
- },
- getAll: function() {
- if (this.models.length === 0) {
- return null;
- }
- return this.filter(function(set) {
- return true;
- });
- },
- getById: function(setId) {
- return this.find(function(set) {
- return set.get('id') == setId;
- });
- }
- });
- App.collections.PhotoStore = Backbone.Collection.extend({
- model: App.models.Photo,
- setId: null,
- fetched: false,
- url: function() {
- if (!this.setId) {
- throw "Need to set a setId on the collection before fetching";
- }
- return '/photo?set_id=' + this.setId;
- },
- initialize: function() {
- },
- comparator: function(photo) {
- return Date.parseExact(photo.get('date_taken'), 'HH:mm:ss dd-MM-yyyy');
- },
- getAll: function() {
- if (this.models.length === 0) {
- return null;
- }
- return this.filter(function(set) {
- return true;
- });
- }
- });