source: frontend/node_modules/cssstyle/lib/properties/azimuth.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[9af201e]1'use strict';
2
3var parsers = require('../parsers');
4
5module.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
13 .toLowerCase()
14 .trim()
15 .split(/\s+/);
16 var hasBehind = false;
17 if (keywords.length > 2) {
18 return;
19 }
20 var behindIndex = keywords.indexOf('behind');
21 hasBehind = behindIndex !== -1;
22
23 if (keywords.length === 2) {
24 if (!hasBehind) {
25 return;
26 }
27 keywords.splice(behindIndex, 1);
28 }
29 if (keywords[0] === 'leftwards' || keywords[0] === 'rightwards') {
30 if (hasBehind) {
31 return;
32 }
33 return this._setProperty('azimuth', keywords[0]);
34 }
35 if (keywords[0] === 'behind') {
36 return this._setProperty('azimuth', '180deg');
37 }
38 switch (keywords[0]) {
39 case 'left-side':
40 return this._setProperty('azimuth', '270deg');
41 case 'far-left':
42 return this._setProperty('azimuth', (hasBehind ? 240 : 300) + 'deg');
43 case 'left':
44 return this._setProperty('azimuth', (hasBehind ? 220 : 320) + 'deg');
45 case 'center-left':
46 return this._setProperty('azimuth', (hasBehind ? 200 : 340) + 'deg');
47 case 'center':
48 return this._setProperty('azimuth', (hasBehind ? 180 : 0) + 'deg');
49 case 'center-right':
50 return this._setProperty('azimuth', (hasBehind ? 160 : 20) + 'deg');
51 case 'right':
52 return this._setProperty('azimuth', (hasBehind ? 140 : 40) + 'deg');
53 case 'far-right':
54 return this._setProperty('azimuth', (hasBehind ? 120 : 60) + 'deg');
55 case 'right-side':
56 return this._setProperty('azimuth', '90deg');
57 default:
58 return;
59 }
60 }
61 },
62 get: function() {
63 return this.getPropertyValue('azimuth');
64 },
65 enumerable: true,
66 configurable: true,
67};
Note: See TracBrowser for help on using the repository browser.