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