AdBanner is now working
This commit is contained in:
parent
f530eb7112
commit
68cea1ea49
|
@ -9,13 +9,15 @@ class AdBanner
|
|||
field :unpost_date,type: Date
|
||||
field :context
|
||||
field :direct_to_after_click,type: Boolean
|
||||
field :ad_style #TODO Design should explain
|
||||
field :ad_fx #TODO Design should explain
|
||||
|
||||
|
||||
before_save :save_or_destroy
|
||||
|
||||
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 new_ad_images=(*attrs)
|
||||
attrs[0].each do |attr| #Loop by JSs,Themes,Imgs
|
||||
unless attr[:file].nil?
|
||||
|
|
|
@ -34,6 +34,10 @@
|
|||
<%= f.label :direct_to_after_click, t('admin.direct_to_after_click') %>
|
||||
<%= f.check_box :direct_to_after_click %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :ad_fx, t('admin.ad_fx') %>
|
||||
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label :ad_images, t('admin.ad_images') %>
|
||||
<ul>
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
<!-- example -->
|
||||
<div id="header_top" class="header">
|
||||
This is the first level of header
|
||||
<r:adbanner name='banner_1'>
|
||||
</r:adbanner>
|
||||
</div>
|
||||
<div id="header_bottom" class="header">
|
||||
This is the second level of header
|
||||
|
|
|
@ -74,6 +74,25 @@ module ParserBackEnd
|
|||
end
|
||||
res
|
||||
end
|
||||
c.define_tag 'adbanner' do |tag|
|
||||
ret = ''
|
||||
ad_banner = AdBanner.first(conditions:{title: tag.attr["name"]})
|
||||
ret << "<script type='text/javascript' src='http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.latest.js'></script>"
|
||||
ret << "<script type='text/javascript'> $(document).ready(function() { $('.slideshow').cycle({ fx: '#{ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx}' }); }); </script>"
|
||||
|
||||
ret << "<div id='#{tag.attr['name']}' ad_banner_id='#{ad_banner.id}' class='editable' style='border:solid 1px; margin:5px; padding:5px;'>"
|
||||
ret << "<div class='edit_link' style='display:none'>"
|
||||
ret << " <a href='#{edit_admin_ad_banner_path(ad_banner.id)}' class='nav'>#{t(:edit)}</a>"
|
||||
ret << '</div>'
|
||||
#==================================
|
||||
ret << "<div class='slideshow'>"
|
||||
ad_banner.ad_images.each do |ad_image|
|
||||
ret << "<img src='#{ad_image.file}' />"
|
||||
end
|
||||
ret << "</div>"
|
||||
#==================================
|
||||
ret << "</div>"
|
||||
end
|
||||
c.define_tag 'layout_part' do |tag|
|
||||
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
|
||||
ret = ''
|
||||
|
|
|
@ -82,6 +82,18 @@ module ParserFrontEnd
|
|||
end
|
||||
res
|
||||
end
|
||||
c.define_tag 'adbanner' do |tag|
|
||||
res = ''
|
||||
ad_banner = AdBanner.first(conditions:{title: tag.attr["name"]})
|
||||
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 << "<div class='slideshow'>"
|
||||
ad_banner.ad_images.each do |ad_image|
|
||||
res << "<img src='#{ad_image.file}' />"
|
||||
end
|
||||
res << "</div>"
|
||||
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
|
||||
|
|
|
@ -15,6 +15,8 @@ module ParserLayout
|
|||
end
|
||||
c.define_tag 'stylesheets' do |tag|
|
||||
end
|
||||
c.define_tag 'adbanner' do |tag|
|
||||
end
|
||||
c.define_tag 'menu' do |tag|
|
||||
layout.build_menu(:levels => 0, :values => {}) unless layout.menu
|
||||
layout.menu.levels = i = tag.attr['level'].to_i
|
||||
|
|
Reference in New Issue