| 1 |
define([ |
| 2 |
"dojo/_base/array", |
| 3 |
"dojo/_base/declare", |
| 4 |
"dojo/dom-attr", |
| 5 |
"dojo/_base/kernel", |
| 6 |
"dojo/keys", |
| 7 |
"dojo/_base/lang", |
| 8 |
"./registry", |
| 9 |
"./_Container", |
| 10 |
"./_FocusMixin", |
| 11 |
"./_KeyNavMixin" |
| 12 |
], function(array, declare, domAttr, kernel, keys, lang, registry, _Container, _FocusMixin, _KeyNavMixin){ |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
return declare("dijit._KeyNavContainer", [_FocusMixin, _KeyNavMixin, _Container], { |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
connectKeyNavHandlers: function( prevKeyCodes, nextKeyCodes){ |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
var keyCodes = (this._keyNavCodes = {}); |
| 41 |
var prev = lang.hitch(this, "focusPrev"); |
| 42 |
var next = lang.hitch(this, "focusNext"); |
| 43 |
array.forEach(prevKeyCodes, function(code){ |
| 44 |
keyCodes[code] = prev; |
| 45 |
}); |
| 46 |
array.forEach(nextKeyCodes, function(code){ |
| 47 |
keyCodes[code] = next; |
| 48 |
}); |
| 49 |
keyCodes[keys.HOME] = lang.hitch(this, "focusFirstChild"); |
| 50 |
keyCodes[keys.END] = lang.hitch(this, "focusLastChild"); |
| 51 |
}, |
| 52 |
|
| 53 |
startupKeyNavChildren: function(){ |
| 54 |
kernel.deprecated("startupKeyNavChildren() call no longer needed", "", "2.0"); |
| 55 |
}, |
| 56 |
|
| 57 |
startup: function(){ |
| 58 |
this.inherited(arguments); |
| 59 |
array.forEach(this.getChildren(), lang.hitch(this, "_startupChild")); |
| 60 |
}, |
| 61 |
|
| 62 |
addChild: function( widget, insertIndex){ |
| 63 |
this.inherited(arguments); |
| 64 |
this._startupChild(widget); |
| 65 |
}, |
| 66 |
|
| 67 |
_startupChild: function( widget){ |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
widget.set("tabIndex", "-1"); |
| 82 |
}, |
| 83 |
|
| 84 |
_getFirst: function(){ |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
var children = this.getChildren(); |
| 90 |
return children.length ? children[0] : null; |
| 91 |
}, |
| 92 |
|
| 93 |
_getLast: function(){ |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
var children = this.getChildren(); |
| 99 |
return children.length ? children[children.length - 1] : null; |
| 100 |
}, |
| 101 |
|
| 102 |
focusNext: function(){ |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
this.focusChild(this._getNextFocusableChild(this.focusedChild, 1)); |
| 108 |
}, |
| 109 |
|
| 110 |
focusPrev: function(){ |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
this.focusChild(this._getNextFocusableChild(this.focusedChild, -1), true); |
| 117 |
}, |
| 118 |
|
| 119 |
childSelector: function( node){ |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
var node = registry.byNode(node); |
| 125 |
return node && node.getParent() == this; |
| 126 |
} |
| 127 |
}); |
| 128 |
}); |