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);
}
});
Ajax::prototype 源码解读 之 prototype.js 五[转载]
prototype 还有两个源码文件 effects.js compat.js 就不贴出来了。两者并不常用,effects.js 看example 做花哨的效果还不错,不过代码中没有太多新鲜的东西。










