rails_javascript_helpers 1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
|
|
1
|
+
require 'rails_javascript_helpers/rails_javascript_helpers'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RailsJavaScriptHelpers
|
2
|
+
# arg:: Object
|
3
|
+
# Does a simple transition on types from Ruby to Javascript.
|
4
|
+
def format_type_to_js(arg)
|
5
|
+
puts '&' * 400
|
6
|
+
case arg
|
7
|
+
when Array
|
8
|
+
"[#{arg.map{|value| format_type_to_js(value)}.join(',')}]"
|
9
|
+
when Hash
|
10
|
+
"{#{arg.map{ |key, value|
|
11
|
+
k = key.is_a?(Symbol) ? key.to_s.camelize.sub(/^./, key.to_s[0,1].downcase) : key.to_s
|
12
|
+
"#{k}:#{format_type_to_js(value)}"
|
13
|
+
}.join(',')}}"
|
14
|
+
when Fixnum
|
15
|
+
arg.to_s
|
16
|
+
when TrueClass
|
17
|
+
arg.to_s
|
18
|
+
when FalseClass
|
19
|
+
arg.to_s
|
20
|
+
when NilClass
|
21
|
+
'null'
|
22
|
+
else
|
23
|
+
arg.to_s =~ %r{^\s*function\s*\(} ? "'#{escape_javascript(arg.to_s)}'" : "'#{escape_javascript(arg.to_s)}'"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# id:: DOM ID of element
|
28
|
+
# Ensure that the DOM ID starts with a '#'
|
29
|
+
# if the provided values is a string starting
|
30
|
+
# with a letter
|
31
|
+
# (Basically compat mode with prototype style)
|
32
|
+
def format_id(id)
|
33
|
+
id.to_s[0,1] =~ /[A-Za-z0-9]/ ? "##{id}" : id
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_javascript_helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: "1.0"
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Chris Roberts
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-06-10 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rails
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 5
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 3
|
32
|
+
version: "2.3"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: JavaScript helpers for rails
|
36
|
+
email: chrisroberts.code@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- lib/rails_javascript_helpers/rails_javascript_helpers.rb
|
45
|
+
- lib/rails_javascript_helpers/version.rb
|
46
|
+
- lib/rails_javascript_helpers.rb
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://github.com/chrisroberts/rails_javascript_helpers
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.6.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Javascript Helpers for Rails
|
81
|
+
test_files: []
|
82
|
+
|