Commit 3f6a94be72ac83bfc7cb25c211652c6fad49b22b
1 parent
9eda5678
Exists in
master
and in
22 other branches
ActionItem135: cosmetic stuff
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1154 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
33 additions
and
20 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -158,12 +158,10 @@ module ApplicationHelper | @@ -158,12 +158,10 @@ module ApplicationHelper | ||
158 | @profile || raise("There is no current profile") | 158 | @profile || raise("There is no current profile") |
159 | end | 159 | end |
160 | 160 | ||
161 | - # displays an | ||
162 | - # | ||
163 | - # Current implementation generates a <label> tag for +label+ and wrap the | ||
164 | - # label and the control with a <div> tag with class 'formfield' | ||
165 | - def labelled_form_field(label, html_for_field) | ||
166 | - content_tag('div', content_tag('div', content_tag('label', label)) + html_for_field, :class => 'formfield') | 161 | + # create a form field structure (as if it were generated with |
162 | + # labelled_form_for), but with a customized control and label. | ||
163 | + def labelled_form_field(label, field_html) | ||
164 | + NoosferoFormBuilder::output_field(label, field_html) | ||
167 | end | 165 | end |
168 | alias_method :display_form_field, :labelled_form_field | 166 | alias_method :display_form_field, :labelled_form_field |
169 | 167 | ||
@@ -179,20 +177,32 @@ module ApplicationHelper | @@ -179,20 +177,32 @@ module ApplicationHelper | ||
179 | 177 | ||
180 | class NoosferoFormBuilder < ActionView::Helpers::FormBuilder | 178 | class NoosferoFormBuilder < ActionView::Helpers::FormBuilder |
181 | include GetText | 179 | include GetText |
180 | + extend ActionView::Helpers::TagHelper | ||
181 | + | ||
182 | + def self.output_field(text, field_html, field_id = nil) | ||
183 | + # try to guess an id if none given | ||
184 | + if field_id.nil? | ||
185 | + field_html =~ /id=['"]([^'"]*)['"]/ | ||
186 | + field_id = $1 | ||
187 | + end | ||
188 | + | ||
189 | + label_html = content_tag('label', text, :class => 'formlabel', :for => field_id) | ||
190 | + control_html = content_tag('div', field_html, :class => 'formfield' ) | ||
191 | + | ||
192 | + content_tag('div', label_html + control_html, :class => 'formfieldline' ) | ||
193 | + end | ||
182 | 194 | ||
183 | (field_helpers - %w(hidden_field)).each do |selector| | 195 | (field_helpers - %w(hidden_field)).each do |selector| |
184 | src = <<-END_SRC | 196 | src = <<-END_SRC |
185 | def #{selector}(field, *args, &proc) | 197 | def #{selector}(field, *args, &proc) |
186 | column = object.class.columns_hash[field.to_s] | 198 | column = object.class.columns_hash[field.to_s] |
187 | - "<div class='formfieldline'>" + | ||
188 | - "\n <label class='formlabel'" + | ||
189 | - " for='\#{object.class.to_s.downcase}_\#{field}'>" + | ||
190 | - ( column ? | ||
191 | - column.human_name : | ||
192 | - _(field.to_s.humanize) | ||
193 | - ) + | ||
194 | - "</label>" + | ||
195 | - "\n <div class='formfield #{selector}'>" + super + "</div>\n</div>" | 199 | + text = |
200 | + ( column ? | ||
201 | + column.human_name : | ||
202 | + _(field.to_s.humanize) | ||
203 | + ) | ||
204 | + | ||
205 | + NoosferoFormBuilder::output_field(text, super) | ||
196 | end | 206 | end |
197 | END_SRC | 207 | END_SRC |
198 | class_eval src, __FILE__, __LINE__ | 208 | class_eval src, __FILE__, __LINE__ |
app/views/cms/_rss_feed.rhtml
1 | <%= f.text_field :name %> | 1 | <%= f.text_field :name %> |
2 | 2 | ||
3 | -<%= labelled_form_field(_('Limit of articles'), f.text_field(:limit)) %> | 3 | +<%= labelled_form_field(_('Limit of articles'), text_field(:article, :limit)) %> |
4 | 4 | ||
5 | -<%= labelled_form_field(_('Use as item description:'), f.select(:feed_item_description, [ [ _('Article abstract'), 'abstract'], [ _('Article body'), 'body']])) %> | 5 | +<%= labelled_form_field(_('Use as item description:'), select(:article, :feed_item_description, [ [ _('Article abstract'), 'abstract'], [ _('Article body'), 'body']])) %> |
6 | 6 | ||
7 | -<%= labelled_form_field(_('Include:'), f.select(:include, [ [ _('All articles'), 'all' ], [ _('Only articles child of the same article as the feed'), 'parent_and_children']] )) %> | 7 | +<%= labelled_form_field(_('Include in the feed:'), select(:article, :include, [ [ _('All articles'), 'all' ], [ _('Only articles child of the same article as the feed'), 'parent_and_children']] )) %> |
app/views/cms/_uploaded_file.rhtml
1 | <%= labelled_form_field(_('Select the file you want to upload.'), file_field(:article, :uploaded_data)) %> | 1 | <%= labelled_form_field(_('Select the file you want to upload.'), file_field(:article, :uploaded_data)) %> |
2 | 2 | ||
3 | -<%= labelled_form_field(_('Describe this file:'), f.text_area(:abstract)) %> | 3 | +<%= labelled_form_field(_('Describe this file:'), text_area(:article, :abstract)) %> |
app/views/cms/view.rhtml
@@ -48,7 +48,10 @@ | @@ -48,7 +48,10 @@ | ||
48 | <%# display the article content %> | 48 | <%# display the article content %> |
49 | <div id='article-contents' style='clear: left;'> | 49 | <div id='article-contents' style='clear: left;'> |
50 | <% if @article %> | 50 | <% if @article %> |
51 | - <h2><%= @article.name %></h2> | 51 | + <h2> |
52 | + <%= @article.name %> | ||
53 | + <%= image_tag(icon_for_article(@article)) %> | ||
54 | + </h2> | ||
52 | <% button_bar(:id => 'article-controls') do %> | 55 | <% button_bar(:id => 'article-controls') do %> |
53 | 56 | ||
54 | <ul> | 57 | <ul> |