- Known Subclasses:
-
YAHOO.widget.SimpleDialog
Dialog is an implementation of Panel that can be used to submit form
data. Built-in functionality for buttons with event handlers is included,
and button sets can be build dynamically, or the preincluded ones for
Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3
ways -- via an asynchronous Connection utility call, a simple form
POST or GET, or manually.
Constructor
YAHOO.widget.Dialog
(
el
,
userConfig
)
- Parameters:
-
el
<String>
The element ID representing the Dialog OR
-
el
<HTMLElement>
The element representing the Dialog
-
userConfig
<Object>
The configuration object literal containing
the configuration that should be set for this Dialog. See configuration
documentation for more details.
Properties
The internally maintained callback object for use with the
Connection utility
The arbitraty argument or arguments to pass to the Connection
callback functions
The function to execute upon failure of the
Connection submission
The function to execute upon success of the
Connection submission
Constant representing the Dialog's configuration properties
EVENT_TYPES
- private final Object
Constant representing the name of the Dialog's events
Object reference to the Dialog's
<form>
element.
Default Value: null
Constant representing the default CSS class used for a Dialog
body,
browser,
cfg,
contructor,
DEFAULT_CONFIG,
element,
EVENT_TYPES,
footer,
header,
id,
imageRoot,
isSecure,
platform
Methods
void
blurButtons
(
)
Blurs all the buttons defined via the "buttons"
configuration property.
void
cancel
(
)
Executes the cancel of the Dialog followed by a hide.
void
configButtons
(
type
,
args
,
obj
)
The default event handler for the "buttons" configuration property
- Parameters:
-
type <String>
The CustomEvent type (usually the property name)
-
args <Object[]>
The CustomEvent arguments. For configuration
handlers, args[0] will equal the newly applied value for the property.
-
obj <Object>
The scope object. For configuration handlers,
this will usually equal the owner.
- Returns:
void
void
configClose
(
type
,
args
,
obj
)
The default event handler fired when the "close" property is
changed. The method controls the appending or hiding of the close
icon at the top right of the Dialog.
- Parameters:
-
type <String>
The CustomEvent type (usually the property name)
-
args <Object[]>
The CustomEvent arguments. For
configuration handlers, args[0] will equal the newly applied value
for the property.
-
obj <Object>
The scope object. For configuration handlers,
this will usually equal the owner.
- Returns:
void
void
configPostMethod
(
type
,
args
,
obj
)
The default event handler for the "postmethod" configuration property
- Parameters:
-
type <String>
The CustomEvent type (usually the property name)
-
args <Object[]>
The CustomEvent arguments. For
configuration handlers, args[0] will equal the newly applied value
for the property.
-
obj <Object>
The scope object. For configuration handlers,
this will usually equal the owner.
- Returns:
void
void
destroy
(
)
Removes the Panel element from the DOM and sets all child elements
to null.
void
doSubmit
(
)
Submits the Dialog's form depending on the value of the
"postmethod" configuration property.
Please note:
As of version 2.3 this method will automatically handle
asyncronous file uploads should the Dialog instance's form contain
<input type="file">
elements. If a Dialog
instance will be handling asyncronous file uploads, its
callback
property will need to be setup with a
upload
handler rather than the standard
success
and, or
failure
handlers. For more
information, see the
Connection Manager documenation on file uploads.
void
focusDefaultButton
(
)
Sets the focus to the button that is designated as the default via
the "buttons" configuration property. By default, this method is
called when the Dialog is made visible.
void
focusFirst
(
)
Sets focus to the first element in the Dialog's form or the first
button defined via the "buttons" configuration property. Called
when the Dialog is made visible.
void
focusFirstButton
(
)
Sets the focus to the first button created via the "buttons"
configuration property.
void
focusLast
(
)
Sets focus to the last element in the Dialog's form or the last
button defined via the "buttons" configuration property.
void
focusLastButton
(
)
Sets the focus to the last button created via the "buttons"
configuration property.
Array
getButtons
(
)
Returns an array containing each of the Dialog's
buttons, by default an array of HTML <BUTTON<
elements. If the Dialog's buttons were created using the
YAHOO.widget.Button class (via the inclusion of the optional Button
dependancy on the page), an array of YAHOO.widget.Button instances
is returned.
Object
getData
(
)
Returns a JSON-compatible data structure representing the data
currently contained in the form.
- Returns:
Object
- A JSON object reprsenting the data of the
current form.
void
init
(
el
,
userConfig
)
The Dialog initialization method, which is executed for Dialog and
all of its subclasses. This method is automatically called by the
constructor, and sets up all DOM references for pre-existing markup,
and creates required markup if it is not already present.
- Parameters:
-
el <String>
The element ID representing the Dialog OR
-
el <HTMLElement>
The element representing the Dialog
-
userConfig <Object>
The configuration object literal
containing the configuration that should be set for this Dialog.
See configuration documentation for more details.
- Returns:
void
void
initDefaultConfig
(
)
Initializes the class's configurable properties which can be changed
using the Dialog's Config object (cfg).
void
initEvents
(
)
Initializes the custom events for Dialog which are fired
automatically at appropriate times by the Dialog class.
void
registerForm
(
)
Prepares the Dialog's internal FORM object, creating one if one is
not currently present.
void
submit
(
)
Executes a submit of the Dialog followed by a hide, if validation
is successful.
String
toString
(
)
Returns a string representation of the object.
- Returns:
String
- The string representation of the Dialog
void
validate
(
)
Built-in function hook for writing a validation function that will
be checked for a "true" value prior to a submit. This function, as
implemented by default, always returns true, so it should be
overridden if validation is necessary.
buildMask, buildWrapper, configClose, configDraggable, configHeight, configKeyListeners, configModal, configUnderlay, configWidth, configzIndex, destroy, hideMask, init, initDefaultConfig, initEvents, registerDragDrop, removeMask, render, showMask, sizeMask, sizeUnderlay, stackMask, toString
_addToParent, appendToBody, appendToFooter, appendToHeader, configMonitorResize, configVisible, destroy, hide, init, initDefaultConfig, initEvents, initResizeMonitor, onDomResize, render, setBody, setFooter, setHeader, show, toString
align, bringToTop, center, configConstrainToViewport, configContext, configFixedCenter, configHeight, configIframe, configVisible, configWidth, configX, configXY, configY, configzIndex, destroy, doCenterOnDOMEvent, enforceConstraints, hideIframe, hideMacGeckoScrollbars, init, initDefaultConfig, initEvents, moveTo, onDomResize, showIframe, showMacGeckoScrollbars, stackIframe, syncIframe, syncPosition, toString
Events
asyncSubmitEvent
(
)
CustomEvent fired prior to asynchronous submission
beforeSubmitEvent
(
)
CustomEvent fired prior to submission
cancelEvent
(
)
CustomEvent fired after cancel
formSubmitEvent
(
)
CustomEvent fired prior to form-based submission
manualSubmitEvent
(
)
CustomEvent fired prior to manual submission
submitEvent
(
)
CustomEvent fired after submission
Configuration Attributes
buttons
- {Array|String}
Array of object literals, each containing a set of properties
defining a button to be appended into the Dialog's footer.
Each button object in the buttons array can have three properties:
text:
The text that will display on the face of the button.
Please note: As of version 2.3, the text can include
HTML.
handler:
Can be either:
- A reference to a function that should fire when the
button is clicked. (In this case scope of this function is
always its Dialog instance.)
- An object literal representing the code to be
executed when the button is clicked. Format:
{
fn: Function, // The handler to call
when the event fires.
obj: Object,
// An object to pass back to the handler.
scope: Object // The object to use for the
scope of the handler.
}
Please note: this
functionality was added in version 2.3.
isDefault:
An optional boolean value that specifies that a button
should be highlighted and focused by default.
Default Value: "none"
The method to use for posting the Dialog's form. Possible values
are "async", "form", and "manual".
Default Value: async
Configuration attributes inherited from YAHOO.widget.Overlay:
constraintoviewport, context, fixedcenter, height, iframe, width, x, xy, y, zIndex,