AJAX technology (2) common class
Related Tags:
* (C) 2005 Sam Stephenson <sam@conio.net>
*
* THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff
* Against the source tree, available from the Prototype darcs repository.
*
* Prototype is freely distributable under the terms of an MIT-style license.
*
*
/*------------------------------------------------ --------------------------*/
= (Var Prototype
Version:'1 .3.1 '
EmptyFunction: function () ()
)
Var class = (
Create: function () (
Return function () (
This.initialize.apply (this, arguments);
)
)
)
Var Abstract = new Object ();
Object.extend = function (destination, source) (
For (property in source) (
Destination [property] = source [property];
)
Return destination;
)
Object.prototype.extend = function (object) (
Return Object.extend.apply (this, [this, the object]);
)
Function.prototype.bind = function (object) (
Var __method = this;
Return function () (
__method.apply (Object, arguments);
)
)
Function.prototype.bindAsEventListener = function (object) (
Var __method = this;
Return function (event) (
__method.call (Object, event | | window.event);
)
)
Number.prototype.toColorPart = function () (
Var digits = this.toString (16);
If (this <16) return'0 '+ digits;
Return digits;
)
= (Var Try
These: function () (
Var returnValue;
For (var i = 0; i <arguments.length; i + +) (
Var lambda = arguments [i];
Try (
ReturnValue = lambda ();
Break;
) Catch (e) ()
)
Return returnValue;
)
)
/*------------------------------------------------ --------------------------*/
Var PeriodicalExecuter = Class.create ();
PeriodicalExecuter.prototype = (
Initialize: function (callback, frequency) (
This.callback = callback;
This.frequency = frequency;
This.currentlyExecuting = false;
This.registerCallback ();
)
RegisterCallback: function () (
SetInterval (this.onTimerEvent.bind (this), this.frequency * 1000);
)
OnTimerEvent: function () (
If (! This.currentlyExecuting) (
Try (
This.currentlyExecuting = true;
This.callback ();
Finally ()
This.currentlyExecuting = false;
)
)
)
)
/*------------------------------------------------ --------------------------*/
$ Function () (
Var elements = new Array ();
For (var i = 0; i <arguments.length; i + +) (
Var Element [i] = arguments;
If (typeof element == 'string')
Element = document.getElementById (element);
If (arguments.length == 1)
Return element;
Elements.push (element);
)
Return elements;
)
If (! Array.prototype.push) (
Array.prototype.push = function () (
Var startLength = this.length;
For (var i = 0; i <arguments.length; i + +)
This [startLength + i] [i] = arguments;
Return this.length;
)
)
If (! Function.prototype.apply) (
/ / Based on code from http://www.youngpup.net/
Function.prototype.apply = function (object, parameters) (
Var parameterStrings = new Array ();
If (! Object) = window object;
If (! Parameters) parameters = new Array ();
For (var i = 0; i <parameters.length; i + +)
ParameterStrings [i] = 'parameters [' + i + ']';
Object.__apply__ = this;
Var result = eval ( 'object.__apply__ (' +
ParameterStrings.join ( '') +')');
Object.__apply__ = null;
Return result;
)
)
String.prototype.extend ((
StripTags: function () (
Return this.replace (/ <\ /?[^>]+>/ gi,'');
)
EscapeHTML: function () (
Var div = document.createElement ( 'div');
Var text = document.createTextNode (this);
Div.appendChild (text);
Return div.innerHTML;
)
UnescapeHTML: function () (
Var div = document.createElement ( 'div');
Div.innerHTML = this.stripTags ();
Return div.childNodes [0]. NodeValue;
)
));
= (Var Ajax
GetTransport: function () (
Return Try.these (
Function () (return new ActiveXObject ( 'Msxml2.XMLHTTP')),
Function () (return new ActiveXObject ( 'Microsoft.XMLHTTP')),
Function () (return new XMLHttpRequest ())
) | | False;
)
)
Ajax.Base = function () ();
Ajax.Base.prototype = (
SetOptions: function (options) (
This.options = (
Method: 'post'
Asynchronous: true,
Parameters:''
). Extend (options | | ());
)
ResponseIsSuccess: function () (
== Undefined return this.transport.status
| | == 0 this.transport.status
| | (This.transport.status> = 200 & & this.transport.status <300);
)
ResponseIsFailure: function () (
Return! This.responseIsSuccess ();
)
)
Ajax.Request = Class.create ();
Ajax.Request.Events =
[ 'Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
Ajax.Request.prototype = (new Ajax.Base ()). Extend ((
Initialize: function (url, options) (
This.transport = Ajax.getTransport ();
This.setOptions (options);
This.request (url);
)
Request: function (url) (
Var parameters this.options.parameters = | |'';
If (parameters.length> 0) + = parameters'&_=';
Try (
If (this.options.method == 'get')
url + = 'a' + parameters;
This.transport.open (this.options.method, url,
This.options.asynchronous);
If (this.options.asynchronous) (
This.transport.onreadystatechange = this.onStateChange.bind (this);
SetTimeout ((function () (this.respondToReadyState (1))). Bind (this), 10);
)
This.setRequestHeaders ();
Var body = this.options.postBody? This.options.postBody: parameters;
This.transport.send (this.options.method == 'post'? Body: null);
) Catch (e) (
)
)
SetRequestHeaders: function () (
Var requestHeaders =
[ 'X-Requested-With', 'XMLHttpRequest'
'X-Prototype-Version', Prototype.Version];
If (this.options.method == 'post') (
RequestHeaders.push ( 'Content-type',
'Application / x-www-form-urlencoded');
/ * Force "Connection: close" for Mozilla browsers to work around
* A bug where XMLHttpReqeuest sends an incorrect Content-length
* Header. See Mozilla Bugzilla # 246651.
* /
If (this.transport.overrideMimeType)
RequestHeaders.push ( 'Connection', 'close');
)
If (this.options.requestHeaders)
RequestHeaders.push.apply (requestHeaders, this.options.requestHeaders);
For (var i = 0; i <requestHeaders.length; i + = 2)
This.transport.setRequestHeader (requestHeaders [i], requestHeaders [i +1]);
)
OnStateChange: function () (
Var readyState = this.transport.readyState;
If (readyState! = 1)
This.respondToReadyState (this.transport.readyState);
)
RespondToReadyState: function (readyState) (
Var event = Ajax.Request.Events [readyState];
If (event == 'Complete')
(This.options [ 'on' this.transport.status +]
| | This.options [ 'on' + (this.responseIsSuccess ()? 'Success':' Failure ')]
| | Prototype.emptyFunction) (this.transport);
(This.options [ 'on' + event] | | Prototype.emptyFunction) (this.transport);
/ * Avoid memory leak in MSIE: clean up the oncomplete event handler * /
If (event == 'Complete')
This.transport.onreadystatechange = Prototype.emptyFunction;
)
));
Ajax.Updater = Class.create ();
Ajax.Updater.ScriptFragment'(?:< script .*?>)(( = \ n |.)*?)(?:< \ / script ") ';
Ajax.Updater.prototype.extend (Ajax.Request.prototype). Extend ((
Initialize: function (container, url, options) (
This.containers = (
Success: container.success? $ (Container.success): $ (container),
Failure: container.failure? $ (Container.failure):
(Container.success? Null: $ (container))
)
This.transport = Ajax.getTransport ();
This.setOptions (options);
Var onComplete this.options.onComplete = | | Prototype.emptyFunction;
This.options.onComplete = (function () (
This.updateContent ();
OnComplete (this.transport);
)). Bind (this);
This.request (url);
)
UpdateContent: function () (
Var receiver = this.responseIsSuccess ()?
This.containers.success: this.containers.failure;
Var match = new RegExp (Ajax.Updater.ScriptFragment, 'img');
Var response = this.transport.responseText.replace (match,'');
Var scripts = this.transport.responseText.match (match);
If (receiver) (
If (this.options.insertion) (
New this.options.insertion (receiver, response);
Else ()
Receiver.innerHTML = response;
)
)
If (this.responseIsSuccess ()) (
If (this.onComplete)
SetTimeout ((function () (this.onComplete (
This.transport))). Bind (this), 10);
)
If (this.options.evalScripts & scripts) (
Match = new RegExp (Ajax.Updater.ScriptFragment, 'im');
SetTimeout ((function () (
For (var i = 0; i <scripts.length; i + +)
Eval (scripts [i]. Match (match) [1]);
)). Bind (this), 10);
)
)
));
Ajax.PeriodicalUpdater = Class.create ();
Ajax.PeriodicalUpdater.prototype = (new Ajax.Base ()). Extend ((
Initialize: function (container, url, options) (
This.setOptions (options);
This.onComplete = this.options.onComplete;
This.frequency = (this.options.frequency | | 2);
This.decay = 1;
This.updater = ();
This.container = container;
This.url = url;
This.start ();
)
Start: function () (
This.options.onComplete = this.updateComplete.bind (this);
This.onTimerEvent ();
)
Stop: function () (
This.updater.onComplete = undefined;
ClearTimeout (this.timer);
(This.onComplete | | Ajax.emptyFunction). Apply (this, arguments);
)
UpdateComplete: function (request) (
If (this.options.decay) (
This.decay = (request.responseText == this.lastText?
This.decay * this.options.decay: 1);
This.lastText = request.responseText;
)
This.timer = setTimeout (this.onTimerEvent.bind (this),
This.frequency this.decay * * 1000);
)
OnTimerEvent: function () (
This.updater = new Ajax.Updater (this.container, this.url, this.options);
)
));
Document.getElementsByClassName = function (className) (
Var children = document.getElementsByTagName ('*') | | document.all;
Var elements = new Array ();
For (var i = 0; i <children.length; i + +) (
Var child [i] = children;
Var classNames = child.className.split ( '');
For (var j = 0; j <classNames.length; j + +) (
If (classNames [j] == className) (
Elements.push (child);
Break;
)
)
)
Return elements;
)
/*------------------------------------------------ --------------------------*/
If (! Window.Element) (
Var Element = new Object ();
)
Object.extend (Element, (
Toggle: function () (
For (var i = 0; i <arguments.length; i + +) (
Var element = ($ arguments [i]);
Element.style.display =
(Element.style.display == 'none'?'': 'None');
)
)
Hide: function () (
For (var i = 0; i <arguments.length; i + +) (
Var element = ($ arguments [i]);
Element.style.display = 'none';
)
)
Show: function () (
For (var i = 0; i <arguments.length; i + +) (
Var element = ($ arguments [i]);
Element.style.display ='';
)
)
Remove: function (element) (
Element = $ (element);
Element.parentNode.removeChild (element);
)
GetHeight: function (element) (
Element = $ (element);
Return element.offsetHeight;
)
HasClassName: function (element, className) (
Element = $ (element);
If (! Element)
Return;
Var a = element.className.split ( '');
For (var i = 0; i <a.length; i + +) (
If (a [i] == className)
Return true;
)
Return false;
)
AddClassName: function (element, className) (
Element = $ (element);
Element.removeClassName (element, className);
Element.className + = '' + className;
)
RemoveClassName: function (element, className) (
Element = $ (element);
If (! Element)
Return;
Var newClassName ='';
Var a = element.className.split ( '');
For (var i = 0; i <a.length; i + +) (
If (a [i]! = ClassName) (
If (i> 0)
NewClassName + = '';
NewClassName + = a [i];
)
)
Element.className = newClassName;
)
/ / Removes whitespace-only text node children
CleanWhitespace: function (element) (
Var element = $ (element);
For (var i = 0; i <element.childNodes.length; i + +) (
Var node = element.childNodes [i];
If (node.nodeType == 3 & &! / \ S / .test (node.nodeValue))
Element.remove (node);
)
)
));
Var Toggle = new Object ();
Toggle.display = Element.toggle;
/*------------------------------------------------ --------------------------*/
Abstract.Insertion = function (adjacency) (
This.adjacency = adjacency;
)
Abstract.Insertion.prototype = (
Initialize: function (element, content) (
This.element = $ (element);
This.content = content;
If (this.adjacency & this.element.insertAdjacentHTML) (
This.element.insertAdjacentHTML (this.adjacency, this.content);
Else ()
This.range = this.element.ownerDocument.createRange ();
If (this.initializeRange) this.initializeRange ();
This.fragment = this.range.createContextualFragment (this.content);
This.insertContent ();
)
)
)
Var Insertion = new Object ();
Insertion.Before = Class.create ();
Insertion.Before.prototype = (new Abstract.Insertion ( 'beforeBegin')). Extend ((
InitializeRange: function () (
This.range.setStartBefore (this.element);
)
InsertContent: function () (
This.element.parentNode.insertBefore (this.fragment, this.element);
)
));
Insertion.Top = Class.create ();
Insertion.Top.prototype = (new Abstract.Insertion ( 'afterBegin')). Extend ((
InitializeRange: function () (
This.range.selectNodeContents (this.element);
This.range.collapse (true);
)
InsertContent: function () (
This.element.insertBefore (this.fragment, this.element.firstChild);
)
));
Insertion.Bottom = Class.create ();
Insertion.Bottom.prototype = (new Abstract.Insertion ( 'beforeEnd')). Extend ((
InitializeRange: function () (
This.range.selectNodeContents (this.element);
This.range.collapse (this.element);
)
InsertContent: function () (
This.element.appendChild (this.fragment);
)
));
Insertion.After = Class.create ();
Insertion.After.prototype = (new Abstract.Insertion ( 'afterEnd')). Extend ((
InitializeRange: function () (
This.range.setStartAfter (this.element);
)
InsertContent: function () (
This.element.parentNode.insertBefore (this.fragment,
This.element.nextSibling);
)
));
= (Var Field
Clear: function () (
For (var i = 0; i <arguments.length; i + +)
($ Arguments [i]). Value ='';
)
Focus: function (element) (
$ (Element). Focus ();
)
Present: function () (
For (var i = 0; i <arguments.length; i + +)
If (($ arguments [i]). Value =='') return false;
Return true;
)
Select: function (element) (
$ (Element). Select ();
)
Activate: function (element) (
$ (Element). Focus ();
$ (Element). Select ();
)
)
/*------------------------------------------------ --------------------------*/
= (Var Form
Serialize: function (form) (
Var elements = Form.getElements ($ (form));
Var queryComponents = new Array ();
For (var i = 0; i <elements.length; i + +) (
Var queryComponent = Form.Element.serialize (elements [i]);
If (queryComponent)
QueryComponents.push (queryComponent);
)
Return queryComponents.join ('&');
)
GetElements: function (form) (
= $ Var form (form);
Var elements = new Array ();
For (tagName in Form.Element.Serializers) (
Var tagElements = form.getElementsByTagName (tagName);
For (var j = 0; j <tagElements.length; j + +)
Elements.push (tagElements [j]);
)
Return elements;
)
GetInputs: function (form, typeName, name) (
= $ Var form (form);
Var inputs = form.getElementsByTagName ( 'input');
If (! TypeName & &! Name)
Return inputs;
Var matchingInputs = new Array ();
For (var i = 0; i <inputs.length; i + +) (
Var input [i] = inputs;
If ((typeName & input.type! = TypeName) | |
(Name & input.name! = Name))
Continue;
MatchingInputs.push (input);
)
Return matchingInputs;
)
Disable: function (form) (
Var elements = Form.getElements (form);
For (var i = 0; i <elements.length; i + +) (
Var element [i] = elements;
Element.blur ();
Element.disabled = 'true';
)
)
Enable: function (form) (
Var elements = Form.getElements (form);
For (var i = 0; i <elements.length; i + +) (
Var element [i] = elements;
Element.disabled ='';
)
)
FocusFirstElement: function (form) (
= $ Var form (form);
Var elements = Form.getElements (form);
For (var i = 0; i <elements.length; i + +) (
Var element [i] = elements;
If (element.type! = 'Hidden' & &! Element.disabled) (
Field.activate (element);
Break;
)
)
)
Reset: function (form) (
$ (Form). Reset ();
)
)
Form.Element = (
Serialize: function (element) (
Var element = $ (element);
Var method = element.tagName.toLowerCase ();
Var parameter = Form.Element.Serializers [method] (element);
If (parameter)
Return encodeURIComponent (parameter [0]) + '=' +
EncodeURIComponent (parameter [1]);
)
GetValue: function (element) (
Var element = $ (element);
Var method = element.tagName.toLowerCase ();
Var parameter = Form.Element.Serializers [method] (element);
If (parameter)
Return parameter [1];
)
)
Form.Element.Serializers = (
Input: function (element) (
Switch (element.type.toLowerCase ()) (
Case 'submit':
Case 'hidden':
Case 'password':
Case 'text':
Return Form.Element.Serializers.textarea (element);
Case 'checkbox':
Case 'radio':
Return Form.Element.Serializers.inputSelector (element);
)
Return false;
)
InputSelector: function (element) (
If (element.checked)
Return [element.name, element.value];
)
Textarea: function (element) (
Return [element.name, element.value];
)
Select: function (element) (
Var value ='';
If (element.type == 'select-one') (
Var index = element.selectedIndex;
If (index> = 0)
Element.options value = [index]. Value | | element.options [index]. Text;
Else ()
Value = new Array ();
For (var i = 0; i <element.length; i + +) (
Var opt = element.options [i];
If (opt.selected)
Value.push (opt.value | | opt.text);
)
)
Return [element.name, value];
)
)
/*------------------------------------------------ --------------------------*/
Var $ F = Form.Element.getValue;
/*------------------------------------------------ --------------------------*/
Abstract.TimedObserver = function () ()
Abstract.TimedObserver.prototype = (
Initialize: function (element, frequency, callback) (
This.frequency = frequency;
This.element = $ (element);
This.callback = callback;
This.lastValue = this.getValue ();
This.registerCallback ();
)
RegisterCallback: function () (
SetInterval (this.onTimerEvent.bind (this), this.frequency * 1000);
)
OnTimerEvent: function () (
Var value = this.getValue ();
If (this.lastValue! = Value) (
This.callback (this.element, value);
This.lastValue = value;
)
)
)
Form.Element.Observer = Class.create ();
Form.Element.Observer.prototype = (new Abstract.TimedObserver ()). Extend ((
GetValue: function () (
Return Form.Element.getValue (this.element);
)
));
Form.Observer = Class.create ();
Form.Observer.prototype = (new Abstract.TimedObserver ()). Extend ((
GetValue: function () (
Return Form.serialize (this.element);
)
));
/*------------------------------------------------ --------------------------*/
Abstract.EventObserver = function () ()
Abstract.EventObserver.prototype = (
Initialize: function (element, callback) (
This.element = $ (element);
This.callback = callback;
This.lastValue = this.getValue ();
If (this.element.tagName.toLowerCase () == 'form')
This.registerFormCallbacks ();
Else
This.registerCallback (this.element);
)
OnElementEvent: function () (
Var value = this.getValue ();
If (this.lastValue! = Value) (
This.callback (this.element, value);
This.lastValue = value;
)
)
RegisterFormCallbacks: function () (
Var elements = Form.getElements (this.element);
For (var i = 0; i <elements.length; i + +)
This.registerCallback (elements [i]);
)
RegisterCallback: function (element) (
If (element.type) (
Switch (element.type.toLowerCase ()) (
Case 'checkbox':
Case 'radio':
Element.target = this;
Element.onclick element.prev_onclick = | | Prototype.emptyFunction;
Element.onclick = function () (
This.prev_onclick ();
This.target.onElementEvent ();
)
Break;
Case 'password':
Case 'text':
Case 'textarea':
Case 'select-one':
Case '-select multiple':
Element.target = this;
Element.onchange element.prev_onchange = | | Prototype.emptyFunction;
Element.onchange = function () (
This.prev_onchange ();
This.target.onElementEvent ();
)
Break;
)
)
)
)
Form.Element.EventObserver = Class.create ();
Form.Element.EventObserver.prototype = (new Abstract.EventObserver ()). Extend ((
GetValue: function () (
Return Form.Element.getValue (this.element);
)
));
Form.EventObserver = Class.create ();
Form.EventObserver.prototype = (new Abstract.EventObserver ()). Extend ((
GetValue: function () (
Return Form.serialize (this.element);
)
));
If (! Window.Event) (
Var Event = new Object ();
)
Object.extend (Event, (
KEY_BACKSPACE: 8,
KEY_TAB: 9,
KEY_RETURN: 13,
KEY_ESC: 27,
KEY_LEFT: 37,
KEY_UP: 38,
KEY_RIGHT: 39,
KEY_DOWN: 40,
KEY_DELETE: 46,
Element: function (event) (
Return event.target | | event.srcElement;
)
IsLeftClick: function (event) (
Return (((event.which) & & (event.which == 1)) | |
((Event.button) & & (event.button == 1)));
)
PointerX: function (event) (
Return event.pageX | | (event.clientX +
(Document.documentElement.scrollLeft | | document.body.scrollLeft));
)
PointerY: function (event) (
Return event.pageY | | (event.clientY +
(Document.documentElement.scrollTop | | document.body.scrollTop));
)
Stop: function (event) (
If (event.preventDefault) (
Event.preventDefault ();
Event.stopPropagation ();
Else ()
Event.returnValue = false;
)
)
/ / Find the first node with the given tagName, starting from the
/ / Node the event was triggered on; traverses the DOM upwards
FindElement: function (event, tagName) (
Var element = Event.element (event);
While (element.parentNode & & (! Element.tagName | |
(Element.tagName.toUpperCase ()! = TagName.toUpperCase ())))
Element = element.parentNode;
Return element;
)
Observers: false,
_observeAndCache: Function (element, the name, observer, useCapture) (
If (! This.observers) this.observers = [];
If (element.addEventListener) (
This.observers.push ([element, the name, observer, useCapture]);
Element.addEventListener (name, observer, useCapture);
) Else if (element.attachEvent) (
This.observers.push ([element, the name, observer, useCapture]);
Element.attachEvent ( 'on' + name, observer);
)
)
UnloadCache: function () (
If (! Event.observers) return;
For (var i = 0; i <Event.observers.length; i + +) (
Event.stopObserving.apply (this, Event.observers [i]);
Event.observers [i] [0] = null;
)
Event.observers = false;
)
Observe: function (element, the name, observer, useCapture) (
Var element = $ (element);
UseCapture useCapture = | | false;
If (name == 'keypress' & &
((Navigator.appVersion.indexOf ( 'AppleWebKit')> 0)
| | Element.attachEvent))
Name = 'keydown';
This._observeAndCache (element, the name, observer, useCapture);
)
StopObserving: function (element, the name, observer, useCapture) (
Var element = $ (element);
UseCapture useCapture = | | false;
If (name == 'keypress' & &
((Navigator.appVersion.indexOf ( 'AppleWebKit')> 0)
| | Element.detachEvent))
Name = 'keydown';
If (element.removeEventListener) (
Element.removeEventListener (name, observer, useCapture);
) Else if (element.detachEvent) (
Element.detachEvent ( 'on' + name, observer);
)
)
));
/ * Prevent memory leaks in IE * /
Event.observe (window, 'unload' Event.unloadCache, false);
= (Var Position
/ / Set to true if needed, warning: firefox performance problems
/ / NOT neeeded for page scrolling, only if draggable contained in
/ / Scrollable elements
IncludeScrollOffsets: false,
/ / Must be called before calling withinIncludingScrolloffset, every time the
/ / Page is scrolled
Prepare: function () (
This.deltaX = window.pageXOffset
| | Document.documentElement.scrollLeft
| | Document.body.scrollLeft
| | 0;
This.deltaY = window.pageYOffset
| | Document.documentElement.scrollTop
| | Document.body.scrollTop
| | 0;
)
RealOffset: function (element) (
Var valueT = 0, valueL = 0;
Do (
Element.scrollTop valueT + = | | 0;
Element.scrollLeft valueL + = | | 0;
Element = element.parentNode;
) While (element);
Return [valueL, valueT];
)
CumulativeOffset: function (element) (
Var valueT = 0, valueL = 0;
Do (
Element.offsetTop valueT + = | | 0;
Element.offsetLeft valueL + = | | 0;
Element = element.offsetParent;
) While (element);
Return [valueL, valueT];
)
/ / Caches x / y coordinate pair to use with overlap
Within: function (element, x, y) (
If (this.includeScrollOffsets)
Return this.withinIncludingScrolloffsets (element, x, y);
This.xcomp = x;
This.ycomp = y;
This.offset = this.cumulativeOffset (element);
Return (y> = this.offset [1] & &
Y <this.offset [1] + & element.offsetHeight
X> = this.offset [0] & &
X <this.offset [0] + element.offsetWidth);
)
WithinIncludingScrolloffsets: function (element, x, y) (
Var offsetcache = this.realOffset (element);
This.xcomp offsetcache = x + [0] - this.deltaX;
This.ycomp = y + offsetcache [1] - this.deltaY;
This.offset = this.cumulativeOffset (element);
Return (this.ycomp> = this.offset [1] & &
This.ycomp <this.offset [1] + & element.offsetHeight
This.xcomp> = this.offset [0] & &
This.xcomp <this.offset [0] + element.offsetWidth);
)
/ / Within must be called directly before
Overlap: function (mode, the element) (
If (! Mode) return 0;
If (mode == 'vertical')
Return ((this.offset [1] + element.offsetHeight) - this.ycomp) /
Element.offsetHeight;
If (mode == 'horizontal')
Return ((this.offset [0] + element.offsetWidth) - this.xcomp) /
Element.offsetWidth;
)
Clone: function (source, target) (
Source = $ (source);
Target = $ (target);
Target.style.position = 'absolute';
Var offsets = this.cumulativeOffset (source);
Target.style.top = offsets [1] + 'px';
Target.style.left = offsets [0] + 'px';
Target.style.width source.offsetWidth + = 'px';
Target.style.height source.offsetHeight + = 'px';
)
)
- Div CSS page layout: class portfolio realized
- Id with the class structure of principles and the use of skills
- Div + CSS page layout: class portfolio realized
- The Flash ActionScript Record Second Class
- CSS Guide Intermediate class and id selectors
- Div ? ? ? ¨°
- Id different definition of the class with css
- DIV
- Flash will be converted into the internal XML object class
- Understand CSS class class and logo id selectors
- XHTML structure of the class id and the use of principles and skills
- Id and class distinction
- Based on the unlimited class menu Ajax
- AJAX technology (2) common class
- CSS achieve unlimited-class menu
- Flash AS3.0 class and bonding
- Application of the same element of a number of priority class test!
- Flash ActionScript Filter Class 8 entry filters
- CSS selector: the distinction between class and ID!
- Ajax controls and class libraries Analysis
Business model unknown Web2.0 rare find new profit point

An imported term Web 2.0, almost dominated the China Internet two years, many people become the most talked about topic has been described China's Internet revolution. Web 2.0 fiery behind than 1.0 website can do what revolutionary advantages? We used one week, ...
Personal websites on the position of your interest still rely on operators

If you have a personal stand on income over 10,000 of this has no significance to you on the commercial site planning in the future I will write, if your site income 0-9000 yuan / month, I suggest you carefully read the full text. Personal profit site is a headache for many hea...
Fireworks MX combustion produced results

In photoshop, we generally use wind, wave filters coupled with the access technology to make good hot combustion effect, as a Fireworks lovers, I hope Fireworks can also make such wonderful results. Now, Fireworks MX provide a strong new features pixel map processing capability, ...
IE bug explain hide-and-seek (Duomaomao)

IE bug hide-and-seek (peek-a-boo), the reason is because the name from the text appears under certain conditions disappear, only when reloading pages again. Emergence of this bug to the conditions that: a floating element and with a number of non-floating elements, and then is a ...
Ajax and CSS-station design

This is a pleasant site, you will learn a lot of things, you can know that Ajax has a role to play in the website, especially WEB2.0 site, in any event, the style of the station on the good. GOOGLE RSS READER are used, and also LIVE.com. Feel good. Fro...