24,26c24 < < var iMask = Class.create(); < iMask.prototype = { --- > var iMask = new Class({ 35,39c33,37 < onFocus: Prototype.emptyFunction, < onBlur: Prototype.emptyFunction, < onValid: Prototype.emptyFunction, < onInvalid: Prototype.emptyFunction, < onKeyDown: Prototype.emptyFunction --- > onFocus: Class.empty, > onBlur: Class.empty, > onValid: Class.empty, > onInvalid: Class.empty, > onKeyDown: Class.empty 43,53c41 < < if ( options.onValid ) < this.options.onValid = options.onValid; < if ( options.onInvalid ) < this.options.onInvalid = options.onInvalid; < if ( options.onFocus ) < this.options.onFocus = options.onFocus; < if ( options.onBlur ) < this.options.onBlur = options.onBlur; < if ( options.onKeyDown ) < this.options.onKeyDown = options.onKeyDown; --- > this.setOptions(options); 56d43 < var _this = this; 58,62c45,48 < obj.options = obj.alt.evalJSON(); < < if(obj.options.type == "number") obj.setStyle("text-align: right"); < < Event.observe(obj, "mousedown", function(event) { --- > obj.options = Json.evaluate(obj.alt); > if(obj.options.type == "number") obj.setStyle("text-align", "right"); > obj.addEvent("mousedown", function(event) { > event = new Event(event); 65c51,52 < Event.observe(obj, "mouseup", function(event) { --- > obj.addEvent("mouseup", function(event) { > event = new Event(event); 67,69c54,57 < _this._onMouseUp(event, obj); < }); < Event.observe(obj ,"click", function(event) { --- > this._onMouseUp(event, obj); > }.bind(this)); > obj.addEvent("click", function(event) { > event = new Event(event); 72,85c60,70 < Event.observe(obj ,"keydown", function(event) { < _this._onKeyDown(event, obj); < if ( _this.options.onKeyDown ) < _this.options.onKeyDown.delay(0.2, obj); < }); < Event.observe(obj, "keypress", function(event) { < _this._onKeyPress(event, obj); < }); < Event.observe(obj, "focus", function(event) { < event.stop(); < _this._onFocus(event, obj); < _this.options.onFocus.delay(0.2, obj); < }); < Event.observe(obj, "blur", function(event) { --- > obj.addEvent("keydown", function(event) { > event = new Event(event); > this._onKeyDown(event, obj); > this.fireEvent("onKeyDown", obj, 20); > }.bind(this)); > obj.addEvent("keypress", function(event) { > event = new Event(event); > this._onKeyPress(event, obj); > }.bind(this)); > obj.addEvent("focus", function(event) { > event = new Event(event); 87,90c72,81 < _this._onBlur(event, obj); < _this.options.onBlur.delay(0.2, obj); < }); < }); --- > this._onFocus(event, obj); > this.fireEvent("onFocus", obj, 20); > }.bind(this)); > obj.addEvent("blur", function(event) { > event = new Event(event); > event.stop(); > this._onBlur(event, obj); > this.fireEvent("onBlur", obj, 20); > }.bind(this)); > }.bind(this)); 103c94 < if(event.keyCode == 13) { // enter --- > if(event.code == 13) { // enter 106c97 < } else if(!(event.keyCode == 9)) { --- > } else if(!(event.code == 9)) { 110c101 < switch(event.keyCode) { --- > switch(event.code) { 138c129 < this.options.onValid.delay(0.2, event, obj); --- > this.fireEvent("onValid", [event, obj], 20); 141c132 < this.options.onInvalid.delay(0.2, event, obj); --- > this.fireEvent("onInvalid", [event, obj], 20); 146c137 < switch(event.keyCode) { --- > switch(event.code) { 155c146 < this.options.onValid.delay(0.2, event, obj); --- > this.fireEvent("onValid", [event, obj], 20); 157c148 < this.options.onInvalid.delay(0.2, event, obj); --- > this.fireEvent("onInvalid", [event, obj], 20); 167,172c158,163 < !(event.keyCode == 9) // tab < && !(event.shift && event.keyCode == 9) // shift + tab < && !(event.keyCode == 13) // enter < && !(event.ctrl && event.keyCode == 67) // ctrl + c < && !(event.ctrl && event.keyCode == 86) // ctrl + v < && !(event.ctrl && event.keyCode == 88) // ctrl + x --- > !(event.code == 9) // tab > && !(event.shift && event.code == 9) // shift + tab > && !(event.code == 13) // enter > && !(event.ctrl && event.code == 67) // ctrl + c > && !(event.ctrl && event.code == 86) // ctrl + v > && !(event.ctrl && event.code == 88) // ctrl + x 181c172 < {this._selectFirst.delay(0.2, obj, this);} --- > {this._selectFirst.delay(20, this, obj);} 183c174 < {this._setEnd.delay(0.2, obj, this);} --- > {this._setEnd.delay(20, this, obj);} 195,196c186 < _selectFirst: function(obj, bind) { < if ( bind === undefined ) bind = this; --- > _selectFirst: function(obj) { 198,199c188,189 < if(bind._isInputPosition(obj, i)) { < bind._setSelection(obj, i, (i + 1)); --- > if(this._isInputPosition(obj, i)) { > this._setSelection(obj, i, (i + 1)); 263,264c253 < _setEnd: function(obj, bind) { < if ( bind === undefined ) bind = this; --- > _setEnd: function(obj) { 266c255 < bind._setSelection(obj, len, len); --- > this._setSelection(obj, len, len); 272c261 < if(Object.isNumber(obj.selectionStart) ) p = obj.selectionStart; --- > if($type(obj.selectionStart) == "number") p = obj.selectionStart; 285c274 < if(Object.isNumber(obj.selectionEnd) ) --- > if($type(obj.selectionEnd) == "number") 379c368 < switch(event.keyCode) { --- > switch(event.code) { 411c400 < chr = String.fromCharCode(event.keyCode).toLowerCase(); // key pressed as a lowercase string --- > chr = event.key; // key pressed as a lowercase string 472,476c461,463 < } < < function $chk(obj){ < return !!(obj || obj === 0); < }; --- > }); > iMask.implement(new Events); // Implements addEvent(type, fn), fireEvent(type, [args], delay) and removeEvent(type, fn) > iMask.implement(new Options);// Implements setOptions(defaults, options) \ No newline at end of file