_DialogMixin.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. define("dijit/_DialogMixin", [
  2. "dojo/_base/declare", // declare
  3. "./a11y" // _getTabNavigable
  4. ], function(declare, a11y){
  5. // module:
  6. // dijit/_DialogMixin
  7. // summary:
  8. // _DialogMixin provides functions useful to Dialog and TooltipDialog
  9. return declare("dijit._DialogMixin", null, {
  10. // summary:
  11. // This provides functions useful to Dialog and TooltipDialog
  12. execute: function(/*Object*/ /*===== formContents =====*/){
  13. // summary:
  14. // Callback when the user hits the submit button.
  15. // Override this method to handle Dialog execution.
  16. // description:
  17. // After the user has pressed the submit button, the Dialog
  18. // first calls onExecute() to notify the container to hide the
  19. // dialog and restore focus to wherever it used to be.
  20. //
  21. // *Then* this method is called.
  22. // type:
  23. // callback
  24. },
  25. onCancel: function(){
  26. // summary:
  27. // Called when user has pressed the Dialog's cancel button, to notify container.
  28. // description:
  29. // Developer shouldn't override or connect to this method;
  30. // it's a private communication device between the TooltipDialog
  31. // and the thing that opened it (ex: `dijit.form.DropDownButton`)
  32. // type:
  33. // protected
  34. },
  35. onExecute: function(){
  36. // summary:
  37. // Called when user has pressed the dialog's OK button, to notify container.
  38. // description:
  39. // Developer shouldn't override or connect to this method;
  40. // it's a private communication device between the TooltipDialog
  41. // and the thing that opened it (ex: `dijit.form.DropDownButton`)
  42. // type:
  43. // protected
  44. },
  45. _onSubmit: function(){
  46. // summary:
  47. // Callback when user hits submit button
  48. // type:
  49. // protected
  50. this.onExecute(); // notify container that we are about to execute
  51. this.execute(this.get('value'));
  52. },
  53. _getFocusItems: function(){
  54. // summary:
  55. // Finds focusable items in dialog,
  56. // and sets this._firstFocusItem and this._lastFocusItem
  57. // tags:
  58. // protected
  59. var elems = a11y._getTabNavigable(this.containerNode);
  60. this._firstFocusItem = elems.lowest || elems.first || this.closeButtonNode || this.domNode;
  61. this._lastFocusItem = elems.last || elems.highest || this._firstFocusItem;
  62. }
  63. });
  64. });