bivouac 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/README +9 -0
  2. data/bin/bivouac +15 -19
  3. data/doc/rdoc/classes/BivouacHelpers.html +117 -0
  4. data/doc/rdoc/classes/BivouacHelpers/BaseView.html +140 -0
  5. data/doc/rdoc/classes/BivouacHelpers/FormView.html +398 -0
  6. data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +274 -0
  7. data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +573 -0
  8. data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +258 -0
  9. data/doc/rdoc/classes/BivouacHelpers/TooltipView.html +158 -0
  10. data/doc/rdoc/classes/JavaScriptGenerator.html +564 -0
  11. data/doc/rdoc/created.rid +1 -1
  12. data/doc/rdoc/files/AUTHORS.html +14 -0
  13. data/doc/rdoc/files/COPYING.html +14 -0
  14. data/doc/rdoc/files/README.html +40 -1
  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/examples/bivouac_sample/app/bivouac_sample.rb +61 -0
  22. data/examples/bivouac_sample/app/controllers/autocomplete.rb +24 -0
  23. data/examples/bivouac_sample/app/controllers/drag_and_drop.rb +11 -0
  24. data/examples/bivouac_sample/app/controllers/index.rb +7 -0
  25. data/examples/bivouac_sample/app/controllers/observe.rb +14 -0
  26. data/examples/bivouac_sample/app/controllers/periodically_call.rb +12 -0
  27. data/examples/bivouac_sample/app/controllers/remote_form.rb +10 -0
  28. data/examples/bivouac_sample/app/controllers/remote_link.rb +11 -0
  29. data/examples/bivouac_sample/app/controllers/submit_remote.rb +17 -0
  30. data/examples/bivouac_sample/app/controllers/toggle.rb +10 -0
  31. data/examples/bivouac_sample/app/controllers/toggle_sortable.rb +11 -0
  32. data/examples/bivouac_sample/app/helpers/_helpers.rb +25 -0
  33. data/examples/bivouac_sample/app/helpers/source.rb +25 -0
  34. data/examples/bivouac_sample/app/views/_autocomplete_result.rb +9 -0
  35. data/examples/bivouac_sample/app/views/_drag_and_drop_result.rb +5 -0
  36. data/examples/bivouac_sample/app/views/_observe_result.rb +17 -0
  37. data/examples/bivouac_sample/app/views/_periodically_call_result.rb +5 -0
  38. data/examples/bivouac_sample/app/views/_remote_link_result.rb +5 -0
  39. data/examples/bivouac_sample/app/views/_sortable_result.rb +5 -0
  40. data/examples/bivouac_sample/app/views/_submit_remote_result.rb +5 -0
  41. data/examples/bivouac_sample/app/views/autocomplete.rb +28 -0
  42. data/examples/bivouac_sample/app/views/drag_and_drop.rb +35 -0
  43. data/examples/bivouac_sample/app/views/index.rb +19 -0
  44. data/examples/bivouac_sample/app/views/observe.rb +19 -0
  45. data/examples/bivouac_sample/app/views/periodically_call.rb +17 -0
  46. data/examples/bivouac_sample/app/views/remote_form.rb +19 -0
  47. data/examples/bivouac_sample/app/views/remote_link.rb +20 -0
  48. data/examples/bivouac_sample/app/views/submit_remote.rb +21 -0
  49. data/examples/bivouac_sample/app/views/toggle.rb +44 -0
  50. data/examples/bivouac_sample/app/views/toggle_sortable.rb +52 -0
  51. data/examples/bivouac_sample/config/environment.rb +37 -0
  52. data/examples/bivouac_sample/config/postamble.rb +62 -0
  53. data/examples/bivouac_sample/log/BivouacSample.log +77 -0
  54. data/examples/bivouac_sample/public/images/camping.png +0 -0
  55. data/examples/bivouac_sample/public/index.html +242 -0
  56. data/examples/bivouac_sample/public/javascripts/builder.js +131 -0
  57. data/examples/bivouac_sample/public/javascripts/controls.js +835 -0
  58. data/examples/bivouac_sample/public/javascripts/dragdrop.js +944 -0
  59. data/examples/bivouac_sample/public/javascripts/effects.js +1090 -0
  60. data/examples/bivouac_sample/public/javascripts/prototype.js +2515 -0
  61. data/examples/bivouac_sample/public/javascripts/scriptaculous.js +51 -0
  62. data/examples/bivouac_sample/public/javascripts/slider.js +278 -0
  63. data/examples/bivouac_sample/public/javascripts/tooltip.js +208 -0
  64. data/examples/bivouac_sample/public/javascripts/unittest.js +564 -0
  65. data/examples/bivouac_sample/public/stylesheets/autocomplete.css +22 -0
  66. data/examples/bivouac_sample/public/stylesheets/coderay.css +104 -0
  67. data/examples/bivouac_sample/script/generate +3 -0
  68. data/examples/bivouac_sample/script/server +5 -0
  69. data/lib/bivouac/helpers/view/goh/base.rb +16 -0
  70. data/lib/bivouac/helpers/view/goh/form.rb +170 -0
  71. data/lib/bivouac/helpers/view/goh/html.rb +138 -0
  72. data/lib/bivouac/helpers/view/goh/javascript.rb +532 -0
  73. data/lib/bivouac/helpers/view/goh/scriptaculous.rb +133 -0
  74. data/lib/bivouac/helpers/view/goh/tooltip.rb +33 -0
  75. data/lib/bivouac/template.rb +3 -3
  76. data/lib/bivouac/template/application/helpers_erb.rb +11 -0
  77. data/lib/bivouac/template/application/helpers_goh.rb +25 -0
  78. data/lib/bivouac/template/application/postamble.rb +62 -0
  79. data/lib/bivouac/template/application_erb.rb +4 -0
  80. data/lib/bivouac/template/application_goh.rb +4 -0
  81. data/lib/bivouac/template/environment.rb +19 -5
  82. data/lib/bivouac/template/server.rb +1 -1
  83. data/lib/bivouac/template/static/autocomplete.css +22 -0
  84. data/lib/bivouac/template/static/builder.js +131 -0
  85. data/lib/bivouac/template/static/controls.js +835 -0
  86. data/lib/bivouac/template/static/dragdrop.js +944 -0
  87. data/lib/bivouac/template/static/effects.js +1090 -0
  88. data/lib/bivouac/template/static/prototype.js +2515 -0
  89. data/lib/bivouac/template/static/scriptaculous.js +51 -0
  90. data/lib/bivouac/template/static/slider.js +278 -0
  91. data/lib/bivouac/template/static/tooltip.js +208 -0
  92. data/lib/bivouac/template/static/unittest.js +564 -0
  93. metadata +124 -7
  94. data/lib/bivouac/template/application/postamble_cgi.rb +0 -8
  95. data/lib/bivouac/template/application/postamble_fastcgi.rb +0 -8
  96. data/lib/bivouac/template/application/postamble_mongrel.rb +0 -19
  97. data/lib/bivouac/template/application/postamble_none.rb +0 -1
  98. data/lib/bivouac/template/application/postamble_webrick.rb +0 -19
@@ -0,0 +1,274 @@
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::HtmlView
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::HtmlView</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::HtmlView<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::HtmlView" class="page_shade">
89
+ <div class="page">
90
+ <h3>Module BivouacHelpers::HtmlView &lt; Object</h3>
91
+
92
+ (in files
93
+ <a href="../../files/lib/bivouac/helpers/view/goh/html_rb.html">lib/bivouac/helpers/view/goh/html.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="M000038">image_tag( source, options = {} )</a></strong> <a href="#M000038"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: image_tag" /></a></h4>
107
+
108
+ <p>
109
+ Returns an html image tag for the <tt>source</tt>. The <tt>source</tt> must
110
+ be a file that exists in your public images directory (public/images). You
111
+ can add html attributes using the <tt>options</tt>. If no alt text is
112
+ given, the file name part of the <tt>source</tt> is used (capitalized and
113
+ without the extension)
114
+ </p>
115
+ <pre>
116
+ image_tag(&quot;icon.png&quot;) # =&gt;
117
+ &lt;img src=&quot;/public/images/icon.png&quot; alt=&quot;Icon&quot; /&gt;
118
+
119
+ image_tag(&quot;icon.png&quot;, :alt =&gt; &quot;Edit Entry&quot;) # =&gt;
120
+ &lt;img src=&quot;/public/images/icon.png&quot; alt=&quot;Edit Entry&quot; /&gt;
121
+ </pre>
122
+
123
+ <div class="sourcecode">
124
+ <p class="source-link">[ <a href="javascript:toggleSource('M000038_source')" id="l_M000038_source">show source</a> ]</p>
125
+ <div id="M000038_source" class="dyn-source">
126
+ <pre>
127
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/html.rb, line 73</span>
128
+ 73: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image_tag</span>( <span class="ruby-identifier">source</span>, <span class="ruby-identifier">options</span> = {} )
129
+ 74: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:src</span>] = <span class="ruby-node">&quot;/public/images/#{source}&quot;</span>
130
+ 75: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:alt</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:src</span>], <span class="ruby-value str">'.*'</span>).<span class="ruby-identifier">split</span>(<span class="ruby-value str">'.'</span>).<span class="ruby-identifier">first</span>.<span class="ruby-identifier">capitalize</span>
131
+ 76:
132
+ 77: <span class="ruby-identifier">img</span>( <span class="ruby-identifier">options</span> )
133
+ 78: <span class="ruby-keyword kw">end</span>
134
+ </pre>
135
+ </div>
136
+ </div>
137
+ <h4 class="ruled">Public Instance method:
138
+ <strong><a name="M000037">javascript_include_tag( *sources )</a></strong> <a href="#M000037"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: javascript_include_tag" /></a></h4>
139
+
140
+ <p>
141
+ Returns an html script tag for each of the <tt>sources</tt> provided. You
142
+ can pass in the filename (.js extension is optional) of javascript files
143
+ that exist in your public/javascripts directory for inclusion into the
144
+ current page. To include the Prototype and Scriptaculous javascript
145
+ libraries in your application, pass :defaults as the source.
146
+ </p>
147
+ <pre>
148
+ javascript_include_tag &quot;xmlhr&quot; # =&gt;
149
+ &lt;script type=&quot;text/javascript&quot; src=&quot;/public/javascripts/xmlhr.js&quot;&gt;&lt;/script&gt;
150
+
151
+ javascript_include_tag &quot;common.javascript&quot;, &quot;elsewhere/cools&quot; # =&gt;
152
+ &lt;script type=&quot;text/javascript&quot; src=&quot;/public/javascripts/common.javascript&quot;&gt;&lt;/script&gt;
153
+ &lt;script type=&quot;text/javascript&quot; src=&quot;/public/javascripts/elsewhere/cools.js&quot;&gt;&lt;/script&gt;
154
+ </pre>
155
+
156
+ <div class="sourcecode">
157
+ <p class="source-link">[ <a href="javascript:toggleSource('M000037_source')" id="l_M000037_source">show source</a> ]</p>
158
+ <div id="M000037_source" class="dyn-source">
159
+ <pre>
160
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/html.rb, line 43</span>
161
+ 43: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">javascript_include_tag</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">sources</span> )
162
+ 44: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">sources</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">sources</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> { }
163
+ 45: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:type</span>] = <span class="ruby-value str">&quot;text/javascript&quot;</span>
164
+ 46:
165
+ 47: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">sources</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">:defaults</span>)
166
+ 48: <span class="ruby-identifier">sources</span> = <span class="ruby-identifier">sources</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span>(<span class="ruby-identifier">sources</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">:defaults</span>))] <span class="ruby-operator">+</span>
167
+ 49: <span class="ruby-ivar">@@javascript_default_sources</span>.<span class="ruby-identifier">dup</span> <span class="ruby-operator">+</span>
168
+ 50: <span class="ruby-identifier">sources</span>[(<span class="ruby-identifier">sources</span>.<span class="ruby-identifier">index</span>(<span class="ruby-identifier">:defaults</span>) <span class="ruby-operator">+</span> <span class="ruby-value">1</span>)<span class="ruby-operator">..</span><span class="ruby-identifier">sources</span>.<span class="ruby-identifier">length</span>]
169
+ 51:
170
+ 52: <span class="ruby-identifier">sources</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:defaults</span>)
171
+ 53: <span class="ruby-keyword kw">end</span>
172
+ 54: <span class="ruby-identifier">sources</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
173
+ 55: <span class="ruby-identifier">file</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">to_s</span>
174
+ 56: <span class="ruby-identifier">file</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;.js&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">file</span>).<span class="ruby-identifier">blank?</span>
175
+ 57: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:src</span>] = <span class="ruby-node">&quot;/public/javascripts/#{file}&quot;</span>
176
+ 58: <span class="ruby-identifier">script</span>( <span class="ruby-identifier">options</span> ) {}
177
+ 59: <span class="ruby-keyword kw">end</span>
178
+ 60: <span class="ruby-keyword kw">end</span>
179
+ </pre>
180
+ </div>
181
+ </div>
182
+ <h4 class="ruled">Public Instance method:
183
+ <strong><a name="M000039">link_to(name, address, options = {})</a></strong> <a href="#M000039"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: link_to" /></a></h4>
184
+
185
+ <p>
186
+ Creates a link tag of the given <tt>name</tt> using <tt>address</tt> has
187
+ the href for the link
188
+ </p>
189
+ <p>
190
+ The <tt>options</tt> will accept a hash of html attributes for the link
191
+ tag. It also accepts 2 modifiers that specialize the link behavior.
192
+ </p>
193
+ <ul>
194
+ <li><tt>:confirm =&gt; &#8216;question?&#8216;</tt>: This will add a JavaScript
195
+ confirm prompt with the question specified. If the user accepts, the link
196
+ is processed normally, otherwise no action is taken.
197
+
198
+ </li>
199
+ <li><tt>:popup =&gt; true || array of window options</tt>: This will force the
200
+ link to open in a popup window. By passing true, a default browser window
201
+ will be opened with the URL. You can also specify an array of options that
202
+ are passed-thru to JavaScripts window.open method.
203
+
204
+ </li>
205
+ </ul>
206
+ <p>
207
+ You can mix and match the <tt>options</tt>.
208
+ </p>
209
+ <pre>
210
+ link_to &quot;Documentation&quot;, &quot;http://camping.rubyforge.org/&quot;, :confirm =&gt; &quot;Are you sure?&quot;
211
+ link_to &quot;Help&quot;, R( Help ), :popup =&gt; true
212
+ link_to image_tag( &quot;thumb.png&quot; ), &quot;/public/images/fullsize.png&quot;, :popup =&gt; ['My house', 'height=300,width=600']
213
+ </pre>
214
+
215
+ <div class="sourcecode">
216
+ <p class="source-link">[ <a href="javascript:toggleSource('M000039_source')" id="l_M000039_source">show source</a> ]</p>
217
+ <div id="M000039_source" class="dyn-source">
218
+ <pre>
219
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/html.rb, line 99</span>
220
+ 99: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">link_to</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">address</span>, <span class="ruby-identifier">options</span> = {})
221
+ 100: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">javascript_options</span>( <span class="ruby-identifier">options</span> )
222
+ 101: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:href</span>] = <span class="ruby-identifier">address</span>
223
+ 102:
224
+ 103: <span class="ruby-identifier">a</span>( <span class="ruby-identifier">options</span> ) <span class="ruby-keyword kw">do</span>; <span class="ruby-identifier">name</span>; <span class="ruby-keyword kw">end</span>
225
+ 104: <span class="ruby-keyword kw">end</span>
226
+ </pre>
227
+ </div>
228
+ </div>
229
+ <h4 class="ruled">Public Instance method:
230
+ <strong><a name="M000036">stylesheet_link_tag( *data )</a></strong> <a href="#M000036"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: stylesheet_link_tag" /></a></h4>
231
+
232
+ <p>
233
+ Returns a stylesheet link tag for the sources specified as arguments. If
234
+ you don&#8216;t specify an extension, .css will be appended automatically.
235
+ You can modify the link attributes by passing a hash as the last argument.
236
+ </p>
237
+ <pre>
238
+ stylesheet_link_tag &quot;style&quot; # =&gt;
239
+ &lt;link href=&quot;/public/stylesheets/style.css&quot; media=&quot;screen&quot; rel=&quot;Stylesheet&quot; type=&quot;text/css&quot; /&gt;
240
+
241
+ stylesheet_link_tag &quot;style&quot;, :media =&gt; &quot;all&quot; # =&gt;
242
+ &lt;link href=&quot;/public/stylesheets/style.css&quot; media=&quot;all&quot; rel=&quot;Stylesheet&quot; type=&quot;text/css&quot; /&gt;
243
+
244
+ stylesheet_link_tag &quot;random.styles&quot;, &quot;/css/stylish&quot; # =&gt;
245
+ &lt;link href=&quot;/public/stylesheets/random.styles&quot; media=&quot;screen&quot; rel=&quot;Stylesheet&quot; type=&quot;text/css&quot; /&gt;
246
+ &lt;link href=&quot;/public/stylesheets/css/stylish.css&quot; media=&quot;screen&quot; rel=&quot;Stylesheet&quot; type=&quot;text/css&quot; /&gt;
247
+ </pre>
248
+
249
+ <div class="sourcecode">
250
+ <p class="source-link">[ <a href="javascript:toggleSource('M000036_source')" id="l_M000036_source">show source</a> ]</p>
251
+ <div id="M000036_source" class="dyn-source">
252
+ <pre>
253
+ <span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/html.rb, line 20</span>
254
+ 20: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stylesheet_link_tag</span>( <span class="ruby-operator">*</span><span class="ruby-identifier">data</span> )
255
+ 21: <span class="ruby-identifier">options</span> = <span class="ruby-identifier">data</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">data</span>.<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> { }
256
+ 22: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:rel</span>] = <span class="ruby-value str">&quot;Stylesheet&quot;</span>
257
+ 23: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:type</span>] = <span class="ruby-value str">&quot;text/css&quot;</span>
258
+ 24: <span class="ruby-identifier">data</span>.<span class="ruby-identifier">collect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
259
+ 25: <span class="ruby-identifier">file</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;.css&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">file</span>).<span class="ruby-identifier">blank?</span>
260
+ 26: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:href</span>] = <span class="ruby-node">&quot;/public/stylesheets/#{file}&quot;</span>
261
+ 27: <span class="ruby-identifier">link</span>( <span class="ruby-identifier">options</span> )
262
+ 28: <span class="ruby-keyword kw">end</span>
263
+ 29: <span class="ruby-keyword kw">end</span>
264
+ </pre>
265
+ </div>
266
+ </div>
267
+
268
+ </div>
269
+ </div>
270
+
271
+
272
+ </div>
273
+ </body>
274
+ </html>
@@ -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="M000027">escape_javascript(javascript)</a></strong> <a href="#M000027"><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('M000027_source')" id="l_M000027_source">show source</a> ]</p>
115
+ <div id="M000027_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="M000028">javascript_tag( content, options = {} )</a></strong> <a href="#M000028"><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('M000028_source')" id="l_M000028_source">show source</a> ]</p>
146
+ <div id="M000028_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="M000031">link_to_function( name, *args, &amp;block )</a></strong> <a href="#M000031"><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#M000029">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('M000031_source')" id="l_M000031_source">show source</a> ]</p>
217
+ <div id="M000031_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="M000032">link_to_remote(name, options = {}, html_options = {})</a></strong> <a href="#M000032"><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('M000032_source')" id="l_M000032_source">show source</a> ]</p>
362
+ <div id="M000032_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="M000034">observe_field(field_id, options = {})</a></strong> <a href="#M000034"><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#M000032">link_to_remote</a>.
423
+ </p>
424
+
425
+ <div class="sourcecode">
426
+ <p class="source-link">[ <a href="javascript:toggleSource('M000034_source')" id="l_M000034_source">show source</a> ]</p>
427
+ <div id="M000034_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="M000033">periodically_call_remote(options = {})</a></strong> <a href="#M000033"><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#M000032">link_to_remote</a>.
450
+ </p>
451
+
452
+ <div class="sourcecode">
453
+ <p class="source-link">[ <a href="javascript:toggleSource('M000033_source')" id="l_M000033_source">show source</a> ]</p>
454
+ <div id="M000033_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="M000035">remote_function(options)</a></strong> <a href="#M000035"><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#M000032">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('M000035_source')" id="l_M000035_source">show source</a> ]</p>
490
+ <div id="M000035_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="M000029">update_page( &amp;block )</a></strong> <a href="#M000029"><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('M000029_source')" id="l_M000029_source">show source</a> ]</p>
536
+ <div id="M000029_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="M000030">update_page_tag( options = {}, &amp;block )</a></strong> <a href="#M000030"><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#M000029">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('M000030_source')" id="l_M000030_source">show source</a> ]</p>
557
+ <div id="M000030_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>