From b54578ce1e44e9f49be5f490ab0e21f4b159861d Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 9 Apr 2012 12:44:08 +0800 Subject: [PATCH] ad banner preview --- app/helpers/admin/ad_banner_helper.rb | 24 ++------------- .../admin/ad_banners/_ad_banner_tab.html.erb | 2 +- .../ad_banners/_modal_ad_banner_form.html.erb | 19 ++++++++++-- .../admin/ad_banners/_preview_block.html.erb | 29 +++++++++++++++++++ app/views/admin/ad_banners/index.html.erb | 5 ++-- 5 files changed, 52 insertions(+), 27 deletions(-) create mode 100644 app/views/admin/ad_banners/_preview_block.html.erb diff --git a/app/helpers/admin/ad_banner_helper.rb b/app/helpers/admin/ad_banner_helper.rb index 2de0504b..eff12427 100644 --- a/app/helpers/admin/ad_banner_helper.rb +++ b/app/helpers/admin/ad_banner_helper.rb @@ -1,12 +1,5 @@ module Admin::AdBannerHelper - def preview_block(ad_banner) - res ='' - #same code as in frontend backend parser - if ad_banner - res << "" - res << "
" + def preview_block_ad_images_helper(ad_banner) printable_ad_images = [] ad_banner.ad_images.each do |ad_image| if ad_image.display? @@ -17,18 +10,7 @@ module Admin::AdBannerHelper end printable_ad_images.shuffle! - printable_ad_images.each do |ad_image| #TODO Need Reflact - res << "" - end - res << "
" - res.html_safe - end - end + end + end \ No newline at end of file diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index 19ba5087..d9b1b902 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -15,5 +15,5 @@ <%= link_to 'Add AdImage',new_admin_ad_banner_ad_image_path(ad_banner_tab) %> <% end -%> - <%= preview_block ad_banner_tab %> + <%= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %> diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index 418b8c8f..8e8de1d9 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -1,5 +1,3 @@ - <% end %> + diff --git a/app/views/admin/ad_banners/_preview_block.html.erb b/app/views/admin/ad_banners/_preview_block.html.erb new file mode 100644 index 00000000..4e8432b6 --- /dev/null +++ b/app/views/admin/ad_banners/_preview_block.html.erb @@ -0,0 +1,29 @@ +<% if ad_banner -%> +<%= link_to 'Preview',"#slideshow-#{ad_banner.title.dehumanize}",:class=>"btn btn-primary btn-large",:data=>{:toggle=>'modal'} %> + + + +<% end -%> + + + diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 54d95e00..38b67dd7 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -1,9 +1,9 @@
@@ -13,4 +13,3 @@
-