Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81145 views
1
'use strict';
2
3
var parsers = require('../parsers');
4
5
module.exports.definition = {
6
set: function (v) {
7
var valueType = parsers.valueType(v);
8
if (valueType === parsers.TYPES.ANGLE) {
9
return this._setProperty('azimuth', parsers.parseAngle(v));
10
}
11
if (valueType === parsers.TYPES.KEYWORD) {
12
var keywords = v.toLowerCase().trim().split(/\s+/);
13
var hasBehind = false;
14
if (keywords.length > 2) {
15
return;
16
}
17
var behindIndex = keywords.indexOf('behind');
18
hasBehind = (behindIndex !== -1);
19
20
if (keywords.length === 2) {
21
if (!hasBehind) {
22
return;
23
}
24
keywords.splice(behindIndex, 1);
25
}
26
if (keywords[0] === 'leftwards' || keywords[0] === 'rightwards') {
27
if (hasBehind) {
28
return;
29
}
30
return this._setProperty('azimuth', keywords[0]);
31
}
32
if (keywords[0] === 'behind') {
33
return this._setProperty('azimuth', '180deg');
34
}
35
var deg;
36
switch (keywords[0]) {
37
case 'left-side':
38
return this._setProperty('azimuth', '270deg');
39
case 'far-left':
40
return this._setProperty('azimuth', (hasBehind ? 240 : 300) + 'deg');
41
case 'left':
42
return this._setProperty('azimuth', (hasBehind ? 220 : 320) + 'deg');
43
case 'center-left':
44
return this._setProperty('azimuth', (hasBehind ? 200 : 340) + 'deg');
45
case 'center':
46
return this._setProperty('azimuth', (hasBehind ? 180 : 0) + 'deg');
47
case 'center-right':
48
return this._setProperty('azimuth', (hasBehind ? 160 : 20) + 'deg');
49
case 'right':
50
return this._setProperty('azimuth', (hasBehind ? 140 : 40) + 'deg');
51
case 'far-right':
52
return this._setProperty('azimuth', (hasBehind ? 120 : 60) + 'deg');
53
case 'right-side':
54
return this._setProperty('azimuth', '90deg');
55
default:
56
return;
57
}
58
}
59
},
60
get: function () {
61
return this.getPropertyValue('azimuth');
62
},
63
enumerable: true,
64
configurable: true
65
};
66
67