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:
parent
a9a4ca6ede
commit
51190a79cb
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("a.preview_trigger").click(function(){
|
$("a.preview_trigger").click(function(){
|
||||||
$(this).after("<p id='show_preview'></p>");
|
$(this).after("<span id='show_preview'></span>");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:"PUT",
|
type:"PUT",
|
||||||
url:$(this).attr("href"),
|
url:$(this).attr("href"),
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Admin::AdBannersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def realtime_preview
|
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])
|
#@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ class AdBanner
|
||||||
|
|
||||||
before_save :save_or_destroy
|
before_save :save_or_destroy
|
||||||
validates_uniqueness_of :title
|
validates_uniqueness_of :title
|
||||||
|
validates :title , :length => { :minimum => 2 }
|
||||||
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"]
|
||||||
|
|
|
@ -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 %>>
|
<div class="tab-pane <%= "active" if ad_banner_tab==@active %>" id=<%= ad_banner_tab.title %>>
|
||||||
<p><%= t("admin.ad.banner_best_size") %>:</p>
|
<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 => "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"), 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>
|
</div>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -44,9 +44,6 @@ $('#new_ad_banner_tab_but').on('shown', function (e) {
|
||||||
$('#new-a-banner').modal({show: true});
|
$('#new-a-banner').modal({show: true});
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#new-a-banner').on('shown', function (e) {
|
|
||||||
alert('show!');
|
|
||||||
})
|
|
||||||
|
|
||||||
$('#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');
|
$(".nav.nav-tabs a[id!='new_ad_banner_tab_but']:last").tab('show');
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<%#= stylesheet_link_tag "admin/ad_banner_preview" %>
|
<%#= stylesheet_link_tag "admin/ad_banner_preview" %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% content_for :page_specific_css do -%>
|
<% content_for :page_specific_css do -%>
|
||||||
|
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
|
||||||
<%= javascript_include_tag "inc/modal-preview" %>
|
<%= javascript_include_tag "inc/modal-preview" %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<%= javascript_include_tag "lib/datepicker" %>
|
<%= javascript_include_tag "lib/datepicker" %>
|
||||||
<%= javascript_include_tag "lib/date.format" %>
|
<%= javascript_include_tag "lib/date.format" %>
|
||||||
<%= javascript_include_tag "inc/modal-preview" %>
|
<%= javascript_include_tag "inc/modal-preview" %>
|
||||||
|
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
@ -182,9 +183,9 @@
|
||||||
</div>
|
</div>
|
||||||
<!--Post End-->
|
<!--Post End-->
|
||||||
<div class="form-actions">
|
<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%>
|
<%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(@ad_image.ad_banner.title) ,:class=>"preview_trigger btn btn-success" rescue nil%>
|
||||||
<button class="btn btn-primary" type="submit"><%= t("submit")%></button>
|
<%= f.submit t("submit"),:class=>"btn btn-primary" %>
|
||||||
<button class="btn" type="reset"><%= t("cancel")%></button>
|
<%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
|
@ -25,14 +25,12 @@ Orbit::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
match 'ad_banner/:title/preivew' => '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
|
||||||
match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
|
match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
|
||||||
end
|
end
|
||||||
member do
|
|
||||||
match 'preivew' => 'ad_banners#realtime_preview',:as => :realtime_preview,:via => :put
|
|
||||||
end
|
|
||||||
resources :ad_images ,:except => [:show,:index]
|
resources :ad_images ,:except => [:show,:index]
|
||||||
end
|
end
|
||||||
resources :dashboards
|
resources :dashboards
|
||||||
|
|
Reference in New Issue