eita-jrails 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -5
- data/lib/action_view/helpers/generator.rb +48 -0
- data/lib/action_view/helpers/jquery_helper.rb +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac5315a66f733fa62593b837fd866863155ad6d6
|
4
|
+
data.tar.gz: b6de086369229f39a5656cb4ae76806c3fa31fc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 201ff9009860f096014f75c7890e1be8f2f4bb708d444e4bf54148ad9305cbd2337e394b443ee02cd5b3514d195c37e2009fabcfb3d7194d15a997becedbc98f
|
7
|
+
data.tar.gz: 6c6dee6926adc9f41a20c468d8273c3df34d06592e1f785eaeacd2aac2b73460c06a252fdee84a4c2239b6a76d98d2e2ba1d234c663cb7b482640c8f6231eed6
|
data/README.md
CHANGED
@@ -1,18 +1,19 @@
|
|
1
|
-
|
1
|
+
jRails
|
2
|
+
======
|
2
3
|
|
3
4
|
jRails is a drop-in jQuery replacement for the prototope-rails gem, so that you can still use RJS and Jquery/JqueryUi helpers with the same API as Prototype/Scryptaculous helpers
|
4
5
|
|
5
6
|
Support Rails 3.1+
|
6
7
|
|
7
|
-
== Resources
|
8
|
-
|
9
8
|
Install
|
9
|
+
-------
|
10
10
|
|
11
11
|
Add to your Gemfile
|
12
12
|
|
13
|
-
|
13
|
+
gem 'eita-jrails'
|
14
14
|
|
15
|
-
Project
|
15
|
+
Project
|
16
|
+
-------
|
16
17
|
|
17
18
|
* https://github.com/coletivoEITA/jrails.git
|
18
19
|
|
@@ -320,6 +320,7 @@ module ActionView
|
|
320
320
|
end
|
321
321
|
|
322
322
|
private
|
323
|
+
|
323
324
|
def jquery_id(id)
|
324
325
|
id.to_s.count('#.*,>+~:[/ ') == 0 ? "##{id}" : id
|
325
326
|
end
|
@@ -328,6 +329,53 @@ module ActionView
|
|
328
329
|
Array(ids).map{|id| jquery_id(id)}.join(',')
|
329
330
|
end
|
330
331
|
|
332
|
+
def loop_on_multiple_args(method, ids)
|
333
|
+
record(ids.size>1 ?
|
334
|
+
"#{javascript_object_for(ids)}.each(#{method})" :
|
335
|
+
"#{method}(#{javascript_object_for(ids.first)})")
|
336
|
+
end
|
337
|
+
|
338
|
+
def page
|
339
|
+
self
|
340
|
+
end
|
341
|
+
|
342
|
+
def record(line)
|
343
|
+
line = "#{line.to_s.chomp.gsub(/\;\z/, '')};"
|
344
|
+
self << line
|
345
|
+
line
|
346
|
+
end
|
347
|
+
|
348
|
+
def render(*options)
|
349
|
+
with_formats(:html) do
|
350
|
+
case option = options.first
|
351
|
+
when Hash
|
352
|
+
@context.render(*options)
|
353
|
+
else
|
354
|
+
option.to_s
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
|
359
|
+
def with_formats(*args)
|
360
|
+
return yield unless @context
|
361
|
+
|
362
|
+
lookup = @context.lookup_context
|
363
|
+
begin
|
364
|
+
old_formats, lookup.formats = lookup.formats, args
|
365
|
+
yield
|
366
|
+
ensure
|
367
|
+
lookup.formats = old_formats
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
def block_to_function(block)
|
372
|
+
generator = self.class.new(@context, &block)
|
373
|
+
literal("function() { #{generator.to_s} }")
|
374
|
+
end
|
375
|
+
|
376
|
+
def method_missing(method, *arguments)
|
377
|
+
JavaScriptProxy.new(self, method.to_s.camelize)
|
378
|
+
end
|
331
379
|
end
|
332
380
|
end
|
333
381
|
|
@@ -444,6 +444,30 @@ module ActionView
|
|
444
444
|
build_observer(form_id, options)
|
445
445
|
end
|
446
446
|
|
447
|
+
# Yields a JavaScriptGenerator and returns the generated JavaScript code.
|
448
|
+
# Use this to update multiple elements on a page in an Ajax response.
|
449
|
+
# See JavaScriptGenerator for more information.
|
450
|
+
#
|
451
|
+
# Example:
|
452
|
+
#
|
453
|
+
# update_page do |page|
|
454
|
+
# page.hide 'spinner'
|
455
|
+
# end
|
456
|
+
def update_page(&block)
|
457
|
+
JavaScriptGenerator.new(self, &block).to_s.html_safe
|
458
|
+
end
|
459
|
+
|
460
|
+
# Works like update_page but wraps the generated JavaScript in a
|
461
|
+
# <tt>\<script></tt> tag. Use this to include generated JavaScript in an
|
462
|
+
# ERb template. See JavaScriptGenerator for more information.
|
463
|
+
#
|
464
|
+
# +html_options+ may be a hash of <tt>\<script></tt> attributes to be
|
465
|
+
# passed to ActionView::Helpers::JavaScriptHelper#javascript_tag.
|
466
|
+
def update_page_tag(html_options = {}, &block)
|
467
|
+
javascript_tag update_page(&block), html_options
|
468
|
+
end
|
469
|
+
|
470
|
+
|
447
471
|
protected
|
448
472
|
def options_for_ajax(options)
|
449
473
|
js_options = build_callbacks(options)
|