forked from subtleGradient/Sheet.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSheetParser.Styles.js
115 lines (95 loc) · 5.33 KB
/
SheetParser.Styles.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
---
name : SheetParser.Styles
authors : Yaroslaff Fedin
license : MIT
requires : SheetParser.Property
provides : SheetParser.Styles
...
*/
(function() {
var SheetParser = (typeof exports == 'undefined') ? window.SheetParser : exports.SheetParser;
var CSS = SheetParser.Properties = {
background: [[['backgroundColor', 'backgroundImage', 'backgroundRepeat',
'backgroundAttachment', 'backgroundPositionX', 'backgroundPositionY']], 'multiple'],
backgroundColor: ['color', 'transparent', 'inherit'],
backgroundImage: ['url', 'none', 'inherit'],
backgroundRepeat: ['repeat', 'no-repeat', 'repeat-x', 'repeat-y', 'inherit', 'space', 'round'],
backgroundAttachment: ['fixed', 'scroll', 'inherit', 'local', 'fixed'],
backgroundPosition: [['backgroundPositionX', 'backgroundPositionY']],
backgroundPositionX: ['percentage', 'center', 'left', 'right', 'length', 'inherit'],
backgroundPositionY: ['percentage', 'center', 'top', 'bottom', 'length', 'inherit'],
textShadow: [['textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY', 'textShadowColor'], 'multiple'],
textShadowBlur: ['length'],
textShadowOffsetX: ['length'],
textShadowOffsetY: ['length'],
textShadowColor: ['color'],
boxShadow: [['boxShadowBlur', 'boxShadowOffsetX', 'boxShadowOffsetY', 'boxShadowColor'], 'multiple'],
boxShadowBlur: ['length'],
boxShadowOffsetX: ['length'],
boxShadowOffsetY: ['length'],
boxShadowColor: ['color'],
outline: ['outlineWidth', 'outlineStyle', 'outlineColor'],
outlineWidth: ['length'],
outlineStyle: ['dotted', 'dashed', 'solid', 'double', 'groove', 'reidge', 'inset', 'outset'],
outlineColor: ['color'],
font: [[
['fontStyle', 'fontVariant', 'fontWeight'],
'fontSize',
['lineHeight'],
'fontFamily'
]],
fontStyle: ['normal', 'italic', 'oblique', 'inherit'],
fontVariant: ['normal', 'small-caps', 'inherit'],
fontWeight: ['normal', 'number', 'bold', 'inherit'],
fontFamily: ['strings', 'inherit'],
fontSize: ['length', 'percentage', 'inherit',
'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'smaller', 'larger'],
color: ['color'],
letterSpacing: ['normal', 'length', 'inherit'],
textDecoration: ['none', 'capitalize', 'uppercase', 'lowercase'],
textAlign: ['left', 'right', 'center', 'justify'],
textIdent: ['length', 'percentage'],
lineHeight: ['normal', 'length', 'number', 'percentage'],
height: ['length', 'auto'],
maxHeight: ['length', 'auto'],
minHeight: ['length', 'auto'],
width: ['length', 'auto'],
maxWidth: ['length', 'auto'],
minWidth: ['length', 'auto'],
display: ['inline', 'block', 'list-item', 'run-in', 'inline-block', 'table', 'inline-table', 'none',
'table-row-group', 'table-header-group', 'table-footer-group', 'table-row',
'table-column-group', 'table-column', 'table-cell', 'table-caption'],
visibility: ['visible', 'hidden'],
'float': ['none', 'left', 'right'],
clear: ['none', 'left', 'right', 'both', 'inherit'],
overflow: ['visible', 'hidden', 'scroll', 'auto'],
position: ['static', 'relative', 'absolute', 'fixed'],
top: ['length', 'auto'],
left: ['length', 'auto'],
right: ['length', 'auto'],
bottom: ['length', 'auto'],
zIndex: ['integer'],
cursor: ['auto', 'crosshair', 'default', 'hand', 'move', 'e-resize', 'ne-resize', 'nw-resize',
'n-resize', 'se-resize', 'sw-resize', 's-resize', 'w-resize', 'text', 'wait', 'help']
};
var expanded = ['borderWidth', 'borderColor', 'borderStyle', 'padding', 'margin', 'border'];
for (var side, sides = ['Top', 'Right', 'Bottom', 'Left'], i = 0; side = sides[i++];) {
CSS['border' + side] = [['border' + side + 'Width', 'border' + side + 'Style', 'border' + side + 'Color']];
CSS['border' + side + 'Width'] = ['length', 'thin', 'thick', 'medium'];
CSS['border' + side + 'Style'] = ['none', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset', 'inherit', 'none'];
CSS['border' + side + 'Color'] = ['color'];
CSS['margin' + side] = ['length', 'percentage', 'auto'];
CSS['padding' + side] = ['length', 'percentage', 'auto'];
for (var j = 0, prop; prop = expanded[j++];) {
if (!CSS[prop]) CSS[prop] = [[]];
CSS[prop][0].push(prop.replace(/^([a-z]*)/, '$1' + side));
if (i == 4) CSS[prop].push('collection')
}
if (i % 2 == 0)
for (var j = 1, adj; adj = sides[j+=2];)
CSS['borderRadius' + side + adj] = ['length', 'none'];
};
var Styles = SheetParser.Styles = {}
for (var property in CSS) Styles[property] = SheetParser.Property.compile(CSS[property], Styles);
})();