`
lexloo
  • 浏览: 14885 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

prototype.js 1.5

阅读更多

$()函数:

document.getElementById()的替代品,支持多个参数,能使用元素Id或元素本身

$F()函数

获取表单中text box, drop-down list的值,能使用元素Id或元素本身

$A()函数

把接收到的单个参数转化为一个Array对象

$H()函数

把一些对象转化成一个可以枚举的和联合数组类似的Hash对象

$R()参数

获取一系列值。是new ObjectRange(lowBound,upperBound,excludeBounds)的缩写

Try.these()函数

调用直到一个成功。

-----------------------------

Event扩展
Property Type Description
KEY_BACKSPACE NumberNumber 8: Constant. Code for the Backspace key.
KEY_TAB Number 9: Constant. Code for the Tab key.
KEY_RETURN Number 13: Constant. Code for the Return key.
KEY_ESC Number 27: Constant. Code for the Esc key.
KEY_LEFT Number 37: Constant. Code for the Left arrow key.
KEY_UP Number 38: Constant. Code for the Up arrow key.
KEY_RIGHT Number 39: Constant. Code for the Right arrow key.
KEY_DOWN Number 40: Constant. Code for the Down arrow key.
KEY_DELETE Number 46: Constant. Code for the Delete key.
observers: Array List of cached observers. Part of the internal implementation details of the object.

Method Kind Arguments Description
element(event) static event: an Event object 返回事件源对象。
isLeftClick(event) static event: an Event object 如果点击了鼠标左键,返回true.
pointerX(event) static event: an Event object 返回鼠标的X座标。
pointerY(event) static event: an Event object 返回鼠标的Y座标。
stop(event) static event: an Event object 使用此函数来中断事件的默认行为并阻止传递(冒泡)。
findElement(event, tagName) static event: an Event object, tagName: name of the desired tag. 从事件源对象开始向上搜索DOM树,直到找到第一个符合tagName的元素
observe(element, name, observer, useCapture) static element: object or id, name: event name (like 'click', 'load', etc), observer: function to handle the event, useCapture: if true, handles the event in the capture phase and if false in the bubbling phase. 为对象的某个事件增加一个处理函数。
stopObserving(element, name, observer, useCapture) static element: object or id, name: event name (like 'click'), observer: function that is handling the event, useCapture: if true handles the event in the capture phase and if false in the bubbling phase. 和上面的函数相反。
_observeAndCache(element, name, observer, useCapture) static 私有函数,别管它。
unloadCache() static (none) 私有函数,别管它。从内存中清除所有的observers缓存

The PeriodicalExecuter object
这个对象提供一定间隔时间上重复调用一个方法的逻辑。

Method Kind Arguments Description
[ctor](callback, interval) constructor callback: a parameterless function, interval: number of seconds 创建这个对象的实例将会重复调用给定的方法。


Property Type Description
callback Function() 被调用的方法,该方法不能传入参数。
frequency Number 以秒为单位的间隔。
currentlyExecuting Boolean 表示这个方法是否正在执行。

The Prototype object
Prototype 没有太重要的作用,只是声明了该程序包的版本 。

Property Type Description
Version String 版本。
emptyFunction Function() 空函数。
K Function(obj) 一个仅仅回传参数的函数。
ScriptFragment String 识别script的正则式。

The Enumerable object
Enumberable对象能够已更优雅的方式实现对列表样式的结构进行枚举。

很多其它的对象通过扩展自Enumberable对象来得到这些有用的接口。

Method Kind Arguments Description
each(iterator) instance iterator: a function object conforming to Function(value, index) 把每个element做为第一个参数,element的index作为第一个参数调用iterator函数。
all([iterator]) instance iterator: a function object conforming to Function(value, index) 这个函数会用给出的iterator测试整个集合,如果集合中任一元素在iterator函数测试中返回false或null,那么这个函数返回false,否则返回true。如果没有给出iterator,那么就会测试所有的元素是不是不等于false和null。你可以简单的把它看成是“检测每个元素都为非空非负”。
any(iterator) instance iterator: a function object conforming to Function(value, index), optional. 这个函数会用给出的iterator测试整个集合,如果集合中任一元素在iterator函数测试中返回true,那么这个函数返回true,否则返回false。如果没有给出iterator,那么就会测试所有的元素是不是有一个不等于false和null。你可以简单的把它看成是“检测元素中是不是有非空非负的”。
collect(iterator) instance iterator: a function object conforming to Function(value, index) 调用iterator函数根据集合中每个元素返回一个结果,然后按照原来集合中的顺序,返回一个Array。
detect(iterator) instance iterator: a function object conforming to Function(value, index) 集合中每个元素调用一次Iterator,返回第一个使Iterator返回True的元素,如果最终都没有为true的调用,那么返回null。
entries() instance (none) 等于toArray().
find(iterator) instance iterator: a function object conforming to Function(value, index) 等于 detect().
findAll(iterator) instance iterator: a function object conforming to Function(value, index) 集合中每个元素调用Iterator,返回一个由所有调用Iterator返回结果等于true的元素组成的数组。和reject()相反。
grep(pattern [, iterator]) instance pattern: a RegExp object used to match the elements, iterator: a function object conforming to Function(value, index) 用pattern参数正则表达式测试集合中的每个元素,返回一个包含所有匹配正则式的元素的Array,如果给出了Iterator,那个每个结果还要经过一下Iterator处理。
include(obj) instance obj: any object 判断集合中包不包含指定对象。
inject(initialValue, iterator) instance initialValue: any object to be used as the initial value, iterator: a function object conforming to Function(accumulator, value, index) 用Iterator联接所有集合中的元素。Iterator在被调用时把上一次迭代的结果做为第一个参数传给accumulator。第一次迭代时,accurmelator等于initialValue,最后返回accumulator的值。
invoke(methodName [, arg1 [, arg2 [...]]]) instance methodName: name of the method that will be called in each element, arg1..argN: arguments that will be passed in the method invocation. 集合中的每个元素调用指定的函数(查看源代码可以发现指定函数被调用时,this指针被传成当前元素),并传入给出的参数,返回调用结果组成的Array。
map(iterator) instance iterator: a function object conforming to Function(value, index) 同collect().
max([iterator]) instance iterator: a function object conforming to Function(value, index) 返回集合中元素的最大值,或调用Iterator后返回值的最大值(如果给出了Iterator的话)。
member(obj) instance obj: any object 同 include().
min([iterator]) instance iterator: a function object conforming to Function(value, index) 返回最小值,参见max()。
partition([iterator]) instance iterator: a function object conforming to Function(value, index) 返回一个包含两个Array的Array,第一个Array包含所有调用Iterator返回True的元素,第二个Array包含剩下的元素。如果Iterator没有给出,那么就根据元素本身判断。
pluck(propertyName) instance propertyName name of the property that will be read from each element. This can also contain the index of the element 返回每个元素的指定属性名的属性的值组成的Array。
reject(iterator) instance iterator: a function object conforming to Function(value, index) 和 findAll()相反(返回所有等于false的元素).
select(iterator) instance iterator: a function object conforming to Function(value, index) 同 findAll().
sortBy(iterator) instance iterator: a function object conforming to Function(value, index) 根据每个元素调用Iterator返回的值进行排序返回一个Array。
toArray() instance (none) 返回由集合所有元素组成的一个Array。
zip(collection1[, collection2 [, ... collectionN [,transform]]]) instance collection1 .. collectionN: enumerations that will be merged, transform: a function object conforming to Function(value, index) 合并每个给出的集合到当前集合。合并操作返回一个新的array,这个array的元素个数和原集合的元素个数一样,这个array的每个元素又是一个子array,它合并了所有集合中相同index的元素。如果transform函数被指定,那么array的每个元素还会调用transform函数先做处理。举个例子: [1,2,3].zip([4,5,6], [7,8,9]).inspect() 返回 "[ [1,4,7],[2,5,8],[3,6,9] ]"

The Hash object
Hash对象实现一种Hash结构,也就是一个Key:Value对的集合。

Hash中的每个Item是一个有两个元素的array,前一个是Key,后一个是Value,每个Item也有两个不需加以说明的属性,key和value。

Method Kind Arguments Description
keys() instance (none) 返回所有Item的key的集合的一个array。
values() instance (none) 返回所有Item的value的集合的一个array。
merge(otherHash) instance otherHash: Hash object 合并给出的Hash,返回一个新Hash。
toQueryString() instance (none) 以QueryString那样的样式返回hash中所有的item,例如: 'key1=value1&key2=value2&key3=value3'
inspect() instance (none) 用一种合适的方法显示hash中的key:value对。

The ObjectRange class
继承自 Enumerable

用上、下边界描述一个对象区域。

Property Type Kind Description
start (any) instance range的下边界

end (any) instance range的上边界
exclusive Boolean instance 决定边界自身是不是range的一部分。


Method Kind Arguments Description
[ctor](start, end, exclusive) constructor start: the lower bound, end: the upper bound, exclusive: include the bounds in the range? 创建一个range对象,从start生成到end,这里要注意的是,start和end必段类型一致,而且该类型要有succ()方法。
include(searchedValue) instance searchedValue: value that we are looking for 检查一个value是不是在range中。

分享到:
评论

相关推荐

    测试prototype.js 1.5 出的问题

    附带的阿,保存资料啊 博文链接:https://liujc2004.iteye.com/blog/49578

    prototype.js 1.5 api 帮助手册

    原文翻译 http://www.cnblogs.com/Hafeyang/archive/2007/09/06/Prototype_150_API.html 英文官方:http://prototypejs.org/现在1.6出来了

    prototype.js 源码解读, 中文帮助文档

    开发者网站: http://prototype.conio.net/ prototype学习资料包括: prototype14参考 prototype 1.3 源码解读.txt prototype 1.5 参考图 prototype 1.5pre1.js prototype 1.4.js

    prototype-1.6.0.3.js+prototype1.4 、1.5中文手册+prototype1.6英文手册

    prototype-1.6.0.3.js prototype1.4中文手册(chm) prototype1.5中文手册(chm) prototype1.6英文手册(chm)

    Prototype.js

    Prototype.js (ver:1.5.1.1) Prototype.js 帮助(ver:1.5.1)英文PDF Prototype.js 帮助(ver:1.4)中文CHM Prototype.js 帮助(ver:1.4)中文PDF

    Prototype 1.5 中文文档 chm

    Prototype 最新的1.5 版中文文档,chm格式,很多人都在找。Prototype 是一个非常优秀的javascript基础类库,可以很好的支持Ajax,国外有多个基于此类库的扩展,这是最新的1.5中文文档,AJAX编程必备手册。

    prototype.js

    其中里面包含了prototype1.5 prototype1.5.1 prototype1.5.1.1 prototype1.5.1.2 prototype1.6.0。五个版本。 http://blog.csdn.net/boat1980/archive/2008/04/10/2278259.aspx这个连接有1.5.1.1代码的注释。

    prototype1.5

    prototype.js 1.5版本,对学习Ajax的朋友们应该会有帮助吧

    prototype(JS类库).rar

    包括prototype1.6 prototype1.5 prototype1.4 以及所有使用手册 希望大家一起探讨学习

    prototype.js_1.6_中文文档

    一个不错javascript的插件,很不错,1.5的中文版,呵呵

    Really easy field validation with Prototype 1.5.4.1 中文修改版

    所做的更改: <br>1、prototype.js 版本更新为 v1.5.1.1 <br>2、effects.js 版本更新为 v1.7.1_beta3 <br>3、所有校验错误提示信息均修改为中文,提供UTF-8和GB18030两种编码的版本 <br>4、增加"YYYY-MM...

    prototype中文手册及API

    prototype中文手册及API --------------------- prototype.js(1.5.1.1) prototype中文手册 prototype.chm

    prototypejs和例子代码

    prototype1.4.js和prototype1.5.js,以及一些例子代码

    Div+css布局教程,Prototype教程,js教程

    压缩包内包含的文件如下: 1.手册与教程: ...CSS 2.0样式表中文手册(推荐); ... javascript_Refer_CN.CHM:javascript中文参考手册(推荐);...prototype-1.5.1.2源码.js; prototype-1.6.0.2源码.js; Prototype 1.4.0源码.js.

    Prototype1.5中文文档

    Prototype 是一个非常优秀的javascript基础类库,可以很好的支持Ajax,国外有多个基于此类库的扩展,这是最新的1.5中文文档,AJAX编程必备手册。资源截图: 资源太大,传百度网盘了,链接在附件中,有需要的...

    decimal.js - JavaScript的任意精度Decimal类型-javascript

    无依赖性 宽平台兼容性:仅使用 JavaScript 1.5 (ECMAScript 3) 功能全面的文档和测试集包括一个 TypeScript 声明文件:decimal.d.ts 该库类似于 bignumber.js,但这里的精度是根据有效数字而不是小数位指定的,并且...

Global site tag (gtag.js) - Google Analytics