Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const _ = require('underscore');
- const BaseModel = require('./BaseModel');
- const UserConfig = require('./../../../config/model/User');
- module.exports = BaseModel.extend({
- defaults: UserConfig.avatars,
- idAttribute: 'default',
- url: 'Avatar',
- exportStore: function () {
- return _.clone(this.attributes);
- },
- /**
- * Create avatar urls
- *
- * m - 23x23
- * a - 68x68
- * p - 130x130
- *
- * @param response
- * @returns {{default: (*|void|XML|string), small: (*|void|XML|string), big: (*|null|Avatar)}}
- */
- parse: function (response) {
- this.avatarExists = response && response.avatar;
- return this.avatarExists ? {
- 'default': response.avatar.replace(/(\/)[a-z](_[0-9]+)/, '$1m$2'),
- small: response.avatar.replace(/(\/)[a-z](_[0-9]+)/, '$1m$2'),
- big: response.avatar
- } : {};
- },
- destroy: function() {
- this.resetToDefaults();
- this.avatarExists = false;
- return this.constructor.__super__.destroy.apply(this, arguments);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement