Changeset 16233
- Timestamp:
- 01/06/09 04:40:56 (14 months ago)
- Location:
- dijit/trunk
- Files:
-
- 7 modified
-
Menu.js (modified) (9 diffs)
-
MenuBar.js (modified) (1 diff)
-
tests/test_Menu.html (modified) (6 diffs)
-
themes/dijit.css (modified) (2 diffs)
-
themes/nihilo/Menu.css (modified) (2 diffs)
-
themes/soria/Menu.css (modified) (2 diffs)
-
themes/tundra/Menu.css (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/Menu.js
r16207 r16233 16 16 // popupDelay: Integer 17 17 // number of milliseconds before hovering (without clicking) causes the popup to automatically open. 18 // set this to -1 to disable automatically opening of submenus.19 18 popupDelay: 500, 20 19 … … 52 51 53 52 onItemHover: function(/*MenuItem*/ item){ 54 // summary: Called when cursor is over a MenuItem 55 this.focusChild(item); 56 57 if(this.focusedChild.popup && !this.focusedChild.disabled && !this.hover_timer && this.popupDelay>=0){ 58 this.hover_timer = setTimeout(dojo.hitch(this, "_openPopup"), this.popupDelay); 53 // summary: 54 // Called when cursor is over a MenuItem. 55 56 // Don't do anything unless user has "activated" the menu by: 57 // 1) clicking it 58 // 2) tabbing into it 59 // 3) opening it from a parent menu (which automatically focuses it) 60 if(this.isActive){ 61 this.focusChild(item); 62 63 if(this.focusedChild.popup && !this.focusedChild.disabled && !this.hover_timer){ 64 this.hover_timer = setTimeout(dojo.hitch(this, "_openPopup"), this.popupDelay); 65 } 59 66 } 60 67 }, 61 68 62 69 _onChildBlur: function(item){ 63 // summary: Close all popups that are open and descendants of this menu 70 // summary: 71 // Called when a child MenuItem becomes inactive because focus 72 // has been removed from the MenuItem *and* it's descendant menus. 73 74 item._setSelected(false); 75 76 // Close all popups that are open and descendants of this menu 64 77 dijit.popup.close(item.popup); 65 item._blur();66 78 this._stopPopupTimer(); 67 79 }, … … 69 81 onItemUnhover: function(/*MenuItem*/ item){ 70 82 // summary: Callback fires when mouse exits a MenuItem 71 this._stopPopupTimer(); 83 if(this.isActive){ 84 this._stopPopupTimer(); 85 } 72 86 }, 73 87 … … 87 101 // summary: user defined function to handle clicks on an item 88 102 if(item.disabled){ return false; } 103 104 this.focusChild(item); 89 105 90 106 if(item.popup){ … … 149 165 }, 150 166 167 _onFocus: function(){ 168 // summary: 169 // Called when this Menu gets focus from: 170 // 1) clicking it 171 // 2) tabbing into it 172 // 3) being opened by a parent menu. 173 // This is not called just from mouse hover. 174 this.isActive = true; 175 dojo.addClass(this.domNode, "dijitMenuActive"); 176 dojo.removeClass(this.domNode, "dijitMenuPassive"); 177 this.inherited(arguments); 178 }, 179 151 180 _onBlur: function(){ 181 // summary: 182 // Called when focus is moved away from this Menu and it's submenus 183 this.isActive = false; 184 dojo.removeClass(this.domNode, "dijitMenuActive"); 185 dojo.addClass(this.domNode, "dijitMenuPassive"); 186 152 187 // If user blurs/clicks away from a MenuBar (or always visible Menu), then close all popped up submenus etc. 153 188 this.onClose(); 189 154 190 this.inherited(arguments); 155 191 }, … … 177 213 178 214 templateString: 179 '<table class="dijit dijitMenu dijit Reset dijitMenuTable" waiRole="menu" tabIndex="${tabIndex}" dojoAttachEvent="onkeypress:_onKeyPress">' +215 '<table class="dijit dijitMenu dijitMenuPassive dijitReset dijitMenuTable" waiRole="menu" tabIndex="${tabIndex}" dojoAttachEvent="onkeypress:_onKeyPress">' + 180 216 '<tbody class="dijitReset" dojoAttachPoint="containerNode"></tbody>'+ 181 217 '</table>', … … 429 465 _onHover: function(){ 430 466 // summary: callback when mouse is moved onto menu item 467 dojo.addClass(this.domNode, 'dijitMenuItemHover'); 431 468 this.getParent().onItemHover(this); 432 469 }, 433 470 434 471 _onUnhover: function(){ 435 // summary: callback when mouse is moved off of menu item 472 // summary: 473 // Callback when mouse is moved off of menu item, 474 // possibly to a child menu, or maybe to a sibling 475 // menuitem or somewhere else entirely. 436 476 437 477 // if we are unhovering the currently selected item 438 478 // then unselect it 479 dojo.removeClass(this.domNode, 'dijitMenuItemHover'); 439 480 this.getParent().onItemUnhover(this); 440 481 }, … … 450 491 451 492 focus: function(){ 452 dojo.addClass(this.domNode, 'dijitMenuItemHover'); 493 // summary: 494 // Focus on this MenuItem 453 495 try{ 454 496 dijit.focus(this.focusNode); … … 458 500 }, 459 501 460 _blur: function(){ 461 dojo.removeClass(this.domNode, 'dijitMenuItemHover'); 502 _onFocus: function(){ 503 this._setSelected(true); 504 }, 505 506 _setSelected: function(selected){ 507 // summary: 508 // Indicate that this node is the currently selected one 509 510 /*** 511 * TODO: remove this method and calls to it, when _onBlur() is working for MenuItem. 512 * Currently _onBlur() gets called when focus is moved from the MenuItem to a child menu. 513 * That's not supposed to happen, but the problem is: 514 * In order to allow dijit.popup's getTopPopup() work,a sub menu's popupParent 515 * points to the parent Menu, bypassing the parent MenuItem... thus the 516 * MenuItem is not in the chain of active widgets and gets a premature call to 517 * _onBlur() 518 */ 519 520 dojo.toggleClass(this.domNode, "dijitMenuItemSelected", selected); 462 521 }, 463 522 -
dijit/trunk/MenuBar.js
r16188 r16233 7 7 // A menu bar, listing menu choices horizontally, like the "File" menu in most desktop applications 8 8 9 templateString: '<div class="dijitMenuBar " dojoAttachPoint="containerNode" tabIndex="${tabIndex}" dojoAttachEvent="onkeypress: _onKeyPress"></div>',9 templateString: '<div class="dijitMenuBar dijitMenuPassive" dojoAttachPoint="containerNode" tabIndex="${tabIndex}" dojoAttachEvent="onkeypress: _onKeyPress"></div>', 10 10 11 11 _isMenuBar: true, -
dijit/trunk/tests/test_Menu.html
r16168 r16233 91 91 } 92 92 dojo.addOnLoad(function(){ 93 // need to explicitly update our buttons states, otherwise the94 // browser will remember the last states of them before reloading95 // (so a programmatic menu is created, reload, and "the create96 // programmatic menu" button is still in disabled state)97 updateButtons(false);93 // need to explicitly update our buttons states, otherwise the 94 // browser will remember the last states of them before reloading 95 // (so a programmatic menu is created, reload, and "the create 96 // programmatic menu" button is still in disabled state) 97 updateButtons(false); 98 98 }); 99 99 </script> … … 192 192 <div dojoType="dijit.MenuBarItem"> 193 193 <span>File</span> 194 <div dojoType="dijit.Menu" >194 <div dojoType="dijit.Menu" id="fileMenu"> 195 195 <div dojoType="dijit.MenuItem">New</div> 196 196 <div dojoType="dijit.MenuItem">Open</div> … … 202 202 <div dojoType="dijit.MenuBarItem"> 203 203 <span>Edit</span> 204 <div dojoType="dijit.Menu" >204 <div dojoType="dijit.Menu" id="editMenu"> 205 205 <div dojoType="dijit.MenuItem" iconClass="dijitEditorIcon dijitEditorIconCut" 206 206 onClick="console.log('not actually cutting anything, just a test!')">Cut</div> … … 213 213 <div dojoType="dijit.MenuBarItem"> 214 214 <span>View</span> 215 <div dojoType="dijit.Menu" >215 <div dojoType="dijit.Menu" id="viewMenu"> 216 216 <div dojoType="dijit.MenuItem">Normal</div> 217 217 <div dojoType="dijit.MenuItem">Outline</div> 218 218 <div dojoType="dijit.PopupMenuItem"> 219 219 <span>Zoom</span> 220 <div dojoType="dijit.Menu" id=" menuBarSub1">220 <div dojoType="dijit.Menu" id="zoomMenu"> 221 221 <div dojoType="dijit.MenuItem">50%</div> 222 222 <div dojoType="dijit.MenuItem">75%</div> … … 230 230 <div dojoType="dijit.MenuBarItem"> 231 231 <span>Help</span> 232 <div dojoType="dijit.Menu" >232 <div dojoType="dijit.Menu" id="helpMenu"> 233 233 <div dojoType="dijit.MenuItem">Help Topics</div> 234 234 <div dojoType="dijit.MenuItem">About Dijit</div> … … 295 295 <li>left click context menu (left click on input on far right) 296 296 <li>Example of programatically created menu 297 <li>Note: while some accelerator (shortcut) keys are displayed in the context menu, they are not actually hooked up to the corresponding actions (if any), they need to be setup explicitly by the user explicitly297 <li>Note: while some accelerator (shortcut) keys are displayed in the context menu, they are not actually hooked up to the corresponding actions (if any), they need to be setup explicitly by the user 298 298 </ul> 299 299 -
dijit/trunk/themes/dijit.css
r16216 r16233 983 983 } 984 984 985 .dijitMenuItemHover { 985 .dijitMenuPassive .dijitMenuItemHover, 986 .dijitMenuItemSelected { 987 /* 988 * dijitMenuItemHover refers to actual mouse over 989 * dijitMenuItemSelected is used after a menu has been "activated" by 990 * clicking it, tabbing into it, or being opened from a parent menu, 991 * and denotes that the menu item has focus or that focus is on a child 992 * menu 993 */ 986 994 background-color:black; 987 995 color:white; … … 1011 1019 } 1012 1020 1013 .dijit_a11y .dijitMenuItem Hover.dijitMenuItemLabel {1021 .dijit_a11y .dijitMenuItemSelected .dijitMenuItemLabel { 1014 1022 border-width: 1px; 1015 1023 border-style: solid; 1016 1024 } 1017 .dijit_a11y .dijitMenuItem Hover{1025 .dijit_a11y .dijitMenuItemSelected { 1018 1026 border: 1px #fff dotted !important; 1019 1027 } -
dijit/trunk/themes/nihilo/Menu.css
r16141 r16233 25 25 } 26 26 27 .nihilo .dijitMenuItemHover { 27 .nihilo .dijitMenuPassive .dijitMenuItemHover, 28 .nihilo .dijitMenuItemSelected { 28 29 background-color: #ffe284; /* #95a0b0; #555555; #aaaaaa; #646464; #60a1ea; #848484; */ 29 30 color: #243C5F; … … 69 70 .nihilo .dijitCheckedMenuItemIcon { 70 71 background-image: url('images/spriteCheckbox.gif'); 71 background-position: - 16px;72 background-position: -80px; 72 73 } 73 74 74 75 .nihilo .dijitCheckedMenuItemIconChecked { 75 background-position: 0px;76 }77 78 .nihilo .dijitMenuItemHover .dijitCheckedMenuItemIcon {79 background-position: -80px;80 }81 82 .nihilo .dijitMenuItemHover .dijitCheckedMenuItemIconChecked {83 76 background-position: -64px; 84 77 } -
dijit/trunk/themes/soria/Menu.css
r16141 r16233 25 25 } 26 26 27 .soria .dijitMenuItemHover { 27 .soria .dijitMenuPassive .dijitMenuItemHover, 28 .soria .dijitMenuItemSelected { 28 29 background-color: #d9e6f9; /* #95a0b0; #555555; #aaaaaa; #646464; #60a1ea; #848484; */ 29 30 color: #243C5F; … … 69 70 .soria .dijitCheckedMenuItemIcon { 70 71 background-image: url('images/spriteCheckbox.gif'); 71 background-position: - 16px;72 background-position: -80px; 72 73 } 73 74 74 75 .soria .dijitCheckedMenuItemIconChecked { 75 background-position: 0px;76 }77 78 .soria .dijitMenuItemHover .dijitCheckedMenuItemIcon {79 background-position: -80px;80 }81 82 .soria .dijitMenuItemHover .dijitCheckedMenuItemIconChecked {83 76 background-position: -64px; 84 77 } -
dijit/trunk/themes/tundra/Menu.css
r16141 r16233 24 24 } 25 25 26 .tundra .dijitMenuItemHover { 26 .tundra .dijitMenuPassive .dijitMenuItemHover, 27 .tundra .dijitMenuItemSelected { 27 28 background-color: #3559ac; 28 29 color:#fff; … … 63 64 .tundra .dijitCheckedMenuItemIcon { 64 65 background-image: url('images/checkmark.png'); 65 background-position: - 16px;66 background-position: -80px; 66 67 } 67 68 … … 74 75 } 75 76 76 .tundra .dijitMenuItemHover .dijitCheckedMenuItemIcon { 77 background-position: -80px; 78 } 79 80 .tundra .dijitMenuItemHover .dijitCheckedMenuItemIconChecked { 77 .tundra .dijitCheckedMenuItemIconChecked { 81 78 background-position: -64px; 82 79 }