fixed the resizable text area with IE problem fixed the ad space with IE problem merged the 7.2.0 and 7.1.4 change logs
764 lines
29 KiB
HTML
764 lines
29 KiB
HTML
|
|
<html>
|
|
<head>
|
|
<title>JavaScript Documentation - Dialog.js</title>
|
|
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="header">
|
|
<h1>JavaScript Documentation</h1>
|
|
<h3><a href="./index.html">Yahoo! UI Library: Container</a></h3>
|
|
|
|
<div class="breadcrumbs">
|
|
|
|
|
|
|
|
|
|
<a href="./index.html">Yahoo! UI Library: Container</a>
|
|
>
|
|
<strong>Dialog.js</strong>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="body">
|
|
|
|
|
|
<div class="nav">
|
|
<div class="module resources">
|
|
<ul class="content">
|
|
<li><a href="overview-tree.html">Tree View</a></li>
|
|
<li><a href="index-all.html">Element Index</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
<div class="module">
|
|
<h4><a href="./allclasses-noframe.html">Classes</a></h4>
|
|
<ul class="content">
|
|
|
|
|
|
|
|
<li>
|
|
<a href="YAHOO.util.Config.html">
|
|
YAHOO.util.Config</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.util.KeyListener.html">
|
|
YAHOO.util.KeyListener</a>
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.ContainerEffect.html">
|
|
YAHOO.widget.ContainerEffect</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.Dialog.html">
|
|
YAHOO.widget.Dialog</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.Module.html">
|
|
YAHOO.widget.Module</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.Overlay.html">
|
|
YAHOO.widget.Overlay</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.OverlayManager.html">
|
|
YAHOO.widget.OverlayManager</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.Panel.html">
|
|
YAHOO.widget.Panel</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.SimpleDialog.html">
|
|
YAHOO.widget.SimpleDialog</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="YAHOO.widget.Tooltip.html">
|
|
YAHOO.widget.Tooltip</a>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="module">
|
|
<h4><a href="./overview-summary.html">Files</a></h4>
|
|
<ul class="content">
|
|
|
|
<li>
|
|
<a href="overview-summary-Config.js.html">
|
|
Config.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-ContainerEffect.js.html">
|
|
ContainerEffect.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-Dialog.js.html">
|
|
Dialog.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-KeyListener.js.html">
|
|
KeyListener.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-Module.js.html">
|
|
Module.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-Overlay.js.html">
|
|
Overlay.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-OverlayManager.js.html">
|
|
OverlayManager.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-Panel.js.html">
|
|
Panel.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-SimpleDialog.js.html">
|
|
SimpleDialog.js</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="overview-summary-Tooltip.js.html">
|
|
Tooltip.js</a>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="main">
|
|
|
|
|
|
|
|
|
|
<h2>Dialog.js</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="meta">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="quick-links">
|
|
<strong>Quick Links:</strong>
|
|
|
|
|
|
<a href="#classSummary">Class Summary</a> |
|
|
|
|
|
|
|
|
|
|
|
|
<a href="#source">Source Code</a>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="section class summaries">
|
|
<h3><a name="classSummary">Class Summary</a> <span class="top">[<a href="#top">top</a>]</span></h3>
|
|
|
|
<div class="content">
|
|
<table border="1" cellpadding="3" cellspacing="0">
|
|
|
|
<tr>
|
|
<td class="name">
|
|
<a href="YAHOO.widget.Dialog.html">YAHOO.widget.Dialog</a>
|
|
</td>
|
|
<td class="overview"> </td>
|
|
</tr>
|
|
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="section source">
|
|
<h3><a name="source">Souce Code</a> <span class="top">[<a href="#top">top</a>]</span></h3>
|
|
<pre class="sourceview"><span class="comment">/*
|
|
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
|
Code licensed under the BSD License:
|
|
http://developer.yahoo.net/yui/license.txt
|
|
Version 0.11.3
|
|
*/</span>
|
|
|
|
<span class="comment">/**
|
|
* 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.
|
|
* <span class="attrib">@extends</span> YAHOO.widget.Panel
|
|
* <span class="attrib">@param</span> {string} el The element ID representing the Dialog <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} el The element representing the Dialog
|
|
* <span class="attrib">@param</span> {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
|
|
* <span class="attrib">@constructor</span>
|
|
*/</span>
|
|
YAHOO.widget.Dialog = <span class="reserved">function</span>(el, userConfig) {
|
|
YAHOO.widget.Dialog.superclass.constructor.call(<span class="reserved">this</span>, el, userConfig);
|
|
};
|
|
|
|
YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the default CSS class used for a Dialog
|
|
* <span class="attrib">@type</span> string
|
|
* <span class="attrib">@final</span>
|
|
*/</span>
|
|
YAHOO.widget.Dialog.CSS_DIALOG = <span class="literal">"dialog"</span>;
|
|
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired prior to submission
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.beforeSubmitEvent = null;
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired after submission
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.submitEvent = null;
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired prior to manual submission
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.manualSubmitEvent = null;
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired prior to asynchronous submission
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.asyncSubmitEvent = null;
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired prior to form-based submission
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.formSubmitEvent = null;
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired after cancel
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.cancelEvent = null;
|
|
|
|
|
|
<span class="comment">/**
|
|
* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.initDefaultConfig = <span class="reserved">function</span>() {
|
|
YAHOO.widget.Dialog.superclass.initDefaultConfig.call(<span class="reserved">this</span>);
|
|
|
|
<span class="comment">/**
|
|
* The internally maintained callback object for use with the Connection utility
|
|
* <span class="attrib">@type</span> object
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
<span class="reserved">this</span>.callback = {
|
|
success : null,
|
|
failure : null,
|
|
argument: null
|
|
};
|
|
|
|
<span class="reserved">this</span>.doSubmit = <span class="reserved">function</span>() {
|
|
var method = <span class="reserved">this</span>.cfg.getProperty(<span class="literal">"postmethod"</span>);
|
|
switch (method) {
|
|
case <span class="literal">"async"</span>:
|
|
YAHOO.util.Connect.setForm(<span class="reserved">this</span>.form);
|
|
var cObj = YAHOO.util.Connect.asyncRequest(<span class="literal">'POST'</span>, <span class="reserved">this</span>.form.action, <span class="reserved">this</span>.callback);
|
|
<span class="reserved">this</span>.asyncSubmitEvent.fire();
|
|
break;
|
|
case <span class="literal">"form"</span>:
|
|
<span class="reserved">this</span>.form.submit();
|
|
<span class="reserved">this</span>.formSubmitEvent.fire();
|
|
break;
|
|
case <span class="literal">"none"</span>:
|
|
case <span class="literal">"manual"</span>:
|
|
<span class="reserved">this</span>.manualSubmitEvent.fire();
|
|
break;
|
|
}
|
|
};
|
|
|
|
<span class="comment">// Add form dialog config properties //</span>
|
|
<span class="reserved">this</span>.cfg.addProperty(<span class="literal">"postmethod"</span>, { value:<span class="literal">"async"</span>, validator:<span class="reserved">function</span>(val) {
|
|
<span class="reserved">if</span> (val != <span class="literal">"form"</span> && val != <span class="literal">"async"</span> && val != <span class="literal">"none"</span> && val != <span class="literal">"manual"</span>) {
|
|
<span class="reserved">return</span> false;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">return</span> true;
|
|
}
|
|
} });
|
|
|
|
<span class="reserved">this</span>.cfg.addProperty(<span class="literal">"buttons"</span>, { value:<span class="literal">"none"</span>, handler:<span class="reserved">this</span>.configButtons } );
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.initEvents = <span class="reserved">function</span>() {
|
|
YAHOO.widget.Dialog.superclass.initEvents.call(<span class="reserved">this</span>);
|
|
|
|
<span class="reserved">this</span>.beforeSubmitEvent = new YAHOO.util.CustomEvent(<span class="literal">"beforeSubmit"</span>);
|
|
<span class="reserved">this</span>.submitEvent = new YAHOO.util.CustomEvent(<span class="literal">"submit"</span>);
|
|
|
|
<span class="reserved">this</span>.manualSubmitEvent = new YAHOO.util.CustomEvent(<span class="literal">"manualSubmit"</span>);
|
|
<span class="reserved">this</span>.asyncSubmitEvent = new YAHOO.util.CustomEvent(<span class="literal">"asyncSubmit"</span>);
|
|
<span class="reserved">this</span>.formSubmitEvent = new YAHOO.util.CustomEvent(<span class="literal">"formSubmit"</span>);
|
|
|
|
<span class="reserved">this</span>.cancelEvent = new YAHOO.util.CustomEvent(<span class="literal">"cancel"</span>);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* 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.
|
|
* <span class="attrib">@param</span> {string} el The element ID representing the Dialog <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} el The element representing the Dialog
|
|
* <span class="attrib">@param</span> {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.init = <span class="reserved">function</span>(el, userConfig) {
|
|
YAHOO.widget.Dialog.superclass.init.call(<span class="reserved">this</span>, el<span class="comment">/*, userConfig*/</span>); <span class="comment">// Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level</span>
|
|
|
|
<span class="reserved">this</span>.beforeInitEvent.fire(YAHOO.widget.Dialog);
|
|
|
|
YAHOO.util.Dom.addClass(<span class="reserved">this</span>.element, YAHOO.widget.Dialog.CSS_DIALOG);
|
|
|
|
<span class="reserved">this</span>.cfg.setProperty(<span class="literal">"visible"</span>, false);
|
|
|
|
<span class="reserved">if</span> (userConfig) {
|
|
<span class="reserved">this</span>.cfg.applyConfig(userConfig, true);
|
|
}
|
|
|
|
<span class="reserved">this</span>.renderEvent.subscribe(<span class="reserved">this</span>.registerForm, <span class="reserved">this</span>, true);
|
|
|
|
<span class="reserved">this</span>.showEvent.subscribe(<span class="reserved">this</span>.focusFirst, <span class="reserved">this</span>, true);
|
|
<span class="reserved">this</span>.beforeHideEvent.subscribe(<span class="reserved">this</span>.blurButtons, <span class="reserved">this</span>, true);
|
|
|
|
<span class="reserved">this</span>.beforeRenderEvent.subscribe(<span class="reserved">function</span>() {
|
|
var buttonCfg = <span class="reserved">this</span>.cfg.getProperty(<span class="literal">"buttons"</span>);
|
|
<span class="reserved">if</span> (buttonCfg && buttonCfg != <span class="literal">"none"</span>) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.footer) {
|
|
<span class="reserved">this</span>.setFooter(<span class="literal">""</span>);
|
|
}
|
|
}
|
|
}, <span class="reserved">this</span>, true);
|
|
|
|
<span class="reserved">this</span>.initEvent.fire(YAHOO.widget.Dialog);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Prepares the Dialog's internal FORM object, creating one if one is not currently present.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.registerForm = <span class="reserved">function</span>() {
|
|
var form = <span class="reserved">this</span>.element.getElementsByTagName(<span class="literal">"FORM"</span>)[0];
|
|
|
|
<span class="reserved">if</span> (! form) {
|
|
var formHTML = <span class="literal">"<form name=\"</span>frm_<span class="literal">" + this.id + "</span>\<span class="literal">" action=\"</span>\<span class="literal">"></form>"</span>;
|
|
<span class="reserved">this</span>.body.innerHTML += formHTML;
|
|
form = <span class="reserved">this</span>.element.getElementsByTagName(<span class="literal">"FORM"</span>)[0];
|
|
}
|
|
|
|
<span class="reserved">this</span>.firstFormElement = <span class="reserved">function</span>() {
|
|
<span class="reserved">for</span> (var f=0;f<form.elements.length;f++ ) {
|
|
var el = form.elements[f];
|
|
<span class="reserved">if</span> (el.focus) {
|
|
<span class="reserved">if</span> (el.type && el.type != <span class="literal">"hidden"</span>) {
|
|
<span class="reserved">return</span> el;
|
|
}
|
|
}
|
|
}
|
|
<span class="reserved">return</span> null;
|
|
}();
|
|
|
|
<span class="reserved">this</span>.lastFormElement = <span class="reserved">function</span>() {
|
|
<span class="reserved">for</span> (var f=form.elements.length-1;f>=0;f-- ) {
|
|
var el = form.elements[f];
|
|
<span class="reserved">if</span> (el.focus) {
|
|
<span class="reserved">if</span> (el.type && el.type != <span class="literal">"hidden"</span>) {
|
|
<span class="reserved">return</span> el;
|
|
}
|
|
}
|
|
}
|
|
<span class="reserved">return</span> null;
|
|
}();
|
|
|
|
<span class="reserved">this</span>.form = form;
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.cfg.getProperty(<span class="literal">"modal"</span>) && <span class="reserved">this</span>.form) {
|
|
|
|
var me = <span class="reserved">this</span>;
|
|
|
|
var firstElement = <span class="reserved">this</span>.firstFormElement || <span class="reserved">this</span>.firstButton;
|
|
<span class="reserved">if</span> (firstElement) {
|
|
<span class="reserved">this</span>.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
|
|
<span class="reserved">this</span>.showEvent.subscribe(<span class="reserved">this</span>.preventBackTab.enable, <span class="reserved">this</span>.preventBackTab, true);
|
|
<span class="reserved">this</span>.hideEvent.subscribe(<span class="reserved">this</span>.preventBackTab.disable, <span class="reserved">this</span>.preventBackTab, true);
|
|
}
|
|
|
|
var lastElement = <span class="reserved">this</span>.lastButton || <span class="reserved">this</span>.lastFormElement;
|
|
<span class="reserved">if</span> (lastElement) {
|
|
<span class="reserved">this</span>.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
|
|
<span class="reserved">this</span>.showEvent.subscribe(<span class="reserved">this</span>.preventTabOut.enable, <span class="reserved">this</span>.preventTabOut, true);
|
|
<span class="reserved">this</span>.hideEvent.subscribe(<span class="reserved">this</span>.preventTabOut.disable, <span class="reserved">this</span>.preventTabOut, true);
|
|
}
|
|
}
|
|
};
|
|
|
|
<span class="comment">// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //</span>
|
|
|
|
<span class="comment">/**
|
|
* The default event handler for the "buttons" configuration property
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.configButtons = <span class="reserved">function</span>(type, args, obj) {
|
|
var buttons = args[0];
|
|
<span class="reserved">if</span> (buttons != <span class="literal">"none"</span>) {
|
|
<span class="reserved">this</span>.buttonSpan = null;
|
|
<span class="reserved">this</span>.buttonSpan = document.createElement(<span class="literal">"SPAN"</span>);
|
|
<span class="reserved">this</span>.buttonSpan.className = <span class="literal">"button-group"</span>;
|
|
|
|
<span class="reserved">for</span> (var b=0;b<buttons.length;b++) {
|
|
var button = buttons[b];
|
|
|
|
var htmlButton = document.createElement(<span class="literal">"BUTTON"</span>);
|
|
htmlButton.setAttribute(<span class="literal">"type"</span>, <span class="literal">"button"</span>);
|
|
|
|
<span class="reserved">if</span> (button.isDefault) {
|
|
htmlButton.className = <span class="literal">"default"</span>;
|
|
<span class="reserved">this</span>.defaultHtmlButton = htmlButton;
|
|
}
|
|
|
|
htmlButton.appendChild(document.createTextNode(button.text));
|
|
YAHOO.util.Event.addListener(htmlButton, <span class="literal">"click"</span>, button.handler, <span class="reserved">this</span>, true);
|
|
|
|
<span class="reserved">this</span>.buttonSpan.appendChild(htmlButton);
|
|
button.htmlButton = htmlButton;
|
|
|
|
<span class="reserved">if</span> (b === 0) {
|
|
<span class="reserved">this</span>.firstButton = button.htmlButton;
|
|
}
|
|
|
|
<span class="reserved">if</span> (b == (buttons.length-1)) {
|
|
<span class="reserved">this</span>.lastButton = button.htmlButton;
|
|
}
|
|
|
|
}
|
|
|
|
<span class="reserved">this</span>.setFooter(<span class="reserved">this</span>.buttonSpan);
|
|
|
|
<span class="reserved">this</span>.cfg.refireEvent(<span class="literal">"iframe"</span>);
|
|
<span class="reserved">this</span>.cfg.refireEvent(<span class="literal">"underlay"</span>);
|
|
} <span class="reserved">else</span> { <span class="comment">// Do cleanup</span>
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.buttonSpan) {
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.buttonSpan.parentNode) {
|
|
<span class="reserved">this</span>.buttonSpan.parentNode.removeChild(<span class="reserved">this</span>.buttonSpan);
|
|
}
|
|
|
|
<span class="reserved">this</span>.buttonSpan = null;
|
|
<span class="reserved">this</span>.firstButton = null;
|
|
<span class="reserved">this</span>.lastButton = null;
|
|
<span class="reserved">this</span>.defaultHtmlButton = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* The default handler fired when the "success" property is changed. Used for asynchronous submission only.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.configOnSuccess = <span class="reserved">function</span>(type,args,obj){};
|
|
|
|
<span class="comment">/**
|
|
* The default handler fired when the "failure" property is changed. Used for asynchronous submission only.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.configOnFailure = <span class="reserved">function</span>(type,args,obj){};
|
|
|
|
<span class="comment">/**
|
|
* Executes a submission of the form based on the value of the postmethod property.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.doSubmit = <span class="reserved">function</span>() {};
|
|
|
|
<span class="comment">/**
|
|
* The default event handler used to focus the first field of the form when the Dialog is shown.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.focusFirst = <span class="reserved">function</span>(type,args,obj) {
|
|
<span class="reserved">if</span> (args) {
|
|
var e = args[1];
|
|
<span class="reserved">if</span> (e) {
|
|
YAHOO.util.Event.stopEvent(e);
|
|
}
|
|
}
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.firstFormElement) {
|
|
<span class="reserved">this</span>.firstFormElement.focus();
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.focusDefaultButton();
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Sets the focus to the last button in the button or form element in the Dialog
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.focusLast = <span class="reserved">function</span>(type,args,obj) {
|
|
<span class="reserved">if</span> (args) {
|
|
var e = args[1];
|
|
<span class="reserved">if</span> (e) {
|
|
YAHOO.util.Event.stopEvent(e);
|
|
}
|
|
}
|
|
|
|
var buttons = <span class="reserved">this</span>.cfg.getProperty(<span class="literal">"buttons"</span>);
|
|
<span class="reserved">if</span> (buttons && buttons instanceof Array) {
|
|
<span class="reserved">this</span>.focusLastButton();
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.lastFormElement) {
|
|
<span class="reserved">this</span>.lastFormElement.focus();
|
|
}
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Sets the focus to the button that is designated as the default. By default, his handler is executed when the show event is fired.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.focusDefaultButton = <span class="reserved">function</span>() {
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.defaultHtmlButton) {
|
|
<span class="reserved">this</span>.defaultHtmlButton.focus();
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Blurs all the html buttons
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.blurButtons = <span class="reserved">function</span>() {
|
|
var buttons = <span class="reserved">this</span>.cfg.getProperty(<span class="literal">"buttons"</span>);
|
|
<span class="reserved">if</span> (buttons && buttons instanceof Array) {
|
|
var html = buttons[0].htmlButton;
|
|
<span class="reserved">if</span> (html) {
|
|
html.blur();
|
|
}
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Sets the focus to the first button in the button list
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.focusFirstButton = <span class="reserved">function</span>() {
|
|
var buttons = <span class="reserved">this</span>.cfg.getProperty(<span class="literal">"buttons"</span>);
|
|
<span class="reserved">if</span> (buttons && buttons instanceof Array) {
|
|
var html = buttons[0].htmlButton;
|
|
<span class="reserved">if</span> (html) {
|
|
html.focus();
|
|
}
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Sets the focus to the first button in the button list
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.focusLastButton = <span class="reserved">function</span>() {
|
|
var buttons = <span class="reserved">this</span>.cfg.getProperty(<span class="literal">"buttons"</span>);
|
|
<span class="reserved">if</span> (buttons && buttons instanceof Array) {
|
|
var html = buttons[buttons.length-1].htmlButton;
|
|
<span class="reserved">if</span> (html) {
|
|
html.focus();
|
|
}
|
|
}
|
|
};
|
|
|
|
<span class="comment">// END BUILT-IN PROPERTY EVENT HANDLERS //</span>
|
|
|
|
<span class="comment">/**
|
|
* 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.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.validate = <span class="reserved">function</span>() {
|
|
<span class="reserved">return</span> true;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Executes a submit of the Dialog followed by a hide, if validation is successful.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.submit = <span class="reserved">function</span>() {
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.validate()) {
|
|
<span class="reserved">this</span>.beforeSubmitEvent.fire();
|
|
<span class="reserved">this</span>.doSubmit();
|
|
<span class="reserved">this</span>.submitEvent.fire();
|
|
<span class="reserved">this</span>.hide();
|
|
<span class="reserved">return</span> true;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Executes the cancel of the Dialog followed by a hide.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.cancel = <span class="reserved">function</span>() {
|
|
<span class="reserved">this</span>.cancelEvent.fire();
|
|
<span class="reserved">this</span>.hide();
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns a JSON-compatible data structure representing the data currently contained in the form.
|
|
* <span class="attrib">@return</span> {object} A JSON object reprsenting the data of the current form.
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.getData = <span class="reserved">function</span>() {
|
|
var form = <span class="reserved">this</span>.form;
|
|
var data = {};
|
|
|
|
<span class="reserved">if</span> (form) {
|
|
<span class="reserved">for</span> (var i in <span class="reserved">this</span>.form) {
|
|
var formItem = form[i];
|
|
<span class="reserved">if</span> (formItem) {
|
|
<span class="reserved">if</span> (formItem.tagName) { <span class="comment">// Got a single form item</span>
|
|
switch (formItem.tagName) {
|
|
case <span class="literal">"INPUT"</span>:
|
|
switch (formItem.type) {
|
|
case <span class="literal">"checkbox"</span>:
|
|
data[i] = formItem.checked;
|
|
break;
|
|
case <span class="literal">"textbox"</span>:
|
|
case <span class="literal">"text"</span>:
|
|
case <span class="literal">"hidden"</span>:
|
|
data[i] = formItem.value;
|
|
break;
|
|
}
|
|
break;
|
|
case <span class="literal">"TEXTAREA"</span>:
|
|
data[i] = formItem.value;
|
|
break;
|
|
case <span class="literal">"SELECT"</span>:
|
|
var val = [];
|
|
<span class="reserved">for</span> (var x=0;x<formItem.options.length;x++) {
|
|
var option = formItem.options[x];
|
|
<span class="reserved">if</span> (option.selected) {
|
|
var selval = option.value;
|
|
<span class="reserved">if</span> (! selval || selval === <span class="literal">""</span>) {
|
|
selval = option.text;
|
|
}
|
|
val[val.length] = selval;
|
|
}
|
|
}
|
|
data[i] = val;
|
|
break;
|
|
}
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (formItem[0] && formItem[0].tagName) { <span class="comment">// this is an array of form items</span>
|
|
switch (formItem[0].tagName) {
|
|
case <span class="literal">"INPUT"</span> :
|
|
switch (formItem[0].type) {
|
|
case <span class="literal">"radio"</span>:
|
|
<span class="reserved">for</span> (var r=0; r<formItem.length; r++) {
|
|
var radio = formItem[r];
|
|
<span class="reserved">if</span> (radio.checked) {
|
|
data[radio.name] = radio.value;
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
case <span class="literal">"checkbox"</span>:
|
|
var cbArray = [];
|
|
<span class="reserved">for</span> (var c=0; c<formItem.length; c++) {
|
|
var check = formItem[c];
|
|
<span class="reserved">if</span> (check.checked) {
|
|
cbArray[cbArray.length] = check.value;
|
|
}
|
|
}
|
|
data[formItem[0].name] = cbArray;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
<span class="reserved">return</span> data;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns a string representation of the object.
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
YAHOO.widget.Dialog.<span class="reserved">prototype</span>.toString = <span class="reserved">function</span>() {
|
|
<span class="reserved">return</span> <span class="literal">"Dialog "</span> + <span class="reserved">this</span>.id;
|
|
};</pre>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div id="footer">
|
|
<hr />
|
|
Copyright © 2006 Yahoo! Inc. All rights reserved.
|
|
<br /><br />
|
|
Documentation generated by <a href="http://jsdoc.sourceforge.net/">
|
|
JSDoc</a>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|