@@ -6,62 +6,62 @@ var ValidationTypes = {
6
6
var text = part . text . toString ( ) . toLowerCase ( ) ,
7
7
args = literals . split ( " | " ) ,
8
8
i , len , found = false ;
9
-
9
+
10
10
for ( i = 0 , len = args . length ; i < len && ! found ; i ++ ) {
11
11
if ( text == args [ i ] . toLowerCase ( ) ) {
12
12
found = true ;
13
13
}
14
14
}
15
-
16
- return found ;
15
+
16
+ return found ;
17
17
} ,
18
-
18
+
19
19
isSimple : function ( type ) {
20
20
return ! ! this . simple [ type ] ;
21
21
} ,
22
-
22
+
23
23
isComplex : function ( type ) {
24
24
return ! ! this . complex [ type ] ;
25
25
} ,
26
-
26
+
27
27
/**
28
28
* Determines if the next part(s) of the given expression
29
29
* are any of the given types.
30
30
*/
31
31
isAny : function ( expression , types ) {
32
32
var args = types . split ( " | " ) ,
33
33
i , len , found = false ;
34
-
34
+
35
35
for ( i = 0 , len = args . length ; i < len && ! found && expression . hasNext ( ) ; i ++ ) {
36
36
found = this . isType ( expression , args [ i ] ) ;
37
37
}
38
-
39
- return found ;
38
+
39
+ return found ;
40
40
} ,
41
-
41
+
42
42
/**
43
43
* Determines if the next part(s) of the given expression
44
44
* are one of a group.
45
45
*/
46
46
isAnyOfGroup : function ( expression , types ) {
47
47
var args = types . split ( " || " ) ,
48
48
i , len , found = false ;
49
-
49
+
50
50
for ( i = 0 , len = args . length ; i < len && ! found ; i ++ ) {
51
51
found = this . isType ( expression , args [ i ] ) ;
52
52
}
53
-
53
+
54
54
return found ? args [ i - 1 ] : false ;
55
55
} ,
56
-
56
+
57
57
/**
58
58
* Determines if the next part(s) of the given expression
59
59
* are of a given type.
60
60
*/
61
61
isType : function ( expression , type ) {
62
62
var part = expression . peek ( ) ,
63
63
result = false ;
64
-
64
+
65
65
if ( type . charAt ( 0 ) != "<" ) {
66
66
result = this . isLiteral ( part , type ) ;
67
67
if ( result ) {
@@ -75,116 +75,116 @@ var ValidationTypes = {
75
75
} else {
76
76
result = this . complex [ type ] ( expression ) ;
77
77
}
78
-
78
+
79
79
return result ;
80
80
} ,
81
-
82
-
83
-
81
+
82
+
83
+
84
84
simple : {
85
85
86
86
"<absolute-size>" : function ( part ) {
87
87
return ValidationTypes . isLiteral ( part , "xx-small | x-small | small | medium | large | x-large | xx-large" ) ;
88
88
} ,
89
-
89
+
90
90
"<attachment>" : function ( part ) {
91
91
return ValidationTypes . isLiteral ( part , "scroll | fixed | local" ) ;
92
92
} ,
93
-
93
+
94
94
"<attr>" : function ( part ) {
95
95
return part . type == "function" && part . name == "attr" ;
96
96
} ,
97
-
97
+
98
98
"<bg-image>" : function ( part ) {
99
99
return this [ "<image>" ] ( part ) || this [ "<gradient>" ] ( part ) || part == "none" ;
100
- } ,
101
-
100
+ } ,
101
+
102
102
"<gradient>" : function ( part ) {
103
103
return part . type == "function" && / ^ (?: \- (?: m s | m o z | o | w e b k i t ) \- ) ? (?: r e p e a t i n g \- ) ? (?: r a d i a l \- | l i n e a r \- ) ? g r a d i e n t / i. test ( part ) ;
104
104
} ,
105
-
105
+
106
106
"<box>" : function ( part ) {
107
107
return ValidationTypes . isLiteral ( part , "padding-box | border-box | content-box" ) ;
108
108
} ,
109
-
109
+
110
110
"<content>" : function ( part ) {
111
111
return part . type == "function" && part . name == "content" ;
112
- } ,
113
-
112
+ } ,
113
+
114
114
"<relative-size>" : function ( part ) {
115
115
return ValidationTypes . isLiteral ( part , "smaller | larger" ) ;
116
116
} ,
117
-
117
+
118
118
//any identifier
119
119
"<ident>" : function ( part ) {
120
120
return part . type == "identifier" ;
121
121
} ,
122
-
122
+
123
123
"<length>" : function ( part ) {
124
124
if ( part . type == "function" && / ^ (?: \- (?: m s | m o z | o | w e b k i t ) \- ) ? c a l c / i. test ( part ) ) {
125
125
return true ;
126
126
} else {
127
127
return part . type == "length" || part . type == "number" || part . type == "integer" || part == "0" ;
128
128
}
129
129
} ,
130
-
130
+
131
131
"<color>" : function ( part ) {
132
132
return part . type == "color" || part == "transparent" ;
133
133
} ,
134
-
134
+
135
135
"<number>" : function ( part ) {
136
136
return part . type == "number" || this [ "<integer>" ] ( part ) ;
137
137
} ,
138
-
138
+
139
139
"<integer>" : function ( part ) {
140
140
return part . type == "integer" ;
141
141
} ,
142
-
142
+
143
143
"<line>" : function ( part ) {
144
144
return part . type == "integer" ;
145
145
} ,
146
-
146
+
147
147
"<angle>" : function ( part ) {
148
148
return part . type == "angle" ;
149
- } ,
150
-
149
+ } ,
150
+
151
151
"<uri>" : function ( part ) {
152
152
return part . type == "uri" ;
153
153
} ,
154
-
154
+
155
155
"<image>" : function ( part ) {
156
156
return this [ "<uri>" ] ( part ) ;
157
157
} ,
158
-
158
+
159
159
"<percentage>" : function ( part ) {
160
160
return part . type == "percentage" || part == "0" ;
161
161
} ,
162
162
163
163
"<border-width>" : function ( part ) {
164
164
return this [ "<length>" ] ( part ) || ValidationTypes . isLiteral ( part , "thin | medium | thick" ) ;
165
165
} ,
166
-
166
+
167
167
"<border-style>" : function ( part ) {
168
168
return ValidationTypes . isLiteral ( part , "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset" ) ;
169
169
} ,
170
-
170
+
171
171
"<margin-width>" : function ( part ) {
172
172
return this [ "<length>" ] ( part ) || this [ "<percentage>" ] ( part ) || ValidationTypes . isLiteral ( part , "auto" ) ;
173
173
} ,
174
-
174
+
175
175
"<padding-width>" : function ( part ) {
176
176
return this [ "<length>" ] ( part ) || this [ "<percentage>" ] ( part ) ;
177
177
} ,
178
-
178
+
179
179
"<shape>" : function ( part ) {
180
180
return part . type == "function" && ( part . name == "rect" || part . name == "inset-rect" ) ;
181
181
} ,
182
-
182
+
183
183
"<time>" : function ( part ) {
184
184
return part . type == "time" ;
185
185
}
186
186
} ,
187
-
187
+
188
188
complex : {
189
189
190
190
"<bg-position>" : function ( expression ) {
@@ -201,7 +201,7 @@ var ValidationTypes = {
201
201
while ( expression . peek ( count ) && expression . peek ( count ) != "," ) {
202
202
count ++ ;
203
203
}
204
-
204
+
205
205
/*
206
206
<position> = [
207
207
[ left | center | right | top | bottom | <percentage> | <length> ]
@@ -254,7 +254,7 @@ var ValidationTypes = {
254
254
}
255
255
}
256
256
}
257
-
257
+
258
258
return result ;
259
259
} ,
260
260
@@ -264,29 +264,29 @@ var ValidationTypes = {
264
264
result = false ,
265
265
numeric = "<percentage> | <length> | auto" ,
266
266
part ,
267
- i , len ;
268
-
267
+ i , len ;
268
+
269
269
if ( ValidationTypes . isAny ( expression , "cover | contain" ) ) {
270
270
result = true ;
271
271
} else if ( ValidationTypes . isAny ( expression , numeric ) ) {
272
- result = true ;
272
+ result = true ;
273
273
ValidationTypes . isAny ( expression , numeric ) ;
274
274
}
275
-
275
+
276
276
return result ;
277
277
} ,
278
-
278
+
279
279
"<repeat-style>" : function ( expression ) {
280
280
//repeat-x | repeat-y | [repeat | space | round | no-repeat]{1,2}
281
281
var result = false ,
282
282
values = "repeat | space | round | no-repeat" ,
283
283
part ;
284
-
284
+
285
285
if ( expression . hasNext ( ) ) {
286
286
part = expression . next ( ) ;
287
-
287
+
288
288
if ( ValidationTypes . isLiteral ( part , "repeat-x | repeat-y" ) ) {
289
- result = true ;
289
+ result = true ;
290
290
} else if ( ValidationTypes . isLiteral ( part , values ) ) {
291
291
result = true ;
292
292
@@ -295,62 +295,62 @@ var ValidationTypes = {
295
295
}
296
296
}
297
297
}
298
-
298
+
299
299
return result ;
300
-
300
+
301
301
} ,
302
-
302
+
303
303
"<shadow>" : function ( expression ) {
304
304
//inset? && [ <length>{2,4} && <color>? ]
305
305
var result = false ,
306
306
count = 0 ,
307
307
inset = false ,
308
308
color = false ,
309
309
part ;
310
-
311
- if ( expression . hasNext ( ) ) {
312
-
310
+
311
+ if ( expression . hasNext ( ) ) {
312
+
313
313
if ( ValidationTypes . isAny ( expression , "inset" ) ) {
314
314
inset = true ;
315
315
}
316
-
316
+
317
317
if ( ValidationTypes . isAny ( expression , "<color>" ) ) {
318
318
color = true ;
319
- }
320
-
319
+ }
320
+
321
321
while ( ValidationTypes . isAny ( expression , "<length>" ) && count < 4 ) {
322
322
count ++ ;
323
323
}
324
-
325
-
324
+
325
+
326
326
if ( expression . hasNext ( ) ) {
327
327
if ( ! color ) {
328
328
ValidationTypes . isAny ( expression , "<color>" ) ;
329
329
}
330
-
330
+
331
331
if ( ! inset ) {
332
332
ValidationTypes . isAny ( expression , "inset" ) ;
333
333
}
334
334
335
335
}
336
-
336
+
337
337
result = ( count >= 2 && count <= 4 ) ;
338
-
338
+
339
339
}
340
-
340
+
341
341
return result ;
342
342
} ,
343
-
343
+
344
344
"<x-one-radius>" : function ( expression ) {
345
345
//[ <length> | <percentage> ] [ <length> | <percentage> ]?
346
346
var result = false ,
347
347
simple = "<length> | <percentage> | inherit" ;
348
-
348
+
349
349
if ( ValidationTypes . isAny ( expression , simple ) ) {
350
350
result = true ;
351
351
ValidationTypes . isAny ( expression , simple ) ;
352
- }
353
-
352
+ }
353
+
354
354
return result ;
355
355
}
356
356
}
0 commit comments