Ad banner close complete,need validation
This commit is contained in:
parent
5cebb638ce
commit
d107d54a82
|
@ -18,6 +18,13 @@ class AdBanner
|
||||||
|
|
||||||
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"]
|
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)
|
def new_ad_images=(*attrs)
|
||||||
attrs[0].each do |attr| #Loop by JSs,Themes,Imgs
|
attrs[0].each do |attr| #Loop by JSs,Themes,Imgs
|
||||||
unless attr[:file].nil?
|
unless attr[:file].nil?
|
||||||
|
|
|
@ -7,10 +7,23 @@ class AdImage
|
||||||
field :time_to_next #Weight
|
field :time_to_next #Weight
|
||||||
field :picture_intro
|
field :picture_intro
|
||||||
field :out_link
|
field :out_link
|
||||||
|
field :link_open
|
||||||
|
|
||||||
field :to_save, :type => Boolean
|
field :to_save, :type => Boolean
|
||||||
field :to_destroy, :type => Boolean
|
field :to_destroy, :type => Boolean
|
||||||
|
|
||||||
|
LINK_OPEN_TYPES = ["new_window","local"]
|
||||||
|
|
||||||
|
|
||||||
embedded_in :ad_banner
|
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
|
end
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<div id="basic_block" class="roles_block">
|
<div id="basic_block" class="roles_block">
|
||||||
<%= image_tag ad_image.file %>
|
<%= image_tag ad_image.file %>
|
||||||
|
<p>
|
||||||
Time to next: <%= ad_image.time_to_next %>
|
Time to next: <%= ad_image.time_to_next %>
|
||||||
Intro: <%= ad_image.picture_intro %>
|
Intro: <%= ad_image.picture_intro %>
|
||||||
Out Link <%= link_to ad_image.out_link %>
|
Out Link <%= link_to ad_image.out_link %> by <%= ad_image.link_open %>
|
||||||
<%= render :partial => "ad_image_update", :locals => { :ad_image => ad_image } %>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
Time: <%= f.text_field :time_to_next ,:class=> 'ad_time'%>
|
Time: <%= f.text_field :time_to_next ,:class=> 'ad_time'%>
|
||||||
Link:<%= f.text_field :out_link ,:class=> 'ad_out_link'%>
|
Link:<%= f.text_field :out_link ,:class=> 'ad_out_link'%>
|
||||||
|
Open Type <%= f.select :link_open ,AdImage::LINK_OPEN_TYPES %>
|
||||||
|
|
||||||
<%= f.hidden_field :to_save %>
|
<%= f.hidden_field :to_save %>
|
|
@ -22,8 +22,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= f.label :unpost_date, t('admin.unpost_date') %>
|
<%= 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') } %>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<%= f.label :context, t('admin.context') %>
|
<%= f.label :context, t('admin.context') %>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<td><%= t('admin.unpost_date') %></td>
|
<td><%= t('admin.unpost_date') %></td>
|
||||||
<td><%= t('admin.context') %></td>
|
<td><%= t('admin.context') %></td>
|
||||||
<td><%= t('admin.direct_to_after_click') %></td>
|
<td><%= t('admin.direct_to_after_click') %></td>
|
||||||
|
<td><%= t('admin.now_display?') %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<% @ad_banners.each do |ad_banner| %>
|
<% @ad_banners.each do |ad_banner| %>
|
||||||
|
@ -27,9 +28,10 @@
|
||||||
<td><%= ad_banner.title %></td>
|
<td><%= ad_banner.title %></td>
|
||||||
<td><%= ad_banner.picture_position %></td>
|
<td><%= ad_banner.picture_position %></td>
|
||||||
<td><%= ad_banner.post_date %></td>
|
<td><%= ad_banner.post_date %></td>
|
||||||
<td><%= ad_banner.unpost_date %></td>
|
<td><%= ad_banner.unpost_date.nil?? t('form.date_unlimited'): ad_banner.unpost_date %></td>
|
||||||
<td><%= ad_banner.context %></td>
|
<td><%= ad_banner.context %></td>
|
||||||
<td><%= ad_banner.direct_to_after_click %></td>
|
<td><%= ad_banner.direct_to_after_click %></td>
|
||||||
|
<td><%= ad_banner.display? %></td>
|
||||||
<td class="action">
|
<td class="action">
|
||||||
<%= link_to t(:show), admin_ad_banner_path(ad_banner), :class => 'show' %>
|
<%= 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(:edit), edit_admin_ad_banner_path(ad_banner), :class => 'edit' %>
|
||||||
|
|
|
@ -85,15 +85,29 @@ module ParserFrontEnd
|
||||||
c.define_tag 'adbanner' do |tag|
|
c.define_tag 'adbanner' do |tag|
|
||||||
res = ''
|
res = ''
|
||||||
ad_banner = AdBanner.first(conditions:{title: tag.attr["name"]})
|
ad_banner = AdBanner.first(conditions:{title: tag.attr["name"]})
|
||||||
|
if ad_banner.display?
|
||||||
res << "<script type='text/javascript' src='http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js'></script>"
|
res << "<script type='text/javascript' src='http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js'></script>"
|
||||||
res << "<script type='text/javascript'> $(document).ready(function() { $('.slideshow').cycle({ fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); }); </script>"
|
res << "<script type='text/javascript'>function onAfter(e) {
|
||||||
|
var parent = $(this).parent();
|
||||||
|
var time_to_next = $(this).attr('time_to_next');
|
||||||
|
parent.cycle('pause');
|
||||||
|
setTimeout(function(){parent.cycle('resume')},time_to_next);
|
||||||
|
|
||||||
|
} $(document).ready(function() { $('.slideshow').cycle({after: onAfter,timeout:1 ,fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }).children('img').click(function(){if($(this).attr('link_open')=='new_window'){window.open($(this).attr('link_url'));} else{document.location.href=$(this).attr('link_url');}});; }); </script>"
|
||||||
|
|
||||||
res << "<div class='slideshow'>"
|
res << "<div class='slideshow'>"
|
||||||
ad_banner.ad_images.each do |ad_image|
|
ad_banner.ad_images.each do |ad_image|
|
||||||
res << "<img src='#{ad_image.file}' />"
|
res << "<img src='#{ad_image.file}' "
|
||||||
|
res << "alt='#{ad_image.picture_intro || ' '}' "
|
||||||
|
res << "time_to_next='#{ad_image.get_delay_time}' "
|
||||||
|
res << "link_open='#{ad_image.link_open}' "
|
||||||
|
res << "link_url='#{(ad_banner.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
|
||||||
|
res << "/>"
|
||||||
end
|
end
|
||||||
res << "</div>"
|
res << "</div>"
|
||||||
end
|
end
|
||||||
|
res
|
||||||
|
end
|
||||||
c.define_tag 'image' do |tag|
|
c.define_tag 'image' do |tag|
|
||||||
image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) }
|
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
|
image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image
|
||||||
|
|
Reference in New Issue