Commit aaefdf5b3737c64f7da056e5fc5fb2b01c9fcf71
1 parent
00c7c23e
Exists in
master
and in
29 other branches
A better highlights block config interface
Beauty, useful, readable and code cleanner. ActionItem2613
Showing
3 changed files
with
51 additions
and
18 deletions
Show diff stats
app/helpers/block_helper.rb
... | ... | @@ -6,4 +6,21 @@ module BlockHelper |
6 | 6 | content_tag 'h3', content_tag('span', title), :class => tag_class |
7 | 7 | end |
8 | 8 | |
9 | + def highlights_block_config_image_fields(block, image={}) | |
10 | + " | |
11 | + <tr class=\"image-data-line\"> | |
12 | + <td> | |
13 | + #{select_tag 'block[images][][image_id]', content_tag(:option) + option_groups_from_collection_for_select(block.folder_choices, :images, :name, :id, :name, image[:image_id].to_i)} | |
14 | + </td> | |
15 | + <td>#{text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 20}</td> | |
16 | + <td>#{text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 1}</td> | |
17 | + </tr><tr class=\"image-title\"> | |
18 | + <td colspan=\"3\"><label>#{ | |
19 | + content_tag('span', _('Title')) + | |
20 | + text_field_tag('block[images][][title]', image[:title], :class => 'highlight-title', :size => 45) | |
21 | + }</label></td> | |
22 | + </tr> | |
23 | + " | |
24 | + end | |
25 | + | |
9 | 26 | end | ... | ... |
app/views/box_organizer/_highlights_block.rhtml
1 | 1 | <strong><%= _('Highlights') %></strong> |
2 | 2 | |
3 | -<table id='highlights' class='noborder'> | |
4 | - <tr><th><%= _('Image') %></th><th><%= _('Address') %></th><th><%= _('Position') %></th><th><%= _('Title') %></th></tr> | |
3 | +<table class="noborder"><tbody id="highlights-data-table"> | |
4 | + <tr><th><%= _('Image') %></th><th><%= _('Address') %></th><th><%= _('Position') %></th></tr> | |
5 | 5 | <% for image in @block.images do %> |
6 | - <tr> | |
7 | - <td> | |
8 | - <%= select_tag 'block[images][][image_id]', content_tag(:option) + option_groups_from_collection_for_select(@block.folder_choices, :images, :name, :id, :name, image[:image_id].to_i), :style => "width: 100px" %></p> | |
9 | - </td> | |
10 | - <td><%= text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 10 %></td> | |
11 | - <td><%= text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 3 %></td> | |
12 | - <td><%= text_field_tag 'block[images][][title]', image[:title], :class => 'highlight-title', :size => 10 %></td> | |
13 | - </tr> | |
6 | + <%= highlights_block_config_image_fields @block, image %> | |
14 | 7 | <% end %> |
15 | -</table> | |
8 | +</tbody></table> | |
16 | 9 | |
17 | 10 | <%= link_to_function(_('New highlight'), nil, :class => 'button icon-add with-text') do |page| |
18 | - page.insert_html :bottom, 'highlights', content_tag('tr', | |
19 | - content_tag('td', select_tag('block[images][][image_id]', content_tag(:option) + option_groups_from_collection_for_select(@block.folder_choices, :images, :name, :id, :name), :style => "width: 100px")) + | |
20 | - content_tag('td', text_field_tag('block[images][][address]', nil, :class => 'highlight-address', :size => 10)) + | |
21 | - content_tag('td', text_field_tag('block[images][][position]', nil, :class => 'highlight-position', :size => 3)) + | |
22 | - content_tag('td', text_field_tag('block[images][][title]', nil, :class => 'highlight-position', :size => 10)) | |
23 | - ) + | |
24 | - javascript_tag("$('edit-link-list-block').scrollTop = $('edit-link-list-block').scrollHeight") | |
11 | + page.insert_html :bottom, 'highlights-data-table', highlights_block_config_image_fields(@block) | |
25 | 12 | end %> |
26 | 13 | |
27 | 14 | <%= labelled_form_field _('Image transition:'), select('block', 'interval', [[_('No automatic transition'), 0]] + [1, 2, 3, 4, 5, 10, 20, 30, 60].map {|item| [n_('Every 1 second', 'Every %d seconds', item) % item, item]}) %> | ... | ... |
public/stylesheets/application.css
... | ... | @@ -4314,6 +4314,35 @@ h1#agenda-title { |
4314 | 4314 | text-align: center; |
4315 | 4315 | overflow: hidden; |
4316 | 4316 | } |
4317 | + | |
4318 | +.block-config-options.HighlightsBlock-options .image-data-line select { | |
4319 | + width: 150px; | |
4320 | +} | |
4321 | + | |
4322 | +.block-config-options.HighlightsBlock-options td { | |
4323 | + text-align: center; | |
4324 | +} | |
4325 | + | |
4326 | +.block-config-options.HighlightsBlock-options .image-data-line td { | |
4327 | + padding-top: 7px; | |
4328 | +} | |
4329 | + | |
4330 | +.block-config-options.HighlightsBlock-options .image-title { | |
4331 | + white-space: nowrap; | |
4332 | + border-bottom: 1px solid #CCC; | |
4333 | +} | |
4334 | +.block-config-options.HighlightsBlock-options .image-title:last-child { | |
4335 | + border: none; | |
4336 | +} | |
4337 | + | |
4338 | +.block-config-options.HighlightsBlock-options .image-title td { | |
4339 | + padding-bottom: 7px; | |
4340 | +} | |
4341 | + | |
4342 | +.block-config-options.HighlightsBlock-options .image-title span { | |
4343 | + padding-right: 5px; | |
4344 | +} | |
4345 | + | |
4317 | 4346 | /* Featured Products stuff */ |
4318 | 4347 | |
4319 | 4348 | .featured-product-items { | ... | ... |