Initial commit
This commit is contained in:
40
lib/assets/javascripts/builder/data/static-asset-model.js
Executable file
40
lib/assets/javascripts/builder/data/static-asset-model.js
Executable file
@@ -0,0 +1,40 @@
|
||||
var _ = require('underscore');
|
||||
var AssetModel = require('./asset-model');
|
||||
|
||||
module.exports = AssetModel.extend({
|
||||
|
||||
defaults: {
|
||||
ext: 'svg',
|
||||
folder: 'maki-icons',
|
||||
host: 'https://s3.amazonaws.com',
|
||||
bucket: 'com.cartodb.users-assets.production',
|
||||
kind: 'marker',
|
||||
name: '',
|
||||
public_url: '',
|
||||
size: '18',
|
||||
state: 'idle'
|
||||
},
|
||||
|
||||
getURLFor: function (name) {
|
||||
var url = this.get('host') + '/' + this.get('bucket') + '/' + this.get('folder') + '/' + name;
|
||||
var size = this.get('size') ? '-' + this.get('size') : '';
|
||||
return url + size + '.' + this.get('ext');
|
||||
},
|
||||
|
||||
toJSON: function () {
|
||||
var attributes = _.clone(this.attributes);
|
||||
|
||||
attributes['public_url'] = this.getURLFor(attributes['icon']);
|
||||
return attributes;
|
||||
},
|
||||
|
||||
get: function (attributeName) {
|
||||
var attribute = this.attributes[attributeName];
|
||||
|
||||
if (attributeName === 'public_url') {
|
||||
attribute = this.getURLFor(this.attributes['icon']);
|
||||
}
|
||||
|
||||
return attribute;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user