Changeset 12144
- Timestamp:
- 01/23/08 07:49:57 (12 months ago)
- Location:
- dijit/trunk
- Files:
-
- 4 modified
-
Dialog.js (modified) (11 diffs)
-
layout/templates/TooltipDialog.html (modified) (1 diff)
-
templates/Dialog.html (modified) (2 diffs)
-
tests/test_Dialog.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/Dialog.js
r12068 r12144 136 136 duration: 400, 137 137 138 // _firstFocusItem: DomNode 139 // The pointer to the first focusable node in the dialog 140 _firstFocusItem:null, 141 138 142 // _lastFocusItem: DomNode 139 143 // The pointer to which node has focus prior to our dialog … … 149 153 this.connect(this, "onExecute", "hide"); 150 154 this.connect(this, "onCancel", "hide"); 151 this._modalconnects = []; 155 this._modalconnects = []; 152 156 }, 153 157 … … 172 176 "class": dojo.map(this["class"].split(/\s/), function(s){ return s+"_underlay"; }).join(" ") 173 177 }); 178 179 // find and store focusable Items 180 if (!this.firstFocusItem){ 181 var focusItem = dijit.getFirstInTabbingOrder(this.domNode); 182 this._firstFocusItem = focusItem ? focusItem : this.domNode; 183 focusItem = dijit.getLastInTabbingOrder(this.domNode); 184 this._lastFocusItem = focusItem ? focusItem : this._firstFocusItem; 185 } 174 186 175 187 var node = this.domNode; … … 228 240 }, 229 241 230 _findLastFocus: function(/*Event*/ evt){231 // summary: called from onblur of dialog container to determine the last focusable item232 this._lastFocused = evt.target;233 },234 235 _cycleFocus: function(/*Event*/ evt){236 // summary: when tabEnd receives focus, advance focus around to titleBar237 238 // on first focus to tabEnd, store the last focused item in dialog239 if(!this._lastFocusItem){240 this._lastFocusItem = this._lastFocused;241 }242 this.titleBar.focus();243 },244 245 242 _onKey: function(/*Event*/ evt){ 246 243 // summary: handles the keyboard events for accessibility reasons 247 244 if(evt.keyCode){ 248 245 var node = evt.target; 249 // see if we are shift-tabbing from titleBar 250 if(node == this.titleBar && evt.shiftKey && evt.keyCode == dojo.keys.TAB){ 251 if(this._lastFocusItem){ 252 this._lastFocusItem.focus(); // send focus to last item in dialog if known 246 var singleFocusItem = (this._firstFocusItem == this._lastFocusItem); 247 // see if we are shift-tabbing from first focusable item on dialog 248 if(node == this._firstFocusItem && evt.shiftKey && evt.keyCode == dojo.keys.TAB){ 249 if(!singleFocusItem){ 250 dijit.focus(this._lastFocusItem); // send focus to last item in dialog 251 } 252 dojo.stopEvent(evt); 253 }else if(node == this._lastFocusItem && evt.keyCode == dojo.keys.TAB && !evt.shiftKey){ 254 if (!singleFocusItem){ 255 dijit.focus(this._firstFocusItem); // send focus to first item in dialog 253 256 } 254 257 dojo.stopEvent(evt); … … 271 274 }else if (!dojo.isOpera){ 272 275 try{ 273 this. titleBar.focus();276 this._firstFocusItem.focus(); 274 277 }catch(e){/*squelch*/} 275 278 } … … 296 299 this._modalconnects.push(dojo.connect(document.documentElement, "onkeypress", this, "_onKey")); 297 300 298 // IE doesn't bubble onblur events - use ondeactivate instead299 var ev = typeof(document.ondeactivate) == "object" ? "ondeactivate" : "onblur";300 this._modalconnects.push(dojo.connect(this.containerNode, ev, this, "_findLastFocus"));301 302 301 dojo.style(this.domNode, "opacity", 0); 303 302 this.domNode.style.display="block"; … … 313 312 // set timeout to allow the browser to render dialog 314 313 setTimeout(dojo.hitch(this, function(){ 315 dijit.focus(this. titleBar);314 dijit.focus(this._firstFocusItem); 316 315 }), 50); 317 316 }, … … 372 371 title: "", 373 372 373 // _firstFocusItem: DomNode 374 // The pointer to the first focusable node in the dialog 375 _firstFocusItem:null, 376 374 377 // _lastFocusItem: DomNode 375 378 // The domNode that had focus before we took it. … … 382 385 this.inherited("postCreate",arguments); 383 386 this.connect(this.containerNode, "onkeypress", "_onKey"); 384 385 // IE doesn't bubble onblur events - use ondeactivate instead386 var ev = typeof(document.ondeactivate) == "object" ? "ondeactivate" : "onblur";387 this.connect(this.containerNode, ev, "_findLastFocus");388 387 this.containerNode.title=this.title; 389 388 }, … … 396 395 onOpen: function(/*Object*/ pos){ 397 396 // summary: called when dialog is displayed 397 398 // first time we show the dialog, there's some initialization stuff to do 399 if(!this._alreadyInitialized){ 400 this._setup(); 401 this._alreadyInitialized=true; 402 } 403 398 404 this.orient(this.domNode,pos.aroundCorner, pos.corner); 399 405 this._loadCheck(); // lazy load trigger 400 this.containerNode.focus(); 406 dijit.focus(this._firstFocusItem); 407 }, 408 409 _setup: function(){ 410 // find and store focusable Items 411 var focusItem = dijit.getFirstInTabbingOrder(this.containerNode); 412 this._firstFocusItem = focusItem ? focusItem : this.containerNode; 413 focusItem = dijit.getLastInTabbingOrder(this.containerNode); 414 this._lastFocusItem = focusItem ? focusItem : this._firstFocusItem; 401 415 }, 402 416 403 417 _onKey: function(/*Event*/ evt){ 404 418 // summary: keep keyboard focus in dialog; close dialog on escape key 419 var node = evt.target; 420 var singleFocusItem = (this._firstFocusItem == this._lastFocusItem); 405 421 if(evt.keyCode == dojo.keys.ESCAPE){ 406 422 this.onCancel(); 407 }else if(evt.target == this.containerNode && evt.shiftKey && evt.keyCode == dojo.keys.TAB){ 408 if (this._lastFocusItem){ 409 this._lastFocusItem.focus(); 423 }else if(node == this._firstFocusItem && evt.shiftKey && evt.keyCode == dojo.keys.TAB){ 424 if(!singleFocusItem){ 425 dijit.focus(this._lastFocusItem); // send focus to last item in dialog 426 } 427 dojo.stopEvent(evt); 428 }else if(node == this._lastFocusItem && evt.keyCode == dojo.keys.TAB && !evt.shiftKey){ 429 if(!singleFocusItem){ 430 dijit.focus(this._firstFocusItem); // send focus to first item in dialog 410 431 } 411 432 dojo.stopEvent(evt); … … 415 436 evt.stopPropagation(); 416 437 } 417 },418 419 _findLastFocus: function(/*Event*/ evt){420 // summary: called from onblur of dialog container to determine the last focusable item421 this._lastFocused = evt.target;422 },423 424 _cycleFocus: function(/*Event*/ evt){425 // summary: when tabEnd receives focus, advance focus around to containerNode426 427 // on first focus to tabEnd, store the last focused item in dialog428 if(!this._lastFocusItem){429 this._lastFocusItem = this._lastFocused;430 }431 this.containerNode.focus();432 438 } 433 439 } -
dijit/trunk/layout/templates/TooltipDialog.html
r10527 r12144 1 1 <div class="dijitTooltipDialog" > 2 2 <div class="dijitTooltipContainer"> 3 <div class ="dijitTooltipContents dijitTooltipFocusNode" dojoAttachPoint="containerNode" tabindex=" 0" waiRole="dialog"></div>3 <div class ="dijitTooltipContents dijitTooltipFocusNode" dojoAttachPoint="containerNode" tabindex="-1" waiRole="dialog"></div> 4 4 </div> 5 <span dojoAttachPoint="tabEnd" tabindex="0" dojoAttachEvent="focus:_cycleFocus"></span>6 5 <div class="dijitTooltipConnector" ></div> 7 6 </div> -
dijit/trunk/templates/Dialog.html
r11737 r12144 1 <div class="dijitDialog" >2 <div dojoAttachPoint="titleBar" class="dijitDialogTitleBar" tabindex="0" waiRole="dialog">3 <span dojoAttachPoint="titleNode" class="dijitDialogTitle" >${title}</span>1 <div class="dijitDialog" tabindex="-1" waiRole="dialog" waiState="labelledby-${id}_title"> 2 <div dojoAttachPoint="titleBar" class="dijitDialogTitleBar"> 3 <span dojoAttachPoint="titleNode" class="dijitDialogTitle" id="${id}_title">${title}</span> 4 4 <span dojoAttachPoint="closeButtonNode" class="dijitDialogCloseIcon" dojoAttachEvent="onclick: onCancel"> 5 5 <span dojoAttachPoint="closeText" class="closeText">x</span> … … 7 7 </div> 8 8 <div dojoAttachPoint="containerNode" class="dijitDialogPaneContent"></div> 9 <span dojoAttachPoint="tabEnd" dojoAttachEvent="onfocus:_cycleFocus" tabindex="0"></span>10 9 </div> -
dijit/trunk/tests/test_Dialog.html
r11722 r12144 162 162 <div dojoType="dijit.form.DropDownButton"> 163 163 <span>Test slowloading HREF Tooltip Dialog</span> 164 <div dojoType="dijit.TooltipDialog" href="layout/getResponse.php?delay=500&messId=2" >164 <div dojoType="dijit.TooltipDialog" href="layout/getResponse.php?delay=500&messId=2" title="tooltip dialog with no focusable items"> 165 165 </div> 166 166 </div> |