mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Removal of unused yahoo script dirs
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4836 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,151 +0,0 @@
|
||||
Connection Manager Release Notes
|
||||
|
||||
*** version 0.12.0 ***
|
||||
|
||||
* When uploading files via setForm() and asyncRequest includes a POST data
|
||||
argument, appendPostData() will create hidden input fields for each postData
|
||||
label/value and append each field to the form object.
|
||||
|
||||
* setForm() returns the assembled label/value string of the parsed HTML form
|
||||
fields.
|
||||
|
||||
* NOTE: Opera 9.02 does not allow for more than 12 concurrent Connection Manager
|
||||
objects.
|
||||
|
||||
The following example creates 12 requests in a loop:
|
||||
for(var n=0; n<=12; i++){
|
||||
conn[n] = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
|
||||
}
|
||||
|
||||
If n > 13, Opera 9.02 will crash. Connection manager objects count n must be <=
|
||||
12 at all times. This condition was not present in Opera version 9.01.
|
||||
|
||||
This condition does not apply to other A-Grade browsers (
|
||||
http://developer.yahoo.com/yui/articles/gbs/gbs_browser-chart.html)
|
||||
|
||||
*** version 0.11.3 ***
|
||||
|
||||
* YUI Event dependency for file uploading is now optional.
|
||||
|
||||
* uploadFile() now sets unique IDs for each file upload transaction to prevent
|
||||
iframe collisions with parallel uploads.
|
||||
|
||||
* The callback object now has property responseXML to provide support for file
|
||||
upload transactions that return an XML document.
|
||||
|
||||
* setForm() will verify if a select option value attribute is present and use
|
||||
its value, including empty string, before using the text node value.
|
||||
|
||||
* Modified polling mechanism in handleReadyState() and
|
||||
handleTransactionResponse() to prevent infinite polling if JavaScript errors
|
||||
occur in the user-defined callback.
|
||||
|
||||
* createFrame() will now accept a boolean argument of true to set the frame
|
||||
source to "javascript:false" to prevent IE from throwing security warnings in an
|
||||
HTTPS environment.
|
||||
|
||||
* setHeader() now enumerates through the _http_header object using
|
||||
hasOwnProperty() to prevent collisions with members added to Object via
|
||||
prototype.
|
||||
|
||||
* If using setForm() and asyncRequest includes a POST data argument, the data
|
||||
will be concatenated to the HTML form POST message.
|
||||
|
||||
*** version 0.11.2 ***
|
||||
|
||||
* No revisions.
|
||||
|
||||
*** version 0.11.1 ***
|
||||
|
||||
* uploadFile() now verifies the existence of callback.upload before invoking
|
||||
callback, with or without object scope.
|
||||
|
||||
*** version 0.11.0 ***
|
||||
|
||||
* Each transaction can be defined with a timeout threshold, in milliseconds,
|
||||
through the callback object. If the threshold is reached, and the transaction
|
||||
hasn't yet completed, the transaction will call abort().
|
||||
|
||||
* abort() will now accept a callback object as the second argument. The
|
||||
failure callback will receive a response object to indicate the transaction was
|
||||
aborted.
|
||||
|
||||
* setForm() will now support file uploads by setting the second argument to
|
||||
true (e.g., YAHOO.util.Connect.setForm(formObject, true). File upload does not
|
||||
use the callback success or failure handler. Instead, it uses a new callback
|
||||
object handler: upload.
|
||||
|
||||
* HTML form submit will no longer submit form fields without a defined name
|
||||
attribute.
|
||||
|
||||
* The default POST header of 'Content-Type','application/x-www-form-urlencoded'
|
||||
can be overridden by calling setDefaultPostHeader(false). This
|
||||
will remove the default header from non-HTML form, POST submissions.
|
||||
|
||||
* setHeader() now enumerates through the _http_header object with
|
||||
propertyIsEnumerable to prevent collisions with members added to Object via
|
||||
prototype.
|
||||
|
||||
*** version 0.10.0 ***
|
||||
|
||||
* handleTransactionResponse() now treats the full HTTP 2xx range as a success
|
||||
case, instead of just HTTP 200.
|
||||
|
||||
* To accommodate multiple field values in Mozilla/Firefox, multiple initHeader
|
||||
calls with the same label will now result in the values concatenated to a
|
||||
comma- delimited string value.
|
||||
Example:
|
||||
Setting Content-Type:'application/x-www-form-urlencoded' and Content-
|
||||
Type:'text/xml' will result in Content-Type:'application/x-www-form-urlencoded,
|
||||
text/xml'.
|
||||
|
||||
* Default polling interval lowered to 50ms.
|
||||
|
||||
* YAHOO.util.Connect.setPollingInterval() will allow you to set a polling
|
||||
interval -- in milliseconds -- to override the default value.
|
||||
|
||||
* YAHOO.util.Connect.getResponseHeader[headerLabel] now supported as a response
|
||||
object property to provide symmetry with the native XHR object's property.
|
||||
Example:
|
||||
YAHOO.util.Connect.getResponseHeader['Content-Length'] will return the value
|
||||
for the Content-Length header, if the header is available.
|
||||
|
||||
* YAHOO.util.Connect.allResponseHeaders property renamed to
|
||||
getAllResponseHeaders to provide symmetry with the native XHR object's
|
||||
property.
|
||||
|
||||
* YAHOO.util.Connect.setForm() now supports HTTP GET as well as HTTP POST.
|
||||
|
||||
* YAHOO.util.Connect.setForm() now accepts an HTML form object as well as its
|
||||
name attribute value.
|
||||
|
||||
* YAHOO.util.Connect.setForm() will not submit HTML form fields that are
|
||||
disabled or do not have a name attribute value.
|
||||
|
||||
* [FIXED] Response exceptions result in infinite callback loop in
|
||||
Mozilla/Firefox.
|
||||
|
||||
* [FIXED] YAHOO.util.Connect.abort() now properly clears polling interval.
|
||||
|
||||
* [FIXED] isCallInProgress() now verifies whether XHR instance still exists,
|
||||
and returns false if the connection object is no longer available.
|
||||
|
||||
*** version 0.9.0 ***
|
||||
|
||||
* Initial release
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -1,978 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 0.12.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @description
|
||||
* The Connection Manager provides a simplified interface to the XMLHttpRequest
|
||||
* object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
|
||||
* interactive states and server response, returning the results to a pre-defined
|
||||
* callback you create.
|
||||
*
|
||||
* @namespace YAHOO.util
|
||||
* @module Connection
|
||||
* @Class Connect
|
||||
*/
|
||||
YAHOO.util.Connect =
|
||||
{
|
||||
/**
|
||||
* @description Array of MSFT ActiveX ids for XMLHttpRequest.
|
||||
* @property _msxml_progid
|
||||
* @private
|
||||
* @static
|
||||
* @type array
|
||||
*/
|
||||
_msxml_progid:[
|
||||
'MSXML2.XMLHTTP.3.0',
|
||||
'MSXML2.XMLHTTP',
|
||||
'Microsoft.XMLHTTP'
|
||||
],
|
||||
|
||||
/**
|
||||
* @description Object literal of HTTP header(s)
|
||||
* @property _http_header
|
||||
* @private
|
||||
* @static
|
||||
* @type object
|
||||
*/
|
||||
_http_header:{},
|
||||
|
||||
/**
|
||||
* @description Determines if HTTP headers are set.
|
||||
* @property _has_http_headers
|
||||
* @private
|
||||
* @static
|
||||
* @type boolean
|
||||
*/
|
||||
_has_http_headers:false,
|
||||
|
||||
/**
|
||||
* @description Determines if a default header of
|
||||
* Content-Type of 'application/x-www-form-urlencoded'
|
||||
* will be added to any client HTTP headers sent for POST
|
||||
* transactions.
|
||||
* @property _use_default_post_header
|
||||
* @private
|
||||
* @static
|
||||
* @type boolean
|
||||
*/
|
||||
_use_default_post_header:true,
|
||||
|
||||
/**
|
||||
* @description Determines if a default header of
|
||||
* Content-Type of 'application/x-www-form-urlencoded'
|
||||
* will be added to any client HTTP headers sent for POST
|
||||
* transactions.
|
||||
* @property _default_post_header
|
||||
* @private
|
||||
* @static
|
||||
* @type boolean
|
||||
*/
|
||||
_default_post_header:'application/x-www-form-urlencoded',
|
||||
|
||||
/**
|
||||
* @description Property modified by setForm() to determine if the data
|
||||
* should be submitted as an HTML form.
|
||||
* @property _isFormSubmit
|
||||
* @private
|
||||
* @static
|
||||
* @type boolean
|
||||
*/
|
||||
_isFormSubmit:false,
|
||||
|
||||
/**
|
||||
* @description Property modified by setForm() to determine if a file(s)
|
||||
* upload is expected.
|
||||
* @property _isFileUpload
|
||||
* @private
|
||||
* @static
|
||||
* @type boolean
|
||||
*/
|
||||
_isFileUpload:false,
|
||||
|
||||
/**
|
||||
* @description Property modified by setForm() to set a reference to the HTML
|
||||
* form node if the desired action is file upload.
|
||||
* @property _formNode
|
||||
* @private
|
||||
* @static
|
||||
* @type object
|
||||
*/
|
||||
_formNode:null,
|
||||
|
||||
/**
|
||||
* @description Property modified by setForm() to set the HTML form data
|
||||
* for each transaction.
|
||||
* @property _sFormData
|
||||
* @private
|
||||
* @static
|
||||
* @type string
|
||||
*/
|
||||
_sFormData:null,
|
||||
|
||||
/**
|
||||
* @description Collection of polling references to the polling mechanism in handleReadyState.
|
||||
* @property _poll
|
||||
* @private
|
||||
* @static
|
||||
* @type object
|
||||
*/
|
||||
_poll:{},
|
||||
|
||||
/**
|
||||
* @description Queue of timeout values for each transaction callback with a defined timeout value.
|
||||
* @property _timeOut
|
||||
* @private
|
||||
* @static
|
||||
* @type object
|
||||
*/
|
||||
_timeOut:{},
|
||||
|
||||
/**
|
||||
* @description The polling frequency, in milliseconds, for HandleReadyState.
|
||||
* when attempting to determine a transaction's XHR readyState.
|
||||
* The default is 50 milliseconds.
|
||||
* @property _polling_interval
|
||||
* @private
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
_polling_interval:50,
|
||||
|
||||
/**
|
||||
* @description A transaction counter that increments the transaction id for each transaction.
|
||||
* @property _transaction_id
|
||||
* @private
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
_transaction_id:0,
|
||||
|
||||
/**
|
||||
* @description Member to add an ActiveX id to the existing xml_progid array.
|
||||
* In the event(unlikely) a new ActiveX id is introduced, it can be added
|
||||
* without internal code modifications.
|
||||
* @method setProgId
|
||||
* @public
|
||||
* @static
|
||||
* @param {string} id The ActiveX id to be added to initialize the XHR object.
|
||||
* @return void
|
||||
*/
|
||||
setProgId:function(id)
|
||||
{
|
||||
this._msxml_progid.unshift(id);
|
||||
YAHOO.log('ActiveX Program Id ' + id + ' added to _msxml_progid.', 'info', 'Connection');
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Member to enable or disable the default POST header.
|
||||
* @method setDefaultPostHeader
|
||||
* @public
|
||||
* @static
|
||||
* @param {boolean} b Set and use default header - true or false .
|
||||
* @return void
|
||||
*/
|
||||
setDefaultPostHeader:function(b)
|
||||
{
|
||||
this._use_default_post_header = b;
|
||||
YAHOO.log('Use default POST header set to ' + b, 'info', 'Connection');
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Member to modify the default polling interval.
|
||||
* @method setPollingInterval
|
||||
* @public
|
||||
* @static
|
||||
* @param {int} i The polling interval in milliseconds.
|
||||
* @return void
|
||||
*/
|
||||
setPollingInterval:function(i)
|
||||
{
|
||||
if(typeof i == 'number' && isFinite(i)){
|
||||
this._polling_interval = i;
|
||||
YAHOO.log('Default polling interval set to ' + i +'ms', 'info', 'Connection');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Instantiates a XMLHttpRequest object and returns an object with two properties:
|
||||
* the XMLHttpRequest instance and the transaction id.
|
||||
* @method createXhrObject
|
||||
* @private
|
||||
* @static
|
||||
* @param {int} transactionId Property containing the transaction id for this transaction.
|
||||
* @return object
|
||||
*/
|
||||
createXhrObject:function(transactionId)
|
||||
{
|
||||
var obj,http;
|
||||
try
|
||||
{
|
||||
// Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
|
||||
http = new XMLHttpRequest();
|
||||
// Object literal with http and tId properties
|
||||
obj = { conn:http, tId:transactionId };
|
||||
YAHOO.log('XHR object created for transaction ' + transactionId, 'info', 'Connection');
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
for(var i=0; i<this._msxml_progid.length; ++i){
|
||||
try
|
||||
{
|
||||
// Instantiates XMLHttpRequest for IE and assign to http.
|
||||
http = new ActiveXObject(this._msxml_progid[i]);
|
||||
// Object literal with conn and tId properties
|
||||
obj = { conn:http, tId:transactionId };
|
||||
YAHOO.log('ActiveX XHR object created for transaction ' + transactionId, 'info', 'Connection');
|
||||
break;
|
||||
}
|
||||
catch(e){}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @description This method is called by asyncRequest to create a
|
||||
* valid connection object for the transaction. It also passes a
|
||||
* transaction id and increments the transaction id counter.
|
||||
* @method getConnectionObject
|
||||
* @private
|
||||
* @static
|
||||
* @return {object}
|
||||
*/
|
||||
getConnectionObject:function()
|
||||
{
|
||||
var o;
|
||||
var tId = this._transaction_id;
|
||||
|
||||
try
|
||||
{
|
||||
o = this.createXhrObject(tId);
|
||||
if(o){
|
||||
this._transaction_id++;
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
finally
|
||||
{
|
||||
return o;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Method for initiating an asynchronous request via the XHR object.
|
||||
* @method asyncRequest
|
||||
* @public
|
||||
* @static
|
||||
* @param {string} method HTTP transaction method
|
||||
* @param {string} uri Fully qualified path of resource
|
||||
* @param {callback} callback User-defined callback function or object
|
||||
* @param {string} postData POST body
|
||||
* @return {object} Returns the connection object
|
||||
*/
|
||||
asyncRequest:function(method, uri, callback, postData)
|
||||
{
|
||||
var o = this.getConnectionObject();
|
||||
|
||||
if(!o){
|
||||
YAHOO.log('Unable to create connection object.', 'error', 'Connection');
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
if(this._isFormSubmit){
|
||||
if(this._isFileUpload){
|
||||
this.uploadFile(o.tId, callback, uri, postData);
|
||||
this.releaseObject(o);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//If the specified HTTP method is GET, setForm() will return an
|
||||
//encoded string that is concatenated to the uri to
|
||||
//create a querystring.
|
||||
if(method == 'GET'){
|
||||
if(this._sFormData.length != 0){
|
||||
// If the URI already contains a querystring, append an ampersand
|
||||
// and then concatenate _sFormData to the URI.
|
||||
uri += ((uri.indexOf('?') == -1)?'?':'&') + this._sFormData;
|
||||
}
|
||||
else{
|
||||
uri += "?" + this._sFormData;
|
||||
}
|
||||
}
|
||||
else if(method == 'POST'){
|
||||
//If POST data exist in addition to the HTML form data,
|
||||
//it will be concatenated to the form data.
|
||||
postData = postData?this._sFormData + "&" + postData:this._sFormData;
|
||||
}
|
||||
}
|
||||
|
||||
o.conn.open(method, uri, true);
|
||||
|
||||
if(this._isFormSubmit || (postData && this._use_default_post_header)){
|
||||
this.initHeader('Content-Type', this._default_post_header);
|
||||
YAHOO.log('Initialize default header Content-Type to application/x-www-form-urlencoded.', 'info', 'Connection');
|
||||
}
|
||||
else if(this._isFormSubmit){
|
||||
this.resetFormState();
|
||||
}
|
||||
|
||||
if(this._has_http_headers){
|
||||
this.setHeader(o);
|
||||
}
|
||||
|
||||
this.handleReadyState(o, callback);
|
||||
o.conn.send(postData || null);
|
||||
|
||||
return o;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @description This method serves as a timer that polls the XHR object's readyState
|
||||
* property during a transaction, instead of binding a callback to the
|
||||
* onreadystatechange event. Upon readyState 4, handleTransactionResponse
|
||||
* will process the response, and the timer will be cleared.
|
||||
* @method handleReadyState
|
||||
* @private
|
||||
* @static
|
||||
* @param {object} o The connection object
|
||||
* @param {callback} callback The user-defined callback object
|
||||
* @return {void}
|
||||
*/
|
||||
handleReadyState:function(o, callback)
|
||||
{
|
||||
var oConn = this;
|
||||
|
||||
if(callback && callback.timeout){
|
||||
this._timeOut[o.tId] = window.setTimeout(function(){ oConn.abort(o, callback, true); }, callback.timeout);
|
||||
}
|
||||
|
||||
this._poll[o.tId] = window.setInterval(
|
||||
function(){
|
||||
if(o.conn && o.conn.readyState == 4){
|
||||
window.clearInterval(oConn._poll[o.tId]);
|
||||
delete oConn._poll[o.tId];
|
||||
|
||||
if(callback && callback.timeout){
|
||||
delete oConn._timeOut[o.tId];
|
||||
}
|
||||
|
||||
oConn.handleTransactionResponse(o, callback);
|
||||
}
|
||||
}
|
||||
,this._polling_interval);
|
||||
},
|
||||
|
||||
/**
|
||||
* @description This method attempts to interpret the server response and
|
||||
* determine whether the transaction was successful, or if an error or
|
||||
* exception was encountered.
|
||||
* @method handleTransactionResponse
|
||||
* @private
|
||||
* @static
|
||||
* @param {object} o The connection object
|
||||
* @param {object} callback The sser-defined callback object
|
||||
* @param {boolean} isAbort Determines if the transaction was aborted.
|
||||
* @return {void}
|
||||
*/
|
||||
handleTransactionResponse:function(o, callback, isAbort)
|
||||
{
|
||||
// If no valid callback is provided, then do not process any callback handling.
|
||||
if(!callback){
|
||||
this.releaseObject(o);
|
||||
YAHOO.log('No callback object to process. Transaction complete.', 'warn', 'Connection');
|
||||
return;
|
||||
}
|
||||
|
||||
var httpStatus, responseObject;
|
||||
|
||||
try
|
||||
{
|
||||
if(o.conn.status !== undefined && o.conn.status != 0){
|
||||
httpStatus = o.conn.status;
|
||||
}
|
||||
else{
|
||||
httpStatus = 13030;
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
// 13030 is the custom code to indicate the condition -- in Mozilla/FF --
|
||||
// when the o object's status and statusText properties are
|
||||
// unavailable, and a query attempt throws an exception.
|
||||
httpStatus = 13030;
|
||||
}
|
||||
|
||||
if(httpStatus >= 200 && httpStatus < 300){
|
||||
responseObject = this.createResponseObject(o, callback.argument);
|
||||
if(callback.success){
|
||||
if(!callback.scope){
|
||||
callback.success(responseObject);
|
||||
YAHOO.log('Success callback. HTTP code is ' + httpStatus, 'info', 'Connection');
|
||||
}
|
||||
else{
|
||||
// If a scope property is defined, the callback will be fired from
|
||||
// the context of the object.
|
||||
callback.success.apply(callback.scope, [responseObject]);
|
||||
YAHOO.log('Success callback with scope. HTTP code is ' + httpStatus, 'info', 'Connection');
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
switch(httpStatus){
|
||||
// The following cases are wininet.dll error codes that may be encountered.
|
||||
case 12002: // Server timeout
|
||||
case 12029: // 12029 to 12031 correspond to dropped connections.
|
||||
case 12030:
|
||||
case 12031:
|
||||
case 12152: // Connection closed by server.
|
||||
case 13030: // See above comments for variable status.
|
||||
responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort?isAbort:false));
|
||||
if(callback.failure){
|
||||
if(!callback.scope){
|
||||
callback.failure(responseObject);
|
||||
YAHOO.log('Failure callback. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
|
||||
}
|
||||
else{
|
||||
callback.failure.apply(callback.scope, [responseObject]);
|
||||
YAHOO.log('Failure callback with scope. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
responseObject = this.createResponseObject(o, callback.argument);
|
||||
if(callback.failure){
|
||||
if(!callback.scope){
|
||||
callback.failure(responseObject);
|
||||
YAHOO.log('Failure callback. HTTP status code is ' + httpStatus, 'warn', 'Connection');
|
||||
}
|
||||
else{
|
||||
callback.failure.apply(callback.scope, [responseObject]);
|
||||
YAHOO.log('Failure callback with scope. HTTP status code is ' + httpStatus, 'warn', 'Connection');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.releaseObject(o);
|
||||
responseObject = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description This method evaluates the server response, creates and returns the results via
|
||||
* its properties. Success and failure cases will differ in the response
|
||||
* object's property values.
|
||||
* @method createResponseObject
|
||||
* @private
|
||||
* @static
|
||||
* @param {object} o The connection object
|
||||
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
|
||||
* @return {object}
|
||||
*/
|
||||
createResponseObject:function(o, callbackArg)
|
||||
{
|
||||
var obj = {};
|
||||
var headerObj = {};
|
||||
|
||||
try
|
||||
{
|
||||
var headerStr = o.conn.getAllResponseHeaders();
|
||||
var header = headerStr.split('\n');
|
||||
for(var i=0; i<header.length; i++){
|
||||
var delimitPos = header[i].indexOf(':');
|
||||
if(delimitPos != -1){
|
||||
headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos+2);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e){}
|
||||
|
||||
obj.tId = o.tId;
|
||||
obj.status = o.conn.status;
|
||||
obj.statusText = o.conn.statusText;
|
||||
obj.getResponseHeader = headerObj;
|
||||
obj.getAllResponseHeaders = headerStr;
|
||||
obj.responseText = o.conn.responseText;
|
||||
obj.responseXML = o.conn.responseXML;
|
||||
|
||||
if(typeof callbackArg !== undefined){
|
||||
obj.argument = callbackArg;
|
||||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description If a transaction cannot be completed due to dropped or closed connections,
|
||||
* there may be not be enough information to build a full response object.
|
||||
* The failure callback will be fired and this specific condition can be identified
|
||||
* by a status property value of 0.
|
||||
*
|
||||
* If an abort was successful, the status property will report a value of -1.
|
||||
*
|
||||
* @method createExceptionObject
|
||||
* @private
|
||||
* @static
|
||||
* @param {int} tId The Transaction Id
|
||||
* @param {callbackArg} callbackArg The user-defined argument or arguments to be passed to the callback
|
||||
* @param {boolean} isAbort Determines if the exception case is caused by a transaction abort
|
||||
* @return {object}
|
||||
*/
|
||||
createExceptionObject:function(tId, callbackArg, isAbort)
|
||||
{
|
||||
var COMM_CODE = 0;
|
||||
var COMM_ERROR = 'communication failure';
|
||||
var ABORT_CODE = -1;
|
||||
var ABORT_ERROR = 'transaction aborted';
|
||||
|
||||
var obj = {};
|
||||
|
||||
obj.tId = tId;
|
||||
if(isAbort){
|
||||
obj.status = ABORT_CODE;
|
||||
obj.statusText = ABORT_ERROR;
|
||||
}
|
||||
else{
|
||||
obj.status = COMM_CODE;
|
||||
obj.statusText = COMM_ERROR;
|
||||
}
|
||||
|
||||
if(callbackArg){
|
||||
obj.argument = callbackArg;
|
||||
}
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Public method that stores the custom HTTP headers for each transaction.
|
||||
* @method initHeader
|
||||
* @public
|
||||
* @static
|
||||
* @param {string} label The HTTP header label
|
||||
* @param {string} value The HTTP header value
|
||||
* @return {void}
|
||||
*/
|
||||
initHeader:function(label,value)
|
||||
{
|
||||
if(this._http_header[label] === undefined){
|
||||
this._http_header[label] = value;
|
||||
}
|
||||
else{
|
||||
// Concatenate multiple values, comma-delimited,
|
||||
// for the same header label,
|
||||
this._http_header[label] = value + "," + this._http_header[label];
|
||||
}
|
||||
|
||||
this._has_http_headers = true;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Accessor that sets the HTTP headers for each transaction.
|
||||
* @method setHeader
|
||||
* @private
|
||||
* @static
|
||||
* @param {object} o The connection object for the transaction.
|
||||
* @return {void}
|
||||
*/
|
||||
setHeader:function(o)
|
||||
{
|
||||
for(var prop in this._http_header){
|
||||
if(this._http_header.hasOwnProperty(prop)){
|
||||
o.conn.setRequestHeader(prop, this._http_header[prop]);
|
||||
YAHOO.log('HTTP header ' + prop + ' set with value of ' + this._http_header[prop], 'info', 'Connection');
|
||||
}
|
||||
}
|
||||
delete this._http_header;
|
||||
|
||||
this._http_header = {};
|
||||
this._has_http_headers = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description This method assembles the form label and value pairs and
|
||||
* constructs an encoded string.
|
||||
* asyncRequest() will automatically initialize the
|
||||
* transaction with a HTTP header Content-Type of
|
||||
* application/x-www-form-urlencoded.
|
||||
* @method setForm
|
||||
* @public
|
||||
* @static
|
||||
* @param {string || object} form id or name attribute, or form object.
|
||||
* @param {string} optional boolean to indicate SSL environment.
|
||||
* @param {string || boolean} optional qualified path of iframe resource for SSL in IE.
|
||||
* @return {string} string of the HTML form field name and value pairs..
|
||||
*/
|
||||
setForm:function(formId, isUpload, secureUri)
|
||||
{
|
||||
if(typeof formId == 'string'){
|
||||
// Determine if the argument is a form id or a form name.
|
||||
// Note form name usage is deprecated by supported
|
||||
// here for legacy reasons.
|
||||
var oForm = (document.getElementById(formId) || document.forms[formId]);
|
||||
}
|
||||
else if(typeof formId == 'object'){
|
||||
// Treat argument as an HTML form object.
|
||||
var oForm = formId;
|
||||
}
|
||||
else{
|
||||
YAHOO.log('Unable to create form object ' + formId, 'warn', 'Connection');
|
||||
return;
|
||||
}
|
||||
|
||||
// If the isUpload argument is true, setForm will call createFrame to initialize
|
||||
// an iframe as the form target.
|
||||
//
|
||||
// The argument secureURI is also required by IE in SSL environments
|
||||
// where the secureURI string is a fully qualified HTTP path, used to set the source
|
||||
// of the iframe, to a stub resource in the same domain.
|
||||
if(isUpload){
|
||||
|
||||
// Create iframe in preparation for file upload.
|
||||
this.createFrame(secureUri?secureUri:null);
|
||||
|
||||
// Set form reference and file upload properties to true.
|
||||
this._isFormSubmit = true;
|
||||
this._isFileUpload = true;
|
||||
this._formNode = oForm;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var oElement, oName, oValue, oDisabled;
|
||||
var hasSubmit = false;
|
||||
|
||||
// Iterate over the form elements collection to construct the
|
||||
// label-value pairs.
|
||||
for (var i=0; i<oForm.elements.length; i++){
|
||||
oElement = oForm.elements[i];
|
||||
oDisabled = oForm.elements[i].disabled;
|
||||
oName = oForm.elements[i].name;
|
||||
oValue = oForm.elements[i].value;
|
||||
|
||||
// Do not submit fields that are disabled or
|
||||
// do not have a name attribute value.
|
||||
if(!oDisabled && oName)
|
||||
{
|
||||
switch (oElement.type)
|
||||
{
|
||||
case 'select-one':
|
||||
case 'select-multiple':
|
||||
for(var j=0; j<oElement.options.length; j++){
|
||||
if(oElement.options[j].selected){
|
||||
if(window.ActiveXObject){
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text) + '&';
|
||||
}
|
||||
else{
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text) + '&';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'radio':
|
||||
case 'checkbox':
|
||||
if(oElement.checked){
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
|
||||
}
|
||||
break;
|
||||
case 'file':
|
||||
// stub case as XMLHttpRequest will only send the file path as a string.
|
||||
case undefined:
|
||||
// stub case for fieldset element which returns undefined.
|
||||
case 'reset':
|
||||
// stub case for input type reset button.
|
||||
case 'button':
|
||||
// stub case for input type button elements.
|
||||
break;
|
||||
case 'submit':
|
||||
if(hasSubmit == false){
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
|
||||
hasSubmit = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._isFormSubmit = true;
|
||||
this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1);
|
||||
|
||||
YAHOO.log('Form initialized for transaction. HTML form POST message is: ' + this._sFormData, 'info', 'Connection');
|
||||
|
||||
return this._sFormData;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Resets HTML form properties when an HTML form or HTML form
|
||||
* with file upload transaction is sent.
|
||||
* @method resetFormState
|
||||
* @private
|
||||
* @static
|
||||
* @param {boolean} isUpload Indicates if file upload properties should be reset.
|
||||
* @return {void}
|
||||
*/
|
||||
resetFormState:function(isUpload){
|
||||
this._isFormSubmit = false;
|
||||
this._sFormData = null;
|
||||
if(isUpload){
|
||||
this._isFileUpload = false;
|
||||
this._formNode = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Creates an iframe to be used for form file uploads. It is remove from the
|
||||
* document upon completion of the upload transaction.
|
||||
* @method createFrame
|
||||
* @private
|
||||
* @static
|
||||
* @param {string} optional qualified path of iframe resource for SSL in IE.
|
||||
* @return {void}
|
||||
*/
|
||||
createFrame:function(secureUri){
|
||||
|
||||
// IE does not allow the setting of id and name attributes as object
|
||||
// properties via createElement(). A different iframe creation
|
||||
// pattern is required for IE.
|
||||
var frameId = 'yuiIO' + this._transaction_id;
|
||||
if(window.ActiveXObject){
|
||||
var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
|
||||
|
||||
// IE will throw a security exception in an SSL environment if the
|
||||
// iframe source is undefined.
|
||||
if(typeof secureUri == 'boolean'){
|
||||
io.src = 'javascript:false';
|
||||
}
|
||||
else if(typeof secureURI == 'string'){
|
||||
// Deprecated
|
||||
io.src = secureUri;
|
||||
}
|
||||
}
|
||||
else{
|
||||
var io = document.createElement('iframe');
|
||||
io.id = frameId;
|
||||
io.name = frameId;
|
||||
}
|
||||
|
||||
io.style.position = 'absolute';
|
||||
io.style.top = '-1000px';
|
||||
io.style.left = '-1000px';
|
||||
|
||||
document.body.appendChild(io);
|
||||
YAHOO.log('File upload iframe created. Id is:' + frameId, 'info', 'Connection');
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Parses the POST data and creates hidden form elements
|
||||
* for each key-value, and appends them to the HTML form object.
|
||||
* @method appendPostData
|
||||
* @private
|
||||
* @static
|
||||
* @param {string} postData The HTTP POST data
|
||||
* @return {array} formElements Collection of hidden fields.
|
||||
*/
|
||||
appendPostData:function(postData)
|
||||
{
|
||||
var formElements = new Array();
|
||||
var postMessage = postData.split('&');
|
||||
for(var i=0; i < postMessage.length; i++){
|
||||
var delimitPos = postMessage[i].indexOf('=');
|
||||
if(delimitPos != -1){
|
||||
formElements[i] = document.createElement('input');
|
||||
formElements[i].type = 'hidden';
|
||||
formElements[i].name = postMessage[i].substring(0,delimitPos);
|
||||
formElements[i].value = postMessage[i].substring(delimitPos+1);
|
||||
this._formNode.appendChild(formElements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return formElements;
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Uploads HTML form, including files/attachments, to the
|
||||
* iframe created in createFrame.
|
||||
* @method uploadFile
|
||||
* @private
|
||||
* @static
|
||||
* @param {int} id The transaction id.
|
||||
* @param {object} callback - User-defined callback object.
|
||||
* @param {string} uri Fully qualified path of resource.
|
||||
* @return {void}
|
||||
*/
|
||||
uploadFile:function(id, callback, uri, postData){
|
||||
|
||||
// Each iframe has an id prefix of "yuiIO" followed
|
||||
// by the unique transaction id.
|
||||
var frameId = 'yuiIO' + id;
|
||||
var io = document.getElementById(frameId);
|
||||
|
||||
// Initialize the HTML form properties in case they are
|
||||
// not defined in the HTML form.
|
||||
this._formNode.action = uri;
|
||||
this._formNode.method = 'POST';
|
||||
this._formNode.target = frameId;
|
||||
|
||||
if(this._formNode.encoding){
|
||||
// IE does not respect property enctype for HTML forms.
|
||||
// Instead use property encoding.
|
||||
this._formNode.encoding = 'multipart/form-data';
|
||||
}
|
||||
else{
|
||||
this._formNode.enctype = 'multipart/form-data';
|
||||
}
|
||||
|
||||
|
||||
if(postData){
|
||||
var oElements = this.appendPostData(postData);
|
||||
}
|
||||
|
||||
this._formNode.submit();
|
||||
|
||||
if(oElements && oElements.length > 0){
|
||||
for(var i=0; i < oElements.length; i++){
|
||||
this._formNode.removeChild(oElements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset HTML form status properties.
|
||||
this.resetFormState();
|
||||
|
||||
// Create the upload callback handler that fires when the iframe
|
||||
// receives the load event. Subsequently, the event handler is detached
|
||||
// and the iframe removed from the document.
|
||||
|
||||
var uploadCallback = function()
|
||||
{
|
||||
var obj = {};
|
||||
obj.tId = id;
|
||||
obj.argument = callback.argument;
|
||||
|
||||
try
|
||||
{
|
||||
obj.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
|
||||
obj.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
|
||||
}
|
||||
catch(e){}
|
||||
|
||||
if(callback.upload){
|
||||
if(!callback.scope){
|
||||
callback.upload(obj);
|
||||
YAHOO.log('Upload callback.', 'info', 'Connection');
|
||||
}
|
||||
else{
|
||||
callback.upload.apply(callback.scope, [obj]);
|
||||
YAHOO.log('Upload callback with scope.', 'info', 'Connection');
|
||||
}
|
||||
}
|
||||
|
||||
if(YAHOO.util.Event){
|
||||
YAHOO.util.Event.removeListener(io, "load", uploadCallback);
|
||||
}
|
||||
else if(window.detachEvent){
|
||||
io.detachEvent('onload', uploadCallback);
|
||||
}
|
||||
else{
|
||||
io.removeEventListener('load', uploadCallback, false);
|
||||
}
|
||||
setTimeout(
|
||||
function(){
|
||||
document.body.removeChild(io);
|
||||
YAHOO.log('File upload iframe destroyed. Id is:' + frameId, 'info', 'Connection');
|
||||
}, 100);
|
||||
};
|
||||
|
||||
|
||||
// Bind the onload handler to the iframe to detect the file upload response.
|
||||
if(YAHOO.util.Event){
|
||||
YAHOO.util.Event.addListener(io, "load", uploadCallback);
|
||||
}
|
||||
else if(window.attachEvent){
|
||||
io.attachEvent('onload', uploadCallback);
|
||||
}
|
||||
else{
|
||||
io.addEventListener('load', uploadCallback, false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Method to terminate a transaction, if it has not reached readyState 4.
|
||||
* @method abort
|
||||
* @public
|
||||
* @static
|
||||
* @param {object} o The connection object returned by asyncRequest.
|
||||
* @param {object} callback User-defined callback object.
|
||||
* @param {string} isTimeout boolean to indicate if abort was a timeout.
|
||||
* @return {boolean}
|
||||
*/
|
||||
abort:function(o, callback, isTimeout)
|
||||
{
|
||||
if(this.isCallInProgress(o)){
|
||||
o.conn.abort();
|
||||
window.clearInterval(this._poll[o.tId]);
|
||||
delete this._poll[o.tId];
|
||||
if(isTimeout){
|
||||
delete this._timeOut[o.tId];
|
||||
}
|
||||
|
||||
this.handleTransactionResponse(o, callback, true);
|
||||
YAHOO.log('Transaction ' + o.tId + ' aborted.', 'info', 'Connection');
|
||||
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
YAHOO.log('Transaction ' + o.tId + ' abort call failed.', 'warn', 'Connection');
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Public method to check if the transaction is still being processed.
|
||||
*
|
||||
* @method isCallInProgress
|
||||
* @public
|
||||
* @static
|
||||
* @param {object} o The connection object returned by asyncRequest
|
||||
* @return {boolean}
|
||||
*/
|
||||
isCallInProgress:function(o)
|
||||
{
|
||||
// if the XHR object assigned to the transaction has not been dereferenced,
|
||||
// then check its readyState status. Otherwise, return false.
|
||||
if(o.conn){
|
||||
return o.conn.readyState != 4 && o.conn.readyState != 0;
|
||||
}
|
||||
else{
|
||||
//The XHR object has been destroyed.
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @description Dereference the XHR instance and the connection object after the transaction is completed.
|
||||
* @method releaseObject
|
||||
* @private
|
||||
* @static
|
||||
* @param {object} o The connection object
|
||||
* @return {void}
|
||||
*/
|
||||
releaseObject:function(o)
|
||||
{
|
||||
//dereference the XHR instance.
|
||||
o.conn = null;
|
||||
YAHOO.log('Connection object for transaction ' + o.tId + ' destroyed.', 'info', 'Connection');
|
||||
//dereference the connection object.
|
||||
o = null;
|
||||
}
|
||||
};
|
@@ -1,66 +0,0 @@
|
||||
Dom Release Notes
|
||||
|
||||
*** version .12.0 ***
|
||||
|
||||
* fixed getXY for IE null parent
|
||||
* branching set/getStyle at load time instead of run time
|
||||
|
||||
*** version 0.11.3 ***
|
||||
|
||||
* fixed getX and getY returning incorrect values for collections
|
||||
* fixed getXY incorrectly calculated for Opera inline elements
|
||||
* fixed isAncestor failure in safari when 2nd arg is document.documentElement
|
||||
* fixed infinite loop in replaceClass when oldClassName == newClassName
|
||||
* getDocumentWidth no longer includes scrollbars
|
||||
|
||||
|
||||
*** version 0.11.2 ***
|
||||
* limit depth of parent.document crawl to 1 for getXY
|
||||
* test offsetParent instead of parentNode for getXY
|
||||
* return null if no el fo r get
|
||||
* just addClass if no class to replace for replaceClass
|
||||
|
||||
|
||||
*** version 0.11.1 ***
|
||||
|
||||
* return null if el is null for get()
|
||||
* test offsetParent rather than parentNode for getXY()
|
||||
* limit depth of parent.document crawl for IE getXY() to 1
|
||||
* if no oldClassName to replace, just addClass for replaceClass()
|
||||
|
||||
|
||||
*** version 0.11.0 ***
|
||||
* Work around Opera 9 broken currentStyle
|
||||
* Removed timeout wrapper from setXY retry
|
||||
* Tagname tests now case-insensitive
|
||||
* Internal "this" references changed to allow for method shorthand
|
||||
* get/setStyle now accept both camel and hyphen case
|
||||
* Gecko reverted to crawling offsets for getXY
|
||||
|
||||
|
||||
*** version 0.10.0 ***
|
||||
|
||||
* Safari now fails gracefully when querying computedStyle of an unavailable element
|
||||
|
||||
* Class management functions added (hasClass, addClass, removeClass, replaceClass, getElementsByClassName)
|
||||
|
||||
* All methods that accept HTMLElements or IDs now also accept arrays of HTMLElements and/or IDs
|
||||
|
||||
* GenerateId method added
|
||||
|
||||
* isAncestor method added
|
||||
|
||||
* inDocument method added
|
||||
|
||||
* getElementsBy method added
|
||||
|
||||
* batch method added
|
||||
|
||||
* getClientHeight/Width deprecated in favor of getViewportHeight/Width
|
||||
|
||||
* getDocumentHeight/Width methods added
|
||||
|
||||
*** version 0.9.0 ***
|
||||
|
||||
* Initial release
|
||||
|
@@ -1,916 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 0.12.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The dom module provides helper methods for manipulating Dom elements.
|
||||
* @module dom
|
||||
*
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var Y = YAHOO.util, // internal shorthand
|
||||
getStyle, // for load time browser branching
|
||||
setStyle, // ditto
|
||||
id_counter = 0, // for use with generateId
|
||||
propertyCache = {}; // for faster hyphen converts
|
||||
|
||||
// brower detection
|
||||
var ua = navigator.userAgent.toLowerCase(),
|
||||
isOpera = (ua.indexOf('opera') > -1),
|
||||
isSafari = (ua.indexOf('safari') > -1),
|
||||
isGecko = (!isOpera && !isSafari && ua.indexOf('gecko') > -1),
|
||||
isIE = (!isOpera && ua.indexOf('msie') > -1);
|
||||
|
||||
// regex cache
|
||||
var patterns = {
|
||||
HYPHEN: /(-[a-z])/i
|
||||
};
|
||||
|
||||
var logger = {};
|
||||
logger.log = function() { YAHOO.log.apply(window, arguments); };
|
||||
|
||||
var toCamel = function(property) {
|
||||
if ( !patterns.HYPHEN.test(property) ) {
|
||||
return property; // no hyphens
|
||||
}
|
||||
|
||||
if (propertyCache[property]) { // already converted
|
||||
return propertyCache[property];
|
||||
}
|
||||
|
||||
while( patterns.HYPHEN.exec(property) ) {
|
||||
property = property.replace(RegExp.$1,
|
||||
RegExp.$1.substr(1).toUpperCase());
|
||||
}
|
||||
|
||||
propertyCache[property] = property;
|
||||
return property;
|
||||
//return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
|
||||
};
|
||||
|
||||
// branching at load instead of runtime
|
||||
if (document.defaultView && document.defaultView.getComputedStyle) { // W3C DOM method
|
||||
getStyle = function(el, property) {
|
||||
var value = null;
|
||||
|
||||
var computed = document.defaultView.getComputedStyle(el, '');
|
||||
if (computed) { // test computed before touching for safari
|
||||
value = computed[toCamel(property)];
|
||||
}
|
||||
|
||||
return el.style[property] || value;
|
||||
};
|
||||
} else if (document.documentElement.currentStyle && isIE) { // IE method
|
||||
getStyle = function(el, property) {
|
||||
switch( toCamel(property) ) {
|
||||
case 'opacity' :// IE opacity uses filter
|
||||
var val = 100;
|
||||
try { // will error if no DXImageTransform
|
||||
val = el.filters['DXImageTransform.Microsoft.Alpha'].opacity;
|
||||
|
||||
} catch(e) {
|
||||
try { // make sure its in the document
|
||||
val = el.filters('alpha').opacity;
|
||||
} catch(e) {
|
||||
logger.log('getStyle: IE filter failed',
|
||||
'error', 'Dom');
|
||||
}
|
||||
}
|
||||
return val / 100;
|
||||
break;
|
||||
default:
|
||||
// test currentStyle before touching
|
||||
var value = el.currentStyle ? el.currentStyle[property] : null;
|
||||
return ( el.style[property] || value );
|
||||
}
|
||||
};
|
||||
} else { // default to inline only
|
||||
getStyle = function(el, property) { return el.style[property]; };
|
||||
}
|
||||
|
||||
if (isIE) {
|
||||
setStyle = function(el, property, val) {
|
||||
switch (property) {
|
||||
case 'opacity':
|
||||
if ( typeof el.style.filter == 'string' ) { // in case not appended
|
||||
el.style.filter = 'alpha(opacity=' + val * 100 + ')';
|
||||
|
||||
if (!el.currentStyle || !el.currentStyle.hasLayout) {
|
||||
el.style.zoom = 1; // when no layout or cant tell
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
el.style[property] = val;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
setStyle = function(el, property, val) {
|
||||
el.style[property] = val;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides helper methods for DOM elements.
|
||||
* @namespace YAHOO.util
|
||||
* @class Dom
|
||||
*/
|
||||
YAHOO.util.Dom = {
|
||||
/**
|
||||
* Returns an HTMLElement reference.
|
||||
* @method get
|
||||
* @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
|
||||
* @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
|
||||
*/
|
||||
get: function(el) {
|
||||
if (!el) { return null; } // nothing to work with
|
||||
|
||||
if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
|
||||
logger.log('get(' + el + ') returning ' + el, 'info', 'Dom');
|
||||
return el;
|
||||
}
|
||||
|
||||
if (typeof el == 'string') { // ID
|
||||
logger.log('get("' + el + '") returning ' + document.getElementById(el), 'info', 'Dom');
|
||||
return document.getElementById(el);
|
||||
}
|
||||
else { // array of ID's and/or elements
|
||||
var collection = [];
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
collection[collection.length] = Y.Dom.get(el[i]);
|
||||
}
|
||||
|
||||
logger.log('get("' + el + '") returning ' + collection, 'info', 'Dom');
|
||||
return collection;
|
||||
}
|
||||
|
||||
logger.log('element ' + el + ' not found', 'error', 'Dom');
|
||||
return null; // safety, should never happen
|
||||
},
|
||||
|
||||
/**
|
||||
* Normalizes currentStyle and ComputedStyle.
|
||||
* @method getStyle
|
||||
* @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
|
||||
* @param {String} property The style property whose value is returned.
|
||||
* @return {String | Array} The current value of the style property for the element(s).
|
||||
*/
|
||||
getStyle: function(el, property) {
|
||||
property = toCamel(property);
|
||||
|
||||
var f = function(element) {
|
||||
return getStyle(element, property);
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
|
||||
* @method setStyle
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
|
||||
* @param {String} property The style property to be set.
|
||||
* @param {String} val The value to apply to the given property.
|
||||
*/
|
||||
setStyle: function(el, property, val) {
|
||||
property = toCamel(property);
|
||||
|
||||
var f = function(element) {
|
||||
setStyle(element, property, val);
|
||||
logger.log('setStyle setting ' + property + ' to ' + val, 'info', 'Dom');
|
||||
|
||||
};
|
||||
|
||||
Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
|
||||
* @method getXY
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
|
||||
* @return {Array} The XY position of the element(s)
|
||||
*/
|
||||
getXY: function(el) {
|
||||
var f = function(el) {
|
||||
|
||||
// has to be part of document to have pageXY
|
||||
if (el.parentNode === null || el.offsetParent === null ||
|
||||
this.getStyle(el, 'display') == 'none') {
|
||||
logger.log('getXY failed: element not available', 'error', 'Dom');
|
||||
return false;
|
||||
}
|
||||
|
||||
var parentNode = null;
|
||||
var pos = [];
|
||||
var box;
|
||||
|
||||
if (el.getBoundingClientRect) { // IE
|
||||
box = el.getBoundingClientRect();
|
||||
var doc = document;
|
||||
if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
|
||||
doc = parent.document;
|
||||
|
||||
if ( !this.isAncestor(doc.documentElement, el) ) {
|
||||
logger.log('getXY failed: element not available', 'error', 'Dom');
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
|
||||
var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
|
||||
|
||||
return [box.left + scrollLeft, box.top + scrollTop];
|
||||
}
|
||||
else { // safari, opera, & gecko
|
||||
pos = [el.offsetLeft, el.offsetTop];
|
||||
parentNode = el.offsetParent;
|
||||
if (parentNode != el) {
|
||||
while (parentNode) {
|
||||
pos[0] += parentNode.offsetLeft;
|
||||
pos[1] += parentNode.offsetTop;
|
||||
parentNode = parentNode.offsetParent;
|
||||
}
|
||||
}
|
||||
if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
|
||||
pos[0] -= document.body.offsetLeft;
|
||||
pos[1] -= document.body.offsetTop;
|
||||
}
|
||||
}
|
||||
|
||||
if (el.parentNode) { parentNode = el.parentNode; }
|
||||
else { parentNode = null; }
|
||||
|
||||
while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
|
||||
{ // account for any scrolled ancestors
|
||||
if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug
|
||||
pos[0] -= parentNode.scrollLeft;
|
||||
pos[1] -= parentNode.scrollTop;
|
||||
}
|
||||
|
||||
if (parentNode.parentNode) {
|
||||
parentNode = parentNode.parentNode;
|
||||
} else { parentNode = null; }
|
||||
}
|
||||
|
||||
logger.log('getXY returning ' + pos, 'info', 'Dom');
|
||||
|
||||
return pos;
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
|
||||
* @method getX
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
|
||||
* @return {String | Array} The X position of the element(s)
|
||||
*/
|
||||
getX: function(el) {
|
||||
var f = function(el) {
|
||||
return Y.Dom.getXY(el)[0];
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
|
||||
* @method getY
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
|
||||
* @return {String | Array} The Y position of the element(s)
|
||||
*/
|
||||
getY: function(el) {
|
||||
var f = function(el) {
|
||||
return Y.Dom.getXY(el)[1];
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the position of an html element in page coordinates, regardless of how the element is positioned.
|
||||
* The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
|
||||
* @method setXY
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
|
||||
* @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
|
||||
* @param {Boolean} noRetry By default we try and set the position a second time if the first fails
|
||||
*/
|
||||
setXY: function(el, pos, noRetry) {
|
||||
var f = function(el) {
|
||||
var style_pos = this.getStyle(el, 'position');
|
||||
if (style_pos == 'static') { // default to relative
|
||||
this.setStyle(el, 'position', 'relative');
|
||||
style_pos = 'relative';
|
||||
}
|
||||
|
||||
var pageXY = this.getXY(el);
|
||||
if (pageXY === false) { // has to be part of doc to have pageXY
|
||||
logger.log('setXY failed: element not available', 'error', 'Dom');
|
||||
return false;
|
||||
}
|
||||
|
||||
var delta = [ // assuming pixels; if not we will have to retry
|
||||
parseInt( this.getStyle(el, 'left'), 10 ),
|
||||
parseInt( this.getStyle(el, 'top'), 10 )
|
||||
];
|
||||
|
||||
if ( isNaN(delta[0]) ) {// in case of 'auto'
|
||||
delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
|
||||
}
|
||||
if ( isNaN(delta[1]) ) { // in case of 'auto'
|
||||
delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
|
||||
}
|
||||
|
||||
if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
|
||||
if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
|
||||
|
||||
var newXY = this.getXY(el);
|
||||
|
||||
// if retry is true, try one more time if we miss
|
||||
if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) {
|
||||
this.setXY(el, pos, true);
|
||||
}
|
||||
|
||||
logger.log('setXY setting position to ' + pos, 'info', 'Dom');
|
||||
};
|
||||
|
||||
Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the X position of an html element in page coordinates, regardless of how the element is positioned.
|
||||
* The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
|
||||
* @method setX
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
|
||||
* @param {Int} x The value to use as the X coordinate for the element(s).
|
||||
*/
|
||||
setX: function(el, x) {
|
||||
Y.Dom.setXY(el, [x, null]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
|
||||
* The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
|
||||
* @method setY
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
|
||||
* @param {Int} x To use as the Y coordinate for the element(s).
|
||||
*/
|
||||
setY: function(el, y) {
|
||||
Y.Dom.setXY(el, [null, y]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the region position of the given element.
|
||||
* The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
|
||||
* @method getRegion
|
||||
* @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
|
||||
* @return {Region | Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
|
||||
*/
|
||||
getRegion: function(el) {
|
||||
var f = function(el) {
|
||||
var region = new Y.Region.getRegion(el);
|
||||
logger.log('getRegion returning ' + region, 'info', 'Dom');
|
||||
return region;
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the width of the client (viewport).
|
||||
* @method getClientWidth
|
||||
* @deprecated Now using getViewportWidth. This interface left intact for back compat.
|
||||
* @return {Int} The width of the viewable area of the page.
|
||||
*/
|
||||
getClientWidth: function() {
|
||||
return Y.Dom.getViewportWidth();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the height of the client (viewport).
|
||||
* @method getClientHeight
|
||||
* @deprecated Now using getViewportHeight. This interface left intact for back compat.
|
||||
* @return {Int} The height of the viewable area of the page.
|
||||
*/
|
||||
getClientHeight: function() {
|
||||
return Y.Dom.getViewportHeight();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a array of HTMLElements with the given class.
|
||||
* For optimized performance, include a tag and/or root node when possible.
|
||||
* @method getElementsByClassName
|
||||
* @param {String} className The class name to match against
|
||||
* @param {String} tag (optional) The tag name of the elements being collected
|
||||
* @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
|
||||
* @return {Array} An array of elements that have the given class name
|
||||
*/
|
||||
getElementsByClassName: function(className, tag, root) {
|
||||
var method = function(el) { return Y.Dom.hasClass(el, className); };
|
||||
return Y.Dom.getElementsBy(method, tag, root);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines whether an HTMLElement has the given className.
|
||||
* @method hasClass
|
||||
* @param {String | HTMLElement | Array} el The element or collection to test
|
||||
* @param {String} className the class name to search for
|
||||
* @return {Boolean | Array} A boolean value or array of boolean values
|
||||
*/
|
||||
hasClass: function(el, className) {
|
||||
var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
|
||||
|
||||
var f = function(el) {
|
||||
logger.log('hasClass returning ' + re.test(el['className']), 'info', 'Dom');
|
||||
return re.test(el['className']);
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a class name to a given element or collection of elements.
|
||||
* @method addClass
|
||||
* @param {String | HTMLElement | Array} el The element or collection to add the class to
|
||||
* @param {String} className the class name to add to the class attribute
|
||||
*/
|
||||
addClass: function(el, className) {
|
||||
var f = function(el) {
|
||||
if (this.hasClass(el, className)) { return; } // already present
|
||||
|
||||
logger.log('addClass adding ' + className, 'info', 'Dom');
|
||||
|
||||
el['className'] = [el['className'], className].join(' ');
|
||||
};
|
||||
|
||||
Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes a class name from a given element or collection of elements.
|
||||
* @method removeClass
|
||||
* @param {String | HTMLElement | Array} el The element or collection to remove the class from
|
||||
* @param {String} className the class name to remove from the class attribute
|
||||
*/
|
||||
removeClass: function(el, className) {
|
||||
var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
|
||||
|
||||
var f = function(el) {
|
||||
if (!this.hasClass(el, className)) { return; } // not present
|
||||
|
||||
logger.log('removeClass removing ' + className, 'info', 'Dom');
|
||||
|
||||
var c = el['className'];
|
||||
el['className'] = c.replace(re, ' ');
|
||||
if ( this.hasClass(el, className) ) { // in case of multiple adjacent
|
||||
this.removeClass(el, className);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Replace a class with another class for a given element or collection of elements.
|
||||
* If no oldClassName is present, the newClassName is simply added.
|
||||
* @method replaceClass
|
||||
* @param {String | HTMLElement | Array} el The element or collection to remove the class from
|
||||
* @param {String} oldClassName the class name to be replaced
|
||||
* @param {String} newClassName the class name that will be replacing the old class name
|
||||
*/
|
||||
replaceClass: function(el, oldClassName, newClassName) {
|
||||
if (oldClassName === newClassName) { // avoid infinite loop
|
||||
return false;
|
||||
}
|
||||
|
||||
var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
|
||||
|
||||
var f = function(el) {
|
||||
logger.log('replaceClass replacing ' + oldClassName + ' with ' + newClassName, 'info', 'Dom');
|
||||
|
||||
if ( !this.hasClass(el, oldClassName) ) {
|
||||
this.addClass(el, newClassName); // just add it if nothing to replace
|
||||
return; // note return
|
||||
}
|
||||
|
||||
el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
|
||||
|
||||
if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
|
||||
this.replaceClass(el, oldClassName, newClassName);
|
||||
}
|
||||
};
|
||||
|
||||
Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Generates a unique ID
|
||||
* @method generateId
|
||||
* @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).
|
||||
* @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen").
|
||||
* @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
|
||||
*/
|
||||
generateId: function(el, prefix) {
|
||||
prefix = prefix || 'yui-gen';
|
||||
el = el || {};
|
||||
|
||||
var f = function(el) {
|
||||
if (el) {
|
||||
el = Y.Dom.get(el);
|
||||
} else {
|
||||
el = {}; // just generating ID in this case
|
||||
}
|
||||
|
||||
if (!el.id) {
|
||||
el.id = prefix + id_counter++;
|
||||
logger.log('generateId generating ' + el.id, 'info', 'Dom');
|
||||
} // dont override existing
|
||||
|
||||
logger.log('generateId returning ' + el.id, 'info', 'Dom');
|
||||
|
||||
return el.id;
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.
|
||||
* @method isAncestor
|
||||
* @param {String | HTMLElement} haystack The possible ancestor
|
||||
* @param {String | HTMLElement} needle The possible descendent
|
||||
* @return {Boolean} Whether or not the haystack is an ancestor of needle
|
||||
*/
|
||||
isAncestor: function(haystack, needle) {
|
||||
haystack = Y.Dom.get(haystack);
|
||||
if (!haystack || !needle) { return false; }
|
||||
|
||||
var f = function(needle) {
|
||||
if (haystack.contains && !isSafari) { // safari "contains" is broken
|
||||
logger.log('isAncestor returning ' + haystack.contains(needle), 'info', 'Dom');
|
||||
return haystack.contains(needle);
|
||||
}
|
||||
else if ( haystack.compareDocumentPosition ) {
|
||||
logger.log('isAncestor returning ' + !!(haystack.compareDocumentPosition(needle) & 16), 'info', 'Dom');
|
||||
return !!(haystack.compareDocumentPosition(needle) & 16);
|
||||
}
|
||||
else { // loop up and test each parent
|
||||
var parent = needle.parentNode;
|
||||
|
||||
while (parent) {
|
||||
if (parent == haystack) {
|
||||
logger.log('isAncestor returning true', 'info', 'Dom');
|
||||
return true;
|
||||
}
|
||||
else if (!parent.tagName || parent.tagName.toUpperCase() == 'HTML') {
|
||||
logger.log('isAncestor returning false', 'info', 'Dom');
|
||||
return false;
|
||||
}
|
||||
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
logger.log('isAncestor returning false', 'info', 'Dom');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
return Y.Dom.batch(needle, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines whether an HTMLElement is present in the current document.
|
||||
* @method inDocument
|
||||
* @param {String | HTMLElement} el The element to search for
|
||||
* @return {Boolean} Whether or not the element is present in the current document
|
||||
*/
|
||||
inDocument: function(el) {
|
||||
var f = function(el) {
|
||||
return this.isAncestor(document.documentElement, el);
|
||||
};
|
||||
|
||||
return Y.Dom.batch(el, f, Y.Dom, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a array of HTMLElements that pass the test applied by supplied boolean method.
|
||||
* For optimized performance, include a tag and/or root node when possible.
|
||||
* @method getElementsBy
|
||||
* @param {Function} method - A boolean method for testing elements which receives the element as its only argument.
|
||||
|
||||
* @param {String} tag (optional) The tag name of the elements being collected
|
||||
* @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
|
||||
*/
|
||||
getElementsBy: function(method, tag, root) {
|
||||
tag = tag || '*';
|
||||
root = Y.Dom.get(root) || document;
|
||||
|
||||
var nodes = [];
|
||||
var elements = root.getElementsByTagName(tag);
|
||||
|
||||
if ( !elements.length && (tag == '*' && root.all) ) {
|
||||
elements = root.all; // IE < 6
|
||||
}
|
||||
|
||||
for (var i = 0, len = elements.length; i < len; ++i) {
|
||||
if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
|
||||
}
|
||||
|
||||
logger.log('getElementsBy returning ' + nodes, 'info', 'Dom');
|
||||
|
||||
return nodes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of elements that have had the supplied method applied.
|
||||
* The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).
|
||||
* @method batch
|
||||
* @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to
|
||||
* @param {Function} method The method to apply to the element(s)
|
||||
* @param {Any} o (optional) An optional arg that is passed to the supplied method
|
||||
* @param {Boolean} override (optional) Whether or not to override the scope of "method" with "o"
|
||||
* @return {HTMLElement | Array} The element(s) with the method applied
|
||||
*/
|
||||
batch: function(el, method, o, override) {
|
||||
var id = el;
|
||||
el = Y.Dom.get(el);
|
||||
|
||||
var scope = (override) ? o : window;
|
||||
|
||||
if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
|
||||
if (!el) {
|
||||
logger.log(id + ' not available', 'error', 'Dom');
|
||||
return false;
|
||||
}
|
||||
return method.call(scope, el, o);
|
||||
}
|
||||
|
||||
var collection = [];
|
||||
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
if (!el[i]) {
|
||||
id = el[i];
|
||||
logger.log(id + ' not available', 'error', 'Dom');
|
||||
}
|
||||
collection[collection.length] = method.call(scope, el[i], o);
|
||||
}
|
||||
|
||||
return collection;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the height of the document.
|
||||
* @method getDocumentHeight
|
||||
* @return {Int} The height of the actual document (which includes the body and its margin).
|
||||
*/
|
||||
getDocumentHeight: function() {
|
||||
var scrollHeight = (document.compatMode != 'CSS1Compat') ? document.body.scrollHeight : document.documentElement.scrollHeight;
|
||||
|
||||
var h = Math.max(scrollHeight, Y.Dom.getViewportHeight());
|
||||
logger.log('getDocumentHeight returning ' + h, 'info', 'Dom');
|
||||
return h;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the width of the document.
|
||||
* @method getDocumentWidth
|
||||
* @return {Int} The width of the actual document (which includes the body and its margin).
|
||||
*/
|
||||
getDocumentWidth: function() {
|
||||
var scrollWidth = (document.compatMode != 'CSS1Compat') ? document.body.scrollWidth : document.documentElement.scrollWidth;
|
||||
var w = Math.max(scrollWidth, Y.Dom.getViewportWidth());
|
||||
logger.log('getDocumentWidth returning ' + w, 'info', 'Dom');
|
||||
return w;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current height of the viewport.
|
||||
* @method getViewportHeight
|
||||
* @return {Int} The height of the viewable area of the page (excludes scrollbars).
|
||||
*/
|
||||
getViewportHeight: function() {
|
||||
var height = self.innerHeight; // Safari, Opera
|
||||
var mode = document.compatMode;
|
||||
|
||||
if ( (mode || isIE) && !isOpera ) { // IE, Gecko
|
||||
height = (mode == 'CSS1Compat') ?
|
||||
document.documentElement.clientHeight : // Standards
|
||||
document.body.clientHeight; // Quirks
|
||||
}
|
||||
|
||||
logger.log('getViewportHeight returning ' + height, 'info', 'Dom');
|
||||
return height;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current width of the viewport.
|
||||
* @method getViewportWidth
|
||||
* @return {Int} The width of the viewable area of the page (excludes scrollbars).
|
||||
*/
|
||||
|
||||
getViewportWidth: function() {
|
||||
var width = self.innerWidth; // Safari
|
||||
var mode = document.compatMode;
|
||||
|
||||
if (mode || isIE) { // IE, Gecko, Opera
|
||||
width = (mode == 'CSS1Compat') ?
|
||||
document.documentElement.clientWidth : // Standards
|
||||
document.body.clientWidth; // Quirks
|
||||
}
|
||||
logger.log('getViewportWidth returning ' + width, 'info', 'Dom');
|
||||
return width;
|
||||
}
|
||||
};
|
||||
})();
|
||||
/**
|
||||
* A region is a representation of an object on a grid. It is defined
|
||||
* by the top, right, bottom, left extents, so is rectangular by default. If
|
||||
* other shapes are required, this class could be extended to support it.
|
||||
* @namespace YAHOO.util
|
||||
* @class Region
|
||||
* @param {Int} t the top extent
|
||||
* @param {Int} r the right extent
|
||||
* @param {Int} b the bottom extent
|
||||
* @param {Int} l the left extent
|
||||
* @constructor
|
||||
*/
|
||||
YAHOO.util.Region = function(t, r, b, l) {
|
||||
|
||||
/**
|
||||
* The region's top extent
|
||||
* @property top
|
||||
* @type Int
|
||||
*/
|
||||
this.top = t;
|
||||
|
||||
/**
|
||||
* The region's top extent as index, for symmetry with set/getXY
|
||||
* @property 1
|
||||
* @type Int
|
||||
*/
|
||||
this[1] = t;
|
||||
|
||||
/**
|
||||
* The region's right extent
|
||||
* @property right
|
||||
* @type int
|
||||
*/
|
||||
this.right = r;
|
||||
|
||||
/**
|
||||
* The region's bottom extent
|
||||
* @property bottom
|
||||
* @type Int
|
||||
*/
|
||||
this.bottom = b;
|
||||
|
||||
/**
|
||||
* The region's left extent
|
||||
* @property left
|
||||
* @type Int
|
||||
*/
|
||||
this.left = l;
|
||||
|
||||
/**
|
||||
* The region's left extent as index, for symmetry with set/getXY
|
||||
* @property 0
|
||||
* @type Int
|
||||
*/
|
||||
this[0] = l;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if this region contains the region passed in
|
||||
* @method contains
|
||||
* @param {Region} region The region to evaluate
|
||||
* @return {Boolean} True if the region is contained with this region,
|
||||
* else false
|
||||
*/
|
||||
YAHOO.util.Region.prototype.contains = function(region) {
|
||||
return ( region.left >= this.left &&
|
||||
region.right <= this.right &&
|
||||
region.top >= this.top &&
|
||||
region.bottom <= this.bottom );
|
||||
|
||||
// this.logger.debug("does " + this + " contain " + region + " ... " + ret);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the area of the region
|
||||
* @method getArea
|
||||
* @return {Int} the region's area
|
||||
*/
|
||||
YAHOO.util.Region.prototype.getArea = function() {
|
||||
return ( (this.bottom - this.top) * (this.right - this.left) );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the region where the passed in region overlaps with this one
|
||||
* @method intersect
|
||||
* @param {Region} region The region that intersects
|
||||
* @return {Region} The overlap region, or null if there is no overlap
|
||||
*/
|
||||
YAHOO.util.Region.prototype.intersect = function(region) {
|
||||
var t = Math.max( this.top, region.top );
|
||||
var r = Math.min( this.right, region.right );
|
||||
var b = Math.min( this.bottom, region.bottom );
|
||||
var l = Math.max( this.left, region.left );
|
||||
|
||||
if (b >= t && r >= l) {
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the region representing the smallest region that can contain both
|
||||
* the passed in region and this region.
|
||||
* @method union
|
||||
* @param {Region} region The region that to create the union with
|
||||
* @return {Region} The union region
|
||||
*/
|
||||
YAHOO.util.Region.prototype.union = function(region) {
|
||||
var t = Math.min( this.top, region.top );
|
||||
var r = Math.max( this.right, region.right );
|
||||
var b = Math.max( this.bottom, region.bottom );
|
||||
var l = Math.min( this.left, region.left );
|
||||
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
};
|
||||
|
||||
/**
|
||||
* toString
|
||||
* @method toString
|
||||
* @return string the region properties
|
||||
*/
|
||||
YAHOO.util.Region.prototype.toString = function() {
|
||||
return ( "Region {" +
|
||||
"top: " + this.top +
|
||||
", right: " + this.right +
|
||||
", bottom: " + this.bottom +
|
||||
", left: " + this.left +
|
||||
"}" );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a region that is occupied by the DOM element
|
||||
* @method getRegion
|
||||
* @param {HTMLElement} el The element
|
||||
* @return {Region} The region that the element occupies
|
||||
* @static
|
||||
*/
|
||||
YAHOO.util.Region.getRegion = function(el) {
|
||||
var p = YAHOO.util.Dom.getXY(el);
|
||||
|
||||
var t = p[1];
|
||||
var r = p[0] + el.offsetWidth;
|
||||
var b = p[1] + el.offsetHeight;
|
||||
var l = p[0];
|
||||
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* A point is a region that is special in that it represents a single point on
|
||||
* the grid.
|
||||
* @namespace YAHOO.util
|
||||
* @class Point
|
||||
* @param {Int} x The X position of the point
|
||||
* @param {Int} y The Y position of the point
|
||||
* @constructor
|
||||
* @extends YAHOO.util.Region
|
||||
*/
|
||||
YAHOO.util.Point = function(x, y) {
|
||||
if (x instanceof Array) { // accept output from Dom.getXY
|
||||
y = x[1];
|
||||
x = x[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
|
||||
* @property x
|
||||
* @type Int
|
||||
*/
|
||||
|
||||
this.x = this.right = this.left = this[0] = x;
|
||||
|
||||
/**
|
||||
* The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
|
||||
* @property y
|
||||
* @type Int
|
||||
*/
|
||||
this.y = this.top = this.bottom = this[1] = y;
|
||||
};
|
||||
|
||||
YAHOO.util.Point.prototype = new YAHOO.util.Region();
|
||||
|
@@ -1,122 +0,0 @@
|
||||
|
||||
YUI Library - Event - Release Notes
|
||||
|
||||
0.12.0
|
||||
|
||||
* If the function argument is not provided to Event.removeListener, all
|
||||
all listeners for the specified event type on the element will be removed.
|
||||
|
||||
* CustomEvent now has an optional parameter that defines the signature of
|
||||
the listeners for this event. Two signatures are supported:
|
||||
|
||||
YAHOO.util.CustomEvent.LIST:
|
||||
param1: event name
|
||||
param2: array of arguments provided to fire()
|
||||
param3: <optional> the custom object supplied to subscribe()
|
||||
|
||||
YAHOO.util.CustomEvent.FLAT:
|
||||
param1: the first argument provided to fire()
|
||||
param2: <optional> the custom object supplied to subscribe()
|
||||
|
||||
The new flat signature makes it possible to provide a better API
|
||||
when using custom events, and it makes it possible to transparently
|
||||
wrap DOM events.
|
||||
|
||||
* The parameters for overriding scope in both Event.addListener, and
|
||||
CustomEvent.subscribe have been augmented. In addition to the
|
||||
previous behavior where a true value would make the previous parameter
|
||||
the execution scope, an object can be supplied instead. If an object
|
||||
is provided, that object becomes the scope obj. This makes it possible
|
||||
to pass a both a custom object and adjust the scope to a different object.
|
||||
|
||||
* Added EventProvider, which is a wrapper for CustomEvent that makes it
|
||||
possible to subscribe to events by name, whether or not the event has
|
||||
been created. This class was designed to be used with YAHOO.augment.
|
||||
EventProvider custom events are created with the new FLAT listener
|
||||
signature.
|
||||
|
||||
* CustomEvent subscribers can return false to stop the propagation of
|
||||
the event.
|
||||
|
||||
* CustomEvents now have an onSubscribe custom event that can used to the
|
||||
case where a subscriber subscribes to an one-time event that has already
|
||||
happened. Also provides a way for the implementer to defer initialization
|
||||
logic until after the first subscription.
|
||||
|
||||
* Event.getCharCode now always returns keyCode if charCode is not available.
|
||||
|
||||
* Added Event.onContentReady, which is similar to onAvailable, but it also
|
||||
checks simblings to try to determine when the element's children are
|
||||
available.
|
||||
|
||||
0.11.4
|
||||
|
||||
* Fixed a memory leak in IE6 that occurred when the utility was hosted in
|
||||
an iframe.
|
||||
|
||||
* Fixed an issue with Safari click listeners when listeners were removed.
|
||||
|
||||
0.11.3
|
||||
|
||||
* The listener cache is now pruned when events are removed. This fixes
|
||||
a performance issue when adding many listeners, removing them, and
|
||||
adding them again repeatedly.
|
||||
|
||||
* Safari click listeners will work correctly if a bound element is removed
|
||||
from the DOM and a new element with the same ID is added.
|
||||
|
||||
* Removed the code that automatically unsubscribed custom event listeners.
|
||||
|
||||
0.11.0
|
||||
|
||||
* Added Event.purgeElement which will remove all listeners added via
|
||||
addListener from the supplied element. If an optional "type" parameter
|
||||
is supplied, only events of that type will be removed. Optionally, the
|
||||
purge can be performed recursively on the element's children as well.
|
||||
|
||||
* Added Event.getListeners which will return all listeners attached to
|
||||
a given element.. either all listeners or listeners of a specific type.
|
||||
|
||||
* getTarget now automatically resolves text nodes. The optional parameter
|
||||
for this feature is now deprecated.
|
||||
|
||||
* getRelatedTarget now resolves text nodes for the browsers that return the
|
||||
text node rather than its host HTML element.
|
||||
|
||||
* CustomEvent now logs the custom event activity if the logger widget is available
|
||||
|
||||
0.10.0
|
||||
|
||||
* Added Safari dblclick to the list of legacy events.
|
||||
|
||||
* When multiple identical event handlers are defined, multiple calls
|
||||
to removeListener can now remove all of them.
|
||||
|
||||
* removeListener works properly for unload events
|
||||
|
||||
* Legacy event bookkeeping is more efficient, improving the performance for
|
||||
adding Safari click events.
|
||||
|
||||
* _unload() is more efficient, improving the page transition experience in
|
||||
Safari in particular.
|
||||
|
||||
* addListener, removeListener now return false if the function argument is
|
||||
not valid.
|
||||
|
||||
* Fixed an operator precedence issue in getCharCode.
|
||||
|
||||
* Added Event.getXY, which returns [Event.getPageX(e), Event.getPageY(e)]
|
||||
|
||||
* Added Event.onAvailable, which will execute the callback when the element
|
||||
with the supplied id is found. Currently searches periodically until the
|
||||
window load event or for up to 10 seconds after the onAvailable method
|
||||
was executed.
|
||||
|
||||
* The lazy listener attachment process now will poll beyond the window load
|
||||
event in order to better handle the case when a listener is defined
|
||||
late in the page but before the element is in the dom.
|
||||
|
||||
* Fixed browser detection for Opera installations reporting as IE.
|
||||
|
||||
* It is now possible to remove and re-add legacy events (Safari click event).
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,112 +0,0 @@
|
||||
TreeView - Release Notes
|
||||
|
||||
0.12.0
|
||||
|
||||
* TreeView now augments EventProvider, and has custom events for expand,
|
||||
collapse, animStart, animComplete, and labelClick. Existing implementations
|
||||
using abstract methods for these events (if they exist) will still work.
|
||||
New events can be plugged into the tree by the Node implementation. For
|
||||
example, TaskNode adds a checkClick event. EventProvider makes it safe
|
||||
to do this because implementing code can call subscribe() prior to the
|
||||
event creation.
|
||||
|
||||
* YAHOO.util.Event is now a requirement for the widget
|
||||
|
||||
* TreeView::removeChildren no longer expands and collapses the node.
|
||||
|
||||
* Documented the moveComplete property
|
||||
|
||||
* createElement("DIV") changed to createElement("div")
|
||||
|
||||
0.11.4
|
||||
|
||||
* Fixed a javascript error on the HTML node example page.
|
||||
|
||||
0.11.3
|
||||
|
||||
* popNode now clears the tree, previousSibling, nextSibling, and parent
|
||||
properties of the node that is being removed from the tree.
|
||||
|
||||
* Fixed the paths to the images in the tree.css file that is included in
|
||||
build/assets.
|
||||
|
||||
0.11.0
|
||||
|
||||
* Added TreeView -> popNode, which differs from removeNode in that the
|
||||
node's children are preserved so the entire branch can be re-inserted
|
||||
into another part of the tree, or another tree.
|
||||
|
||||
* Added TreeView -> getNodesByProperty, which differs from
|
||||
getNodeByProperty by returning an array of all nodes that have the
|
||||
specified property rather than just the first one.
|
||||
|
||||
* Added Node -> insertBefore, insertAfter, and appendTo. These method
|
||||
can be used to reorganize the tree.
|
||||
|
||||
* removeChildren properly resets the node icon when executed against a
|
||||
collpased node.
|
||||
|
||||
* Moved depth assignment from the constructor to appendChild so that the
|
||||
value is set properly if the node is moved within the tree.
|
||||
|
||||
* Fixed broken loop in removeChildren.
|
||||
|
||||
* RootNode -> loadComplete calls tree.draw for hot-wiring the dynamic load
|
||||
feature for the top level nodes.
|
||||
|
||||
* The treeview constructor will accept an element instead of an id.
|
||||
|
||||
0.10.0
|
||||
|
||||
* If the child collection changes prior to a refresh(), the icon is now
|
||||
changed appropriately.
|
||||
|
||||
* Added TreeView removeChildren(node). This will recursively purge the node's
|
||||
children, and reset its dynamic load state.
|
||||
|
||||
* previousSibling and nextSibling are now adjusted correctly when a
|
||||
node is deleted.
|
||||
|
||||
* expand()/collapse() now will not expand/collapse the node if false is
|
||||
returned from the onExpand/onCollapse event handlers.
|
||||
|
||||
* The onExpand and onCollapse events now fire before the node is expanded
|
||||
or collapsed so that the implementer can modify the node's child collection
|
||||
prior to display.
|
||||
|
||||
* The childrenRendered property previous was used to indicate both that
|
||||
a dynamically loaded node has received its data, and also to indicate
|
||||
that the children html has been created. This has been split into
|
||||
two properties. dynamicLoadComplete and childrenRendered.
|
||||
|
||||
* Implemented the renderHidden flag. If set to true, the html for the entire
|
||||
tree will be created when tree.draw() is called, not just the html for the
|
||||
visible nodes.
|
||||
|
||||
* Added an onLabelClick listener to TextNode
|
||||
|
||||
* TreeView.removeNode no longer automatically refreshes the tree. It has an
|
||||
optional parameter to perform the refresh.
|
||||
|
||||
* removeNode can now be executed on nodes that have not been rendered.
|
||||
|
||||
* You can now delete top-level nodes.
|
||||
|
||||
* Added onCheckClick listener to the TaskNode example
|
||||
|
||||
* Added Node.iconMode, which is a property that configures the way
|
||||
dynamically loaded nodes are displayed when they are expanded and contain
|
||||
no children.
|
||||
|
||||
* TreeView/Node.setDynamicLoad now accepts an optional second parameter to
|
||||
set the iconMode property.
|
||||
|
||||
* Fixed an issue in the TaskNode.js example that prevented setting the checked
|
||||
state of a node through the constructor.
|
||||
|
||||
* Fixed an issue in HTMLNode that caused rendering issues when hasIcon was
|
||||
set to true.
|
||||
|
||||
* Added TreeView.removeNode
|
||||
|
||||
* Added Node.refresh
|
File diff suppressed because it is too large
Load Diff
@@ -1,20 +0,0 @@
|
||||
utilities.js Release Notes
|
||||
|
||||
*** version 0.12.0 ***
|
||||
|
||||
The utilities.js file rolls up all of the YUI utility components into a single
|
||||
file; it includes the following components:
|
||||
|
||||
* Yahoo Global Object
|
||||
* Event
|
||||
* Dom
|
||||
* Connection Manager
|
||||
* Animation
|
||||
* Drag & Drop
|
||||
|
||||
For implementations that use a significant subset of these files, it may prove
|
||||
more efficient to include utilities.js as opposed to including separate files
|
||||
for each component.
|
||||
|
||||
Note: If you are require only the Yahoo Global Object, Event Utility and Dom
|
||||
collection, consider using the special yahoo-event-dom.js aggregate instead.
|
@@ -1,23 +0,0 @@
|
||||
yahoo-event-dom.js Release Notes
|
||||
|
||||
*** version 0.12.0 ***
|
||||
|
||||
The yahoo-event-dom.js file rolls up the three most commonly-used YUI Utilities
|
||||
into a single file; it includes the following files:
|
||||
|
||||
* Yahoo Global Object
|
||||
* Event
|
||||
* Dom
|
||||
|
||||
These three files serve as a common foundation for most YUI components and
|
||||
third-party implementations. On pages where you do not need additional YUI
|
||||
Utilities (Connection Manager, Animation Utility, Drag & Drop Utility), the
|
||||
yahoo-event-dom.js aggregate will often be an optimal choice.
|
||||
|
||||
Note: If you do require additional utilities, the full utilities.js file is
|
||||
provided in this distribution; utilities.js includes all YUI Utilities in a
|
||||
single file.
|
||||
|
||||
Please see the blog article on www.yuiblog.com titled "YUI: Weighing in on
|
||||
Pageweights" at http://yuiblog.com/blog/2006/10/16/pageweight-yui0114/ for more
|
||||
details.
|
@@ -1,37 +0,0 @@
|
||||
YAHOO Global Namespace - Release Notes
|
||||
|
||||
0.12.0
|
||||
|
||||
* Added YAHOO.augment, which copies all or part of the prototype of one
|
||||
object to another.
|
||||
|
||||
* YAHOO.namespace now can create multiple namespaces.
|
||||
|
||||
* Added an optional third parameter to YAHOO.extend: overrides. It takes
|
||||
an object literal of properties/methods to apply to the subclass
|
||||
prototype, overriding the superclass if present.
|
||||
|
||||
0.11.4
|
||||
|
||||
* Changed window.YAHOO = window.YAHOO || {} to
|
||||
if (typeof YAHOO == "undefined") YAHOO = {} because the previous statement
|
||||
contributed to a memory leak in IE6 when the library was hosted in an
|
||||
iframe.
|
||||
|
||||
0.11.3
|
||||
|
||||
* Changed var YAHOO = window.YAHOO || {} to window.YAHOO = window.YAHOO || {}.
|
||||
This fixes an issue in IE where YAHOO would get overwritten if previously
|
||||
defined via array notation (window["YAHOO"]).
|
||||
|
||||
0.11.0
|
||||
|
||||
* Added YAHOO.extend, which provides an easy way to assign the prototype,
|
||||
constructor, and superclass properties inheritance properties. It also
|
||||
prevents the constructor of the superclass from being exectuted twice.
|
||||
|
||||
0.10.0
|
||||
|
||||
* Added YAHOO.log that provides a safe way to plumb logging statements in
|
||||
code that will work if the logging component isn't available.
|
||||
|
145
source/web/scripts/ajax/yahoo/yahoo/yahoo-debug.js
vendored
145
source/web/scripts/ajax/yahoo/yahoo/yahoo-debug.js
vendored
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 0.12.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* The YAHOO object is the single global object used by YUI Library. It
|
||||
* contains utility function for setting up namespaces, inheritance, and
|
||||
* logging. YAHOO.util, YAHOO.widget, and YAHOO.example are namespaces
|
||||
* created automatically for and used by the library.
|
||||
* @module yahoo
|
||||
* @title YAHOO Global
|
||||
*/
|
||||
|
||||
/**
|
||||
* The YAHOO global namespace object
|
||||
* @class YAHOO
|
||||
* @static
|
||||
*/
|
||||
if (typeof YAHOO == "undefined") {
|
||||
var YAHOO = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace specified and creates it if it doesn't exist
|
||||
* <pre>
|
||||
* YAHOO.namespace("property.package");
|
||||
* YAHOO.namespace("YAHOO.property.package");
|
||||
* </pre>
|
||||
* Either of the above would create YAHOO.property, then
|
||||
* YAHOO.property.package
|
||||
*
|
||||
* Be careful when naming packages. Reserved words may work in some browsers
|
||||
* and not others. For instance, the following will fail in Safari:
|
||||
* <pre>
|
||||
* YAHOO.namespace("really.long.nested.namespace");
|
||||
* </pre>
|
||||
* This fails because "long" is a future reserved word in ECMAScript
|
||||
*
|
||||
* @method namespace
|
||||
* @static
|
||||
* @param {String*} arguments 1-n namespaces to create
|
||||
* @return {Object} A reference to the last namespace object created
|
||||
*/
|
||||
YAHOO.namespace = function() {
|
||||
var a=arguments, o=null, i, j, d;
|
||||
for (i=0; i<a.length; ++i) {
|
||||
d=a[i].split(".");
|
||||
o=YAHOO;
|
||||
|
||||
// YAHOO is implied, so it is ignored if it is included
|
||||
for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; ++j) {
|
||||
o[d[j]]=o[d[j]] || {};
|
||||
o=o[d[j]];
|
||||
}
|
||||
}
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
/**
|
||||
* Uses YAHOO.widget.Logger to output a log message, if the widget is available.
|
||||
*
|
||||
* @method log
|
||||
* @static
|
||||
* @param {String} msg The message to log.
|
||||
* @param {String} cat The log category for the message. Default
|
||||
* categories are "info", "warn", "error", time".
|
||||
* Custom categories can be used as well. (opt)
|
||||
* @param {String} src The source of the the message (opt)
|
||||
* @return {Boolean} True if the log operation was successful.
|
||||
*/
|
||||
YAHOO.log = function(msg, cat, src) {
|
||||
var l=YAHOO.widget.Logger;
|
||||
if(l && l.log) {
|
||||
return l.log(msg, cat, src);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Utility to set up the prototype, constructor and superclass properties to
|
||||
* support an inheritance strategy that can chain constructors and methods.
|
||||
*
|
||||
* @method extend
|
||||
* @static
|
||||
* @param {Function} subc the object to modify
|
||||
* @param {Function} superc the object to inherit
|
||||
* @param {String[]} overrides additional properties/methods to add to the
|
||||
* subclass prototype. These will override the
|
||||
* matching items obtained from the superclass
|
||||
* if present.
|
||||
*/
|
||||
YAHOO.extend = function(subc, superc, overrides) {
|
||||
var F = function() {};
|
||||
F.prototype=superc.prototype;
|
||||
subc.prototype=new F();
|
||||
subc.prototype.constructor=subc;
|
||||
subc.superclass=superc.prototype;
|
||||
if (superc.prototype.constructor == Object.prototype.constructor) {
|
||||
superc.prototype.constructor=superc;
|
||||
}
|
||||
|
||||
if (overrides) {
|
||||
for (var i in overrides) {
|
||||
subc.prototype[i]=overrides[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Applies all prototype properties in the supplier to the receiver if the
|
||||
* receiver does not have these properties yet. Optionally, one or more
|
||||
* methods/properties can be specified (as additional parameters). This
|
||||
* option will overwrite the property if receiver has it already.
|
||||
*
|
||||
* @method augment
|
||||
* @static
|
||||
* @param {Function} r the object to receive the augmentation
|
||||
* @param {Function} s the object that supplies the properties to augment
|
||||
* @param {String*} arguments zero or more properties methods to augment the
|
||||
* receiver with. If none specified, everything
|
||||
* in the supplier will be used unless it would
|
||||
* overwrite an existing property in the receiver
|
||||
*/
|
||||
YAHOO.augment = function(r, s) {
|
||||
var rp=r.prototype, sp=s.prototype, a=arguments, i, p;
|
||||
if (a[2]) {
|
||||
for (i=2; i<a.length; ++i) {
|
||||
rp[a[i]] = sp[a[i]];
|
||||
}
|
||||
} else {
|
||||
for (p in sp) {
|
||||
if (!rp[p]) {
|
||||
rp[p] = sp[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.namespace("util", "widget", "example");
|
||||
|
Reference in New Issue
Block a user