-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
PropertyComposite.js
44 lines (35 loc) · 980 Bytes
/
PropertyComposite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const Property = require('./Property');
module.exports = Property.extend({
defaults: Object.assign({}, Property.prototype.defaults, {
// 'background' is a good example where to make a difference
// between detached and not
//
// - NOT detached (default)
// background: url(..) no-repeat center ...;
// - Detached
// background-image: url();
// background-repeat: repeat;
// ...
detached: 0,
// Array of sub properties
properties: [],
}),
getDefaultValue() {
let value = this.get('defaults');
if (value) {
return value;
}
value = '';
const properties = this.get('properties');
properties.each((prop, index) => value += `${prop.getDefaultValue()} `);
return value.trim();
},
getFullValue() {
if (this.get('detached')) {
return '';
}
let result = '';
this.get('properties').each(prop => result += `${prop.getFullValue()} `);
return result.trim();
},
});