| | 168 | var partialre = ""; |
| | 169 | // parse the regexp and produce a new regexp that matches valid subsets |
| | 170 | // if the regexp is .* then there's no use in matching subsets since everything is valid |
| | 171 | if(p != ".*"){ this.regExp.replace(/\\.|\[\]|\[.*?[^\\]{1}\]|\{.*?\}|\(\?[=:!]|./g, |
| | 172 | function (re){ |
| | 173 | switch(re.charAt(0)){ |
| | 174 | case '{': |
| | 175 | case '+': |
| | 176 | case '?': |
| | 177 | case '*': |
| | 178 | case '^': |
| | 179 | case '$': |
| | 180 | case '|': |
| | 181 | case '(': partialre += re; break; |
| | 182 | case ")": partialre += "|$)"; break; |
| | 183 | default: partialre += "(?:"+re+"|$)"; break; |
| | 184 | } |
| | 185 | } |
| | 186 | );} |
| | 187 | try{ // this is needed for now since the above regexp parsing needs more test verification |
| | 188 | "".search(partialre); |
| | 189 | }catch(e){ // should never be here unless the original RE is bad or the parsing is bad |
| | 190 | partialre = this.regExp; |
| | 191 | console.debug('RegExp error in ' + this.declaredClass + ': ' + this.regExp); |
| | 192 | } // should never be here unless the original RE is bad or the parsing is bad |
| | 193 | this._partialre = "^(?:" + partialre + ")$"; |
| | 302 | _isDefinitelyOutOfRange: function(){ |
| | 303 | // summary: |
| | 304 | // Returns true if the value is out of range and will remain |
| | 305 | // out of range even if the user types more characters |
| | 306 | var val = this.getValue(); |
| | 307 | var isTooLittle = false; |
| | 308 | var isTooMuch = false; |
| | 309 | if("min" in this.constraints){ |
| | 310 | var min = this.constraints.min; |
| | 311 | val = this.compare(val, ((typeof min == "number") && min >= 0)? 0 : min); |
| | 312 | isTooLittle = (typeof val == "number") && val < 0; |
| | 313 | } |
| | 314 | if("max" in this.constraints){ |
| | 315 | var max = this.constraints.max; |
| | 316 | val = this.compare(val, ((typeof max != "number") || max > 0)? max : 0); |
| | 317 | isTooMuch = (typeof val == "number") && val > 0; |
| | 318 | } |
| | 319 | return isTooLittle || isTooMuch; |
| | 320 | }, |
| | 321 | |
| | 322 | _isValidSubset: function(){ |
| | 323 | return this.inherited(arguments) && !this._isDefinitelyOutOfRange(); |
| | 324 | }, |
| | 325 | |