Commit 8664a3246fd0e4bd690d9e43f61dd51f46522f8f
1 parent
aaccd5c4
Exists in
master
and in
29 other branches
code beauty to article_block
Showing
2 changed files
with
29 additions
and
7 deletions
Show diff stats
app/models/article_block.rb
... | ... | @@ -12,7 +12,11 @@ class ArticleBlock < Block |
12 | 12 | block = self |
13 | 13 | lambda do |
14 | 14 | block_title(block.title) + |
15 | - (block.article ? article_to_html(block.article, :gallery_view=>false, :inside_block=>block) : _('Article not selected yet.')) | |
15 | + (block.article ? article_to_html(block.article, | |
16 | + :gallery_view => false, | |
17 | + :inside_block => block, # For Blogs and folders | |
18 | + :format => block.visualization_format # For Articles and contents | |
19 | + ) : _('Article not selected yet.')) | |
16 | 20 | end |
17 | 21 | end |
18 | 22 | ... | ... |
app/views/box_organizer/_article_block.rhtml
... | ... | @@ -9,15 +9,33 @@ |
9 | 9 | firstText = articles[articles.find_index{|a| a.kind_of?TextArticle}||-1] |
10 | 10 | selected = @block.article || firstText |
11 | 11 | %> |
12 | - <%= select_tag('block[article_id]', options_for_select_with_title(articles.map {|item| [item.path, item.id]}, selected.id), :onchange => 'jQuery("#block_blog_options").toggle(this.blogs.indexOf(this.value) != -1)') %> | |
13 | - <div id="block_blog_options"> | |
14 | - <%= labelled_form_field( _('Number of posts:'), text_field_tag('block[posts_per_page]', @block.posts_per_page) ) %> | |
15 | - <%= labelled_form_field( _('How to display posts:'), select_tag('block[visualization_format]', options_for_select([[_('First paragraph'), 'short'], [_('Full post'), 'full']], @block.visualization_format))) %> | |
12 | + <%= select_tag( | |
13 | + 'block[article_id]', | |
14 | + options_for_select_with_title(articles.map {|item| [item.path, item.id]}, selected.id), | |
15 | + :onchange => 'this.changedTo(this.value)' | |
16 | + )%> | |
17 | + <div id="block_blog_options" style="display:none"> | |
18 | + <%= labelled_form_field( | |
19 | + _('Number of posts:'), | |
20 | + text_field_tag('block[posts_per_page]', @block.posts_per_page) | |
21 | + )%> | |
16 | 22 | </div> |
23 | + <%= labelled_form_field( | |
24 | + _('How to display this content:'), | |
25 | + select_tag( | |
26 | + 'block[visualization_format]', | |
27 | + options_for_select([[_('Lead'), 'short'], [_('Full post'), 'full']], @block.visualization_format) | |
28 | + ) | |
29 | + )%> | |
17 | 30 | <% blogs = @block.available_articles.select{|a|a.blog?} %> |
18 | 31 | <script> |
19 | - jQuery("#block_article_id")[0].blogs = <%= blogs.map{|b| b.id.to_s }.to_json %>; | |
20 | - jQuery("#block_blog_options").toggle(<%= blogs.include?(selected) %>); | |
32 | + var select = jQuery("#block_article_id")[0]; | |
33 | + select.blogs = <%= blogs.map{|b| b.id.to_s }.to_json %>; | |
34 | + select.changedTo = function(articleId) { | |
35 | + var blogSelected = this.blogs.indexOf(articleId) != -1; | |
36 | + jQuery("#block_blog_options").toggle(blogSelected); | |
37 | + } | |
38 | + select.changedTo('<%= selected.id %>'); | |
21 | 39 | </script> |
22 | 40 | <% end %> |
23 | 41 | </div> | ... | ... |