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.
- data/README +6 -7
- data/bin/bivouac +1 -1
- data/doc/rdoc/classes/BivouacHelpers/BaseView.html +178 -0
- data/doc/rdoc/classes/BivouacHelpers/FormView.html +398 -0
- data/doc/rdoc/classes/BivouacHelpers/HtmlView.html +305 -0
- data/doc/rdoc/classes/BivouacHelpers/JavaScriptView.html +573 -0
- data/doc/rdoc/classes/BivouacHelpers/ScriptAculoUsView.html +258 -0
- data/doc/rdoc/classes/BivouacHelpers/TooltipView.html +158 -0
- data/doc/rdoc/classes/BivouacHelpers.html +117 -0
- data/doc/rdoc/classes/JavaScriptGenerator.html +564 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/AUTHORS.html +109 -0
- data/doc/rdoc/files/COPYING.html +533 -0
- data/doc/rdoc/files/README.html +427 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/base_rb.html +109 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/form_rb.html +109 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/html_rb.html +109 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/javascript_rb.html +113 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/scriptaculous_rb.html +113 -0
- data/doc/rdoc/files/lib/bivouac/helpers/view/goh/tooltip_rb.html +109 -0
- data/doc/rdoc/index.html +10 -0
- data/doc/rdoc/permalink.gif +0 -0
- data/doc/rdoc/rdoc-style.css +106 -0
- data/doc/rdoc/rubyfr.png +0 -0
- data/examples/bivouac_sample/Rakefile +48 -0
- data/examples/bivouac_sample/app/bivouac_sample.rb +15 -7
- data/examples/bivouac_sample/app/controllers/index.rb +2 -2
- data/examples/bivouac_sample/app/controllers/sound.rb +10 -0
- data/examples/bivouac_sample/app/helpers/_helpers.rb +6 -3
- data/examples/bivouac_sample/app/views/sound.rb +16 -0
- data/examples/bivouac_sample/config/environment.rb +5 -2
- data/examples/bivouac_sample/config/postamble.rb +89 -18
- data/examples/bivouac_sample/public/javascripts/builder.js +12 -7
- data/examples/bivouac_sample/public/javascripts/controls.js +485 -355
- data/examples/bivouac_sample/public/javascripts/dragdrop.js +82 -52
- data/examples/bivouac_sample/public/javascripts/effects.js +361 -329
- data/examples/bivouac_sample/public/javascripts/prototype.js +2826 -1120
- data/examples/bivouac_sample/public/javascripts/scriptaculous.js +15 -8
- data/examples/bivouac_sample/public/javascripts/slider.js +40 -43
- data/examples/bivouac_sample/public/javascripts/sound.js +55 -0
- data/examples/bivouac_sample/public/javascripts/unittest.js +16 -12
- data/examples/bivouac_sample/public/sound/sword.mp3 +0 -0
- data/examples/bivouac_sample/script/console +6 -0
- data/examples/bivouac_sample/script/plugin +3 -0
- data/examples/bivouac_sample/script/server +2 -1
- data/examples/bivouac_sample/test/test_sound.rb +15 -0
- data/lib/bivouac/helpers/view/goh/sound.rb +38 -0
- data/lib/bivouac/template/application/helpers_goh.rb +2 -0
- data/lib/bivouac/template/static/builder.js +12 -7
- data/lib/bivouac/template/static/controls.js +485 -355
- data/lib/bivouac/template/static/dragdrop.js +82 -52
- data/lib/bivouac/template/static/effects.js +361 -329
- data/lib/bivouac/template/static/prototype.js +2826 -1120
- data/lib/bivouac/template/static/scriptaculous.js +15 -8
- data/lib/bivouac/template/static/slider.js +40 -43
- data/lib/bivouac/template/static/sound.js +55 -0
- data/lib/bivouac/template/static/unittest.js +16 -12
- metadata +45 -2
@@ -0,0 +1,398 @@
|
|
1
|
+
|
2
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>
|
6
|
+
Bivouac, the Documentation » Module: BivouacHelpers::FormView
|
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::FormView</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::FormView<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::FormView" class="page_shade">
|
89
|
+
<div class="page">
|
90
|
+
<h3>Module BivouacHelpers::FormView < Object</h3>
|
91
|
+
|
92
|
+
(in files
|
93
|
+
<a href="../../files/lib/bivouac/helpers/view/goh/form_rb.html">lib/bivouac/helpers/view/goh/form.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="M000043">auto_complete_field( field_id, options = nil )</a></strong> <a href="#M000043"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: auto_complete_field" /></a></h4>
|
107
|
+
|
108
|
+
<p>
|
109
|
+
Adds AJAX autocomplete functionality to the text input field with the DOM
|
110
|
+
ID specified by <tt>field_id</tt>.
|
111
|
+
</p>
|
112
|
+
|
113
|
+
<div class="sourcecode">
|
114
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000043_source')" id="l_M000043_source">show source</a> ]</p>
|
115
|
+
<div id="M000043_source" class="dyn-source">
|
116
|
+
<pre>
|
117
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 6</span>
|
118
|
+
6: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">auto_complete_field</span>( <span class="ruby-identifier">field_id</span>, <span class="ruby-identifier">options</span> = <span class="ruby-keyword kw">nil</span> )
|
119
|
+
7: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">:indicator</span> )
|
120
|
+
8: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:indicator</span>]
|
121
|
+
9: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:indicator</span>] = <span class="ruby-node">"indicator_#{field_id}"</span>
|
122
|
+
10: <span class="ruby-identifier">span</span>( <span class="ruby-identifier">data</span>, <span class="ruby-identifier">:id</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:indicator</span>], <span class="ruby-identifier">:style</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"display: none"</span> )
|
123
|
+
11: <span class="ruby-keyword kw">end</span>
|
124
|
+
12:
|
125
|
+
13: <span class="ruby-identifier">choises_id</span> = <span class="ruby-node">"choises_#{field_id}"</span>
|
126
|
+
14: <span class="ruby-identifier">div</span>( <span class="ruby-identifier">:id</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">choises_id</span>, <span class="ruby-identifier">:class</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"autocomplete"</span> ) <span class="ruby-keyword kw">do</span>; <span class="ruby-keyword kw">end</span>
|
127
|
+
15: <span class="ruby-identifier">url</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">:url</span> )
|
128
|
+
16: <span class="ruby-identifier">javascript_tag</span> <span class="ruby-node">"new Ajax.Autocompleter( '#{field_id}', '#{choises_id}', '#{url}', #{options_for_javascript(options)} );"</span>
|
129
|
+
17: <span class="ruby-keyword kw">end</span>
|
130
|
+
</pre>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
<h4 class="ruled">Public Instance method:
|
134
|
+
<strong><a name="M000045">button_to_function(name, *args, &block)</a></strong> <a href="#M000045"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: button_to_function" /></a></h4>
|
135
|
+
|
136
|
+
<p>
|
137
|
+
Returns a button that‘ll trigger a JavaScript function using the
|
138
|
+
onclick handler.
|
139
|
+
</p>
|
140
|
+
<p>
|
141
|
+
The function argument can be omitted in favor of an update_page block,
|
142
|
+
which evaluates to a string when the template is rendered (instead of
|
143
|
+
making an Ajax request first).
|
144
|
+
</p>
|
145
|
+
|
146
|
+
<div class="sourcecode">
|
147
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000045_source')" id="l_M000045_source">show source</a> ]</p>
|
148
|
+
<div id="M000045_source" class="dyn-source">
|
149
|
+
<pre>
|
150
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 63</span>
|
151
|
+
63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">button_to_function</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
152
|
+
64: <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> {}
|
153
|
+
65: <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>
|
154
|
+
66:
|
155
|
+
67: <span class="ruby-identifier">function</span> = <span class="ruby-identifier">update_page</span>(<span class="ruby-operator">&</span><span class="ruby-identifier">block</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
156
|
+
68:
|
157
|
+
69: <span class="ruby-identifier">input</span>( <span class="ruby-identifier">html_options</span>.<span class="ruby-identifier">merge</span>({
|
158
|
+
70: <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"button"</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span>,
|
159
|
+
71: <span class="ruby-identifier">:onclick</span> =<span class="ruby-operator">></span> (<span class="ruby-identifier">html_options</span>[<span class="ruby-identifier">:onclick</span>] <span class="ruby-operator">?</span> <span class="ruby-node">"#{html_options[:onclick]}; "</span> <span class="ruby-operator">:</span> <span class="ruby-value str">""</span>) <span class="ruby-operator">+</span> <span class="ruby-node">"#{function};"</span>
|
160
|
+
72: }))
|
161
|
+
73: <span class="ruby-keyword kw">end</span>
|
162
|
+
</pre>
|
163
|
+
</div>
|
164
|
+
</div>
|
165
|
+
<h4 class="ruled">Public Instance method:
|
166
|
+
<strong><a name="M000048">form_remote_tag(options = {}, &block)</a></strong> <a href="#M000048"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: form_remote_tag" /></a></h4>
|
167
|
+
|
168
|
+
<p>
|
169
|
+
Returns a form tag that will submit using XMLHttpRequest in the background
|
170
|
+
instead of the regular reloading POST arrangement. Even though it‘s
|
171
|
+
using JavaScript to serialize the form elements, the form submission will
|
172
|
+
work just like a regular submission as viewed by the receiving side. The
|
173
|
+
options for specifying the target with :url and defining callbacks is the
|
174
|
+
same as link_to_remote.
|
175
|
+
</p>
|
176
|
+
<p>
|
177
|
+
A "fall-through" target for browsers that doesn‘t do
|
178
|
+
JavaScript can be specified with the :action/:method options on :html.
|
179
|
+
</p>
|
180
|
+
<p>
|
181
|
+
Example:
|
182
|
+
</p>
|
183
|
+
<pre>
|
184
|
+
form_remote_tag :html => { :url => R(SomePlace) }
|
185
|
+
</pre>
|
186
|
+
<p>
|
187
|
+
The Hash passed to the :html key is equivalent to the options (2nd)
|
188
|
+
argument in the <a href="FormView.html#M000047">form_tag</a> method.
|
189
|
+
</p>
|
190
|
+
<p>
|
191
|
+
By default the fall-through action is the same as the one specified in the
|
192
|
+
:url (and the default method is :post).
|
193
|
+
</p>
|
194
|
+
<p>
|
195
|
+
<a href="FormView.html#M000048">form_remote_tag</a> takes a block, like <a
|
196
|
+
href="FormView.html#M000047">form_tag</a>:
|
197
|
+
</p>
|
198
|
+
<pre>
|
199
|
+
form_remote_tag :url => '/posts' do
|
200
|
+
div do; input( :type => 'submit', :name => 'submit' :value => 'Save' ); end
|
201
|
+
end
|
202
|
+
</pre>
|
203
|
+
|
204
|
+
<div class="sourcecode">
|
205
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000048_source')" id="l_M000048_source">show source</a> ]</p>
|
206
|
+
<div id="M000048_source" class="dyn-source">
|
207
|
+
<pre>
|
208
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 159</span>
|
209
|
+
159: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">form_remote_tag</span>(<span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
210
|
+
160: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:form</span>] = <span class="ruby-keyword kw">true</span>
|
211
|
+
161:
|
212
|
+
162: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>] <span class="ruby-operator">||=</span> {}
|
213
|
+
163: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onsubmit</span>] =
|
214
|
+
164: (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onsubmit</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onsubmit</span>] <span class="ruby-operator">+</span> <span class="ruby-value str">"; "</span> <span class="ruby-operator">:</span> <span class="ruby-value str">""</span>) <span class="ruby-operator">+</span>
|
215
|
+
165: <span class="ruby-node">"#{remote_function(options)}; return false;"</span>
|
216
|
+
166:
|
217
|
+
167: <span class="ruby-identifier">form_tag</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>].<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:url</span>), <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>], <span class="ruby-operator">&</span><span class="ruby-identifier">block</span> )
|
218
|
+
168: <span class="ruby-keyword kw">end</span>
|
219
|
+
</pre>
|
220
|
+
</div>
|
221
|
+
</div>
|
222
|
+
<h4 class="ruled">Public Instance method:
|
223
|
+
<strong><a name="M000047">form_tag(url, options = {}) {|| ...}</a></strong> <a href="#M000047"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: form_tag" /></a></h4>
|
224
|
+
|
225
|
+
<p>
|
226
|
+
Starts a form tag that points the action to an url. The method for the form
|
227
|
+
defaults to POST.
|
228
|
+
</p>
|
229
|
+
<p>
|
230
|
+
Examples:
|
231
|
+
</p>
|
232
|
+
<ul>
|
233
|
+
<li><tt><a href="FormView.html#M000047">form_tag</a>(’/posts’)
|
234
|
+
=> <form action="/posts" method="post"></tt>
|
235
|
+
|
236
|
+
</li>
|
237
|
+
<li><tt><a href="FormView.html#M000047">form_tag</a>(’/upload’,
|
238
|
+
:multipart => true) => <form action="/upload"
|
239
|
+
method="post" enctype="multipart/form-data"></tt>
|
240
|
+
|
241
|
+
</li>
|
242
|
+
</ul>
|
243
|
+
<p>
|
244
|
+
Example:
|
245
|
+
</p>
|
246
|
+
<pre>
|
247
|
+
form_tag R(Post) do
|
248
|
+
div do; input( :type => 'submit', :name => 'submit' :value => 'Save' ); end
|
249
|
+
end
|
250
|
+
</pre>
|
251
|
+
<p>
|
252
|
+
Will output:
|
253
|
+
</p>
|
254
|
+
<pre>
|
255
|
+
<form action="/posts" method="post"><input type="submit" name="submit" value="Save" /></div></form>
|
256
|
+
</pre>
|
257
|
+
<p>
|
258
|
+
Options:
|
259
|
+
</p>
|
260
|
+
<ul>
|
261
|
+
<li><tt>:multipart</tt> - If set to true, the enctype is set to
|
262
|
+
"multipart/form-data".
|
263
|
+
|
264
|
+
</li>
|
265
|
+
<li><tt>:method</tt> - The method to use when submitting the form, usually
|
266
|
+
either "get" or "post".
|
267
|
+
|
268
|
+
<pre>
|
269
|
+
If "put", "delete", or another verb is used, a hidden input with name _method
|
270
|
+
is added to simulate the verb over post.
|
271
|
+
</pre>
|
272
|
+
</li>
|
273
|
+
</ul>
|
274
|
+
|
275
|
+
<div class="sourcecode">
|
276
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000047_source')" id="l_M000047_source">show source</a> ]</p>
|
277
|
+
<div id="M000047_source" class="dyn-source">
|
278
|
+
<pre>
|
279
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 109</span>
|
280
|
+
109: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">form_tag</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">options</span> = {}, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
281
|
+
110: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:enctype</span>] = <span class="ruby-value str">"multipart/form-data"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:multipart</span>)
|
282
|
+
111: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:action</span>] = <span class="ruby-identifier">url</span>
|
283
|
+
112:
|
284
|
+
113: <span class="ruby-identifier">method_tag</span> = <span class="ruby-keyword kw">false</span>
|
285
|
+
114:
|
286
|
+
115: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">method</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">:method</span>).<span class="ruby-identifier">to_s</span>
|
287
|
+
116: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^get$/i</span> <span class="ruby-comment cmt"># must be case-insentive, but can't use downcase as might be nil</span>
|
288
|
+
117: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:method</span>] = <span class="ruby-value str">"get"</span>
|
289
|
+
118: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^post$/i</span>, <span class="ruby-value str">""</span>, <span class="ruby-keyword kw">nil</span>
|
290
|
+
119: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:method</span>] = <span class="ruby-value str">"post"</span>
|
291
|
+
120: <span class="ruby-keyword kw">else</span>
|
292
|
+
121: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:method</span>] = <span class="ruby-value str">"post"</span>
|
293
|
+
122: <span class="ruby-identifier">method_tag</span> = <span class="ruby-keyword kw">true</span>
|
294
|
+
123: <span class="ruby-keyword kw">end</span>
|
295
|
+
124:
|
296
|
+
125: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
297
|
+
126: <span class="ruby-identifier">form</span>( <span class="ruby-identifier">options</span> ) <span class="ruby-keyword kw">do</span>
|
298
|
+
127: <span class="ruby-keyword kw">yield</span>( )
|
299
|
+
128: <span class="ruby-identifier">input</span>( <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"hidden"</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"_method"</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">method</span> ) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">method_tag</span>
|
300
|
+
129: <span class="ruby-keyword kw">end</span>
|
301
|
+
130: <span class="ruby-keyword kw">else</span>
|
302
|
+
131: <span class="ruby-identifier">form</span>( <span class="ruby-identifier">options</span> ) <span class="ruby-keyword kw">do</span>; <span class="ruby-keyword kw">end</span>
|
303
|
+
132: <span class="ruby-keyword kw">end</span>
|
304
|
+
133: <span class="ruby-keyword kw">end</span>
|
305
|
+
</pre>
|
306
|
+
</div>
|
307
|
+
</div>
|
308
|
+
<h4 class="ruled">Public Instance method:
|
309
|
+
<strong><a name="M000046">submit_to_remote(name, value, options = {})</a></strong> <a href="#M000046"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: submit_to_remote" /></a></h4>
|
310
|
+
|
311
|
+
<p>
|
312
|
+
Returns a button input tag that will submit form using XMLHttpRequest in
|
313
|
+
the background instead of regular reloading POST arrangement.
|
314
|
+
<tt>options</tt> argument is the same as in <tt><a
|
315
|
+
href="FormView.html#M000048">form_remote_tag</a></tt>.
|
316
|
+
</p>
|
317
|
+
|
318
|
+
<div class="sourcecode">
|
319
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000046_source')" id="l_M000046_source">show source</a> ]</p>
|
320
|
+
<div id="M000046_source" class="dyn-source">
|
321
|
+
<pre>
|
322
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 78</span>
|
323
|
+
78: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">submit_to_remote</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">options</span> = {})
|
324
|
+
79: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:with</span>] <span class="ruby-operator">||=</span> <span class="ruby-value str">'Form.serialize(this.form)'</span>
|
325
|
+
80:
|
326
|
+
81: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>] <span class="ruby-operator">||=</span> {}
|
327
|
+
82: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:type</span>] = <span class="ruby-value str">'button'</span>
|
328
|
+
83: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:onclick</span>] = <span class="ruby-node">"#{remote_function(options)}; return false;"</span>
|
329
|
+
84: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:name</span>] = <span class="ruby-identifier">name</span>
|
330
|
+
85: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>][<span class="ruby-identifier">:value</span>] = <span class="ruby-identifier">value</span>
|
331
|
+
86:
|
332
|
+
87: <span class="ruby-identifier">input</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:html</span>]
|
333
|
+
88: <span class="ruby-keyword kw">end</span>
|
334
|
+
</pre>
|
335
|
+
</div>
|
336
|
+
</div>
|
337
|
+
<h4 class="ruled">Public Instance method:
|
338
|
+
<strong><a name="M000044">text_field(field_name, value = "", options = {})</a></strong> <a href="#M000044"><img src="../../permalink.gif" border="0" title="Permalink to Public Instance method: text_field" /></a></h4>
|
339
|
+
|
340
|
+
<p>
|
341
|
+
Autocomplete options :
|
342
|
+
</p>
|
343
|
+
<p>
|
344
|
+
+:url+: URL to call for autocompletion results +:tokens+: +:frequency+:
|
345
|
+
+:minChars+: +:indicator+: When sending the Ajax request Autocompleter
|
346
|
+
shows this +:updateElement+: Hook for a custom function called after the
|
347
|
+
element has been updated (i.e. when the user has selected an entry).
|
348
|
+
+:afterUpdateElement+: Hook for a custom function called after the element
|
349
|
+
has been updated (i.e. when the user has selected an entry). +:callback+:
|
350
|
+
This function is called just before the Request is actually made, allowing
|
351
|
+
you to modify the querystring that is sent to the server. +:parameters+: If
|
352
|
+
you need to send any additional parameters through your search form, add
|
353
|
+
them here, in the usual {field: ‘value’,another:
|
354
|
+
‘value’} or ‘field=value&another=value’ manner.
|
355
|
+
</p>
|
356
|
+
|
357
|
+
<div class="sourcecode">
|
358
|
+
<p class="source-link">[ <a href="javascript:toggleSource('M000044_source')" id="l_M000044_source">show source</a> ]</p>
|
359
|
+
<div id="M000044_source" class="dyn-source">
|
360
|
+
<pre>
|
361
|
+
<span class="ruby-comment cmt"># File lib/bivouac/helpers/view/goh/form.rb, line 30</span>
|
362
|
+
30: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">text_field</span>(<span class="ruby-identifier">field_name</span>, <span class="ruby-identifier">value</span> = <span class="ruby-value str">""</span>, <span class="ruby-identifier">options</span> = {})
|
363
|
+
31: <span class="ruby-identifier">autocomplete_options</span> = <span class="ruby-keyword kw">nil</span>
|
364
|
+
32:
|
365
|
+
33: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">:autocomplete</span> )
|
366
|
+
34: <span class="ruby-keyword kw">unless</span> [<span class="ruby-value str">"on"</span>, <span class="ruby-value str">"off"</span>].<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:autocomplete</span>] )
|
367
|
+
35: <span class="ruby-identifier">autocomplete_options</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>( )
|
368
|
+
36: <span class="ruby-identifier">autocomplete_options</span>[<span class="ruby-identifier">:url</span>] = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">:autocomplete</span> )
|
369
|
+
37: <span class="ruby-comment cmt"># options[:autocomplete] = "off"</span>
|
370
|
+
38: <span class="ruby-keyword kw">end</span>
|
371
|
+
39: <span class="ruby-keyword kw">end</span>
|
372
|
+
40:
|
373
|
+
41:
|
374
|
+
42: [<span class="ruby-identifier">:tokens</span>, <span class="ruby-identifier">:frequency</span>, <span class="ruby-identifier">:minChars</span>, <span class="ruby-identifier">:indicator</span>, <span class="ruby-identifier">:updateElement</span>, <span class="ruby-identifier">:afterUpdateElement</span>, <span class="ruby-identifier">:callback</span>, <span class="ruby-identifier">:parameters</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">op</span><span class="ruby-operator">|</span>
|
375
|
+
43: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>.<span class="ruby-identifier">has_key?</span>( <span class="ruby-identifier">op</span> )
|
376
|
+
44: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">autocomplete_options</span>.<span class="ruby-identifier">nil?</span>
|
377
|
+
45: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">op</span> )
|
378
|
+
46: <span class="ruby-keyword kw">else</span>
|
379
|
+
47: <span class="ruby-identifier">autocomplete_options</span>[<span class="ruby-identifier">op</span>] = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>( <span class="ruby-identifier">op</span> )
|
380
|
+
48: <span class="ruby-keyword kw">end</span>
|
381
|
+
49: <span class="ruby-keyword kw">end</span>
|
382
|
+
50: <span class="ruby-keyword kw">end</span>
|
383
|
+
51:
|
384
|
+
52: <span class="ruby-identifier">options</span> = { <span class="ruby-identifier">:id</span> =<span class="ruby-operator">></span> <span class="ruby-node">"default_#{Time.now.to_i}"</span>, <span class="ruby-identifier">:type</span> =<span class="ruby-operator">></span> <span class="ruby-value str">"text"</span>, <span class="ruby-identifier">:name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">field_name</span>, <span class="ruby-identifier">:value</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">value</span> }.<span class="ruby-identifier">merge</span>( <span class="ruby-identifier">options</span> )
|
385
|
+
53: <span class="ruby-identifier">input</span>( <span class="ruby-identifier">options</span> )
|
386
|
+
54: <span class="ruby-identifier">auto_complete_field</span>( <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:id</span>], <span class="ruby-identifier">autocomplete_options</span> ) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">autocomplete_options</span>.<span class="ruby-identifier">nil?</span>
|
387
|
+
55: <span class="ruby-keyword kw">end</span>
|
388
|
+
</pre>
|
389
|
+
</div>
|
390
|
+
</div>
|
391
|
+
|
392
|
+
</div>
|
393
|
+
</div>
|
394
|
+
|
395
|
+
|
396
|
+
</div>
|
397
|
+
</body>
|
398
|
+
</html>
|