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
965 lines
38 KiB
HTML
965 lines
38 KiB
HTML
|
|
<html>
|
|
<head>
|
|
<title>JavaScript Documentation - Module.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>Module.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>Module.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.Module.html">YAHOO.widget.Module</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">/**
|
|
* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.
|
|
* <span class="attrib">@param</span> {string} el The element ID representing the Module <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} el The element representing the Module
|
|
* <span class="attrib">@param</span> {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
|
|
* <span class="attrib">@constructor</span>
|
|
*/</span>
|
|
YAHOO.widget.Module = <span class="reserved">function</span>(el, userConfig) {
|
|
<span class="reserved">if</span> (el) {
|
|
<span class="reserved">this</span>.init(el, userConfig);
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the prefix path to use for non-secure images
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
YAHOO.widget.Module.IMG_ROOT = <span class="literal">"http://us.i1.yimg.com/us.yimg.com/i/"</span>;
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the prefix path to use for securely served images
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
YAHOO.widget.Module.IMG_ROOT_SSL = <span class="literal">"https://a248.e.akamai.net/sec.yimg.com/i/"</span>;
|
|
|
|
<span class="comment">/**
|
|
* Constant for the default CSS class name that represents a Module
|
|
* <span class="attrib">@type</span> string
|
|
* <span class="attrib">@final</span>
|
|
*/</span>
|
|
YAHOO.widget.Module.CSS_MODULE = <span class="literal">"module"</span>;
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the module header
|
|
* <span class="attrib">@type</span> string
|
|
* <span class="attrib">@final</span>
|
|
*/</span>
|
|
YAHOO.widget.Module.CSS_HEADER = <span class="literal">"hd"</span>;
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the module body
|
|
* <span class="attrib">@type</span> string
|
|
* <span class="attrib">@final</span>
|
|
*/</span>
|
|
YAHOO.widget.Module.CSS_BODY = <span class="literal">"bd"</span>;
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the module footer
|
|
* <span class="attrib">@type</span> string
|
|
* <span class="attrib">@final</span>
|
|
*/</span>
|
|
YAHOO.widget.Module.CSS_FOOTER = <span class="literal">"ft"</span>;
|
|
|
|
<span class="comment">/**
|
|
* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
|
|
* <span class="attrib">@type</span> string
|
|
* <span class="attrib">@final</span>
|
|
*/</span>
|
|
YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = <span class="literal">"javascript:false"</span>;
|
|
|
|
YAHOO.widget.Module.<span class="reserved">prototype</span> = {
|
|
|
|
<span class="comment">/**
|
|
* The class's constructor function
|
|
* <span class="attrib">@type</span> function
|
|
*/</span>
|
|
constructor : YAHOO.widget.Module,
|
|
|
|
<span class="comment">/**
|
|
* The main module element that contains the header, body, and footer
|
|
* <span class="attrib">@type</span> Element
|
|
*/</span>
|
|
element : null,
|
|
|
|
<span class="comment">/**
|
|
* The header element, denoted with CSS class "hd"
|
|
* <span class="attrib">@type</span> Element
|
|
*/</span>
|
|
header : null,
|
|
|
|
<span class="comment">/**
|
|
* The body element, denoted with CSS class "bd"
|
|
* <span class="attrib">@type</span> Element
|
|
*/</span>
|
|
body : null,
|
|
|
|
<span class="comment">/**
|
|
* The footer element, denoted with CSS class "ft"
|
|
* <span class="attrib">@type</span> Element
|
|
*/</span>
|
|
footer : null,
|
|
|
|
<span class="comment">/**
|
|
* The id of the element
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
id : null,
|
|
|
|
<span class="comment">/**
|
|
* Array of elements
|
|
* <span class="attrib">@type</span> Element[]
|
|
*/</span>
|
|
childNodesInDOM : null,
|
|
|
|
<span class="comment">/**
|
|
* The string representing the image root
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
imageRoot : YAHOO.widget.Module.IMG_ROOT,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired prior to class initalization.
|
|
* args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
beforeInitEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired after class initalization.
|
|
* args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module)
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
initEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired when the Module is appended to the DOM
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
appendEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired before the Module is rendered
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
beforeRenderEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired after the Module is rendered
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
renderEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired when the header content of the Module is modified
|
|
* args: string/element representing the new header content
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
changeHeaderEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired when the body content of the Module is modified
|
|
* args: string/element representing the new body content
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
changeBodyEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired when the footer content of the Module is modified
|
|
* args: string/element representing the new footer content
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
changeFooterEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired when the content of the Module is modified
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
changeContentEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired when the Module is destroyed
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
destroyEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired before the Module is shown
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
beforeShowEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired after the Module is shown
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
showEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired before the Module is hidden
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
beforeHideEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* CustomEvent fired after the Module is hidden
|
|
* args: none
|
|
* <span class="attrib">@type</span> YAHOO.util.CustomEvent
|
|
*/</span>
|
|
hideEvent : null,
|
|
|
|
<span class="comment">/**
|
|
* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
|
|
*/</span>
|
|
initEvents : <span class="reserved">function</span>() {
|
|
|
|
<span class="reserved">this</span>.beforeInitEvent = new YAHOO.util.CustomEvent(<span class="literal">"beforeInit"</span>);
|
|
<span class="reserved">this</span>.initEvent = new YAHOO.util.CustomEvent(<span class="literal">"init"</span>);
|
|
|
|
<span class="reserved">this</span>.appendEvent = new YAHOO.util.CustomEvent(<span class="literal">"append"</span>);
|
|
|
|
<span class="reserved">this</span>.beforeRenderEvent = new YAHOO.util.CustomEvent(<span class="literal">"beforeRender"</span>);
|
|
<span class="reserved">this</span>.renderEvent = new YAHOO.util.CustomEvent(<span class="literal">"render"</span>);
|
|
|
|
<span class="reserved">this</span>.changeHeaderEvent = new YAHOO.util.CustomEvent(<span class="literal">"changeHeader"</span>);
|
|
<span class="reserved">this</span>.changeBodyEvent = new YAHOO.util.CustomEvent(<span class="literal">"changeBody"</span>);
|
|
<span class="reserved">this</span>.changeFooterEvent = new YAHOO.util.CustomEvent(<span class="literal">"changeFooter"</span>);
|
|
|
|
<span class="reserved">this</span>.changeContentEvent = new YAHOO.util.CustomEvent(<span class="literal">"changeContent"</span>);
|
|
|
|
<span class="reserved">this</span>.destroyEvent = new YAHOO.util.CustomEvent(<span class="literal">"destroy"</span>);
|
|
<span class="reserved">this</span>.beforeShowEvent = new YAHOO.util.CustomEvent(<span class="literal">"beforeShow"</span>);
|
|
<span class="reserved">this</span>.showEvent = new YAHOO.util.CustomEvent(<span class="literal">"show"</span>);
|
|
<span class="reserved">this</span>.beforeHideEvent = new YAHOO.util.CustomEvent(<span class="literal">"beforeHide"</span>);
|
|
<span class="reserved">this</span>.hideEvent = new YAHOO.util.CustomEvent(<span class="literal">"hide"</span>);
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* String representing the current user-agent platform
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
platform : <span class="reserved">function</span>() {
|
|
var ua = navigator.userAgent.toLowerCase();
|
|
<span class="reserved">if</span> (ua.indexOf(<span class="literal">"windows"</span>) != -1 || ua.indexOf(<span class="literal">"win32"</span>) != -1) {
|
|
<span class="reserved">return</span> <span class="literal">"windows"</span>;
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (ua.indexOf(<span class="literal">"macintosh"</span>) != -1) {
|
|
<span class="reserved">return</span> <span class="literal">"mac"</span>;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
}(),
|
|
|
|
<span class="comment">/**
|
|
* String representing the current user-agent browser
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
browser : <span class="reserved">function</span>() {
|
|
var ua = navigator.userAgent.toLowerCase();
|
|
<span class="reserved">if</span> (ua.indexOf(<span class="literal">'opera'</span>)!=-1) { <span class="comment">// Opera (check first in case of spoof)</span>
|
|
<span class="reserved">return</span> <span class="literal">'opera'</span>;
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (ua.indexOf(<span class="literal">'msie 7'</span>)!=-1) { <span class="comment">// IE7</span>
|
|
<span class="reserved">return</span> <span class="literal">'ie7'</span>;
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (ua.indexOf(<span class="literal">'msie'</span>) !=-1) { <span class="comment">// IE</span>
|
|
<span class="reserved">return</span> <span class="literal">'ie'</span>;
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (ua.indexOf(<span class="literal">'safari'</span>)!=-1) { <span class="comment">// Safari (check before Gecko because it includes "like Gecko")</span>
|
|
<span class="reserved">return</span> <span class="literal">'safari'</span>;
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (ua.indexOf(<span class="literal">'gecko'</span>) != -1) { <span class="comment">// Gecko</span>
|
|
<span class="reserved">return</span> <span class="literal">'gecko'</span>;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
}(),
|
|
|
|
<span class="comment">/**
|
|
* Boolean representing whether or not the current browsing context is secure (https)
|
|
* <span class="attrib">@type</span> boolean
|
|
*/</span>
|
|
isSecure : <span class="reserved">function</span>() {
|
|
<span class="reserved">if</span> (window.location.href.toLowerCase().indexOf(<span class="literal">"https"</span>) === 0) {
|
|
<span class="reserved">return</span> true;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
}(),
|
|
|
|
<span class="comment">/**
|
|
* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
|
|
*/</span>
|
|
initDefaultConfig : <span class="reserved">function</span>() {
|
|
<span class="comment">// Add properties //</span>
|
|
|
|
<span class="reserved">this</span>.cfg.addProperty(<span class="literal">"visible"</span>, { value:true, handler:<span class="reserved">this</span>.configVisible, validator:<span class="reserved">this</span>.cfg.checkBoolean } );
|
|
<span class="reserved">this</span>.cfg.addProperty(<span class="literal">"effect"</span>, { suppressEvent:true, supercedes:[<span class="literal">"visible"</span>] } );
|
|
<span class="reserved">this</span>.cfg.addProperty(<span class="literal">"monitorresize"</span>, { value:true, handler:<span class="reserved">this</span>.configMonitorResize } );
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* The Module class's initialization method, which is executed for Module 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 Module <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} el The element representing the Module
|
|
* <span class="attrib">@param</span> {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
|
|
*/</span>
|
|
init : <span class="reserved">function</span>(el, userConfig) {
|
|
|
|
<span class="reserved">this</span>.initEvents();
|
|
|
|
<span class="reserved">this</span>.beforeInitEvent.fire(YAHOO.widget.Module);
|
|
|
|
<span class="reserved">this</span>.cfg = new YAHOO.util.Config(<span class="reserved">this</span>);
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.isSecure) {
|
|
<span class="reserved">this</span>.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
|
|
}
|
|
|
|
<span class="reserved">if</span> (typeof el == <span class="literal">"string"</span>) {
|
|
var elId = el;
|
|
|
|
el = document.getElementById(el);
|
|
<span class="reserved">if</span> (! el) {
|
|
el = document.createElement(<span class="literal">"DIV"</span>);
|
|
el.id = elId;
|
|
}
|
|
}
|
|
|
|
<span class="reserved">this</span>.element = el;
|
|
|
|
<span class="reserved">if</span> (el.id) {
|
|
<span class="reserved">this</span>.id = el.id;
|
|
}
|
|
|
|
var childNodes = <span class="reserved">this</span>.element.childNodes;
|
|
|
|
<span class="reserved">if</span> (childNodes) {
|
|
<span class="reserved">for</span> (var i=0;i<childNodes.length;i++) {
|
|
var child = childNodes[i];
|
|
switch (child.className) {
|
|
case YAHOO.widget.Module.CSS_HEADER:
|
|
<span class="reserved">this</span>.header = child;
|
|
break;
|
|
case YAHOO.widget.Module.CSS_BODY:
|
|
<span class="reserved">this</span>.body = child;
|
|
break;
|
|
case YAHOO.widget.Module.CSS_FOOTER:
|
|
<span class="reserved">this</span>.footer = child;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
<span class="reserved">this</span>.initDefaultConfig();
|
|
|
|
YAHOO.util.Dom.addClass(<span class="reserved">this</span>.element, YAHOO.widget.Module.CSS_MODULE);
|
|
|
|
<span class="reserved">if</span> (userConfig) {
|
|
<span class="reserved">this</span>.cfg.applyConfig(userConfig, true);
|
|
}
|
|
|
|
<span class="comment">// Subscribe to the fireQueue() method of Config so that any queued configuration changes are</span>
|
|
<span class="comment">// excecuted upon render of the Module</span>
|
|
<span class="reserved">if</span> (! YAHOO.util.Config.alreadySubscribed(<span class="reserved">this</span>.renderEvent, <span class="reserved">this</span>.cfg.fireQueue, <span class="reserved">this</span>.cfg)) {
|
|
<span class="reserved">this</span>.renderEvent.subscribe(<span class="reserved">this</span>.cfg.fireQueue, <span class="reserved">this</span>.cfg, true);
|
|
}
|
|
|
|
<span class="reserved">this</span>.initEvent.fire(YAHOO.widget.Module);
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Initialized an empty DOM element that is placed out of the visible area that can be used to detect text resize.
|
|
*/</span>
|
|
initResizeMonitor : <span class="reserved">function</span>() {
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.browser != <span class="literal">"opera"</span>) {
|
|
|
|
var resizeMonitor = document.getElementById(<span class="literal">"_yuiResizeMonitor"</span>);
|
|
|
|
<span class="reserved">if</span> (! resizeMonitor) {
|
|
|
|
resizeMonitor = document.createElement(<span class="literal">"iframe"</span>);
|
|
|
|
var bIE = (<span class="reserved">this</span>.browser.indexOf(<span class="literal">"ie"</span>) === 0);
|
|
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.isSecure &&
|
|
YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL &&
|
|
bIE) {
|
|
|
|
resizeMonitor.src =
|
|
YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL;
|
|
|
|
}
|
|
|
|
resizeMonitor.id = <span class="literal">"_yuiResizeMonitor"</span>;
|
|
resizeMonitor.style.visibility = <span class="literal">"hidden"</span>;
|
|
|
|
document.body.appendChild(resizeMonitor);
|
|
|
|
resizeMonitor.style.width = <span class="literal">"10em"</span>;
|
|
resizeMonitor.style.height = <span class="literal">"10em"</span>;
|
|
resizeMonitor.style.position = <span class="literal">"absolute"</span>;
|
|
|
|
var nLeft = -1 * resizeMonitor.offsetWidth,
|
|
nTop = -1 * resizeMonitor.offsetHeight;
|
|
|
|
resizeMonitor.style.top = nTop + <span class="literal">"px"</span>;
|
|
resizeMonitor.style.left = nLeft + <span class="literal">"px"</span>;
|
|
resizeMonitor.style.borderStyle = <span class="literal">"none"</span>;
|
|
resizeMonitor.style.borderWidth = <span class="literal">"0"</span>;
|
|
YAHOO.util.Dom.setStyle(resizeMonitor, <span class="literal">"opacity"</span>, <span class="literal">"0"</span>);
|
|
|
|
resizeMonitor.style.visibility = <span class="literal">"visible"</span>;
|
|
|
|
<span class="reserved">if</span>(!bIE) {
|
|
|
|
var doc = resizeMonitor.contentWindow.document;
|
|
|
|
doc.open();
|
|
doc.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
<span class="reserved">if</span>(resizeMonitor && resizeMonitor.contentWindow) {
|
|
|
|
<span class="reserved">this</span>.resizeMonitor = resizeMonitor;
|
|
|
|
YAHOO.util.Event.addListener(<span class="reserved">this</span>.resizeMonitor.contentWindow, <span class="literal">"resize"</span>, <span class="reserved">this</span>.onDomResize, <span class="reserved">this</span>, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Event handler fired when the resize monitor element is resized.
|
|
*/</span>
|
|
onDomResize : <span class="reserved">function</span>(e, obj) {
|
|
|
|
var nLeft = -1 * <span class="reserved">this</span>.resizeMonitor.offsetWidth,
|
|
nTop = -1 * <span class="reserved">this</span>.resizeMonitor.offsetHeight;
|
|
|
|
<span class="reserved">this</span>.resizeMonitor.style.top = nTop + <span class="literal">"px"</span>;
|
|
<span class="reserved">this</span>.resizeMonitor.style.left = nLeft + <span class="literal">"px"</span>;
|
|
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created.
|
|
* <span class="attrib">@param</span> {string} headerContent The HTML used to set the header <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} headerContent The Element to append to the header
|
|
*/</span>
|
|
setHeader : <span class="reserved">function</span>(headerContent) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.header) {
|
|
<span class="reserved">this</span>.header = document.createElement(<span class="literal">"DIV"</span>);
|
|
<span class="reserved">this</span>.header.className = YAHOO.widget.Module.CSS_HEADER;
|
|
}
|
|
|
|
<span class="reserved">if</span> (typeof headerContent == <span class="literal">"string"</span>) {
|
|
<span class="reserved">this</span>.header.innerHTML = headerContent;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.header.innerHTML = <span class="literal">""</span>;
|
|
<span class="reserved">this</span>.header.appendChild(headerContent);
|
|
}
|
|
|
|
<span class="reserved">this</span>.changeHeaderEvent.fire(headerContent);
|
|
<span class="reserved">this</span>.changeContentEvent.fire();
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Appends the passed element to the header. If no header is present, one will be automatically created.
|
|
* <span class="attrib">@param</span> {Element} element The element to append to the header
|
|
*/</span>
|
|
appendToHeader : <span class="reserved">function</span>(element) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.header) {
|
|
<span class="reserved">this</span>.header = document.createElement(<span class="literal">"DIV"</span>);
|
|
<span class="reserved">this</span>.header.className = YAHOO.widget.Module.CSS_HEADER;
|
|
}
|
|
|
|
<span class="reserved">this</span>.header.appendChild(element);
|
|
<span class="reserved">this</span>.changeHeaderEvent.fire(element);
|
|
<span class="reserved">this</span>.changeContentEvent.fire();
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
|
|
* <span class="attrib">@param</span> {string} bodyContent The HTML used to set the body <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} bodyContent The Element to append to the body
|
|
*/</span>
|
|
setBody : <span class="reserved">function</span>(bodyContent) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.body) {
|
|
<span class="reserved">this</span>.body = document.createElement(<span class="literal">"DIV"</span>);
|
|
<span class="reserved">this</span>.body.className = YAHOO.widget.Module.CSS_BODY;
|
|
}
|
|
|
|
<span class="reserved">if</span> (typeof bodyContent == <span class="literal">"string"</span>)
|
|
{
|
|
<span class="reserved">this</span>.body.innerHTML = bodyContent;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.body.innerHTML = <span class="literal">""</span>;
|
|
<span class="reserved">this</span>.body.appendChild(bodyContent);
|
|
}
|
|
|
|
<span class="reserved">this</span>.changeBodyEvent.fire(bodyContent);
|
|
<span class="reserved">this</span>.changeContentEvent.fire();
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Appends the passed element to the body. If no body is present, one will be automatically created.
|
|
* <span class="attrib">@param</span> {Element} element The element to append to the body
|
|
*/</span>
|
|
appendToBody : <span class="reserved">function</span>(element) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.body) {
|
|
<span class="reserved">this</span>.body = document.createElement(<span class="literal">"DIV"</span>);
|
|
<span class="reserved">this</span>.body.className = YAHOO.widget.Module.CSS_BODY;
|
|
}
|
|
|
|
<span class="reserved">this</span>.body.appendChild(element);
|
|
<span class="reserved">this</span>.changeBodyEvent.fire(element);
|
|
<span class="reserved">this</span>.changeContentEvent.fire();
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
|
|
* <span class="attrib">@param</span> {string} footerContent The HTML used to set the footer <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} footerContent The Element to append to the footer
|
|
*/</span>
|
|
setFooter : <span class="reserved">function</span>(footerContent) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.footer) {
|
|
<span class="reserved">this</span>.footer = document.createElement(<span class="literal">"DIV"</span>);
|
|
<span class="reserved">this</span>.footer.className = YAHOO.widget.Module.CSS_FOOTER;
|
|
}
|
|
|
|
<span class="reserved">if</span> (typeof footerContent == <span class="literal">"string"</span>) {
|
|
<span class="reserved">this</span>.footer.innerHTML = footerContent;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.footer.innerHTML = <span class="literal">""</span>;
|
|
<span class="reserved">this</span>.footer.appendChild(footerContent);
|
|
}
|
|
|
|
<span class="reserved">this</span>.changeFooterEvent.fire(footerContent);
|
|
<span class="reserved">this</span>.changeContentEvent.fire();
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Appends the passed element to the footer. If no footer is present, one will be automatically created.
|
|
* <span class="attrib">@param</span> {Element} element The element to append to the footer
|
|
*/</span>
|
|
appendToFooter : <span class="reserved">function</span>(element) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.footer) {
|
|
<span class="reserved">this</span>.footer = document.createElement(<span class="literal">"DIV"</span>);
|
|
<span class="reserved">this</span>.footer.className = YAHOO.widget.Module.CSS_FOOTER;
|
|
}
|
|
|
|
<span class="reserved">this</span>.footer.appendChild(element);
|
|
<span class="reserved">this</span>.changeFooterEvent.fire(element);
|
|
<span class="reserved">this</span>.changeContentEvent.fire();
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
|
|
* <span class="attrib">@param</span> {string} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
|
|
* <span class="attrib">@param</span> {Element} appendToNode The element to which the Module should be appended to prior to rendering
|
|
* <span class="attrib">@param</span> {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
|
|
* <span class="attrib">@return</span> {boolean} Success or failure of the render
|
|
*/</span>
|
|
render : <span class="reserved">function</span>(appendToNode, moduleElement) {
|
|
<span class="reserved">this</span>.beforeRenderEvent.fire();
|
|
|
|
<span class="reserved">if</span> (! moduleElement) {
|
|
moduleElement = <span class="reserved">this</span>.element;
|
|
}
|
|
|
|
var me = <span class="reserved">this</span>;
|
|
var appendTo = <span class="reserved">function</span>(element) {
|
|
<span class="reserved">if</span> (typeof element == <span class="literal">"string"</span>) {
|
|
element = document.getElementById(element);
|
|
}
|
|
|
|
<span class="reserved">if</span> (element) {
|
|
element.appendChild(me.element);
|
|
me.appendEvent.fire();
|
|
}
|
|
};
|
|
|
|
<span class="reserved">if</span> (appendToNode) {
|
|
appendTo(appendToNode);
|
|
} <span class="reserved">else</span> { <span class="comment">// No node was passed in. If the element is not pre-marked up, this fails</span>
|
|
<span class="reserved">if</span> (! YAHOO.util.Dom.inDocument(<span class="reserved">this</span>.element)) {
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
}
|
|
|
|
<span class="comment">// Need to get everything into the DOM if it isn't already</span>
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.header && ! YAHOO.util.Dom.inDocument(<span class="reserved">this</span>.header)) {
|
|
<span class="comment">// There is a header, but it's not in the DOM yet... need to add it</span>
|
|
var firstChild = moduleElement.firstChild;
|
|
<span class="reserved">if</span> (firstChild) { <span class="comment">// Insert before first child if exists</span>
|
|
moduleElement.insertBefore(<span class="reserved">this</span>.header, firstChild);
|
|
} <span class="reserved">else</span> { <span class="comment">// Append to empty body because there are no children</span>
|
|
moduleElement.appendChild(<span class="reserved">this</span>.header);
|
|
}
|
|
}
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.body && ! YAHOO.util.Dom.inDocument(<span class="reserved">this</span>.body)) {
|
|
<span class="comment">// There is a body, but it's not in the DOM yet... need to add it</span>
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.footer && YAHOO.util.Dom.isAncestor(<span class="reserved">this</span>.moduleElement, <span class="reserved">this</span>.footer)) { <span class="comment">// Insert before footer if exists in DOM</span>
|
|
moduleElement.insertBefore(<span class="reserved">this</span>.body, <span class="reserved">this</span>.footer);
|
|
} <span class="reserved">else</span> { <span class="comment">// Append to element because there is no footer</span>
|
|
moduleElement.appendChild(<span class="reserved">this</span>.body);
|
|
}
|
|
}
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.footer && ! YAHOO.util.Dom.inDocument(<span class="reserved">this</span>.footer)) {
|
|
<span class="comment">// There is a footer, but it's not in the DOM yet... need to add it</span>
|
|
moduleElement.appendChild(<span class="reserved">this</span>.footer);
|
|
}
|
|
|
|
<span class="reserved">this</span>.renderEvent.fire();
|
|
<span class="reserved">return</span> true;
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Removes the Module element from the DOM and sets all child elements to null.
|
|
*/</span>
|
|
destroy : <span class="reserved">function</span>() {
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.element) {
|
|
var parent = <span class="reserved">this</span>.element.parentNode;
|
|
}
|
|
<span class="reserved">if</span> (parent) {
|
|
parent.removeChild(<span class="reserved">this</span>.element);
|
|
}
|
|
|
|
<span class="reserved">this</span>.element = null;
|
|
<span class="reserved">this</span>.header = null;
|
|
<span class="reserved">this</span>.body = null;
|
|
<span class="reserved">this</span>.footer = null;
|
|
|
|
<span class="reserved">this</span>.destroyEvent.fire();
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
|
|
*/</span>
|
|
show : <span class="reserved">function</span>() {
|
|
<span class="reserved">this</span>.cfg.setProperty(<span class="literal">"visible"</span>, true);
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
|
|
*/</span>
|
|
hide : <span class="reserved">function</span>() {
|
|
<span class="reserved">this</span>.cfg.setProperty(<span class="literal">"visible"</span>, false);
|
|
},
|
|
|
|
<span class="comment">// BUILT-IN EVENT HANDLERS FOR MODULE //</span>
|
|
|
|
<span class="comment">/**
|
|
* Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
|
|
* This method is responsible for firing showEvent and hideEvent.
|
|
*/</span>
|
|
configVisible : <span class="reserved">function</span>(type, args, obj) {
|
|
var visible = args[0];
|
|
<span class="reserved">if</span> (visible) {
|
|
<span class="reserved">this</span>.beforeShowEvent.fire();
|
|
YAHOO.util.Dom.setStyle(<span class="reserved">this</span>.element, <span class="literal">"display"</span>, <span class="literal">"block"</span>);
|
|
<span class="reserved">this</span>.showEvent.fire();
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.beforeHideEvent.fire();
|
|
YAHOO.util.Dom.setStyle(<span class="reserved">this</span>.element, <span class="literal">"display"</span>, <span class="literal">"none"</span>);
|
|
<span class="reserved">this</span>.hideEvent.fire();
|
|
}
|
|
},
|
|
|
|
<span class="comment">/**
|
|
* Default event handler for the "monitorresize" configuration property
|
|
*/</span>
|
|
configMonitorResize : <span class="reserved">function</span>(type, args, obj) {
|
|
var monitor = args[0];
|
|
<span class="reserved">if</span> (monitor) {
|
|
<span class="reserved">this</span>.initResizeMonitor();
|
|
} <span class="reserved">else</span> {
|
|
YAHOO.util.Event.removeListener(<span class="reserved">this</span>.resizeMonitor, <span class="literal">"resize"</span>, <span class="reserved">this</span>.onDomResize);
|
|
<span class="reserved">this</span>.resizeMonitor = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns a string representation of the object.
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
YAHOO.widget.Module.<span class="reserved">prototype</span>.toString = <span class="reserved">function</span>() {
|
|
<span class="reserved">return</span> <span class="literal">"Module "</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>
|