right-rails 0.5.3 → 0.6.0
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.textile +7 -3
- data/Rakefile +19 -0
- data/generators/right_rails/right_rails_generator.rb +8 -0
- data/images/colorpicker.png +0 -0
- data/images/resizable.png +0 -0
- data/javascripts/right-autocompleter-src.js +1 -4
- data/javascripts/right-calendar-src.js +0 -3
- data/javascripts/right-colorpicker-src.js +635 -0
- data/javascripts/right-colorpicker.js +9 -0
- data/javascripts/right-in-edit-src.js +1 -4
- data/javascripts/right-lightbox-src.js +2 -5
- data/javascripts/right-lightbox.js +1 -1
- data/javascripts/right-rails-src.js +29 -5
- data/javascripts/right-rails.js +1 -1
- data/javascripts/right-rater-src.js +1 -4
- data/javascripts/right-resizable-src.js +336 -0
- data/javascripts/right-resizable.js +9 -0
- data/javascripts/right-selectable-src.js +13 -11
- data/javascripts/right-selectable.js +1 -1
- data/javascripts/right-slider-src.js +1 -4
- data/javascripts/right-sortable-src.js +0 -1
- data/javascripts/right-tabs-src.js +2 -5
- data/javascripts/right-tooltips-src.js +19 -11
- data/javascripts/right-tooltips.js +1 -1
- data/javascripts/right-ui-i18n-de.js +8 -2
- data/javascripts/right-ui-i18n-es.js +7 -1
- data/javascripts/right-ui-i18n-fr.js +7 -1
- data/javascripts/right-ui-i18n-hu.js +6 -1
- data/javascripts/right-ui-i18n-jp.js +8 -1
- data/javascripts/right-ui-i18n-nl.js +8 -1
- data/javascripts/right-ui-i18n-pt-br.js +43 -0
- data/javascripts/right-ui-i18n-ru.js +8 -1
- data/javascripts/right-ui-i18n-ua.js +8 -1
- data/javascripts/right-uploader-src.js +1 -4
- data/lib/right_rails/helpers/basic.rb +7 -0
- data/lib/right_rails/helpers/forms.rb +44 -3
- data/lib/right_rails/helpers/misc.rb +55 -16
- data/lib/right_rails/java_script_generator.rb +4 -4
- data/spec/lib/right_rails/helpers/basic_spec.rb +4 -1
- data/spec/lib/right_rails/helpers/forms_spec.rb +10 -0
- data/spec/lib/right_rails/helpers/misc_spec.rb +39 -8
- metadata +11 -4
@@ -10,7 +10,7 @@ module RightRails::Helpers::Misc
|
|
10
10
|
content_tag(:div, text, :class => key)
|
11
11
|
}.sort.join("")
|
12
12
|
|
13
|
-
content_tag(:div, items
|
13
|
+
content_tag(:div, __rjs_hs(items),
|
14
14
|
:id => :flashes, :style => (flash.empty? ? 'display: none' : nil))
|
15
15
|
end
|
16
16
|
|
@@ -36,12 +36,15 @@ module RightRails::Helpers::Misc
|
|
36
36
|
escape = options[:escape].nil? ? true : options[:escape]
|
37
37
|
field = args.first
|
38
38
|
|
39
|
+
|
39
40
|
items = entries.collect{ |entry|
|
40
41
|
entry = entry.send(field) if field
|
41
|
-
|
42
|
+
text = highlight ? highlight(entry, highlight) : escape ? h(entry) : entry
|
43
|
+
|
44
|
+
content_tag :li, __rjs_hs(text)
|
42
45
|
}.join("")
|
43
46
|
|
44
|
-
content_tag :ul, items
|
47
|
+
content_tag :ul, __rjs_hs(items)
|
45
48
|
end
|
46
49
|
|
47
50
|
|
@@ -112,11 +115,13 @@ module RightRails::Helpers::Misc
|
|
112
115
|
content = if tabs_type != :harmonica
|
113
116
|
# tabs list
|
114
117
|
tabs_list = content_tag(:ul,
|
115
|
-
|
116
|
-
|
117
|
-
:
|
118
|
-
|
119
|
-
|
118
|
+
__rjs_hs(
|
119
|
+
@__tabs.collect{ |tab|
|
120
|
+
content_tag(:li, content_tag(:a, tab[:title],
|
121
|
+
:href => tab[:options][:id] ? "##{tab[:options][:id]}" : tab[:options][:url]
|
122
|
+
))
|
123
|
+
}.join("\n")
|
124
|
+
)
|
120
125
|
) + "\n";
|
121
126
|
|
122
127
|
# contents list
|
@@ -124,22 +129,24 @@ module RightRails::Helpers::Misc
|
|
124
129
|
tab[:content] ? content_tag(:li, tab[:content], :id => "#{tab_id_prefix}#{tab[:options][:id]}") + "\n" : ''
|
125
130
|
}.join("")
|
126
131
|
|
127
|
-
content_tag(:ul, tabs_list + bodies_list
|
132
|
+
content_tag(:ul, tabs_list + __rjs_hs(bodies_list), options)
|
128
133
|
else
|
129
134
|
# the harmonicas generator
|
130
135
|
content_tag(:dl,
|
131
|
-
|
132
|
-
|
133
|
-
:
|
134
|
-
|
135
|
-
|
136
|
-
|
136
|
+
__rjs_hs(
|
137
|
+
@__tabs.collect{ |tab|
|
138
|
+
content_tag(:dt, content_tag(:a, tab[:title],
|
139
|
+
:href => tab[:options][:id] ? "##{tab[:options][:id]}" : tab[:options][:url]
|
140
|
+
)) + "\n" +
|
141
|
+
content_tag(:dd, tab[:content] || '', :id => tab[:options][:id] ? "#{tab_id_prefix}#{tab[:options][:id]}" : nil)
|
142
|
+
}.join("\n")
|
143
|
+
),
|
137
144
|
options
|
138
145
|
)
|
139
146
|
|
140
147
|
end
|
141
148
|
|
142
|
-
concat(content + "\n"
|
149
|
+
concat(content + __rjs_hs("\n") + javascript_tag("new Tabs('#{options['id']}');"))
|
143
150
|
end
|
144
151
|
|
145
152
|
def tab(title, options={}, &block)
|
@@ -152,6 +159,31 @@ module RightRails::Helpers::Misc
|
|
152
159
|
}
|
153
160
|
end
|
154
161
|
|
162
|
+
#
|
163
|
+
# The resizable unit helper
|
164
|
+
#
|
165
|
+
# USAGE:
|
166
|
+
# <% resizable(:direction => 'bottom', :minHeight => '100px') do %>
|
167
|
+
# Some content in here
|
168
|
+
# <% end -%>
|
169
|
+
#
|
170
|
+
def resizable(options={}, &block)
|
171
|
+
rightjs_include_module 'resizable'
|
172
|
+
|
173
|
+
tabs_options = rightjs_unit_options(options, RESIZABLE_OPTION_KEYS)
|
174
|
+
options['data-resizable-options'] = tabs_options unless tabs_options == '{}'
|
175
|
+
|
176
|
+
options[:class] ||= ''
|
177
|
+
options[:class] << " right-resizable#{options[:direction] ? "-#{options.delete(:direction)}" : ''}"
|
178
|
+
options[:class].strip!
|
179
|
+
|
180
|
+
concat(content_tag(:div, (
|
181
|
+
content_tag(:div, __rjs_hs(capture(&block)), :class => 'right-resizable-content') +
|
182
|
+
content_tag(:div, '', :class => 'right-resizable-handle')
|
183
|
+
), options
|
184
|
+
))
|
185
|
+
end
|
186
|
+
|
155
187
|
TABS_OPTION_KEYS = %w{
|
156
188
|
idPrefix
|
157
189
|
tabsElement
|
@@ -181,4 +213,11 @@ module RightRails::Helpers::Misc
|
|
181
213
|
mediaHeight
|
182
214
|
}
|
183
215
|
|
216
|
+
RESIZABLE_OPTION_KEYS = %w{
|
217
|
+
minWidth
|
218
|
+
maxWidth
|
219
|
+
minHeight
|
220
|
+
maxHeight
|
221
|
+
}
|
222
|
+
|
184
223
|
end
|
@@ -69,13 +69,13 @@ class RightRails::JavaScriptGenerator
|
|
69
69
|
end
|
70
70
|
|
71
71
|
# builds the record HTML code and then insterts it in place
|
72
|
-
def insert(record)
|
73
|
-
self.RR.insert(record.class.table_name, @util.render(record))
|
72
|
+
def insert(record, position=nil)
|
73
|
+
self.RR.insert(*[record.class.table_name, @util.render(record), position].compact)
|
74
74
|
end
|
75
75
|
|
76
76
|
# generates a script that inserts the record partial, then updates the form and the flashes block
|
77
|
-
def insert_and_care(record)
|
78
|
-
insert(record)
|
77
|
+
def insert_and_care(record, position=nil)
|
78
|
+
insert(record, position)
|
79
79
|
@util.template.instance_variable_set("@#{record.class.table_name.singularize}", record.class.new)
|
80
80
|
replace_form_for(record.class.new)
|
81
81
|
update_flash
|
@@ -69,7 +69,10 @@ describe RightRails::Helpers::Basic do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
after :all do
|
72
|
-
|
72
|
+
# suppressing the warning coz we're being noughty in here and reassign the constant
|
73
|
+
Kernel::silence_warnings do
|
74
|
+
Kernel::RAILS_ENV = 'production'
|
75
|
+
end
|
73
76
|
end
|
74
77
|
|
75
78
|
it "should use the source scripts" do
|
@@ -48,4 +48,14 @@ describe RightRails::Helpers::Forms do
|
|
48
48
|
rater_display(4).should ==
|
49
49
|
%Q{<div class="right-rater right-rater-disabled"><div class="right-rater-glow">★</div><div class="right-rater-glow">★</div><div class="right-rater-glow">★</div><div class="right-rater-glow">★</div><div>★</div></div>}
|
50
50
|
end
|
51
|
+
|
52
|
+
it "should generate a #colorpicker_field_tag" do
|
53
|
+
colorpicker_field_tag('name', '#FF0').should ==
|
54
|
+
%Q{<input id=\"name\" name=\"name\" rel=\"colorpicker\" type=\"text\" value=\"#FF0\" />}
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should generate a #colorpicker_field_tag with options" do
|
58
|
+
colorpicker_field_tag('name', '#FF0', :format => 'rgb').should ==
|
59
|
+
%Q{<input data-colorpicker-options=\"{format:'rgb'}\" id=\"name\" name=\"name\" rel=\"colorpicker\" type=\"text\" value=\"#FF0\" />}
|
60
|
+
end
|
51
61
|
end
|
@@ -7,6 +7,21 @@ describe RightRails::Helpers::Misc do
|
|
7
7
|
include RightRails::Helpers::Basic
|
8
8
|
include RightRails::Helpers::Misc
|
9
9
|
|
10
|
+
# fraking Rails 3 replacement
|
11
|
+
def javascript_tag(script)
|
12
|
+
__rjs_hs(%Q{<script type="text/javascript">\n//<![CDATA[\n#{script}\n//]]>\n</script>})
|
13
|
+
end
|
14
|
+
|
15
|
+
# stubbing those two
|
16
|
+
def capture(&block)
|
17
|
+
return yield()
|
18
|
+
end
|
19
|
+
|
20
|
+
def concat(content)
|
21
|
+
content
|
22
|
+
end
|
23
|
+
|
24
|
+
|
10
25
|
it "should provide the basic #flashes builder" do
|
11
26
|
should_receive(:flash).any_number_of_times.and_return({
|
12
27
|
:warning => "Warning!",
|
@@ -79,19 +94,13 @@ describe RightRails::Helpers::Misc do
|
|
79
94
|
end
|
80
95
|
|
81
96
|
describe "#tabs generator" do
|
82
|
-
def capture(&block)
|
83
|
-
return yield()
|
84
|
-
end
|
85
|
-
|
86
|
-
def concat(content)
|
87
|
-
content
|
88
|
-
end
|
89
|
-
|
90
97
|
it "should generate simple tabs" do
|
91
98
|
tabs(:id => 'my-tabs') {
|
92
99
|
tab("Tab 1", :id => 'tab-1'){ 'content 1' }
|
93
100
|
tab("Tab 2", :id => 'tab-2'){ 'content 2' }
|
94
101
|
}.should == %Q{<ul id=\"my-tabs\"><ul><li><a href=\"#tab-1\">Tab 1</a></li>\n<li><a href=\"#tab-2\">Tab 2</a></li></ul>\n<li id=\"tab-1\">content 1</li>\n<li id=\"tab-2\">content 2</li>\n</ul>\n<script type=\"text/javascript\">\n//<![CDATA[\nnew Tabs('my-tabs');\n//]]>\n</script>}
|
102
|
+
|
103
|
+
@_right_scripts.should == ['tabs']
|
95
104
|
end
|
96
105
|
|
97
106
|
it "should generate tabs with id prefix" do
|
@@ -122,4 +131,26 @@ describe RightRails::Helpers::Misc do
|
|
122
131
|
}.should == %Q{<dl id=\"my-tabs\"><dt><a href=\"#tab-1\">Tab 1</a></dt>\n<dd id=\"tab-1\">content 1</dd>\n<dt><a href=\"#tab-2\">Tab 2</a></dt>\n<dd id=\"tab-2\">content 2</dd></dl>\n<script type=\"text/javascript\">\n//<![CDATA[\nnew Tabs('my-tabs');\n//]]>\n</script>}
|
123
132
|
end
|
124
133
|
end
|
134
|
+
|
135
|
+
describe "#resizable generator" do
|
136
|
+
it "should generate a simple resizable" do
|
137
|
+
resizable {
|
138
|
+
"bla bla bla"
|
139
|
+
}.should == %Q{<div class=\"right-resizable\"><div class=\"right-resizable-content\">bla bla bla</div><div class=\"right-resizable-handle\"></div></div>}
|
140
|
+
|
141
|
+
@_right_scripts.should == ['resizable']
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should generate a resizable with directions" do
|
145
|
+
resizable(:direction => :bottom) {
|
146
|
+
'boo'
|
147
|
+
}.should == %Q{<div class=\"right-resizable-bottom\"><div class=\"right-resizable-content\">boo</div><div class=\"right-resizable-handle\"></div></div>}
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should generate a resizable with constraints" do
|
151
|
+
resizable(:min_width => 100, :maxHeight => '10em'){
|
152
|
+
'boo'
|
153
|
+
}.should == %Q{<div class=\"right-resizable\" data-resizable-options=\"{maxHeight:'10em',minWidth:100}\"><div class=\"right-resizable-content\">boo</div><div class=\"right-resizable-handle\"></div></div>}
|
154
|
+
end
|
155
|
+
end
|
125
156
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nikolay Nemshilov
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-16 00:00:00 +04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -46,6 +46,8 @@ files:
|
|
46
46
|
- javascripts/right-behavior.js
|
47
47
|
- javascripts/right-calendar-src.js
|
48
48
|
- javascripts/right-calendar.js
|
49
|
+
- javascripts/right-colorpicker-src.js
|
50
|
+
- javascripts/right-colorpicker.js
|
49
51
|
- javascripts/right-dnd-src.js
|
50
52
|
- javascripts/right-dnd.js
|
51
53
|
- javascripts/right-effects-src.js
|
@@ -64,6 +66,8 @@ files:
|
|
64
66
|
- javascripts/right-rails.js
|
65
67
|
- javascripts/right-rater-src.js
|
66
68
|
- javascripts/right-rater.js
|
69
|
+
- javascripts/right-resizable-src.js
|
70
|
+
- javascripts/right-resizable.js
|
67
71
|
- javascripts/right-selectable-src.js
|
68
72
|
- javascripts/right-selectable.js
|
69
73
|
- javascripts/right-slider-src.js
|
@@ -82,11 +86,14 @@ files:
|
|
82
86
|
- javascripts/right-ui-i18n-hu.js
|
83
87
|
- javascripts/right-ui-i18n-jp.js
|
84
88
|
- javascripts/right-ui-i18n-nl.js
|
89
|
+
- javascripts/right-ui-i18n-pt-br.js
|
85
90
|
- javascripts/right-ui-i18n-ru.js
|
86
91
|
- javascripts/right-ui-i18n-ua.js
|
87
92
|
- javascripts/right-uploader-src.js
|
88
93
|
- javascripts/right-uploader.js
|
89
94
|
- javascripts/right.js
|
95
|
+
- images/colorpicker.png
|
96
|
+
- images/resizable.png
|
90
97
|
- lib/right-rails.rb
|
91
98
|
- lib/right_rails/controller_extensions.rb
|
92
99
|
- lib/right_rails/helpers/basic.rb
|