diff --git a/app/assets/javascripts/ad_banner.js b/app/assets/javascripts/ad_banner.js index 57176a1c8..bab55a67e 100644 --- a/app/assets/javascripts/ad_banner.js +++ b/app/assets/javascripts/ad_banner.js @@ -15,4 +15,4 @@ $('a.remove_mark').live("click",function(){ $(this).next().remove(); $(this).remove(); return false; -}); \ No newline at end of file +}); diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index 368c70818..e7bffea4b 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -16,6 +16,15 @@ class AdBanner embeds_many :ad_images, :cascade_callbacks => true + FX_TYPES = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"] + + def display? + if (self.post_date <= Date.today && (self.unpost_date.nil? || self.unpost_date>= Date.today)) + return true + end + return false + end + def new_ad_images=(*attrs) attrs[0].each do |attr| #Loop by JSs,Themes,Imgs unless attr[:file].nil? diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index dc8eab8b0..308ae3ace 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -13,4 +13,13 @@ class AdImage embedded_in :ad_banner + def get_delay_time + time = '' + if self.time_to_next.nil? + time = '1000' + else + time = (self.time_to_next.to_i * 1000).to_s + end + time + end end diff --git a/app/views/admin/ad_banners/_form.html.erb b/app/views/admin/ad_banners/_form.html.erb index ff19e5135..2c42fa3bc 100644 --- a/app/views/admin/ad_banners/_form.html.erb +++ b/app/views/admin/ad_banners/_form.html.erb @@ -24,6 +24,7 @@ <%= f.label :unpost_date, t('admin.unpost_date') %> <%= f.date_select :unpost_date, :order => [:year, :month, :day], :use_month_numbers => true %> + <%= f.date_select :unpost_date, :order => [:year, :month, :day], :use_month_numbers => true,:prompt => { :day => t('form.date_unlimited'), :month => t('form.date_unlimited'), :year => t('form.date_unlimited') } %>

<%= f.label :context, t('admin.context') %> diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 542171408..30683cda9 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -20,6 +20,7 @@ <%= t('admin.unpost_date') %> <%= t('admin.context') %> <%= t('admin.direct_to_after_click') %> + <%= t('admin.now_display?') %> <% @ad_banners.each do |ad_banner| %> @@ -28,9 +29,12 @@ <%= ad_banner.picture_position %> <%= ad_banner.post_date %> <%= ad_banner.unpost_date %> + <%= ad_banner.unpost_date.nil?? t('form.date_unlimited'): ad_banner.unpost_date %> <%= ad_banner.context %> <%= ad_banner.direct_to_after_click %> + <%= ad_banner.display? %> + <%= link_to t(:show), admin_ad_banner_path(ad_banner), :class => 'show' %> <%= link_to t(:edit), edit_admin_ad_banner_path(ad_banner), :class => 'edit' %> <%= link_to t(:delete), admin_ad_banner_path(ad_banner), :confirm => t('sure?'), :method => :delete, :class => 'delete' %> diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index 085da8311..57b4be083 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -82,6 +82,31 @@ module ParserFrontEnd end res end + c.define_tag 'adbanner' do |tag| + res = '' + ad_banner = AdBanner.first(conditions:{title: tag.attr["name"]}) + if ad_banner.display? + res << "" + res << "" + + res << "

" + ad_banner.ad_images.each do |ad_image| + res << "" + end + res << "
" + end + res + end c.define_tag 'image' do |tag| image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image