formatted_form 1.0.1 → 1.0.2
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.md +18 -1
- data/VERSION +1 -1
- data/formatted_form.gemspec +8 -5
- data/lib/formatted_form/builder.rb +14 -21
- data/lib/formatted_form/engine.rb +1 -1
- data/lib/generators/formatted_form/javascripts/javascripts_generator.rb +11 -0
- data/lib/generators/formatted_form/stylesheets/stylesheets_generator.rb +11 -0
- data/templates/javascripts/formatted_form.js +17 -0
- data/templates/stylesheets/formatted_form.sass +117 -0
- metadata +8 -12
data/README.md
CHANGED
@@ -18,6 +18,23 @@ A Rails form builder to simplify your forms and keep your views clean.
|
|
18
18
|
|
19
19
|
bundle install
|
20
20
|
|
21
|
+
### 3. Generate the javascript file
|
22
|
+
|
23
|
+
rails g formatted_form:javascripts
|
24
|
+
|
25
|
+
This will create `public/javascripts/formatted_form.js` and you should load it using:
|
26
|
+
|
27
|
+
javascript_include_tag 'formatted_form'
|
28
|
+
|
29
|
+
### 4. (Optionaly) generate the stylesshet (SASS) file
|
30
|
+
|
31
|
+
rails g formatted_form:stylesheets
|
32
|
+
|
33
|
+
This will create `app/views/stylesheets/formatted_form.sass` and you can move it to wherever you keep your SASS files and load it using:
|
34
|
+
|
35
|
+
stylesheet_link_tag 'formatted_form'
|
36
|
+
|
37
|
+
|
21
38
|
|
22
39
|
## Usage (with haml)
|
23
40
|
|
@@ -25,5 +42,5 @@ A Rails form builder to simplify your forms and keep your views clean.
|
|
25
42
|
= f.text_field :email, :label => 'Email address'
|
26
43
|
= f.password_field :password
|
27
44
|
= f.check_box :remember_me, :label => 'Remember me when I come back'
|
28
|
-
= f.submit 'Log In'
|
45
|
+
= f.submit 'Log In', :change_to_text => 'Logging you in ...', :image => true
|
29
46
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/formatted_form.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{formatted_form}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jack Neto"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-04-20}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{jack@theworkinggroup.ca}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,16 +27,19 @@ Gem::Specification.new do |s|
|
|
27
27
|
"formatted_form.gemspec",
|
28
28
|
"lib/formatted_form.rb",
|
29
29
|
"lib/formatted_form/builder.rb",
|
30
|
-
"lib/formatted_form/engine.rb"
|
30
|
+
"lib/formatted_form/engine.rb",
|
31
|
+
"lib/generators/formatted_form/javascripts/javascripts_generator.rb",
|
32
|
+
"lib/generators/formatted_form/stylesheets/stylesheets_generator.rb",
|
33
|
+
"templates/javascripts/formatted_form.js",
|
34
|
+
"templates/stylesheets/formatted_form.sass"
|
31
35
|
]
|
32
36
|
s.homepage = %q{http://github.com/twg/formatted_form}
|
33
37
|
s.licenses = ["MIT"]
|
34
38
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.
|
39
|
+
s.rubygems_version = %q{1.5.2}
|
36
40
|
s.summary = %q{A Rails form builder to simplify you forms}
|
37
41
|
|
38
42
|
if s.respond_to? :specification_version then
|
39
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
43
|
s.specification_version = 3
|
41
44
|
|
42
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -56,31 +56,24 @@ module FormattedForm
|
|
56
56
|
|
57
57
|
end
|
58
58
|
|
59
|
+
# f.submit 'Log In', :change_to_text => 'Logging you in ...'
|
59
60
|
def submit(value, options={}, &block)
|
60
61
|
cancel_link = @template.capture(&block) if block_given?
|
61
62
|
cancel_link ||= options[:cancel_url] ? ' or ' + options.delete(:cancel_url) : ''
|
62
|
-
|
63
|
-
options[:onclick] = "$(this).parent().next().css('display', 'block');$(this).parent().hide();"
|
64
|
-
end
|
65
|
-
if options[:image_button] == true
|
66
|
-
submit_id = Time.now.usec
|
67
|
-
out = @template.content_tag(:div,
|
68
|
-
%{
|
69
|
-
#{super(value, options.merge(:style=>'visibility:hidden;position: absolute', :id => submit_id)).html_safe}
|
70
|
-
<a class="red_button" href="" onclick="$('##{submit_id}').closest('form').submit();return false"><span>#{value}</span></a>
|
71
|
-
#{cancel_link.html_safe}
|
72
|
-
}.html_safe, :class => 'form_element submit_element').html_safe
|
73
|
-
|
74
|
-
else
|
75
|
-
out = @template.content_tag(:div, super(value, options) + cancel_link.html_safe, :class => 'form_element submit_element').html_safe
|
76
|
-
end
|
63
|
+
change_to_text = options.delete(:change_to_text)
|
77
64
|
|
78
|
-
if
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
65
|
+
out = @template.content_tag(:div, :class => "form_element submit#{' change_to_text' if change_to_text}") do
|
66
|
+
if options.delete(:image)
|
67
|
+
content = super(value, options.merge(:style=>'visibility:hidden;position: absolute'))
|
68
|
+
content << @template.link_to(@template.content_tag(:span, value), "#", :class => 'submit_image')
|
69
|
+
content << cancel_link.html_safe
|
70
|
+
else
|
71
|
+
super(value, options) + cancel_link.html_safe
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
if change_to_text
|
76
|
+
out << @template.content_tag(:div, change_to_text, :class => 'form_element submit_text')
|
84
77
|
end
|
85
78
|
out.html_safe
|
86
79
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module FormattedForm
|
2
|
+
class JavascriptsGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
source_root File.expand_path('../../../../..', __FILE__)
|
5
|
+
|
6
|
+
def generate_javascripts
|
7
|
+
copy_file 'templates/javascripts/formatted_form.js', 'public/javascripts/formatted_form.js'
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module FormattedForm
|
2
|
+
class StylesheetsGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
source_root File.expand_path('../../../../..', __FILE__)
|
5
|
+
|
6
|
+
def generate_stylesheets
|
7
|
+
copy_file 'templates/stylesheets/formatted_form.sass', 'app/views/stylesheets/formatted_form.sass'
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// Reset the state of the submit button
|
2
|
+
$(document).ready(function() {
|
3
|
+
$('.form_element.submit.change_to_text').show();
|
4
|
+
$('.submit_text').hide();
|
5
|
+
});
|
6
|
+
|
7
|
+
// Shows the submit button replacement text on click
|
8
|
+
$('.form_element.submit.change_to_text input[type=submit]').live('click', function(){
|
9
|
+
$(this).parent().next().show();
|
10
|
+
$(this).parent().hide();
|
11
|
+
})
|
12
|
+
|
13
|
+
// Activates the submit button click when clicking the image button
|
14
|
+
$('.form_element.submit a.submit_image').live('click', function(){
|
15
|
+
$(this).prev().click();
|
16
|
+
return false;
|
17
|
+
})
|
@@ -0,0 +1,117 @@
|
|
1
|
+
form.formatted
|
2
|
+
font: 13px/20px Trebuchet MS,serif
|
3
|
+
margin: auto
|
4
|
+
background: #eee
|
5
|
+
border: solid #ddd 2px
|
6
|
+
color: #000
|
7
|
+
width: 400px
|
8
|
+
padding: 10px 20px
|
9
|
+
-webkit-box-shadow: 0 1px 4px rgba(0,0,0,0.3)
|
10
|
+
-moz-box-shadow: 0 1px 4px rgba(0,0,0,0.3)
|
11
|
+
box-shadow: 0 1px 4px rgba(0,0,0,0.3)
|
12
|
+
|
13
|
+
// --- Form element container ---
|
14
|
+
.form_element
|
15
|
+
overflow: hidden
|
16
|
+
_height: 1%
|
17
|
+
margin-bottom: 1px
|
18
|
+
padding: 5px 0px
|
19
|
+
.label
|
20
|
+
font: 10px/30px Trebuchet MS,serif
|
21
|
+
color: #6E666E
|
22
|
+
text-transform: uppercase
|
23
|
+
letter-spacing: 1px
|
24
|
+
float: left
|
25
|
+
width: 120px
|
26
|
+
text-align: right
|
27
|
+
.value
|
28
|
+
margin-left: 130px
|
29
|
+
.errors
|
30
|
+
font: 9px/12px Trebuchet MS, serif
|
31
|
+
color: #BE1E2D
|
32
|
+
.description
|
33
|
+
clear: both
|
34
|
+
font: italic 10px/12px Trebuchet MS, serif
|
35
|
+
|
36
|
+
// --- Text and password fields ---
|
37
|
+
.form_element.text_field, .form_element.password_field
|
38
|
+
input
|
39
|
+
width: 250px
|
40
|
+
border: 1px solid #a6a8ab
|
41
|
+
padding: 5px
|
42
|
+
width: 90%
|
43
|
+
|
44
|
+
// --- Text area ---
|
45
|
+
.form_element.text_area
|
46
|
+
textarea
|
47
|
+
width: 250px
|
48
|
+
height: 150px
|
49
|
+
|
50
|
+
// --- Check box and Radio button ---
|
51
|
+
.form_element.check_box, .form_element.radio_button
|
52
|
+
.value
|
53
|
+
label
|
54
|
+
font: 10px/20px Trebuchet MS,serif
|
55
|
+
color: #6E666E
|
56
|
+
text-transform: uppercase
|
57
|
+
margin-right: 10px
|
58
|
+
letter-spacing: 0.1em
|
59
|
+
input
|
60
|
+
margin-right: 5px
|
61
|
+
.fieldWithErrors
|
62
|
+
float: left
|
63
|
+
|
64
|
+
.form_element.radio_button
|
65
|
+
.value
|
66
|
+
.option
|
67
|
+
float: left
|
68
|
+
|
69
|
+
// --- Submit button ---
|
70
|
+
.form_element.submit
|
71
|
+
padding-left: 130px
|
72
|
+
a.submit_image
|
73
|
+
padding: 5px 10px
|
74
|
+
font: bold 12px/20px helvetica,arial,freesans,clean,sans-serif
|
75
|
+
text-decoration: none
|
76
|
+
color: #333
|
77
|
+
text-shadow: 1px 1px 0 #fff
|
78
|
+
white-space: nowrap
|
79
|
+
border: none
|
80
|
+
overflow: visible
|
81
|
+
background: #ddd
|
82
|
+
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#ffffff',endColorstr='#e1e1e1')
|
83
|
+
background: -webkit-gradient(linear,0% 0,0% 100%,from(#fff),to(#e1e1e1))
|
84
|
+
background: -moz-linear-gradient(-90deg,#fff,#e1e1e1)
|
85
|
+
border-bottom: 1px solid #ebebeb
|
86
|
+
-webkit-border-radius: 4px
|
87
|
+
-moz-border-radius: 4px
|
88
|
+
border-radius: 4px
|
89
|
+
-webkit-box-shadow: 0 1px 4px rgba(0,0,0,0.3)
|
90
|
+
-moz-box-shadow: 0 1px 4px rgba(0,0,0,0.3)
|
91
|
+
box-shadow: 0 1px 4px rgba(0,0,0,0.3)
|
92
|
+
cursor: pointer
|
93
|
+
-webkit-font-smoothing: subpixel-antialiased!important
|
94
|
+
a.submit_image:hover
|
95
|
+
color: #fff
|
96
|
+
text-decoration: none
|
97
|
+
text-shadow: -1px -1px 0 rgba(0,0,0,0.3)
|
98
|
+
border-color: #518cc6
|
99
|
+
border-bottom-color: #2a65a0
|
100
|
+
background: #599bdc
|
101
|
+
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#599bdc',endColorstr='#3072b3')
|
102
|
+
background: -webkit-gradient(linear,left top,left bottom,from(#599bdc),to(#3072b3))
|
103
|
+
background: -moz-linear-gradient(top,#599bdc,#3072b3)
|
104
|
+
|
105
|
+
|
106
|
+
.form_element.submit_text
|
107
|
+
padding-left: 130px
|
108
|
+
font: normal 12px/20px Trebuchet MS,serif
|
109
|
+
|
110
|
+
// --- Form error ---
|
111
|
+
.form_error
|
112
|
+
background-color: #BE1E2D
|
113
|
+
color: #fff
|
114
|
+
text-align: center
|
115
|
+
padding: 10px
|
116
|
+
margin-bottom: 1px
|
117
|
+
font-size: 14px
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatted_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 1.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Jack Neto
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-04-20 00:00:00 -04:00
|
18
14
|
default_executable:
|
19
15
|
dependencies: []
|
20
16
|
|
@@ -39,6 +35,10 @@ files:
|
|
39
35
|
- lib/formatted_form.rb
|
40
36
|
- lib/formatted_form/builder.rb
|
41
37
|
- lib/formatted_form/engine.rb
|
38
|
+
- lib/generators/formatted_form/javascripts/javascripts_generator.rb
|
39
|
+
- lib/generators/formatted_form/stylesheets/stylesheets_generator.rb
|
40
|
+
- templates/javascripts/formatted_form.js
|
41
|
+
- templates/stylesheets/formatted_form.sass
|
42
42
|
has_rdoc: true
|
43
43
|
homepage: http://github.com/twg/formatted_form
|
44
44
|
licenses:
|
@@ -53,21 +53,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
53
|
requirements:
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
56
|
version: "0"
|
59
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
58
|
none: false
|
61
59
|
requirements:
|
62
60
|
- - ">="
|
63
61
|
- !ruby/object:Gem::Version
|
64
|
-
segments:
|
65
|
-
- 0
|
66
62
|
version: "0"
|
67
63
|
requirements: []
|
68
64
|
|
69
65
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.5.2
|
71
67
|
signing_key:
|
72
68
|
specification_version: 3
|
73
69
|
summary: A Rails form builder to simplify you forms
|