DropDownMenu.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. require({cache:{
  2. 'url:dijit/templates/Menu.html':"<table class=\"dijit dijitMenu dijitMenuPassive dijitReset dijitMenuTable\" role=\"menu\" tabIndex=\"${tabIndex}\" data-dojo-attach-event=\"onkeypress:_onKeyPress\" cellspacing=\"0\">\n\t<tbody class=\"dijitReset\" data-dojo-attach-point=\"containerNode\"></tbody>\n</table>\n"}});
  3. define("dijit/DropDownMenu", [
  4. "dojo/_base/declare", // declare
  5. "dojo/_base/event", // event.stop
  6. "dojo/keys", // keys
  7. "dojo/text!./templates/Menu.html",
  8. "./_OnDijitClickMixin",
  9. "./_MenuBase"
  10. ], function(declare, event, keys, template, _OnDijitClickMixin, _MenuBase){
  11. /*=====
  12. var _MenuBase = dijit._MenuBase;
  13. var _OnDijitClickMixin = dijit._OnDijitClickMixin;
  14. =====*/
  15. // module:
  16. // dijit/DropDownMenu
  17. // summary:
  18. // dijit.DropDownMenu widget
  19. return declare("dijit.DropDownMenu", [_MenuBase, _OnDijitClickMixin], {
  20. // summary:
  21. // A menu, without features for context menu (Meaning, drop down menu)
  22. templateString: template,
  23. baseClass: "dijitMenu",
  24. postCreate: function(){
  25. var l = this.isLeftToRight();
  26. this._openSubMenuKey = l ? keys.RIGHT_ARROW : keys.LEFT_ARROW;
  27. this._closeSubMenuKey = l ? keys.LEFT_ARROW : keys.RIGHT_ARROW;
  28. this.connectKeyNavHandlers([keys.UP_ARROW], [keys.DOWN_ARROW]);
  29. },
  30. _onKeyPress: function(/*Event*/ evt){
  31. // summary:
  32. // Handle keyboard based menu navigation.
  33. // tags:
  34. // protected
  35. if(evt.ctrlKey || evt.altKey){ return; }
  36. switch(evt.charOrCode){
  37. case this._openSubMenuKey:
  38. this._moveToPopup(evt);
  39. event.stop(evt);
  40. break;
  41. case this._closeSubMenuKey:
  42. if(this.parentMenu){
  43. if(this.parentMenu._isMenuBar){
  44. this.parentMenu.focusPrev();
  45. }else{
  46. this.onCancel(false);
  47. }
  48. }else{
  49. event.stop(evt);
  50. }
  51. break;
  52. }
  53. }
  54. });
  55. });