bivouac 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/README +6 -7
  2. data/bin/bivouac +1 -1
  3. data/doc/rdoc/classes/BivouacHelpers/BaseView.html +178 -0
  4. data/doc/rdoc/classes/BivouacHelpers/FormView.html +398 -0
  5. data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +305 -0
  6. data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +573 -0
  7. data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +258 -0
  8. data/doc/rdoc/classes/BivouacHelpers/TooltipView.html +158 -0
  9. data/doc/rdoc/classes/BivouacHelpers.html +117 -0
  10. data/doc/rdoc/classes/JavaScriptGenerator.html +564 -0
  11. data/doc/rdoc/created.rid +1 -0
  12. data/doc/rdoc/files/AUTHORS.html +109 -0
  13. data/doc/rdoc/files/COPYING.html +533 -0
  14. data/doc/rdoc/files/README.html +427 -0
  15. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/base_rb.html +109 -0
  16. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/form_rb.html +109 -0
  17. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/html_rb.html +109 -0
  18. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +113 -0
  19. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html +113 -0
  20. data/doc/rdoc/files/lib/bivouac/helpers/view/goh/tooltip_rb.html +109 -0
  21. data/doc/rdoc/index.html +10 -0
  22. data/doc/rdoc/permalink.gif +0 -0
  23. data/doc/rdoc/rdoc-style.css +106 -0
  24. data/doc/rdoc/rubyfr.png +0 -0
  25. data/examples/bivouac_sample/Rakefile +48 -0
  26. data/examples/bivouac_sample/app/bivouac_sample.rb +15 -7
  27. data/examples/bivouac_sample/app/controllers/index.rb +2 -2
  28. data/examples/bivouac_sample/app/controllers/sound.rb +10 -0
  29. data/examples/bivouac_sample/app/helpers/_helpers.rb +6 -3
  30. data/examples/bivouac_sample/app/views/sound.rb +16 -0
  31. data/examples/bivouac_sample/config/environment.rb +5 -2
  32. data/examples/bivouac_sample/config/postamble.rb +89 -18
  33. data/examples/bivouac_sample/public/javascripts/builder.js +12 -7
  34. data/examples/bivouac_sample/public/javascripts/controls.js +485 -355
  35. data/examples/bivouac_sample/public/javascripts/dragdrop.js +82 -52
  36. data/examples/bivouac_sample/public/javascripts/effects.js +361 -329
  37. data/examples/bivouac_sample/public/javascripts/prototype.js +2826 -1120
  38. data/examples/bivouac_sample/public/javascripts/scriptaculous.js +15 -8
  39. data/examples/bivouac_sample/public/javascripts/slider.js +40 -43
  40. data/examples/bivouac_sample/public/javascripts/sound.js +55 -0
  41. data/examples/bivouac_sample/public/javascripts/unittest.js +16 -12
  42. data/examples/bivouac_sample/public/sound/sword.mp3 +0 -0
  43. data/examples/bivouac_sample/script/console +6 -0
  44. data/examples/bivouac_sample/script/plugin +3 -0
  45. data/examples/bivouac_sample/script/server +2 -1
  46. data/examples/bivouac_sample/test/test_sound.rb +15 -0
  47. data/lib/bivouac/helpers/view/goh/sound.rb +38 -0
  48. data/lib/bivouac/template/application/helpers_goh.rb +2 -0
  49. data/lib/bivouac/template/static/builder.js +12 -7
  50. data/lib/bivouac/template/static/controls.js +485 -355
  51. data/lib/bivouac/template/static/dragdrop.js +82 -52
  52. data/lib/bivouac/template/static/effects.js +361 -329
  53. data/lib/bivouac/template/static/prototype.js +2826 -1120
  54. data/lib/bivouac/template/static/scriptaculous.js +15 -8
  55. data/lib/bivouac/template/static/slider.js +40 -43
  56. data/lib/bivouac/template/static/sound.js +55 -0
  57. data/lib/bivouac/template/static/unittest.js +16 -12
  58. metadata +45 -2
@@ -0,0 +1,573 @@
1
+
2
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
+ <html>
4
+ <head>
5
+ <title>
6
+ Bivouac, the Documentation &raquo; Module: BivouacHelpers::JavaScriptView
7
+ </title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
9
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
10
+ <script language="JavaScript" type="text/javascript">
11
+ // <![CDATA[
12
+
13
+ function toggleSource( id )
14
+ {
15
+ var elem
16
+ var link
17
+
18
+ if( document.getElementById )
19
+ {
20
+ elem = document.getElementById( id )
21
+ link = document.getElementById( "l_" + id )
22
+ }
23
+ else if ( document.all )
24
+ {
25
+ elem = eval( "document.all." + id )
26
+ link = eval( "document.all.l_" + id )
27
+ }
28
+ else
29
+ return false;
30
+
31
+ if( elem.style.display == "block" )
32
+ {
33
+ elem.style.display = "none"
34
+ link.innerHTML = "show source"
35
+ }
36
+ else
37
+ {
38
+ elem.style.display = "block"
39
+ link.innerHTML = "hide source"
40
+ }
41
+ }
42
+
43
+ function openCode( url )
44
+ {
45
+ window.open( url, "SOURCE_CODE", "width=400,height=400,scrollbars=yes" )
46
+ }
47
+ // ]]>
48
+ </script>
49
+ </head>
50
+ <body>
51
+ <!--
52
+ <div id="menu">
53
+ <h3 class="title">Module: BivouacHelpers::JavaScriptView</h3>
54
+ </div>
55
+ -->
56
+ <div id="fullpage">
57
+ <div id="pager">
58
+ <table>
59
+ <tr><td><img src="../../rubyfr.png" /></td>
60
+ <td id="pagertd">
61
+ <strong># Module: BivouacHelpers::JavaScriptView<br />
62
+ [
63
+ "<a href="../../files/README.html" value="File: README">README</a>",
64
+ "<a href="../../files/AUTHORS.html" value="File: AUTHORS">AUTHORS</a>",
65
+ "<a href="../../files/COPYING.html" value="File: COPYING">COPYING</a>",
66
+ "<a href="../../files/lib/bivouac/helpers/view/goh/base_rb.html" value="File: base.rb">lib/bivouac/helpers/view/goh/base.rb</a>",
67
+ "<a href="../../files/lib/bivouac/helpers/view/goh/form_rb.html" value="File: form.rb">lib/bivouac/helpers/view/goh/form.rb</a>",
68
+ "<a href="../../files/lib/bivouac/helpers/view/goh/html_rb.html" value="File: html.rb">lib/bivouac/helpers/view/goh/html.rb</a>",
69
+ "<a href="../../files/lib/bivouac/helpers/view/goh/tooltip_rb.html" value="File: tooltip.rb">lib/bivouac/helpers/view/goh/tooltip.rb</a>",
70
+ "<a href="../../files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html" value="File: scriptaculous.rb">lib/bivouac/helpers/view/goh/scriptaculous.rb</a>",
71
+ "<a href="../../files/lib/bivouac/helpers/view/goh/javascript_rb.html" value="File: javascript.rb">lib/bivouac/helpers/view/goh/javascript.rb</a>",
72
+ <a href="http://greg.rubyfr.net">nil</a>].each do<br />
73
+ <a href="../../classes/JavaScriptGenerator.html" title="Class: JavaScriptGenerator">JavaScriptGenerator</a>.view_html<br />
74
+ <a href="../../classes/BivouacHelpers.html" title="Module: BivouacHelpers">BivouacHelpers</a>.view_html<br />
75
+ <a href="../../classes/BivouacHelpers/TooltipView.html" title="Module: BivouacHelpers::TooltipView">BivouacHelpers::TooltipView</a>.view_html<br />
76
+ <a href="../../classes/BivouacHelpers/ScriptAculoUsView.html" title="Module: BivouacHelpers::ScriptAculoUsView">BivouacHelpers::ScriptAculoUsView</a>.view_html<br />
77
+ <a href="../../classes/BivouacHelpers/BaseView.html" title="Module: BivouacHelpers::BaseView">BivouacHelpers::BaseView</a>.view_html<br />
78
+ <a href="../../classes/BivouacHelpers/JavaScriptView.html" title="Module: BivouacHelpers::JavaScriptView">BivouacHelpers::JavaScriptView</a>.view_html<br />
79
+ <a href="../../classes/BivouacHelpers/HtmlView.html" title="Module: BivouacHelpers::HtmlView">BivouacHelpers::HtmlView</a>.view_html<br />
80
+ <a href="../../classes/BivouacHelpers/FormView.html" title="Module: BivouacHelpers::FormView">BivouacHelpers::FormView</a>.view_html<br />
81
+ end</strong>
82
+ </td></tr>
83
+ </table>
84
+ </ul>
85
+ </div>
86
+
87
+
88
+ <div id="BivouacHelpers::JavaScriptView" class="page_shade">
89
+ <div class="page">
90
+ <h3>Module BivouacHelpers::JavaScriptView &lt; Object</h3>
91
+
92
+ (in files
93
+ <a href="../../files/lib/bivouac/helpers/view/goh/javascript_rb.html">lib/bivouac/helpers/view/goh/javascript.rb</a>
94
+ )
95
+
96
+ <p>
97
+ bivouac/helpers/view/html
98
+ </p>
99
+
100
+
101
+
102
+
103
+
104
+ <h2 class="ruled">Methods</h2>
105
+ <h4 class="ruled">Public Instance method:
106
+ <strong><a name="M000029">escape_javascript(javascript)</a></strong> <a href="#M000029"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: escape_javascript" /></a></h4>
107
+
108
+ <p>
109
+ Escape carrier returns and single and double quotes for JavaScript
110
+ segments.
111
+ </p>
112
+
113
+ <div class="sourcecode">
114
+ <p class="source-link">[ <a href="javascript:toggleSource('M000029_source')" id="l_M000029_source">show source</a> ]</p>
115
+ <div id="M000029_source" class="dyn-source">
116
+ <pre>
117
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 202</span>
118
+ 202: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">escape_javascript</span>(<span class="ruby-identifier">javascript</span>)
119
+ 203: (<span class="ruby-identifier">javascript</span> <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">'\\'</span>,<span class="ruby-value str">'\0\0'</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\r\n|\n|\r/</span>, <span class="ruby-value str">&quot;\\n&quot;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[&quot;']/</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">m</span><span class="ruby-operator">|</span> <span class="ruby-node">&quot;\\#{m}&quot;</span> }
120
+ 204: <span class="ruby-keyword kw">end</span>
121
+ </pre>
122
+ </div>
123
+ </div>
124
+ <h4 class="ruled">Public Instance method:
125
+ <strong><a name="M000030">javascript_tag( content, options = {} )</a></strong> <a href="#M000030"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: javascript_tag" /></a></h4>
126
+
127
+ <p>
128
+ Returns a JavaScript tag with the <tt>block</tt> inside. Example:
129
+ </p>
130
+ <pre>
131
+ javascript_tag( &quot;alert('Hello World!')&quot;, :defer =&gt; 'true' )
132
+ </pre>
133
+ <p>
134
+ Returns:
135
+ </p>
136
+ <pre>
137
+ &lt;script defer=&quot;true&quot; type=&quot;text/javascript&quot;&gt;
138
+ //&lt;![CDATA[
139
+ alert('Hello World!')
140
+ //]]&gt;
141
+ &lt;/script&gt;
142
+ </pre>
143
+
144
+ <div class="sourcecode">
145
+ <p class="source-link">[ <a href="javascript:toggleSource('M000030_source')" id="l_M000030_source">show source</a> ]</p>
146
+ <div id="M000030_source" class="dyn-source">
147
+ <pre>
148
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 218</span>
149
+ 218: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">javascript_tag</span>( <span class="ruby-identifier">content</span>, <span class="ruby-identifier">options</span> = {} )
150
+ 219: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:type</span>] = <span class="ruby-value str">&quot;text/javascript&quot;</span>
151
+ 220: <span class="ruby-identifier">script</span>( <span class="ruby-identifier">options</span> ) <span class="ruby-keyword kw">do</span>
152
+ 221: <span class="ruby-value str">&quot;//&lt;![CDATA[\n&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">content</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;\n//]]&gt;&quot;</span>
153
+ 222: <span class="ruby-keyword kw">end</span>
154
+ 223: <span class="ruby-keyword kw">end</span>
155
+ </pre>
156
+ </div>
157
+ </div>
158
+ <h4 class="ruled">Public Instance method:
159
+ <strong><a name="M000033">link_to_function( name, *args, &amp;block )</a></strong> <a href="#M000033"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: link_to_function" /></a></h4>
160
+
161
+ <p>
162
+ Returns a link that will trigger a JavaScript function using the onclick
163
+ handler and return false after the fact.
164
+ </p>
165
+ <p>
166
+ The function argument can be omitted in favor of an <a
167
+ href="JavaScriptView.html#M000031">update_page</a> block, which evaluates
168
+ to a string when the template is rendered (instead of making an Ajax
169
+ request first).
170
+ </p>
171
+ <p>
172
+ Examples:
173
+ </p>
174
+ <pre>
175
+ link_to_function &quot;Greeting&quot;, &quot;alert('Hello world!')&quot;
176
+ </pre>
177
+ <p>
178
+ Produces:
179
+ </p>
180
+ <pre>
181
+ &lt;a onclick=&quot;alert('Hello world!'); return false;&quot; href=&quot;#&quot;&gt;Greeting&lt;/a&gt;
182
+
183
+ link_to_function(image_tag(&quot;delete&quot;), &quot;if (confirm('Really?')) do_delete()&quot;)
184
+ </pre>
185
+ <p>
186
+ Produces:
187
+ </p>
188
+ <pre>
189
+ &lt;a onclick=&quot;if (confirm('Really?')) do_delete(); return false;&quot; href=&quot;#&quot;&gt;
190
+ &lt;img src=&quot;/images/delete.png?&quot; alt=&quot;Delete&quot;/&gt;
191
+ &lt;/a&gt;
192
+
193
+ link_to_function(&quot;Show me more&quot;, nil, :id =&gt; &quot;more_link&quot;) do |page|
194
+ page[:details].visual_effect :toggle_blind
195
+ page[:more_link].replace_html &quot;Show me less&quot;
196
+ end
197
+ </pre>
198
+ <p>
199
+ Produces:
200
+ </p>
201
+ <pre>
202
+ &lt;a href=&quot;#&quot; id=&quot;more_link&quot; onclick=&quot;try {
203
+ $(&amp;quot;details&amp;quot;).visualEffect(&amp;quot;toggle_blind&amp;quot;);
204
+ $(&amp;quot;more_link&amp;quot;).update(&amp;quot;Show me less&amp;quot;);
205
+ }
206
+ catch (e) {
207
+ alert('RJS error:\n\n' + e.toString());
208
+ alert('$(\&amp;quot;details\&amp;quot;).visualEffect(\&amp;quot;toggle_blind\&amp;quot;);
209
+ \n$(\&amp;quot;more_link\&amp;quot;).update(\&amp;quot;Show me less\&amp;quot;);');
210
+ throw e
211
+ };
212
+ return false;&quot;&gt;Show me more&lt;/a&gt;
213
+ </pre>
214
+
215
+ <div class="sourcecode">
216
+ <p class="source-link">[ <a href="javascript:toggleSource('M000033_source')" id="l_M000033_source">show source</a> ]</p>
217
+ <div id="M000033_source" class="dyn-source">
218
+ <pre>
219
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 273</span>
220
+ 273: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">link_to_function</span>( <span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
221
+ 274: <span class="ruby-identifier">html_options</span> = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> {}
222
+ 275: <span class="ruby-identifier">function</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
223
+ 276:
224
+ 277: <span class="ruby-identifier">function</span> = <span class="ruby-identifier">update_page</span>( <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> ) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
225
+ 278:
226
+ 279: <span class="ruby-identifier">a</span>( <span class="ruby-identifier">html_options</span>.<span class="ruby-identifier">merge</span>({
227
+ 280: <span class="ruby-identifier">:href</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">html_options</span>[<span class="ruby-identifier">:href</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">&quot;#&quot;</span>,
228
+ 281: <span class="ruby-identifier">:onclick</span> =<span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">html_options</span>[<span class="ruby-identifier">:onclick</span>] <span class="ruby-operator">?</span> <span class="ruby-node">&quot;#{html_options[:onclick]}; &quot;</span> <span class="ruby-operator">:</span> <span class="ruby-value str">&quot;&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-node">&quot;#{function}; return false;&quot;</span>
229
+ 282: }) ) <span class="ruby-keyword kw">do</span>
230
+ 283: <span class="ruby-identifier">name</span>
231
+ 284: <span class="ruby-keyword kw">end</span>
232
+ 285: <span class="ruby-keyword kw">end</span>
233
+ </pre>
234
+ </div>
235
+ </div>
236
+ <h4 class="ruled">Public Instance method:
237
+ <strong><a name="M000034">link_to_remote(name, options = {}, html_options = {})</a></strong> <a href="#M000034"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: link_to_remote" /></a></h4>
238
+
239
+ <p>
240
+ Returns a link to a remote action defined by <tt>options[:url]</tt>
241
+ that&#8216;s called in the background using XMLHttpRequest. The result of
242
+ that request can then be inserted into a DOM object whose id can be
243
+ specified with <tt>options[:update]</tt>. Usually, the result would be a
244
+ partial prepared by the controller.
245
+ </p>
246
+ <p>
247
+ Examples:
248
+ </p>
249
+ <pre>
250
+ link_to_remote &quot;Delete this post&quot;, :update =&gt; &quot;posts&quot;,
251
+ :url =&gt; R(Destroy, 1)
252
+ link_to_remote(image_tag(&quot;refresh&quot;), :update =&gt; &quot;emails&quot;,
253
+ :url =&gt; R(ListEmails)
254
+ </pre>
255
+ <p>
256
+ You can also specify a hash for <tt>options[:update]</tt> to allow for easy
257
+ redirection of output to an other DOM element if a server-side error
258
+ occurs:
259
+ </p>
260
+ <p>
261
+ Example:
262
+ </p>
263
+ <pre>
264
+ link_to_remote &quot;Delete this post&quot;,
265
+ :url =&gt; R(Destroy, 1)
266
+ :update =&gt; { :success =&gt; &quot;posts&quot;, :failure =&gt; &quot;error&quot; }
267
+ </pre>
268
+ <p>
269
+ Optionally, you can use the <tt>options[:position]</tt> parameter to
270
+ influence how the target DOM element is updated. It must be one of
271
+ <tt>:before</tt>, <tt>:top</tt>, <tt>:bottom</tt>, or <tt>:after</tt>.
272
+ </p>
273
+ <p>
274
+ To access the server response, use <tt>request.responseText</tt>, to find
275
+ out the HTTP status, use <tt>request.status</tt>.
276
+ </p>
277
+ <p>
278
+ Example:
279
+ </p>
280
+ <pre>
281
+ link_to_remote word,
282
+ :url =&gt; R(Undo, word_counter)
283
+ :complete =&gt; &quot;undoRequestCompleted(request)&quot;
284
+ </pre>
285
+ <p>
286
+ The callbacks that may be specified are (in order):
287
+ </p>
288
+ <table>
289
+ <tr><td valign="top"><tt>:loading</tt>:</td><td>Called when the remote document is being loaded with data by the browser.
290
+
291
+ </td></tr>
292
+ <tr><td valign="top"><tt>:loaded</tt>:</td><td>Called when the browser has finished loading the remote document.
293
+
294
+ </td></tr>
295
+ <tr><td valign="top"><tt>:interactive</tt>:</td><td>Called when the user can interact with the remote document, even though it
296
+ has not finished loading.
297
+
298
+ </td></tr>
299
+ <tr><td valign="top"><tt>:success</tt>:</td><td>Called when the XMLHttpRequest is completed, and the HTTP status code is in
300
+ the 2XX range.
301
+
302
+ </td></tr>
303
+ <tr><td valign="top"><tt>:failure</tt>:</td><td>Called when the XMLHttpRequest is completed, and the HTTP status code is
304
+ not in the 2XX range.
305
+
306
+ </td></tr>
307
+ <tr><td valign="top"><tt>:complete</tt>:</td><td>Called when the XMLHttpRequest is complete (fires after success/failure if
308
+ they are present).
309
+
310
+ </td></tr>
311
+ </table>
312
+ <p>
313
+ You can further refine <tt>:success</tt> and <tt>:failure</tt> by adding
314
+ additional callbacks for specific status codes.
315
+ </p>
316
+ <p>
317
+ Example:
318
+ </p>
319
+ <pre>
320
+ link_to_remote word,
321
+ :url =&gt; R(Action),
322
+ 404 =&gt; &quot;alert('Not found...? Wrong URL...?')&quot;,
323
+ :failure =&gt; &quot;alert('HTTP Error ' + request.status + '!')&quot;
324
+ </pre>
325
+ <p>
326
+ A status code callback overrides the success/failure handlers if present.
327
+ </p>
328
+ <p>
329
+ If you for some reason or another need synchronous processing
330
+ (that&#8216;ll block the browser while the request is happening), you can
331
+ specify <tt>options[:type] = :synchronous</tt>.
332
+ </p>
333
+ <p>
334
+ You can customize further browser side call logic by passing in JavaScript
335
+ code snippets via some optional parameters. In their order of use these
336
+ are:
337
+ </p>
338
+ <table>
339
+ <tr><td valign="top"><tt>:confirm</tt>:</td><td>Adds confirmation dialog.
340
+
341
+ </td></tr>
342
+ <tr><td valign="top"><tt>:condition</tt>:</td><td>Perform remote request conditionally by this expression. Use this to
343
+ describe browser-side conditions when request should not be initiated.
344
+
345
+ </td></tr>
346
+ <tr><td valign="top"><tt>:before</tt>:</td><td>Called before request is initiated.
347
+
348
+ </td></tr>
349
+ <tr><td valign="top"><tt>:after</tt>:</td><td>Called immediately after request was initiated and before
350
+ <tt>:loading</tt>.
351
+
352
+ </td></tr>
353
+ <tr><td valign="top"><tt>:submit</tt>:</td><td>Specifies the DOM element ID that&#8216;s used as the parent of the form
354
+ elements. By default this is the current form, but it could just as well be
355
+ the ID of a table row or any other DOM element.
356
+
357
+ </td></tr>
358
+ </table>
359
+
360
+ <div class="sourcecode">
361
+ <p class="source-link">[ <a href="javascript:toggleSource('M000034_source')" id="l_M000034_source">show source</a> ]</p>
362
+ <div id="M000034_source" class="dyn-source">
363
+ <pre>
364
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 371</span>
365
+ 371: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">link_to_remote</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-identifier">html_options</span> = {})
366
+ 372: <span class="ruby-identifier">link_to_function</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">remote_function</span>(<span class="ruby-identifier">options</span>), <span class="ruby-identifier">html_options</span>)
367
+ 373: <span class="ruby-keyword kw">end</span>
368
+ </pre>
369
+ </div>
370
+ </div>
371
+ <h4 class="ruled">Public Instance method:
372
+ <strong><a name="M000036">observe_field(field_id, options = {})</a></strong> <a href="#M000036"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: observe_field" /></a></h4>
373
+
374
+ <p>
375
+ Observes the field with the DOM ID specified by <tt>field_id</tt> and makes
376
+ an Ajax call when its contents have changed.
377
+ </p>
378
+ <p>
379
+ Required <tt>options</tt> are either of:
380
+ </p>
381
+ <table>
382
+ <tr><td valign="top"><tt>:url</tt>:</td><td><tt>url_for</tt>-style options for the action to call when the field has
383
+ changed.
384
+
385
+ </td></tr>
386
+ <tr><td valign="top"><tt>:function</tt>:</td><td>Instead of making a remote call to a URL, you can specify a function to be
387
+ called instead.
388
+
389
+ </td></tr>
390
+ </table>
391
+ <p>
392
+ Additional options are:
393
+ </p>
394
+ <table>
395
+ <tr><td valign="top"><tt>:frequency</tt>:</td><td>The frequency (in seconds) at which changes to this field will be detected.
396
+ Not setting this option at all or to a value equal to or less than zero
397
+ will use event based observation instead of time based observation.
398
+
399
+ </td></tr>
400
+ <tr><td valign="top"><tt>:update</tt>:</td><td>Specifies the DOM ID of the element whose innerHTML should be updated with
401
+ the XMLHttpRequest response text.
402
+
403
+ </td></tr>
404
+ <tr><td valign="top"><tt>:with</tt>:</td><td>A JavaScript expression specifying the parameters for the XMLHttpRequest.
405
+ This defaults to &#8216;value&#8217;, which in the evaluated context refers
406
+ to the new field value. If you specify a string without a &quot;=&quot;,
407
+ it&#8216;ll be extended to mean the form key that the value should be
408
+ assigned to. So :with =&gt; &quot;term&quot; gives
409
+ &quot;&#8217;term&#8217;=value&quot;. If a &quot;=&quot; is present, no
410
+ extension will happen.
411
+
412
+ </td></tr>
413
+ <tr><td valign="top"><tt>:on</tt>:</td><td>Specifies which event handler to observe. By default, it&#8216;s set to
414
+ &quot;changed&quot; for text fields and areas and &quot;click&quot; for
415
+ radio buttons and checkboxes. With this, you can specify it instead to be
416
+ &quot;blur&quot; or &quot;focus&quot; or any other event.
417
+
418
+ </td></tr>
419
+ </table>
420
+ <p>
421
+ Additionally, you may specify any of the options documented in <a
422
+ href="JavaScriptView.html#M000034">link_to_remote</a>.
423
+ </p>
424
+
425
+ <div class="sourcecode">
426
+ <p class="source-link">[ <a href="javascript:toggleSource('M000036_source')" id="l_M000036_source">show source</a> ]</p>
427
+ <div id="M000036_source" class="dyn-source">
428
+ <pre>
429
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 420</span>
430
+ 420: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">observe_field</span>(<span class="ruby-identifier">field_id</span>, <span class="ruby-identifier">options</span> = {})
431
+ 421: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:frequency</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:frequency</span>] <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
432
+ 422: <span class="ruby-identifier">build_observer</span>(<span class="ruby-value str">'Form.Element.Observer'</span>, <span class="ruby-identifier">field_id</span>, <span class="ruby-identifier">options</span>)
433
+ 423: <span class="ruby-keyword kw">else</span>
434
+ 424: <span class="ruby-identifier">build_observer</span>(<span class="ruby-value str">'Form.Element.EventObserver'</span>, <span class="ruby-identifier">field_id</span>, <span class="ruby-identifier">options</span>)
435
+ 425: <span class="ruby-keyword kw">end</span>
436
+ 426: <span class="ruby-keyword kw">end</span>
437
+ </pre>
438
+ </div>
439
+ </div>
440
+ <h4 class="ruled">Public Instance method:
441
+ <strong><a name="M000035">periodically_call_remote(options = {})</a></strong> <a href="#M000035"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: periodically_call_remote" /></a></h4>
442
+
443
+ <p>
444
+ Periodically calls the specified url (<tt>options[:url]</tt>) every
445
+ <tt>options[:frequency]</tt> seconds (default is 10). Usually used to
446
+ update a specified div (<tt>options[:update]</tt>) with the results of the
447
+ remote call. The options for specifying the target with :url and defining
448
+ callbacks is the same as <a
449
+ href="JavaScriptView.html#M000034">link_to_remote</a>.
450
+ </p>
451
+
452
+ <div class="sourcecode">
453
+ <p class="source-link">[ <a href="javascript:toggleSource('M000035_source')" id="l_M000035_source">show source</a> ]</p>
454
+ <div id="M000035_source" class="dyn-source">
455
+ <pre>
456
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 380</span>
457
+ 380: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">periodically_call_remote</span>(<span class="ruby-identifier">options</span> = {})
458
+ 381: <span class="ruby-identifier">frequency</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:frequency</span>] <span class="ruby-operator">||</span> <span class="ruby-value">10</span> <span class="ruby-comment cmt"># every ten seconds by default</span>
459
+ 382: <span class="ruby-identifier">code</span> = <span class="ruby-node">&quot;new PeriodicalExecuter(function() {#{remote_function(options)}}, #{frequency})&quot;</span>
460
+ 383: <span class="ruby-identifier">javascript_tag</span>(<span class="ruby-identifier">code</span>)
461
+ 384: <span class="ruby-keyword kw">end</span>
462
+ </pre>
463
+ </div>
464
+ </div>
465
+ <h4 class="ruled">Public Instance method:
466
+ <strong><a name="M000037">remote_function(options)</a></strong> <a href="#M000037"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: remote_function" /></a></h4>
467
+
468
+ <p>
469
+ Returns the JavaScript needed for a remote function. Takes the same
470
+ arguments as <a href="JavaScriptView.html#M000034">link_to_remote</a>.
471
+ </p>
472
+ <p>
473
+ Example:
474
+ </p>
475
+ <pre>
476
+ select( :id =&gt; &quot;options&quot;,
477
+ :onChange =&gt; remote_function(
478
+ :update =&gt; &quot;options&quot;,
479
+ :url =&gt; R(Update),
480
+ :onSuccess =&gt; visual_effect( :highlight, 'my_element' )
481
+ )
482
+ ) do
483
+ option( &quot;Hello&quot;, :value =&gt; 0 )
484
+ option( &quot;World&quot;, :value =&gt; 1 )
485
+ end
486
+ </pre>
487
+
488
+ <div class="sourcecode">
489
+ <p class="source-link">[ <a href="javascript:toggleSource('M000037_source')" id="l_M000037_source">show source</a> ]</p>
490
+ <div id="M000037_source" class="dyn-source">
491
+ <pre>
492
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 442</span>
493
+ 442: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remote_function</span>(<span class="ruby-identifier">options</span>)
494
+ 443: <span class="ruby-identifier">javascript_options</span> = <span class="ruby-identifier">options_for_ajax</span>(<span class="ruby-identifier">options</span>)
495
+ 444:
496
+ 445: <span class="ruby-identifier">update</span> = <span class="ruby-value str">''</span>
497
+ 446: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:update</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:update</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Hash</span>)
498
+ 447: <span class="ruby-identifier">update</span> = []
499
+ 448: <span class="ruby-identifier">update</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;success:'#{options[:update][:success]}'&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:update</span>][<span class="ruby-identifier">:success</span>]
500
+ 449: <span class="ruby-identifier">update</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;failure:'#{options[:update][:failure]}'&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:update</span>][<span class="ruby-identifier">:failure</span>]
501
+ 450: <span class="ruby-identifier">update</span> = <span class="ruby-value str">'{'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">update</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">','</span>) <span class="ruby-operator">+</span> <span class="ruby-value str">'}'</span>
502
+ 451: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:update</span>]
503
+ 452: <span class="ruby-identifier">update</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;'#{options[:update]}'&quot;</span>
504
+ 453: <span class="ruby-keyword kw">end</span>
505
+ 454:
506
+ 455: <span class="ruby-identifier">function</span> = <span class="ruby-identifier">update</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span>
507
+ 456: <span class="ruby-value str">&quot;new Ajax.Request(&quot;</span> <span class="ruby-operator">:</span>
508
+ 457: <span class="ruby-node">&quot;new Ajax.Updater(#{update}, &quot;</span>
509
+ 458:
510
+ 459: <span class="ruby-identifier">function</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;'#{options[:url]}'&quot;</span>
511
+ 460: <span class="ruby-identifier">function</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;, #{javascript_options})&quot;</span>
512
+ 461:
513
+ 462: <span class="ruby-identifier">function</span> = <span class="ruby-node">&quot;#{options[:before]}; #{function}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:before</span>]
514
+ 463: <span class="ruby-identifier">function</span> = <span class="ruby-node">&quot;#{function}; #{options[:after]}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:after</span>]
515
+ 464: <span class="ruby-identifier">function</span> = <span class="ruby-node">&quot;if (#{options[:condition]}) { #{function}; }&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:condition</span>]
516
+ 465: <span class="ruby-identifier">function</span> = <span class="ruby-node">&quot;if (confirm('#{escape_javascript(options[:confirm])}')) { #{function}; }&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:confirm</span>]
517
+ 466:
518
+ 467: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">function</span>
519
+ 468: <span class="ruby-keyword kw">end</span>
520
+ </pre>
521
+ </div>
522
+ </div>
523
+ <h4 class="ruled">Public Instance method:
524
+ <strong><a name="M000031">update_page( &amp;block )</a></strong> <a href="#M000031"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: update_page" /></a></h4>
525
+
526
+ <p>
527
+ Yields a <a href="../JavaScriptGenerator.html">JavaScriptGenerator</a> and
528
+ returns the generated JavaScript code. Use this to update multiple elements
529
+ on a page in an Ajax response. See <a
530
+ href="../JavaScriptGenerator.html">JavaScriptGenerator</a> for more
531
+ information.
532
+ </p>
533
+
534
+ <div class="sourcecode">
535
+ <p class="source-link">[ <a href="javascript:toggleSource('M000031_source')" id="l_M000031_source">show source</a> ]</p>
536
+ <div id="M000031_source" class="dyn-source">
537
+ <pre>
538
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 228</span>
539
+ 228: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_page</span>( <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
540
+ 229: <span class="ruby-constant">JavaScriptGenerator</span>.<span class="ruby-identifier">new</span>( <span class="ruby-keyword kw">self</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> ).<span class="ruby-identifier">to_s</span>
541
+ 230: <span class="ruby-keyword kw">end</span>
542
+ </pre>
543
+ </div>
544
+ </div>
545
+ <h4 class="ruled">Public Instance method:
546
+ <strong><a name="M000032">update_page_tag( options = {}, &amp;block )</a></strong> <a href="#M000032"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: update_page_tag" /></a></h4>
547
+
548
+ <p>
549
+ Works like <a href="JavaScriptView.html#M000031">update_page</a> but wraps
550
+ the generated JavaScript in a &lt;script&gt; tag. See <a
551
+ href="../JavaScriptGenerator.html">JavaScriptGenerator</a> for more
552
+ information.
553
+ </p>
554
+
555
+ <div class="sourcecode">
556
+ <p class="source-link">[ <a href="javascript:toggleSource('M000032_source')" id="l_M000032_source">show source</a> ]</p>
557
+ <div id="M000032_source" class="dyn-source">
558
+ <pre>
559
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/javascript.rb, line 234</span>
560
+ 234: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_page_tag</span>( <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> )
561
+ 235: <span class="ruby-identifier">javascript_tag</span> <span class="ruby-identifier">update_page</span>( <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span> ), <span class="ruby-identifier">options</span>
562
+ 236: <span class="ruby-keyword kw">end</span>
563
+ </pre>
564
+ </div>
565
+ </div>
566
+
567
+ </div>
568
+ </div>
569
+
570
+
571
+ </div>
572
+ </body>
573
+ </html>