jqr-helpers 1.0.26 → 1.0.27

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -50,6 +50,7 @@ the dialog content from a remote route)
50
50
  * `tab_container` - create a tab container
51
51
  * `date_picker_tag` - create a date picker
52
52
  * `buttonset` - create a radio button set
53
+ * `button_to_external` - create a working `button_to` button inside an existing form (!)
53
54
  * `will_paginate_ajax` - create a `will_paginate` interface that uses Ajax to
54
55
  replace the paginated contents.
55
56
 
@@ -277,7 +277,7 @@
277
277
  $(target).remove();
278
278
  }
279
279
  else {
280
- target.fadeOut(500, function() {$(this).remove()});
280
+ target.fadeOut(500, function() {$(this).remove()});
281
281
  }
282
282
  break;
283
283
  }
@@ -328,6 +328,45 @@
328
328
  }
329
329
 
330
330
  function ujsLoadPlugins(event) {
331
+
332
+ function addHiddenField(form, name, value) {
333
+ var input = $('<input type="hidden">');
334
+ input.attr('name', name);
335
+ input.attr('value', value);
336
+ form.append(input);
337
+ }
338
+
339
+ $('.ujs-external-button').each(function() {
340
+ var button = $(this);
341
+ var form = $('<form>');
342
+ var method = button.data('method');
343
+ if (method == 'put' || method == 'delete') {
344
+ form.attr('method', 'post');
345
+ addHiddenField(form, '_method', method);
346
+ }
347
+ else {
348
+ form.attr('method', method);
349
+ }
350
+ form.attr('action', button.data('url'));
351
+ if (method != 'get') {
352
+ form.attr('rel', 'nofollow');
353
+ addHiddenField(form, button.data('token-name'),
354
+ button.data('token-value'));
355
+ }
356
+ $('body').append(form);
357
+ button.click(function(event) {
358
+ event.stopImmediatePropagation();
359
+ if (!$.rails.allowAction(button)) {
360
+ return false;
361
+ }
362
+ if (button.data('disable-with')) {
363
+ button.html(button.data('disable-with'));
364
+ button.attr('disabled', 'disabled');
365
+ }
366
+ form.submit();
367
+ return false;
368
+ });
369
+ });
331
370
  $('.ujs-date-picker', event.target).each(function() {
332
371
  var options = $(this).data('date-options');
333
372
  $(this).datepicker(options);
@@ -201,7 +201,7 @@
201
201
  </div>
202
202
 
203
203
  <div id="footer">
204
- Generated on Sat Jan 4 18:53:11 2014 by
204
+ Generated on Thu Jan 30 16:04:14 2014 by
205
205
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
206
206
  0.8.7.3 (ruby-1.9.3).
207
207
  </div>
@@ -106,7 +106,7 @@
106
106
  </div>
107
107
 
108
108
  <div id="footer">
109
- Generated on Sat Jan 4 18:53:11 2014 by
109
+ Generated on Thu Jan 30 16:04:14 2014 by
110
110
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
111
111
  0.8.7.3 (ruby-1.9.3).
112
112
  </div>
@@ -452,7 +452,7 @@ be passed as is into the HTML &lt;li&gt; tag.</p>
452
452
  </div>
453
453
 
454
454
  <div id="footer">
455
- Generated on Sat Jan 4 18:53:11 2014 by
455
+ Generated on Thu Jan 30 16:04:14 2014 by
456
456
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
457
457
  0.8.7.3 (ruby-1.9.3).
458
458
  </div>
@@ -187,6 +187,31 @@
187
187
  <p>Add a button to create a jQuery dialog.</p>
188
188
  </div></span>
189
189
 
190
+ </li>
191
+
192
+
193
+ <li class="public ">
194
+ <span class="summary_signature">
195
+
196
+ <a href="#button_to_external-instance_method" title="#button_to_external (instance method)">- (Object) <strong>button_to_external</strong>(content, url, options = {}) </a>
197
+
198
+
199
+
200
+ </span>
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+ <span class="summary_desc"><div class='inline'>
211
+ <p>This is identical to the built-in Rails button_to() in every way except
212
+ that it will work inside an existing form.</p>
213
+ </div></span>
214
+
190
215
  </li>
191
216
 
192
217
 
@@ -530,12 +555,12 @@ using content already on the page.</p>
530
555
  <pre class="lines">
531
556
 
532
557
 
533
- 319
534
- 320
535
- 321</pre>
558
+ 353
559
+ 354
560
+ 355</pre>
536
561
  </td>
537
562
  <td>
538
- <pre class="code"><span class="info file"># File 'lib/jqr-helpers/helpers.rb', line 319</span>
563
+ <pre class="code"><span class="info file"># File 'lib/jqr-helpers/helpers.rb', line 353</span>
539
564
 
540
565
  <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__random_string'>_random_string</span>
541
566
  <span class='const'>SecureRandom</span><span class='period'>.</span><span class='id identifier rubyid_hex'>hex</span><span class='lparen'>(</span><span class='int'>16</span><span class='rparen'>)</span>
@@ -810,6 +835,150 @@ button_to, so it can be used inside forms.</p>
810
835
  </td>
811
836
  </tr>
812
837
  </table>
838
+ </div>
839
+
840
+ <div class="method_details ">
841
+ <h3 class="signature " id="button_to_external-instance_method">
842
+
843
+ - (<tt>Object</tt>) <strong>button_to_external</strong>(content, url, options = {})
844
+
845
+
846
+
847
+
848
+
849
+ </h3><div class="docstring">
850
+ <div class="discussion">
851
+
852
+ <p>This is identical to the built-in Rails button_to() in every way except
853
+ that it will work inside an existing form. Instead, it appends a form to
854
+ the body, and uses a click handler to submit it. This does not support the
855
+ :remote option - instead, use <span class='object_link'><a href="#button_to_ajax-instance_method" title="JqrHelpers::Helpers#button_to_ajax (method)">#button_to_ajax</a></span>.</p>
856
+
857
+
858
+ </div>
859
+ </div>
860
+ <div class="tags">
861
+ <p class="tag_title">Parameters:</p>
862
+ <ul class="param">
863
+
864
+ <li>
865
+
866
+ <span class='name'>content</span>
867
+
868
+
869
+ <span class='type'>(<tt>String</tt>)</span>
870
+
871
+
872
+
873
+ &mdash;
874
+ <div class='inline'>
875
+ <p>the text of the button.</p>
876
+ </div>
877
+
878
+ </li>
879
+
880
+ <li>
881
+
882
+ <span class='name'>url</span>
883
+
884
+
885
+ <span class='type'>(<tt>String|Hash</tt>)</span>
886
+
887
+
888
+
889
+ &mdash;
890
+ <div class='inline'>
891
+ <p>the URL (or URL hash) the button should go to.</p>
892
+ </div>
893
+
894
+ </li>
895
+
896
+ <li>
897
+
898
+ <span class='name'>options</span>
899
+
900
+
901
+ <span class='type'>(<tt>Hash</tt>)</span>
902
+
903
+
904
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
905
+
906
+
907
+ &mdash;
908
+ <div class='inline'>
909
+ <p>HTML Options to pass to the button.</p>
910
+ </div>
911
+
912
+ </li>
913
+
914
+ </ul>
915
+
916
+
917
+ </div><table class="source_code">
918
+ <tr>
919
+ <td>
920
+ <pre class="lines">
921
+
922
+
923
+ 324
924
+ 325
925
+ 326
926
+ 327
927
+ 328
928
+ 329
929
+ 330
930
+ 331
931
+ 332
932
+ 333
933
+ 334
934
+ 335
935
+ 336
936
+ 337
937
+ 338
938
+ 339
939
+ 340
940
+ 341
941
+ 342
942
+ 343
943
+ 344
944
+ 345
945
+ 346
946
+ 347
947
+ 348
948
+ 349</pre>
949
+ </td>
950
+ <td>
951
+ <pre class="code"><span class="info file"># File 'lib/jqr-helpers/helpers.rb', line 324</span>
952
+
953
+ <span class='kw'>def</span> <span class='id identifier rubyid_button_to_external'>button_to_external</span><span class='lparen'>(</span><span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
954
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:disabled</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>disabled</span><span class='tstring_end'>'</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:disabled</span><span class='rparen'>)</span>
955
+ <span class='id identifier rubyid_method'>method</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:method</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>post</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span>
956
+ <span class='id identifier rubyid_confirm'>confirm</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:confirm</span><span class='rparen'>)</span>
957
+ <span class='id identifier rubyid_disable_with'>disable_with</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:disable_with</span><span class='rparen'>)</span>
958
+
959
+ <span class='id identifier rubyid_token_name'>token_name</span> <span class='op'>=</span> <span class='id identifier rubyid_token_value'>token_value</span> <span class='op'>=</span> <span class='kw'>nil</span>
960
+ <span class='kw'>if</span> <span class='qwords_beg'>%w(</span><span class='tstring_content'>post</span><span class='words_sep'> </span><span class='tstring_content'>put</span><span class='words_sep'>)</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_protect_against_forgery?'>protect_against_forgery?</span>
961
+ <span class='id identifier rubyid_token_name'>token_name</span> <span class='op'>=</span> <span class='id identifier rubyid_request_forgery_protection_token'>request_forgery_protection_token</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
962
+ <span class='id identifier rubyid_token_value'>token_value</span> <span class='op'>=</span> <span class='id identifier rubyid_form_authenticity_token'>form_authenticity_token</span>
963
+ <span class='kw'>end</span>
964
+ <span class='id identifier rubyid_url'>url</span> <span class='op'>=</span> <span class='id identifier rubyid_url_for'>url_for</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_url'>url</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
965
+
966
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>data-confirm</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_confirm'>confirm</span> <span class='kw'>if</span> <span class='id identifier rubyid_confirm'>confirm</span>
967
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>data-disable-with</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_disable_with'>disable_with</span> <span class='kw'>if</span> <span class='id identifier rubyid_disable_with'>disable_with</span>
968
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>data-method</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_method'>method</span> <span class='kw'>if</span> <span class='id identifier rubyid_method'>method</span>
969
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>data-url</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_url'>url</span>
970
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:class</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
971
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:class</span><span class='rbracket'>]</span> <span class='op'>&lt;&lt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> ujs-external-button</span><span class='tstring_end'>'</span></span>
972
+ <span class='kw'>if</span> <span class='id identifier rubyid_token_name'>token_name</span>
973
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>data-token-name</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_token_name'>token_name</span>
974
+ <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>data-token-value</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_token_value'>token_value</span>
975
+ <span class='kw'>end</span>
976
+
977
+ <span class='id identifier rubyid_content_tag'>content_tag</span><span class='lparen'>(</span><span class='symbol'>:button</span><span class='comma'>,</span> <span class='id identifier rubyid_content'>content</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
978
+ <span class='kw'>end</span></pre>
979
+ </td>
980
+ </tr>
981
+ </table>
813
982
  </div>
814
983
 
815
984
  <div class="method_details ">
@@ -2299,23 +2468,23 @@ selector.</p>
2299
2468
  <pre class="lines">
2300
2469
 
2301
2470
 
2302
- 391
2303
- 392
2304
- 393
2305
- 394
2306
- 395
2307
- 396
2308
- 397
2309
- 398
2310
- 399
2311
- 400
2312
- 401
2313
- 402
2314
- 403
2315
- 404</pre>
2471
+ 425
2472
+ 426
2473
+ 427
2474
+ 428
2475
+ 429
2476
+ 430
2477
+ 431
2478
+ 432
2479
+ 433
2480
+ 434
2481
+ 435
2482
+ 436
2483
+ 437
2484
+ 438</pre>
2316
2485
  </td>
2317
2486
  <td>
2318
- <pre class="code"><span class="info file"># File 'lib/jqr-helpers/helpers.rb', line 391</span>
2487
+ <pre class="code"><span class="info file"># File 'lib/jqr-helpers/helpers.rb', line 425</span>
2319
2488
 
2320
2489
  <span class='kw'>def</span> <span class='id identifier rubyid_will_paginate_ajax'>will_paginate_ajax</span><span class='lparen'>(</span><span class='id identifier rubyid_collection'>collection</span><span class='comma'>,</span> <span class='id identifier rubyid_to_update'>to_update</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
2321
2490
  <span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='const'>AjaxLinkRenderer</span><span class='rparen'>)</span>
@@ -2341,7 +2510,7 @@ selector.</p>
2341
2510
  </div>
2342
2511
 
2343
2512
  <div id="footer">
2344
- Generated on Sat Jan 4 18:53:11 2014 by
2513
+ Generated on Thu Jan 30 16:04:14 2014 by
2345
2514
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2346
2515
  0.8.7.3 (ruby-1.9.3).
2347
2516
  </div>
@@ -92,7 +92,7 @@
92
92
  <dt id="VERSION-constant" class="">VERSION =
93
93
 
94
94
  </dt>
95
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.0.20</span><span class='tstring_end'>'</span></span></pre></dd>
95
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.0.27</span><span class='tstring_end'>'</span></span></pre></dd>
96
96
 
97
97
  </dl>
98
98
 
@@ -108,7 +108,7 @@
108
108
  </div>
109
109
 
110
110
  <div id="footer">
111
- Generated on Sat Jan 4 18:53:11 2014 by
111
+ Generated on Thu Jan 30 16:04:14 2014 by
112
112
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
113
113
  0.8.7.3 (ruby-1.9.3).
114
114
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Sat Jan 4 18:53:11 2014 by
117
+ Generated on Thu Jan 30 16:04:14 2014 by
118
118
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.8.7.3 (ruby-1.9.3).
120
120
  </div>
data/doc/JqrHelpers.html CHANGED
@@ -110,7 +110,7 @@
110
110
  </div>
111
111
 
112
112
  <div id="footer">
113
- Generated on Sat Jan 4 18:53:11 2014 by
113
+ Generated on Thu Jan 30 16:04:13 2014 by
114
114
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
115
115
  0.8.7.3 (ruby-1.9.3).
116
116
  </div>
data/doc/_index.html CHANGED
@@ -174,7 +174,7 @@
174
174
  </div>
175
175
 
176
176
  <div id="footer">
177
- Generated on Sat Jan 4 18:53:11 2014 by
177
+ Generated on Thu Jan 30 16:04:13 2014 by
178
178
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
179
179
  0.8.7.3 (ruby-1.9.3).
180
180
  </div>
data/doc/index.html CHANGED
@@ -174,7 +174,7 @@
174
174
  </div>
175
175
 
176
176
  <div id="footer">
177
- Generated on Sat Jan 4 18:53:11 2014 by
177
+ Generated on Thu Jan 30 16:04:13 2014 by
178
178
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
179
179
  0.8.7.3 (ruby-1.9.3).
180
180
  </div>
data/doc/method_list.html CHANGED
@@ -66,96 +66,102 @@
66
66
 
67
67
 
68
68
  <li class="r2 ">
69
- <span class='object_link'><a href="JqrHelpers/Helpers.html#button_to_remote_dialog-instance_method" title="JqrHelpers::Helpers#button_to_remote_dialog (method)">#button_to_remote_dialog</a></span>
69
+ <span class='object_link'><a href="JqrHelpers/Helpers.html#button_to_external-instance_method" title="JqrHelpers::Helpers#button_to_external (method)">#button_to_external</a></span>
70
70
  <small>JqrHelpers::Helpers</small>
71
71
  </li>
72
72
 
73
73
 
74
74
  <li class="r1 ">
75
- <span class='object_link'><a href="JqrHelpers/Helpers.html#buttonset-instance_method" title="JqrHelpers::Helpers#buttonset (method)">#buttonset</a></span>
75
+ <span class='object_link'><a href="JqrHelpers/Helpers.html#button_to_remote_dialog-instance_method" title="JqrHelpers::Helpers#button_to_remote_dialog (method)">#button_to_remote_dialog</a></span>
76
76
  <small>JqrHelpers::Helpers</small>
77
77
  </li>
78
78
 
79
79
 
80
80
  <li class="r2 ">
81
- <span class='object_link'><a href="JqrHelpers/Helpers.html#confirm_button-instance_method" title="JqrHelpers::Helpers#confirm_button (method)">#confirm_button</a></span>
81
+ <span class='object_link'><a href="JqrHelpers/Helpers.html#buttonset-instance_method" title="JqrHelpers::Helpers#buttonset (method)">#buttonset</a></span>
82
82
  <small>JqrHelpers::Helpers</small>
83
83
  </li>
84
84
 
85
85
 
86
86
  <li class="r1 ">
87
+ <span class='object_link'><a href="JqrHelpers/Helpers.html#confirm_button-instance_method" title="JqrHelpers::Helpers#confirm_button (method)">#confirm_button</a></span>
88
+ <small>JqrHelpers::Helpers</small>
89
+ </li>
90
+
91
+
92
+ <li class="r2 ">
87
93
  <span class='object_link'><a href="JqrHelpers/Generators/InstallGenerator.html#copy_files-instance_method" title="JqrHelpers::Generators::InstallGenerator#copy_files (method)">#copy_files</a></span>
88
94
  <small>JqrHelpers::Generators::InstallGenerator</small>
89
95
  </li>
90
96
 
91
97
 
92
- <li class="r2 ">
98
+ <li class="r1 ">
93
99
  <span class='object_link'><a href="JqrHelpers/Helpers.html#date_picker_tag-instance_method" title="JqrHelpers::Helpers#date_picker_tag (method)">#date_picker_tag</a></span>
94
100
  <small>JqrHelpers::Helpers</small>
95
101
  </li>
96
102
 
97
103
 
98
- <li class="r1 ">
104
+ <li class="r2 ">
99
105
  <span class='object_link'><a href="JqrHelpers/Helpers.html#dialog_title-instance_method" title="JqrHelpers::Helpers#dialog_title (method)">#dialog_title</a></span>
100
106
  <small>JqrHelpers::Helpers</small>
101
107
  </li>
102
108
 
103
109
 
104
- <li class="r2 ">
110
+ <li class="r1 ">
105
111
  <span class='object_link'><a href="JqrHelpers/Helpers.html#form_for_ajax-instance_method" title="JqrHelpers::Helpers#form_for_ajax (method)">#form_for_ajax</a></span>
106
112
  <small>JqrHelpers::Helpers</small>
107
113
  </li>
108
114
 
109
115
 
110
- <li class="r1 ">
116
+ <li class="r2 ">
111
117
  <span class='object_link'><a href="JqrHelpers/Helpers.html#form_tag_ajax-instance_method" title="JqrHelpers::Helpers#form_tag_ajax (method)">#form_tag_ajax</a></span>
112
118
  <small>JqrHelpers::Helpers</small>
113
119
  </li>
114
120
 
115
121
 
116
- <li class="r2 ">
122
+ <li class="r1 ">
117
123
  <span class='object_link'><a href="JqrHelpers/Helpers/PanelRenderer.html#initialize-instance_method" title="JqrHelpers::Helpers::PanelRenderer#initialize (method)">#initialize</a></span>
118
124
  <small>JqrHelpers::Helpers::PanelRenderer</small>
119
125
  </li>
120
126
 
121
127
 
122
- <li class="r1 ">
128
+ <li class="r2 ">
123
129
  <span class='object_link'><a href="JqrHelpers/Helpers.html#link_to_ajax-instance_method" title="JqrHelpers::Helpers#link_to_ajax (method)">#link_to_ajax</a></span>
124
130
  <small>JqrHelpers::Helpers</small>
125
131
  </li>
126
132
 
127
133
 
128
- <li class="r2 ">
134
+ <li class="r1 ">
129
135
  <span class='object_link'><a href="JqrHelpers/Helpers.html#link_to_dialog-instance_method" title="JqrHelpers::Helpers#link_to_dialog (method)">#link_to_dialog</a></span>
130
136
  <small>JqrHelpers::Helpers</small>
131
137
  </li>
132
138
 
133
139
 
134
- <li class="r1 ">
140
+ <li class="r2 ">
135
141
  <span class='object_link'><a href="JqrHelpers/Helpers.html#link_to_remote_dialog-instance_method" title="JqrHelpers::Helpers#link_to_remote_dialog (method)">#link_to_remote_dialog</a></span>
136
142
  <small>JqrHelpers::Helpers</small>
137
143
  </li>
138
144
 
139
145
 
140
- <li class="r2 ">
146
+ <li class="r1 ">
141
147
  <span class='object_link'><a href="JqrHelpers/Helpers/PanelRenderer.html#panel-instance_method" title="JqrHelpers::Helpers::PanelRenderer#panel (method)">#panel</a></span>
142
148
  <small>JqrHelpers::Helpers::PanelRenderer</small>
143
149
  </li>
144
150
 
145
151
 
146
- <li class="r1 ">
152
+ <li class="r2 ">
147
153
  <span class='object_link'><a href="JqrHelpers/Helpers/PanelRenderer.html#panels-instance_method" title="JqrHelpers::Helpers::PanelRenderer#panels (method)">#panels</a></span>
148
154
  <small>JqrHelpers::Helpers::PanelRenderer</small>
149
155
  </li>
150
156
 
151
157
 
152
- <li class="r2 ">
158
+ <li class="r1 ">
153
159
  <span class='object_link'><a href="JqrHelpers/Helpers.html#tab_container-instance_method" title="JqrHelpers::Helpers#tab_container (method)">#tab_container</a></span>
154
160
  <small>JqrHelpers::Helpers</small>
155
161
  </li>
156
162
 
157
163
 
158
- <li class="r1 ">
164
+ <li class="r2 ">
159
165
  <span class='object_link'><a href="JqrHelpers/Helpers.html#will_paginate_ajax-instance_method" title="JqrHelpers::Helpers#will_paginate_ajax (method)">#will_paginate_ajax</a></span>
160
166
  <small>JqrHelpers::Helpers</small>
161
167
  </li>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Sat Jan 4 18:53:11 2014 by
106
+ Generated on Thu Jan 30 16:04:13 2014 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.3 (ruby-1.9.3).
109
109
  </div>
data/jqr-helpers.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jqr-helpers'
3
3
  s.require_paths = %w(. lib lib/jqr-helpers)
4
- s.version = '1.0.26'
5
- s.date = '2014-01-20'
4
+ s.version = '1.0.27'
5
+ s.date = '2014-01-30'
6
6
  s.summary = 'Helpers to print unobtrusive jQuery-UI tags.'
7
7
  s.description = <<-EOF
8
8
  This gem adds helper methods to create unobtrusive jQuery code. It outputs
@@ -314,6 +314,40 @@ module JqrHelpers
314
314
  content_tag(:div, raw(content), html_options)
315
315
  end
316
316
 
317
+ # This is identical to the built-in Rails button_to() in every way except
318
+ # that it will work inside an existing form. Instead, it appends a form
319
+ # to the body, and uses a click handler to submit it.
320
+ # This does not support the :remote option - instead, use {#button_to_ajax}.
321
+ # @param content [String] the text of the button.
322
+ # @param url [String|Hash] the URL (or URL hash) the button should go to.
323
+ # @param options [Hash] HTML Options to pass to the button.
324
+ def button_to_external(content, url, options={})
325
+ options[:disabled] = 'disabled' if options.delete(:disabled)
326
+ method = (options.delete(:method) || 'post').to_s.downcase
327
+ confirm = options.delete(:confirm)
328
+ disable_with = options.delete(:disable_with)
329
+
330
+ token_name = token_value = nil
331
+ if %w(post put).include?(method) && protect_against_forgery?
332
+ token_name = request_forgery_protection_token.to_s
333
+ token_value = form_authenticity_token
334
+ end
335
+ url = url_for(url) if url.is_a?(Hash)
336
+
337
+ options['data-confirm'] = confirm if confirm
338
+ options['data-disable-with'] = disable_with if disable_with
339
+ options['data-method'] = method if method
340
+ options['data-url'] = url
341
+ options[:class] ||= ''
342
+ options[:class] << ' ujs-external-button'
343
+ if token_name
344
+ options['data-token-name'] = token_name
345
+ options['data-token-value'] = token_value
346
+ end
347
+
348
+ content_tag(:button, content, options)
349
+ end
350
+
317
351
  # Generate a random string for IDs.
318
352
  # @return [String]
319
353
  def self._random_string
@@ -1,5 +1,5 @@
1
1
  module JqrHelpers
2
2
  module Rails
3
- VERSION = '1.0.26'
3
+ VERSION = '1.0.27'
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: jqr-helpers
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.26
5
+ version: 1.0.27
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Orner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-20 00:00:00.000000000 Z
12
+ date: 2014-01-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails