Fix ad_banner

This commit is contained in:
Matthew K. Fu JuYuan 2012-04-23 17:03:55 +08:00
parent 170c12bcdd
commit 35452c039d
7 changed files with 32 additions and 13 deletions

View File

@ -6,10 +6,17 @@ $(document).ready(function() {
$("a.preview_trigger").click(function(){ $("a.preview_trigger").click(function(){
$(this).after("<span id='show_preview'></span>"); $(this).after("<span id='show_preview'></span>");
$.ajax({ $.ajax({
type:"put", type: 'PUT',
//async : true,
url:$(this).attr("href"), url:$(this).attr("href"),
data:$(this).parents("form").serialize() contentType: 'application/javascript; charset=utf-8',
}).done(function(){ $("#"+start_modal_with_id).modal('show');}); data:$(this).parents("form").serialize(),
return false;} success: function (msg) {
); $("#"+start_modal_with_id).modal('show'); },
error: function(){
alert("ERROR");
}
});
return false;
});
}); });

View File

@ -4,7 +4,7 @@ class AdBanner
include Mongoid::MultiParameterAttributes include Mongoid::MultiParameterAttributes
field :title field :title
field :transition_sec,type: Integer field :transition_msec,type: Integer
field :ad_fx #TODO Design should explain field :ad_fx #TODO Design should explain
before_save :save_or_destroy before_save :save_or_destroy
@ -13,6 +13,14 @@ class AdBanner
has_many :ad_images , dependent: :delete has_many :ad_images , dependent: :delete
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"]
attr_writer :transition_sec
def transition_sec
self.transition_msec/1000
end
def transition_sec=(sec)
self.transition_msec = sec.to_i*1000
end
def preview_clone def preview_clone
preview_banner = self.clone preview_banner = self.clone

View File

@ -5,14 +5,14 @@
<%= f.label :ad_fx, t('admin.ad.ab_fx') %> <%= f.label :ad_fx, t('admin.ad.ab_fx') %>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %> <%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<%= f.label :transition_sec, t('admin.ad.transition_sec') %> <%= f.label :transition_sec, t('admin.ad.transition_sec') %>
<%= f.text_field :transition_sec,:placeholder=>"3秒請輸入3000",:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> <%= f.text_field :transition_sec,:placeholder=>t('admin.ad.sec_place_holder'),:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %>
<%= f.submit t("admin.ad.update_banner") %> <%= f.submit t("admin.ad.update_banner") %>
<%= f.submit t("cancel"),:type=>'reset' %> <%= f.submit t("cancel"),:type=>'reset' %>
<div> <div>
<%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> <%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %>
<%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %>
<%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> <%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%>
<%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.title) , :class=>'preview_trigger btn btn-success'%> <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_url(ad_banner_tab.title) , :class=>'preview_trigger btn btn-success'%>
</div> </div>
<% end -%> <% end -%>

View File

@ -40,11 +40,13 @@ $('#new_ad_banner_tab_but').on('shown', function (e) {
$('#new-a-banner').modal({show: true}); $('#new-a-banner').modal({show: true});
}); });
<% if params[:action] == "new" -%>
$('#new-a-banner').modal({show: true});
<% end -%>
$('#new-a-banner').on('hidden', function (e) { $('#new-a-banner').on('hidden', function (e) {
$(".nav.nav-tabs a[id!='new_ad_banner_tab_but']:last").tab('show'); $('#post-body-content').find(".nav.nav-tabs").children('li.active').removeClass("active");
$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");
$('.tab-pane').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");
}); });
</script> </script>

View File

@ -43,6 +43,7 @@ en:
action: Action action: Action
ad_banner: AD Banner ad_banner: AD Banner
ad: ad:
sec_place_holder: Enter 3 if 3 sec
ab_fx: FX ab_fx: FX
all_banners: AdBanner list all_banners: AdBanner list
banner_best_size: Banner Best Size banner_best_size: Banner Best Size

View File

@ -40,6 +40,7 @@ zh_tw:
action: 操作 action: 操作
ad_banner: 廣告輪播 ad_banner: 廣告輪播
ad: ad:
sec_place_holder: 3秒請輸入3
ab_fx: 轉場特效 ab_fx: 轉場特效
all_banners: 輪播清單 all_banners: 輪播清單
banner_best_size: Banner 尺寸 banner_best_size: Banner 尺寸

View File

@ -25,7 +25,7 @@ Orbit::Application.routes.draw do
end end
match 'ad_banner/:title/preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put match 'ad_banner/:title/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put
resources :ad_banners do resources :ad_banners do
collection do collection do
match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get