From 2608b72d653198ee4c0c5231e501d2e1d6079b69 Mon Sep 17 00:00:00 2001
From: Matthew Kaito Juyuan Fu
Date: Fri, 3 Feb 2012 14:28:08 +0800
Subject: [PATCH] mistake commit
---
app/assets/javascripts/ad_banner.js | 2 +-
app/models/ad_banner.rb | 9 ++++++++
app/models/ad_image.rb | 9 ++++++++
app/views/admin/ad_banners/_form.html.erb | 1 +
app/views/admin/ad_banners/index.html.erb | 4 ++++
lib/parsers/parser_front_end.rb | 25 +++++++++++++++++++++++
6 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/app/assets/javascripts/ad_banner.js b/app/assets/javascripts/ad_banner.js
index 57176a1c..bab55a67 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 368c7081..e7bffea4 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 dc8eab8b..308ae3ac 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 ff19e513..2c42fa3b 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 54217140..30683cda 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 085da831..57b4be08 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
|