]>
Commit | Line | Data |
---|---|---|
2f01fe57 AD |
1 | /* |
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. | |
3 | Available via Academic Free License >= 2.1 OR the modified BSD license. | |
4 | see: http://dojotoolkit.org/license for details | |
5 | */ | |
6 | ||
7 | ||
8 | if(!dojo._hasResource["dijit._KeyNavContainer"]){ | |
9 | dojo._hasResource["dijit._KeyNavContainer"]=true; | |
10 | dojo.provide("dijit._KeyNavContainer"); | |
11 | dojo.require("dijit._Container"); | |
12 | dojo.declare("dijit._KeyNavContainer",dijit._Container,{tabIndex:"0",_keyNavCodes:{},connectKeyNavHandlers:function(_1,_2){ | |
13 | var _3=(this._keyNavCodes={}); | |
14 | var _4=dojo.hitch(this,this.focusPrev); | |
15 | var _5=dojo.hitch(this,this.focusNext); | |
16 | dojo.forEach(_1,function(_6){ | |
17 | _3[_6]=_4; | |
18 | }); | |
19 | dojo.forEach(_2,function(_7){ | |
20 | _3[_7]=_5; | |
21 | }); | |
22 | this.connect(this.domNode,"onkeypress","_onContainerKeypress"); | |
23 | this.connect(this.domNode,"onfocus","_onContainerFocus"); | |
24 | },startupKeyNavChildren:function(){ | |
25 | dojo.forEach(this.getChildren(),dojo.hitch(this,"_startupChild")); | |
26 | },addChild:function(_8,_9){ | |
27 | dijit._KeyNavContainer.superclass.addChild.apply(this,arguments); | |
28 | this._startupChild(_8); | |
29 | },focus:function(){ | |
30 | this.focusFirstChild(); | |
31 | },focusFirstChild:function(){ | |
32 | var _a=this._getFirstFocusableChild(); | |
33 | if(_a){ | |
34 | this.focusChild(_a); | |
35 | } | |
36 | },focusNext:function(){ | |
37 | var _b=this._getNextFocusableChild(this.focusedChild,1); | |
38 | this.focusChild(_b); | |
39 | },focusPrev:function(){ | |
40 | var _c=this._getNextFocusableChild(this.focusedChild,-1); | |
41 | this.focusChild(_c,true); | |
42 | },focusChild:function(_d,_e){ | |
43 | if(this.focusedChild&&_d!==this.focusedChild){ | |
44 | this._onChildBlur(this.focusedChild); | |
45 | } | |
46 | _d.focus(_e?"end":"start"); | |
47 | this.focusedChild=_d; | |
48 | },_startupChild:function(_f){ | |
49 | _f.set("tabIndex","-1"); | |
50 | this.connect(_f,"_onFocus",function(){ | |
51 | _f.set("tabIndex",this.tabIndex); | |
52 | }); | |
53 | this.connect(_f,"_onBlur",function(){ | |
54 | _f.set("tabIndex","-1"); | |
55 | }); | |
56 | },_onContainerFocus:function(evt){ | |
57 | if(evt.target!==this.domNode){ | |
58 | return; | |
59 | } | |
60 | this.focusFirstChild(); | |
61 | dojo.attr(this.domNode,"tabIndex","-1"); | |
62 | },_onBlur:function(evt){ | |
63 | if(this.tabIndex){ | |
64 | dojo.attr(this.domNode,"tabIndex",this.tabIndex); | |
65 | } | |
66 | this.inherited(arguments); | |
67 | },_onContainerKeypress:function(evt){ | |
68 | if(evt.ctrlKey||evt.altKey){ | |
69 | return; | |
70 | } | |
71 | var _10=this._keyNavCodes[evt.charOrCode]; | |
72 | if(_10){ | |
73 | _10(); | |
74 | dojo.stopEvent(evt); | |
75 | } | |
76 | },_onChildBlur:function(_11){ | |
77 | },_getFirstFocusableChild:function(){ | |
78 | return this._getNextFocusableChild(null,1); | |
79 | },_getNextFocusableChild:function(_12,dir){ | |
80 | if(_12){ | |
81 | _12=this._getSiblingOfChild(_12,dir); | |
82 | } | |
83 | var _13=this.getChildren(); | |
84 | for(var i=0;i<_13.length;i++){ | |
85 | if(!_12){ | |
86 | _12=_13[(dir>0)?0:(_13.length-1)]; | |
87 | } | |
88 | if(_12.isFocusable()){ | |
89 | return _12; | |
90 | } | |
91 | _12=this._getSiblingOfChild(_12,dir); | |
92 | } | |
93 | return null; | |
94 | }}); | |
95 | } |