AdBanner reopen new banner and delete. Rename title with content editable tag.
This commit is contained in:
parent
a31a9c4792
commit
befd3bcdec
|
@ -0,0 +1,41 @@
|
||||||
|
<%#= encoding: utf-8 %>
|
||||||
|
$(function() {
|
||||||
|
var content_holder, content;
|
||||||
|
var selector = 'li[contenteditable="true"]';
|
||||||
|
// prevent clicks inside editable area to fire
|
||||||
|
// a click event on the body
|
||||||
|
// and therefor saving our content before we even edit it
|
||||||
|
$(selector).click(function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// initialize the "save" function
|
||||||
|
$(selector).focus(function(e) {
|
||||||
|
content_holder = $(this);
|
||||||
|
content = content_holder.html();
|
||||||
|
|
||||||
|
// one click outside the editable area saves the content
|
||||||
|
$('body').one('click', function(e) {
|
||||||
|
// but not if the content didn't change
|
||||||
|
if ($(e.target).is(selector) || content == content_holder.html()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: content_holder.data('edit-url'),
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: { body: content_holder.html() },
|
||||||
|
success: function(json) {
|
||||||
|
alert("<%= I18n.t("admin.contenteditable.update_done") %>");
|
||||||
|
//content_holder.effect('highlight', {'color': '#0f0'}, 3000);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert("<%= I18n.t("admin.contenteditable.update_failed") %>");
|
||||||
|
//content_holder.effect('highlight', {'color': '#f00'}, 3000);
|
||||||
|
content_holder.html(content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -4,6 +4,11 @@ class Admin::AdBannersController < OrbitBackendController
|
||||||
before_filter :for_app_manager,:except => [:index,:show]
|
before_filter :for_app_manager,:except => [:index,:show]
|
||||||
before_filter :for_app_sub_manager
|
before_filter :for_app_sub_manager
|
||||||
|
|
||||||
|
def rename
|
||||||
|
@ad_banner = AdBanner.find(params[:id])
|
||||||
|
@ad_banner.title = Nokogiri::HTML.fragment(params["body"]).at("a").children().to_s
|
||||||
|
render :json => {:success =>@ad_banner.save!}
|
||||||
|
end
|
||||||
def destroy
|
def destroy
|
||||||
@ad_banner = AdBanner.find(params[:id])
|
@ad_banner = AdBanner.find(params[:id])
|
||||||
@ad_banner.destroy
|
@ad_banner.destroy
|
||||||
|
|
|
@ -172,11 +172,10 @@ module ApplicationHelper
|
||||||
locale.to_sym == I18n.locale ? 'active in': ''
|
locale.to_sym == I18n.locale ? 'active in': ''
|
||||||
end
|
end
|
||||||
|
|
||||||
<<<<<<< HEAD
|
def at_least_module_manager
|
||||||
def at_least_module_manager
|
|
||||||
is_manager? || is_admin?
|
is_manager? || is_admin?
|
||||||
end
|
end
|
||||||
=======
|
|
||||||
def dislpay_view_count(object)
|
def dislpay_view_count(object)
|
||||||
"#{t(:view_count)}: #{object.view_count}"
|
"#{t(:view_count)}: #{object.view_count}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
<% if at_least_module_manager %>
|
<% if at_least_module_manager %>
|
||||||
<%= show_ad_banner_permission_link ad_banner_tab%>
|
<%= show_ad_banner_permission_link ad_banner_tab%>
|
||||||
|
<%= link_to t('admin.ad.delete_banner'),admin_ad_banner_path(ad_banner_tab),:class => 'btn',:method => :delete,:confirm => t('sure?') %>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<%#= 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" } %>
|
||||||
</div>
|
</div>
|
||||||
<%#= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %>
|
<%#= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
<span id="ad_banner-modal-info"></span>
|
||||||
<%= f.submit t('submit'), :class=>'btn btn-primary',:remote=>true %>
|
<%= f.submit t('submit'), :class=>'btn btn-primary',:remote=>true %>
|
||||||
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
|
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
alert("Error occures:<%= @ad_banner.errors.full_messages%>");
|
$("#ad_banner-modal-info").append("<%= @ad_banner.errors.full_messages.join(',')%>");
|
|
@ -4,21 +4,23 @@
|
||||||
<% content_for :page_specific_javascript do -%>
|
<% content_for :page_specific_javascript do -%>
|
||||||
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
|
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
|
||||||
<%= javascript_include_tag "inc/modal-preview" %>
|
<%= javascript_include_tag "inc/modal-preview" %>
|
||||||
|
<%= javascript_include_tag "lib/contenteditable" %>
|
||||||
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
|
|
||||||
<div id="post-body-content" class="clear">
|
<div id="post-body-content" class="clear">
|
||||||
<ul id="banner_tab" class="nav nav-tabs">
|
<ul id="banner_tab" class="nav nav-tabs">
|
||||||
<% @ad_banners.each do |ab| %>
|
<% @ad_banners.each do |ab| %>
|
||||||
<%= content_tag :li,link_to(ab.title,"##{ab.title.dehumanize}",:data=>{:toggle=>"tab"}),:class => (ab == @active ? 'active' : nil ) %>
|
<%= content_tag :li,link_to(ab.title,"##{ab.title.dehumanize}",:data=>{:toggle=>"tab"}),:class => (ab == @active ? 'active' : nil ), :contenteditable=>"true" ,"data-edit-url"=>(admin_rename_ad_banner_path ab)%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<%#= content_tag :li,link_to(t("admin.ad.new_banner"),"#new-a-banner",:data=>{:toggle=>"modal"}),: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=>"modal"}),:id=>'new_ad_banner_tab_but',:class => (@active.nil? ? 'active' : nil ) %>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content" id="ad_banner-tab-content">
|
||||||
<%= render :partial => 'ad_banner_tab',:collection => @ad_banners %>
|
<%= render :partial => 'ad_banner_tab',:collection => @ad_banners %>
|
||||||
</div>
|
</div>
|
||||||
<%#= render :partial => "modal_ad_banner_form"%>
|
<%= render :partial => "modal_ad_banner_form"%>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
$('<%= escape_javascript(content_tag(:li,link_to(@ad_banner.title,"##{@ad_banner.title}",:data=>{:toggle=>"tab"}))) %>').insertBefore("#new_ad_banner_tab_but");
|
$('<%= 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"));
|
$('<%= escape_javascript(render(:partial => "ad_banner_tab",:locals => {:ad_banner_tab => @ad_banner})) %>').insertAfter($("#ad_banner-tab-content").children(".tab-pane").last());
|
||||||
|
|
||||||
$('.modal').modal('hide');
|
$('.modal').modal('hide');
|
||||||
|
$("#ad_banner-modal-info").empty();
|
||||||
|
$("#new-a-banner form").each(function(){this.reset();});
|
||||||
|
|
||||||
$('#new-a-banner').unbind();
|
$('#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.active').removeClass("active");
|
||||||
|
$("#ad_banner-tab-content").children(".tab-pane").removeClass("active");
|
||||||
$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");
|
$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");
|
||||||
|
$("#ad_banner-tab-content").children(".tab-pane").last().addClass("active");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,8 +82,9 @@ zh_tw:
|
||||||
sec_place_holder: 3秒請輸入3
|
sec_place_holder: 3秒請輸入3
|
||||||
ab_fx: 轉場特效
|
ab_fx: 轉場特效
|
||||||
all_banners: 輪播清單
|
all_banners: 輪播清單
|
||||||
cate_auth: 分類授權
|
|
||||||
banner_best_size: Banner 尺寸
|
banner_best_size: Banner 尺寸
|
||||||
|
cate_auth: 分類授權
|
||||||
|
delete_banner: 刪除整組輪播
|
||||||
new_banner: 新增輪播
|
new_banner: 新增輪播
|
||||||
new_image: 新增橫幅
|
new_image: 新增橫幅
|
||||||
showing: 顯示中
|
showing: 顯示中
|
||||||
|
@ -115,6 +116,9 @@ zh_tw:
|
||||||
choose_file: 請選擇一個文件...
|
choose_file: 請選擇一個文件...
|
||||||
class: 階級
|
class: 階級
|
||||||
content: 內容
|
content: 內容
|
||||||
|
contenteditable:
|
||||||
|
update_done: 更新完成
|
||||||
|
update_failed: 更新失敗
|
||||||
create_error_link: 新增連接時出錯。
|
create_error_link: 新增連接時出錯。
|
||||||
create_error_page: 新增頁面時出錯。
|
create_error_page: 新增頁面時出錯。
|
||||||
create_success_home: 首頁已成功新增。
|
create_success_home: 首頁已成功新增。
|
||||||
|
|
|
@ -37,6 +37,8 @@ Orbit::Application.routes.draw do
|
||||||
|
|
||||||
|
|
||||||
match 'ad_banners/:id/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put
|
match 'ad_banners/:id/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put
|
||||||
|
match 'ad_banners/:id/rename' => 'ad_banners#rename',:as => :rename_ad_banner,:via => :post
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue