@@ -40,7 +40,7 @@ var ValidationTypes = {
40
40
} ,
41
41
42
42
/**
43
- * Determines if the next part(s) of the given expresion
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 ) {
@@ -187,10 +187,16 @@ var ValidationTypes = {
187
187
var types = this ,
188
188
result = false ,
189
189
numeric = "<percentage> | <length>" ,
190
- xDir = "left | center | right" ,
191
- yDir = "top | center | bottom" ,
192
- part ,
193
- i , len ;
190
+ xDir = "left | right" ,
191
+ yDir = "top | bottom" ,
192
+ count = 0 ,
193
+ hasNext = function ( ) {
194
+ return expression . hasNext ( ) && expression . peek ( ) != "," ;
195
+ } ;
196
+
197
+ while ( expression . peek ( count ) && expression . peek ( count ) != "," ) {
198
+ count ++ ;
199
+ }
194
200
195
201
/*
196
202
<position> = [
@@ -202,40 +208,48 @@ var ValidationTypes = {
202
208
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
203
209
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
204
210
]
211
+ */
205
212
206
- */
207
-
208
- if ( ValidationTypes . isAny ( expression , "top | bottom" ) ) {
209
- result = true ;
213
+ if ( count < 3 ) {
214
+ if ( ValidationTypes . isAny ( expression , xDir + " | center | " + numeric ) ) {
215
+ result = true ;
216
+ ValidationTypes . isAny ( expression , yDir + " | center | " + numeric ) ;
217
+ } else if ( ValidationTypes . isAny ( expression , yDir ) ) {
218
+ result = true ;
219
+ ValidationTypes . isAny ( expression , xDir + " | center" ) ;
220
+ }
210
221
} else {
211
-
212
- //must be two-part
213
- if ( ValidationTypes . isAny ( expression , numeric ) ) {
214
- if ( expression . hasNext ( ) ) {
215
- result = ValidationTypes . isAny ( expression , numeric + " | " + yDir ) ;
216
- }
217
- } else if ( ValidationTypes . isAny ( expression , xDir ) ) {
218
- if ( expression . hasNext ( ) ) {
219
-
220
- //two- or three-part
221
- if ( ValidationTypes . isAny ( expression , yDir ) ) {
222
+ if ( ValidationTypes . isAny ( expression , xDir ) ) {
223
+ if ( ValidationTypes . isAny ( expression , yDir ) ) {
224
+ result = true ;
225
+ ValidationTypes . isAny ( expression , numeric ) ;
226
+ } else if ( ValidationTypes . isAny ( expression , numeric ) ) {
227
+ if ( ValidationTypes . isAny ( expression , yDir ) ) {
222
228
result = true ;
223
-
224
229
ValidationTypes . isAny ( expression , numeric ) ;
225
-
226
- } else if ( ValidationTypes . isAny ( expression , numeric ) ) {
227
-
228
- //could also be two-part, so check the next part
229
- if ( ValidationTypes . isAny ( expression , yDir ) ) {
230
- ValidationTypes . isAny ( expression , numeric ) ;
231
- }
232
-
230
+ } else if ( ValidationTypes . isAny ( expression , "center" ) ) {
233
231
result = true ;
234
232
}
235
233
}
236
- }
237
- }
238
-
234
+ } else if ( ValidationTypes . isAny ( expression , yDir ) ) {
235
+ if ( ValidationTypes . isAny ( expression , xDir ) ) {
236
+ result = true ;
237
+ ValidationTypes . isAny ( expression , numeric ) ;
238
+ } else if ( ValidationTypes . isAny ( expression , numeric ) ) {
239
+ if ( ValidationTypes . isAny ( expression , xDir ) ) {
240
+ result = true ;
241
+ ValidationTypes . isAny ( expression , numeric ) ;
242
+ } else if ( ValidationTypes . isAny ( expression , "center" ) ) {
243
+ result = true ;
244
+ }
245
+ }
246
+ } else if ( ValidationTypes . isAny ( expression , "center" ) ) {
247
+ if ( ValidationTypes . isAny ( expression , xDir + " | " + yDir ) ) {
248
+ result = true ;
249
+ ValidationTypes . isAny ( expression , numeric ) ;
250
+ }
251
+ }
252
+ }
239
253
240
254
return result ;
241
255
} ,
@@ -339,4 +353,4 @@ var ValidationTypes = {
339
353
return result ;
340
354
}
341
355
}
342
- } ;
356
+ } ;
0 commit comments