define(function (require) { var can = require('can'); var Contact = can.Model({ findAll: 'GET /contacts', create : "POST /contacts", update : "PUT /contacts/{id}", destroy : "DELETE /contacts/{id}" },{}); Contact.List = can.Model.List({ filter: function(category){ this.attr('length'); var contacts = new Contact.List([]); this.each(function(contact, i){ if(category === 'all' || category === contact.attr('category')) { contacts.push(contact) } }) return contacts; }, count: function(category) { return this.filter(category).length; } }); return Contact; });
import can from 'can'; export default can.Model.extend({ findAll: 'GET /chores', findOne: 'GET /chores/{id}' }, {});
export default can.Model.extend({}, { define : { operation : { set : function(val){ var typeAndOp = val.split(":"); var type = typeAndOp.shift(); var op = typeAndOp.shift(); this.attr({ is_negated: (type !== 'pos'), op : op }); }, get : function(){ var type = this.attr('is_negated') ? 'neg' : 'pos'; var op = this.attr('op'); return [type, op].join(':'); } }, attr_name : { value : 'content' }, op : { value : 'contains_all', set : function(val){ return val; } }, is_negated : { value : false } } });
import moment from "moment"; var Bit = can.Model.extend({ resource : '/api/v3/embeds/{hubId}/entities', }, { formattedThreadUpdatedAt : function(){ return moment(this.attr('thread_updated_at')).format('LL'); }, isTumblrImage : function(){ return this.isPhoto() && this.isTumblr(); }, isInstagramImage : function(){ return this.isPhoto() && this.attr('feed_name') === 'instagram'; }, isPhoto : function(){ return this.attr('type_name') === 'photo'; }, isTumblr : function(){ return this.attr('feed_name') === 'tumblr'; }, isTwitterFollow : function(){ return this.attr('feed_name') === 'twitter' && this.attr('type_name') === 'follow'; }, isYoutube : function(){ return this.attr('feed_name') === 'youtube'; }, youtubeEmbedURL : function(){ return this.attr('url').replace(/watch\?v=/, 'embed/'); } }); Bit.ACTIONS = ['pin', 'unpin', 'approve', 'disapprove'];
import can from "can"; import "can/list/promise/"; var EntityDecision = can.Model.extend({ findAll : '/api/v4/embeds/{hubId}/entities/stats' }, { dec: function(){ this.attr('count', this.attr('count') - 1); }, inc: function(){ this.attr('count', this.attr('count') + 1); } }); EntityDecision.List = EntityDecision.List.extend({ getById : function(id){ var length = this.attr('length'); for(var i = 0; i < length; i++){ if(this[i].id === id){ return this[i]; } } } }); export default EntityDecision;
points.unshift(null); } } return points; }; var alphaVersion = function(color){ return 'rgba' + color.substring(3, color.length - 1) + ', .2)'; }; var Analytics = can.Model.extend({ findAll : '/api/v3/analytics?source_type={sourceType}&resolution={resolution}&owner_id={ownerId}' }, { define : { source : { Type: Service } } }); Analytics.List = Analytics.List.extend({ graphData : function(type){ var length = this.attr('length'); var serviceTimepoints = {}; var service; var timepoints; var isLongest = false; var data = []; var longestPointsLengthLabels = []; var i;
import can from "can"; export default can.Model.extend({ findAll : '/api/v3/services/suggestions/{service}?brand_identity_id={brandIdentityId}' }, {});