Merge branch 'master' into ldap
Conflicts: app/assets/stylesheets/new_admin.css.erb
This commit is contained in:
commit
2eeb530422
19 files changed
+148
-44
No files matched your search
@@ -0,0 +1,15 @@
|
||||
//Preview need a link in form as Ex and a corresponding PUT action in controller
|
||||
//Ex preview trigger:
|
||||
// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%>
|
||||
|
||||
$(document).ready(function() {
|
||||
$("a.preview_trigger").click(function(){
|
||||
$(this).after("<span id='show_preview'></span>");
|
||||
$.ajax({
|
||||
type:"put",
|
||||
url:$(this).attr("href"),
|
||||
data:$(this).parents("form").serialize()
|
||||
}).done(function(){ $("#"+start_modal_with_id).modal('show');});
|
||||
return false;}
|
||||
);
|
||||
});
|
||||
@@ -59,7 +59,7 @@
|
||||
}
|
||||
.select-role {
|
||||
display:none;
|
||||
padding: 10px 0;
|
||||
overflow:hidden;
|
||||
}
|
||||
.file-upload {
|
||||
position:relative;
|
||||
|
||||
@@ -22,9 +22,14 @@ class Admin::AdBannersController < ApplicationController
|
||||
|
||||
def create
|
||||
@ad_banner = AdBanner.new(params[:ad_banner])
|
||||
@ad_banner.save
|
||||
redirect_to admin_ad_banners_url
|
||||
|
||||
if @ad_banner.save
|
||||
@active = @ad_banner
|
||||
respond_to do |format|
|
||||
format.js {render 'new_created_node'}
|
||||
end
|
||||
else
|
||||
render 'create_error_msg'
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -39,13 +44,14 @@ class Admin::AdBannersController < ApplicationController
|
||||
redirect_to admin_ad_banners_url
|
||||
end
|
||||
|
||||
def destroy_ad_image
|
||||
|
||||
def realtime_preview
|
||||
@ad_banner = AdBanner.first(conditions: { title: params[:title] }).preview_clone
|
||||
@ad_banner.update_attributes(params[:ad_banner]).update_attributes(params[:ad_images])
|
||||
end
|
||||
|
||||
def index
|
||||
@ad_banners = AdBanner.all
|
||||
@active = @ad_banners.first
|
||||
@active = @ad_banners.first
|
||||
end
|
||||
|
||||
end
|
||||
@@ -9,11 +9,16 @@ 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"]
|
||||
|
||||
|
||||
def preview_clone
|
||||
preview_banner = self.clone
|
||||
preview_banner.ad_images = self.ad_images
|
||||
preview_banner
|
||||
end
|
||||
# def new_ad_images(*attrs)
|
||||
# debugger
|
||||
# a=1
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<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>尺寸:</p>
|
||||
<div class="tab-pane <%= "active" if ad_banner_tab==@active%>" id=<%= ad_banner_tab.title %>>
|
||||
<p><%= t("admin.ad.banner_best_size") %>:</p>
|
||||
|
||||
<%= form_for ad_banner_tab,:url=> admin_ad_banner_path(ad_banner_tab),:method => :put,:class=>"input-medium" do |f| -%>
|
||||
<%= f.label :ad_fx, t('admin.ad.ab_fx') %>
|
||||
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
|
||||
<%= 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.submit %>
|
||||
<%= f.submit 'Cancel',:type=>'reset' %>
|
||||
<%= f.submit t("admin.ad.update_banner") %>
|
||||
<%= f.submit t("cancel"),:type=>'reset' %>
|
||||
<div>
|
||||
<%= 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 'Add AdImage',new_admin_ad_banner_ad_image_path(ad_banner_tab) %>
|
||||
<%= 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'%>
|
||||
|
||||
</div>
|
||||
<% end -%>
|
||||
<%= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %>
|
||||
<%#= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %>
|
||||
</div>
|
||||
@@ -1,12 +1,12 @@
|
||||
<li class="span3">
|
||||
<%= image_tag ad_image.file rescue nil%>
|
||||
<p>
|
||||
<%= ad_image.display? ? '[Showing]' : '[NotShawing]' %>
|
||||
<%= ad_image.display? ? "[#{t('admin.ad.showing')}]" : "[#{t('admin.ad.not_showing')}]" %>
|
||||
<%= "#{ad_image.post_date ||'NeedReset' }~#{ad_image.unpost_date || 'NeedReset'}" %>
|
||||
</p>
|
||||
<p>
|
||||
<%= link_to 'Edit',edit_admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn btn-primary' %>
|
||||
<%= link_to 'Del',admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn',:method => :delete,:confirm => t('sure?') %>
|
||||
<%= link_to t('edit'),edit_admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn btn-primary' %>
|
||||
<%= link_to t('delete'),admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn',:method => :delete,:confirm => t('sure?') %>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
<div class="modal-header">
|
||||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h3>Add AdBanner</h3>
|
||||
<h3><%= t("admin.ad.new_banner") %></h3>
|
||||
</div>
|
||||
|
||||
<div class="modal-body form-horizontal">
|
||||
@@ -30,26 +30,21 @@
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
|
||||
<%= f.submit t('submit'), :class=>'btn btn-primary',:remote=>true %>
|
||||
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
if(window.location.pathname == "/admin/ad_banners/new"){
|
||||
$('#new-a-banner').modal({show: true});
|
||||
}
|
||||
|
||||
$('#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').modal({show: true});
|
||||
});
|
||||
|
||||
<% if params[:action] == "new" -%>
|
||||
$('#new-a-banner').modal({show: true});
|
||||
<% end -%>
|
||||
$('#new-a-banner').on('hidden', function (e) {
|
||||
$(".nav.nav-tabs a[id!='new_ad_banner_tab_but']:last").tab('show');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<% if ad_banner -%>
|
||||
|
||||
<div class="modal hide fade in banner-preview" id='slideshow-<%=ad_banner.title.dehumanize%>'>
|
||||
<div class="modal-header">
|
||||
<a class="close" data-dismiss="modal">×</a>
|
||||
<h3><%= t("modal.preview") %></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="ad_banner_slideshow">
|
||||
<% preview_block_ad_images_helper(ad_banner).each do |ad_image| -%>
|
||||
<%= image_tag ad_image.file,:alt => (ad_image.title[locale] || ' '),:time_to_next => ad_banner.transition_sec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || ad_banner.context || ' ')) %>
|
||||
<% end -%>
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end -%>
|
||||
|
||||
<script type='text/javascript' src='/static/kernel.js'></script>
|
||||
<script type='text/javascript'>
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#slideshow-<%=ad_banner.title.dehumanize%>').on('show', function () {
|
||||
$('#slideshow-banner_1').find(".ad_banner_slideshow").cycle({delay: -1000, fx: '<%= ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx %>', timeoutFn: getTimeout });
|
||||
});
|
||||
$(".modal").on('hidden', function () {
|
||||
$("#show_preview").remove();
|
||||
});
|
||||
//$('#slideshow-<%=ad_banner.title.dehumanize%>').show();
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -23,7 +23,7 @@
|
||||
<script type='text/javascript' src='/static/kernel.js'></script>
|
||||
<script type='text/javascript'>
|
||||
$('#slideshow-<%=ad_banner.title.dehumanize%>').on('show', function () {
|
||||
$('#slideshow-banner_1').find(".ad_banner_slideshow").cycle({delay: -1000, fx: '<%= ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx %>', timeoutFn: getTimeout });
|
||||
$('#slideshow-<%=ad_banner.title.dehumanize%>').find(".ad_banner_slideshow").cycle({delay: -1000, fx: '<%= ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx %>', timeoutFn: getTimeout });
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
alert("Error occures:<%= @ad_banner.errors.full_messages%>");
|
||||
@@ -1,11 +1,18 @@
|
||||
<%= stylesheet_link_tag "admin/ad_banner_preview" %>
|
||||
<% content_for :page_specific_css do -%>
|
||||
<%#= 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 -%>
|
||||
|
||||
|
||||
<div id="post-body-content" class="clear">
|
||||
<ul class="nav nav-tabs">
|
||||
<% @ad_banners.each do |ab| %>
|
||||
<%= content_tag :li,link_to(ab.title,"##{ab.title}",:data=>{:toggle=>"tab"}),:class => (ab == @active ? 'active' : nil ) %>
|
||||
<% end -%>
|
||||
<%= content_tag :li,link_to('New',"#new-a-banner",:data=>{:toggle=>"tab"}),:id=>'new_ad_banner_tab_but',:class => (@active.nil? ? 'active' : nil ) %>
|
||||
<%= content_tag :li,link_to(t("admin.ad.new_banner"),"#new-a-banner",:data=>{:toggle=>"tab"}),:id=>'new_ad_banner_tab_but',:class => (@active.nil? ? 'active' : nil ) %>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
$('<%= escape_javascript(content_tag(:li,link_to(@ad_banner.title,"##{@ad_banner.title}",:data=>{:toggle=>"tab"}))) %>').insertBefore("#new_ad_banner_tab_but");
|
||||
$('<%= escape_javascript(render(:partial => "ad_banner_tab",:locals => {:ad_banner_tab => @ad_banner})) %>').insertBefore($("#new-a-banner"));
|
||||
|
||||
$('.modal').modal('hide');
|
||||
$('#new-a-banner').unbind();
|
||||
$('#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");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_preview',:locals => {:ad_banner => @ad_banner})) %>");
|
||||
var start_modal_with_id = "slideshow-<%=@ad_banner.title.dehumanize%>"
|
||||
@@ -4,6 +4,9 @@
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= 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 %>
|
||||
|
||||
|
||||
@@ -167,7 +170,7 @@
|
||||
<br/>
|
||||
<div class="context editor">
|
||||
<%= f.fields_for :context, @ad_image.context do |f| %>
|
||||
<%= f.text_area locale,:style => "width:100%", :class => "asd_tinymce_textarea post-title" %>
|
||||
<%= f.text_area locale,:style => "width:100%", :class => "tinymce_textarea post-title" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -184,5 +187,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<!--Post End-->
|
||||
<div class="form-actions">
|
||||
<%= 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>
|
||||
@@ -32,9 +32,9 @@
|
||||
<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') do -%>
|
||||
<%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.ad_banner'), admin_ad_banners_path %>
|
||||
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images')) do -%>
|
||||
<%= content_tag :li, link_to(t('admin.all_ad_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %>
|
||||
<%= content_tag :li, link_to(t('admin.new_ad_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %>
|
||||
<%= content_tag :li, link_to(t('admin.new_ad_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %>
|
||||
<%= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %>
|
||||
<%= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %>
|
||||
<%= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
||||
Reference in new issue
Block a user