line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Prototype::Js; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
99
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
1; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
HTML::Prototype::Js - prototype library, embedded in perl |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $prototype = do { package HTML::Prototype::Js; local $/; }; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
This is the actual Prototype library embedded in a perl __DATA__ |
18
|
|
|
|
|
|
|
section, for easy inclusion in L. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NEW SYNTAX |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
The prototype library provides some functions and classes which effectively |
24
|
|
|
|
|
|
|
change the basic syntax of the JavaScript you write. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over 4 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item $(element) |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This function takes an element / element list and gets all string elements |
31
|
|
|
|
|
|
|
using document.getElementbyId. This is probably one of the most common |
32
|
|
|
|
|
|
|
functions when using javascript for web development, so it will save you |
33
|
|
|
|
|
|
|
a lot of typing. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item Class |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This uses fucntion references to allow namespace-like Class structures |
38
|
|
|
|
|
|
|
in javascript. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item Object.extend |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Simple inheritance for javacsript. Will set all properties of the child |
43
|
|
|
|
|
|
|
in the parent. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item Function.bind |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Allow function refs to be full object method references, through the use |
48
|
|
|
|
|
|
|
of extend and apply |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item Try.these |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Simple try/catch for a list of functions, will return the return value |
54
|
|
|
|
|
|
|
of the first that doesn't throw an exception. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=item Array.push |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
implement push for arrays. returns number of elements in result. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item Function.apply |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Call a function on a given object, using eval. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=back |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 JS OBJECTS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
The Prototype library provides a number of classes you can use |
69
|
|
|
|
|
|
|
to improve interaction with the end user. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=over 4 |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item Ajax |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Provides one useful function, getTransport. This function |
76
|
|
|
|
|
|
|
will return a XMLHttpRequest object suitable for your browser. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item Ajax.Base |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
An abstract base class for the Ajax objects described below. Sets |
81
|
|
|
|
|
|
|
some common options for Ajax objects; |
82
|
|
|
|
|
|
|
B http method, defaults to post. |
83
|
|
|
|
|
|
|
B process in the background, true/false, defaults to true. |
84
|
|
|
|
|
|
|
B extra parameters, defaults to blank. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item Ajax.Updater |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
a subclass of Ajax.Base, this class uses Ajax.Request to populate |
89
|
|
|
|
|
|
|
a container in your web page. Takes container, url and Ajax.Base |
90
|
|
|
|
|
|
|
options as paramters. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item Ajax.Request |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This object represents a plain ajax request. It extends base to |
95
|
|
|
|
|
|
|
add a constructor, as well as some events to handle events. |
96
|
|
|
|
|
|
|
The constructor takes an url, as well as the options described |
97
|
|
|
|
|
|
|
in Ajax.Base. |
98
|
|
|
|
|
|
|
Currently handles the following events: |
99
|
|
|
|
|
|
|
'Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete' |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item Effect.Appear |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Takes an element, and makes that element appear through a fade. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item Effect.ContentZoom |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Takes an element, and zooms the content of that element. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item Effect.Fade |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Takes an element, and makes that element fade out and disappear. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item Effect.Highlight |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Takes an element, and does a highlight of that element. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item Effect.Puff |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Takes an element, and makes that element "blow up" and disappear. |
120
|
|
|
|
|
|
|
(As in disappear in a puff of smoke). |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item Effect.Scale |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Takes an element, and a size, in percent, and scales that element to |
125
|
|
|
|
|
|
|
the given size. If it's a div, the initial size will have to be given |
126
|
|
|
|
|
|
|
in EM. No such restrictions for pictures. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item Effect.Squish |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Takes an element, and shrinks that element until it disappears. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item Element |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
A collection of functions related to basic elements. takes one or more elements. |
135
|
|
|
|
|
|
|
B Toggles the element display style. |
136
|
|
|
|
|
|
|
B Turns off the element's display style. |
137
|
|
|
|
|
|
|
B Turns on the element's display style. |
138
|
|
|
|
|
|
|
B Delete this element from the DOM. |
139
|
|
|
|
|
|
|
B Get the element height. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Also provides a convenience object, Toggle, with one method display which aliases to toggle, |
142
|
|
|
|
|
|
|
so you can call it as |
143
|
|
|
|
|
|
|
Toggle.display(element) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item Field |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Adds some useful functions to HTML Fields with several elements: |
148
|
|
|
|
|
|
|
B remove all content. |
149
|
|
|
|
|
|
|
B Give the element focus. |
150
|
|
|
|
|
|
|
B returns true if all arguments are filled in, false otherwise. |
151
|
|
|
|
|
|
|
B |
152
|
|
|
|
|
|
|
B give the selected element focus, and select it. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item Form |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Some useful utilies for HTML Forms. all of these take a form element |
157
|
|
|
|
|
|
|
as sole argument. |
158
|
|
|
|
|
|
|
B returns a URL serialized version of a given form. |
159
|
|
|
|
|
|
|
B returns all elements in the form. |
160
|
|
|
|
|
|
|
B blurs and disables every element in the form. |
161
|
|
|
|
|
|
|
B Give first element in the form focus. |
162
|
|
|
|
|
|
|
B reset all form elements. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item Form.Element |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Some useful objects for Form Field Elements. These take an element |
167
|
|
|
|
|
|
|
as the sole argument. |
168
|
|
|
|
|
|
|
B url encode the element for use in a URI string. |
169
|
|
|
|
|
|
|
B returns the value of the given element. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item Form.Element.Observer |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item Form.Element.Serializers |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Serializers for various element types. Takes the input element as |
176
|
|
|
|
|
|
|
argument. |
177
|
|
|
|
|
|
|
B determines the element type, and chooses the right serializer. |
178
|
|
|
|
|
|
|
B serialize checkbox/radio. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item Form.Element.Observer |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item Insertion |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This can be used in place of a innerHTML, to insert the content into |
185
|
|
|
|
|
|
|
the dom. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item Insertion.Before |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Puts content before a given dom node. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item Insertion.Top |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Puts content at the top of a given dom node. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item Insertion.Bottom |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Puts content at the bottom of a given dom node. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item Insertion.After |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Puts content after a given dom node. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item PeriodicalExecuter |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This object takes two parameters, a reference to a callback |
206
|
|
|
|
|
|
|
function, and a frequency in seconds. It will execute the callback |
207
|
|
|
|
|
|
|
every second. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=back |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 SEE ALSO |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
L, L |
214
|
|
|
|
|
|
|
L |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head1 AUTHOR |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
Sebastian Riedel, C |
219
|
|
|
|
|
|
|
Marcus Ramberg, C |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Built around Prototype by Sam Stephenson. |
222
|
|
|
|
|
|
|
Much code is ported from Ruby on Rails javascript helpers. |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 LICENSE |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify it under |
227
|
|
|
|
|
|
|
the same terms as perl itself. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |
230
|
|
|
|
|
|
|
__DATA__ |