@@ -40,7 +40,7 @@ var ValidationTypes = {
4040 } ,
4141
4242 /**
43- * Determines if the next part(s) of the given expresion
43+ * Determines if the next part(s) of the given expression
4444 * are one of a group.
4545 */
4646 isAnyOfGroup : function ( expression , types ) {
@@ -187,10 +187,16 @@ var ValidationTypes = {
187187 var types = this ,
188188 result = false ,
189189 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+ }
194200
195201/*
196202<position> = [
@@ -202,40 +208,48 @@ var ValidationTypes = {
202208 [ center | [ left | right ] [ <percentage> | <length> ]? ] &&
203209 [ center | [ top | bottom ] [ <percentage> | <length> ]? ]
204210]
211+ */
205212
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+ }
210221 } 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 ) ) {
222228 result = true ;
223-
224229 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" ) ) {
233231 result = true ;
234232 }
235233 }
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+ }
239253
240254 return result ;
241255 } ,
@@ -339,4 +353,4 @@ var ValidationTypes = {
339353 return result ;
340354 }
341355 }
342- } ;
356+ } ;
0 commit comments