1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /*
- * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
- *
- * http://extjs.com/license
- */
- Ext.KeyNav = function(B, A) {
- this.el = Ext.get(B);
- Ext.apply(this, A);
- if (!this.disabled) {
- this.disabled = true;
- this.enable()
- }
- };
- Ext.KeyNav.prototype = {
- disabled : false,
- defaultEventAction : "stopEvent",
- forceKeyDown : false,
- prepareEvent : function(C) {
- var A = C.getKey();
- var B = this.keyToHandler[A];
- if (Ext.isSafari && B && A >= 37 && A <= 40) {
- C.stopEvent()
- }
- },
- relay : function(C) {
- var A = C.getKey();
- var B = this.keyToHandler[A];
- if (B && this[B]) {
- if (this.doRelay(C, this[B], B) !== true) {
- C[this.defaultEventAction]()
- }
- }
- },
- doRelay : function(C, B, A) {
- return B.call(this.scope || this, C)
- },
- enter : false,
- left : false,
- right : false,
- up : false,
- down : false,
- tab : false,
- esc : false,
- pageUp : false,
- pageDown : false,
- del : false,
- home : false,
- end : false,
- keyToHandler : {
- 37 : "left",
- 39 : "right",
- 38 : "up",
- 40 : "down",
- 33 : "pageUp",
- 34 : "pageDown",
- 46 : "del",
- 36 : "home",
- 35 : "end",
- 13 : "enter",
- 27 : "esc",
- 9 : "tab"
- },
- enable : function() {
- if (this.disabled) {
- if (this.forceKeyDown || Ext.isIE || Ext.isAir) {
- this.el.on("keydown", this.relay, this)
- } else {
- this.el.on("keydown", this.prepareEvent, this);
- this.el.on("keypress", this.relay, this)
- }
- this.disabled = false
- }
- },
- disable : function() {
- if (!this.disabled) {
- if (this.forceKeyDown || Ext.isIE || Ext.isAir) {
- this.el.un("keydown", this.relay)
- } else {
- this.el.un("keydown", this.prepareEvent);
- this.el.un("keypress", this.relay)
- }
- this.disabled = true
- }
- }
- };
|