Preview now can be use at both ad_banner and ad_image,however it won't run correctly if user change its ad_banner at ad_image.

This commit is contained in:
Matthew K. Fu JuYuan 2012-04-17 16:03:48 +08:00 committed by Christophe Vilayphiou
parent e353afb5ac
commit 81b0046f42
8 changed files with 11 additions and 14 deletions

View File

@ -4,7 +4,7 @@
$(document).ready(function() {
$("a.preview_trigger").click(function(){
$(this).after("<p id='show_preview'></p>");
$(this).after("<span id='show_preview'></span>");
$.ajax({
type:"PUT",
url:$(this).attr("href"),

View File

@ -40,7 +40,7 @@ class Admin::AdBannersController < ApplicationController
end
def realtime_preview
@ad_banner = AdBanner.find(params[:id]).preview_clone
@ad_banner = AdBanner.find(conditions: { title: params[:title] }).preview_clone
#@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images])
end

View File

@ -9,6 +9,7 @@ class AdBanner
before_save :save_or_destroy
validates_uniqueness_of :title
validates :title , :length => { :minimum => 2 }
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"]

View File

@ -1,4 +1,3 @@
<script type="text/javascript" src="/static/jquery.cycle.all.latest.js"></script>
<div class="tab-pane <%= "active" if ad_banner_tab==@active %>" id=<%= ad_banner_tab.title %>>
<p><%= t("admin.ad.banner_best_size") %></p>
@ -13,7 +12,7 @@
<%= 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" } %>
<%= 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"), realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger btn btn-success'%>
<%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.title) , :class=>'preview_trigger btn btn-success'%>
</div>
<% end -%>

View File

@ -44,9 +44,6 @@ $('#new_ad_banner_tab_but').on('shown', function (e) {
$('#new-a-banner').modal({show: true});
})
$('#new-a-banner').on('shown', function (e) {
alert('show!');
})
$('#new-a-banner').on('hidden', function (e) {
$(".nav.nav-tabs a[id!='new_ad_banner_tab_but']:last").tab('show');

View File

@ -2,6 +2,7 @@
<%#= stylesheet_link_tag "admin/ad_banner_preview" %>
<% end -%>
<% content_for :page_specific_css do -%>
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end -%>

View File

@ -5,6 +5,7 @@
<%= javascript_include_tag "lib/datepicker" %>
<%= javascript_include_tag "lib/date.format" %>
<%= javascript_include_tag "inc/modal-preview" %>
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
<% end %>
@ -187,9 +188,9 @@
</div>
<!--Post End-->
<div class="form-actions">
<%= link_to t("modal.preview"), realtime_preview_admin_ad_banner_path(@ad_image.ad_banner) ,:class=>"preview_trigger btn btn-success" rescue nil%>
<button class="btn btn-primary" type="submit"><%= t("submit")%></button>
<button class="btn" type="reset"><%= t("cancel")%></button>
<%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(@ad_image.ad_banner.title) ,:class=>"preview_trigger btn btn-success" rescue nil%>
<%= f.submit t("submit"),:class=>"btn btn-primary" %>
<%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %>
</div>
</form>
</div>

View File

@ -25,14 +25,12 @@ Orbit::Application.routes.draw do
end
match 'ad_banner/:title/preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put
resources :ad_banners do
collection do
match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get
match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
end
member do
match 'preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put
end
resources :ad_images ,:except => [:show,:index]
end
resources :dashboards