DropDownMenu.js.uncompressed.js 1.7 KB

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