Prototype 1.5
[Pages:182]Prototype 1.5.1
The Complete API Reference
Sam Stephenson and the Prototype Team
Prototype 1.5.1: The Complete API Reference
Sam Stephenson and the Prototype Team
Published May 2007. 2nd edition for version 1.5.1. Copyright ? 2006-2007 Sam Stephenson. Some rights reserved.
Prototype1 is a JavaScript framework that aims to ease development of dynamic web applications. Prototype was created by Sam Stephenson who released the framework as an open-source project in February 2005. Other members of the core development team are: Thomas Fuchs, Justin Palmer, Andrew Dupont, Dan Webb, Scott Raymond, Seth Dillingham, Mislav Marohni#, Christophe Porteneuve and Tobie Langel. This PDF book version of the Prototype API reference was created by Josh Clark2, but all content comes from the Prototype site and is the intellectual property of Sam Stephenson and the Prototype core team. This PDF is distributed under the Creative Commons Attribution-ShareAlike 2.53. This means that you can copy, redistribute or create your own derivative works from this PDF, provided that you do so with the same Creative Commons license and include the foregoing notice. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
1 2 3
Table of Contents
1. Utility Methods ....................................................................................................................1 $ ....................................................................................................................................1 $$ ..................................................................................................................................3 $A .................................................................................................................................5 $F ..................................................................................................................................6 $H .................................................................................................................................6 $R ..................................................................................................................................6 $w ..................................................................................................................................7 Try.these ........................................................................................................................8 document.getElementsByClassName .................................................................................8
2. Ajax .................................................................................................................................. 11 Ajax Options ................................................................................................................ 11 Ajax.PeriodicalUpdater ................................................................................................... 15 Ajax.Request ................................................................................................................. 17 Ajax.Responders ............................................................................................................ 21 Ajax.Updater ................................................................................................................. 22
3. Array ................................................................................................................................ 25 Why you should stop using for...in to iterate (or never take it up) .................................... 25 What is a developer to do? .............................................................................................. 26 clear ............................................................................................................................. 27 clone ............................................................................................................................ 27 compact ....................................................................................................................... 27 each ............................................................................................................................. 28 first .............................................................................................................................. 28 flatten ........................................................................................................................... 28 from ............................................................................................................................ 28 indexOf ........................................................................................................................ 29 inspect .......................................................................................................................... 29 last ............................................................................................................................... 30 reduce .......................................................................................................................... 30 reverse .......................................................................................................................... 30 size .............................................................................................................................. 31 toArray ......................................................................................................................... 31 toJSON ........................................................................................................................ 31 uniq ............................................................................................................................. 31 without ......................................................................................................................... 32
4. Class ................................................................................................................................. 33 create ........................................................................................................................... 33
5. Date ................................................................................................................................. 35 toJSON ........................................................................................................................ 35
6. Element ............................................................................................................................ 37
addClassName .............................................................................................................. 38 addMethods .................................................................................................................. 38 ancestors ...................................................................................................................... 41 childElements ............................................................................................................... 42 classNames ................................................................................................................... 42 cleanWhitespace ............................................................................................................ 43 descendantOf ................................................................................................................ 44 descendants .................................................................................................................. 44 down ............................................................................................................................ 45 empty ........................................................................................................................... 46 extend .......................................................................................................................... 47 firstDescendant ............................................................................................................. 47 getDimensions .............................................................................................................. 48 getElementsByClassName .............................................................................................. 48 getElementsBySelector ................................................................................................... 49 getHeight ...................................................................................................................... 50 getStyle ......................................................................................................................... 51 getWidth ...................................................................................................................... 52 hasClassName ............................................................................................................... 52 hide .............................................................................................................................. 53 immediateDescendants ................................................................................................... 54 inspect .......................................................................................................................... 54 makeClipping ................................................................................................................ 55 makePositioned ............................................................................................................. 55 match ........................................................................................................................... 56 next ............................................................................................................................. 57 nextSiblings .................................................................................................................. 58 observe ......................................................................................................................... 59 previous ....................................................................................................................... 59 previousSiblings ............................................................................................................ 60 readAttribute ................................................................................................................. 61 recursivelyCollect ........................................................................................................... 61 remove ......................................................................................................................... 62 removeClassName ......................................................................................................... 62 replace .......................................................................................................................... 63 scrollTo ........................................................................................................................ 64 setStyle ......................................................................................................................... 64 show ............................................................................................................................ 65 siblings ......................................................................................................................... 67 stopObserving ............................................................................................................... 67 toggle ........................................................................................................................... 68 toggleClassName ........................................................................................................... 69 undoClipping ................................................................................................................ 69 undoPositioned ............................................................................................................. 70 up ................................................................................................................................ 71
vi | Prototype 1.5.1
update .......................................................................................................................... 72 visible ........................................................................................................................... 74 7. Enumerable ....................................................................................................................... 77 Aliases: it's all about having it your way ............................................................................ 77 Using it efficiently .......................................................................................................... 78 collect, invoke, pluck and each: thinking about the use case ........................................ 78 reject and findAll vs. partition .............................................................................. 78 Mixing Enumerable in your own objects ......................................................................... 78 all ................................................................................................................................ 79 any ............................................................................................................................... 80 collect .......................................................................................................................... 81 detect ........................................................................................................................... 81 each ............................................................................................................................. 81 eachSlice ....................................................................................................................... 83 entries .......................................................................................................................... 84 find .............................................................................................................................. 84 findAll .......................................................................................................................... 85 grep ............................................................................................................................. 85 inGroupsOf .................................................................................................................. 86 include ......................................................................................................................... 86 inject ............................................................................................................................ 87 invoke .......................................................................................................................... 87 map ............................................................................................................................. 88 max .............................................................................................................................. 88 member ........................................................................................................................ 89 min .............................................................................................................................. 89 partition ....................................................................................................................... 89 pluck ............................................................................................................................ 90 reject ............................................................................................................................ 90 select ............................................................................................................................ 91 size .............................................................................................................................. 91 sortBy .......................................................................................................................... 92 toArray ......................................................................................................................... 92 zip ............................................................................................................................... 93 8. Event ................................................................................................................................ 95 # What a wonderful mess (it would be) # ........................................................................ 95 Prototype to the rescue! .................................................................................................. 95 element ........................................................................................................................ 96 findElement .................................................................................................................. 96 isLeftClick .................................................................................................................... 97 observe ......................................................................................................................... 98 pointerX ..................................................................................................................... 100 pointerY ..................................................................................................................... 100 stop ........................................................................................................................... 101 stopObserving ............................................................................................................. 101
| vii
unloadCache ............................................................................................................... 103 9. Form .............................................................................................................................. 105
disable ........................................................................................................................ 105 enable ........................................................................................................................ 106 findFirstElement ......................................................................................................... 106 focusFirstElement ....................................................................................................... 106 getElements ................................................................................................................ 107 getInputs .................................................................................................................... 107 request ....................................................................................................................... 108 reset ........................................................................................................................... 109 serialize ...................................................................................................................... 109 serializeElements ......................................................................................................... 110 10. Form.Element ................................................................................................................ 111 activate ....................................................................................................................... 111 clear ........................................................................................................................... 112 disable ........................................................................................................................ 112 enable ........................................................................................................................ 113 focus .......................................................................................................................... 113 getValue ..................................................................................................................... 113 present ....................................................................................................................... 114 select .......................................................................................................................... 114 serialize ...................................................................................................................... 115 11. Function ........................................................................................................................ 117 What is binding? .......................................................................................................... 117 bind ........................................................................................................................... 117 bindAsEventListener ................................................................................................... 119 12. Hash ............................................................................................................................. 121 Creating a hash ............................................................................................................ 121 each ........................................................................................................................... 122 inspect ........................................................................................................................ 123 keys ........................................................................................................................... 123 merge ......................................................................................................................... 124 remove ....................................................................................................................... 124 toJSON ...................................................................................................................... 124 toQueryString ............................................................................................................. 125 values ......................................................................................................................... 126 13. Insertion ........................................................................................................................ 127 After .......................................................................................................................... 127 Before ........................................................................................................................ 128 Bottom ....................................................................................................................... 128 Top ............................................................................................................................ 129 14. Number ........................................................................................................................ 131 What becomes possible ................................................................................................ 131 succ ........................................................................................................................... 132 times .......................................................................................................................... 132
viii | Prototype 1.5.1
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- js cheatsheet
- core javascript reference card james madison university
- data structures algorithms stack tutorialspoint
- e applications spring 2015 m lampis
- javascript objects and functions
- javascript immutability jfokus
- json web encryption json serialization jwe js
- pseudocode reference university of washington
- dom manipulation go make things
- javascript basics github pages
Related searches
- 1.5 auto loan rate
- minecraft unblocked at school 1.5.2
- minecraft unblocked jar 1.5.2
- minecraft 1.5.2 unblocked games
- minecraft unblocked at school 1 5 2
- download minecraft free launcher 1 5 2
- 1 5 auto loan rate
- minecraft unblocked jar 1 5 2
- minecraft 1 5 2 unblocked games
- minecraft launcher 1 5 3 download
- minecraft 1 5 2 free download pc
- minecraft 1 5 2 jar file download