fix ad_banner. new ad_image with best size from ad_banner. content editable at tab
This commit is contained in:
parent
5d5e798b1a
commit
16ada34585
|
@ -1,25 +1,37 @@
|
||||||
<%#= encoding: utf-8 %>
|
<%#= encoding: utf-8 %>
|
||||||
$(function() {
|
$(function() {
|
||||||
var content_holder, content;
|
var content_holder, content;
|
||||||
var selector = 'li[contenteditable="true"]';
|
var selector = 'a[contenteditable="true"]';
|
||||||
// prevent clicks inside editable area to fire
|
// prevent clicks inside editable area to fire
|
||||||
// a click event on the body
|
// a click event on the body
|
||||||
// and therefor saving our content before we even edit it
|
// and therefor saving our content before we even edit it
|
||||||
$(selector).click(function(e) {
|
|
||||||
e.stopPropagation();
|
$(".nav-tabs").find(".icons-pencil").click(function(){
|
||||||
});
|
$(this).css({
|
||||||
|
"display" : "none"
|
||||||
|
})
|
||||||
|
$(this).next().attr("contenteditable",true).addClass("edit");
|
||||||
|
// $(selector).click(function(e) {
|
||||||
|
// e.stopPropagation();
|
||||||
|
// });
|
||||||
|
|
||||||
// initialize the "save" function
|
// initialize the "save" function
|
||||||
$(selector).focus(function(e) {
|
$(selector).focus(function(e) {
|
||||||
content_holder = $(this);
|
content_holder = $(this);
|
||||||
content = content_holder.html();
|
content = content_holder.html();
|
||||||
|
|
||||||
// one click outside the editable area saves the content
|
// one click outside the editable area saves the content
|
||||||
$('body').one('click', function(e) {
|
$(selector).keypress( function(e) {
|
||||||
// but not if the content didn't change
|
// but not if the content didn't change
|
||||||
if ($(e.target).is(selector) || content == content_holder.html()) {
|
//alert('out!!');
|
||||||
return;
|
if(e.keyCode == 13){
|
||||||
}
|
$(".nav-tabs>li>a").removeClass("edit");
|
||||||
|
$(this).prev(".icons-pencil").css({
|
||||||
|
"display" : "block"
|
||||||
|
})
|
||||||
|
e.preventDefault();
|
||||||
|
// if ($(e.target).is(selector) || content == content_holder.html()) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: content_holder.data('edit-url'),
|
url: content_holder.data('edit-url'),
|
||||||
|
@ -27,6 +39,7 @@ $(function() {
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: { body: content_holder.html() },
|
data: { body: content_holder.html() },
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
|
$(selector).attr("contenteditable",false)
|
||||||
alert("<%= I18n.t("admin.contenteditable.update_done") %>");
|
alert("<%= I18n.t("admin.contenteditable.update_done") %>");
|
||||||
//content_holder.effect('highlight', {'color': '#0f0'}, 3000);
|
//content_holder.effect('highlight', {'color': '#0f0'}, 3000);
|
||||||
},
|
},
|
||||||
|
@ -36,6 +49,8 @@ $(function() {
|
||||||
content_holder.html(content);
|
content_holder.html(content);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
|
@ -606,6 +606,19 @@
|
||||||
.news_paragraph p {
|
.news_paragraph p {
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
.nav-tabs>li>.edit, .nav-tabs>li>.edit:hover {
|
||||||
|
background-color: #333;
|
||||||
|
color: #FFF;
|
||||||
|
padding-right: 12px;
|
||||||
|
}
|
||||||
|
.nav-tabs li .icons-pencil {
|
||||||
|
float: right;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
.nav-tabs li a {
|
||||||
|
padding-right: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*icons*/
|
/*icons*/
|
||||||
.the-icons i:after {
|
.the-icons i:after {
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Admin::AdBannersController < OrbitBackendController
|
||||||
|
|
||||||
def rename
|
def rename
|
||||||
@ad_banner = AdBanner.find(params[:id])
|
@ad_banner = AdBanner.find(params[:id])
|
||||||
@ad_banner.title = Nokogiri::HTML.fragment(params["body"]).at("a").children().to_s
|
@ad_banner.title = params[:body]
|
||||||
render :json => {:success =>@ad_banner.save!}
|
render :json => {:success =>@ad_banner.save!}
|
||||||
end
|
end
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -18,7 +18,8 @@ class Admin::AdImagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@ad_image =AdImage.new
|
ad_banner = AdBanner.find params[:ad_banner_id]
|
||||||
|
@ad_image =ad_banner.ad_images.build
|
||||||
@ad_image.post_date = Date.today
|
@ad_image.post_date = Date.today
|
||||||
@ad_image.unpost_date = Date.today + 30
|
@ad_image.unpost_date = Date.today + 30
|
||||||
#render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil}
|
#render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil}
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
<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 ), :contenteditable=>"true" ,"data-edit-url"=>(admin_rename_ad_banner_path ab)%>
|
<%= content_tag :li ,:class => (ab == @active ? 'active' : nil) do %>
|
||||||
|
<i class="icons-pencil"></i>
|
||||||
|
<%= link_to(ab.title,"##{ab.title.dehumanize}",:contenteditable=>"false",:data=>{:toggle=>"tab" ,'edit-url' =>(admin_rename_ad_banner_path ab) } )%>
|
||||||
|
<% end -%>
|
||||||
<% 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 ) %>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<% if bulletin -%>
|
||||||
|
|
||||||
|
<div class="modal hide fade in banner-preview" id="bulletin-<%=bulletin.id%>" style="width:1024px;height:500px;margin-left:-512px">
|
||||||
|
<div class="modal-header">
|
||||||
|
<a class="close" data-dismiss="modal">×</a>
|
||||||
|
<h3><%= t("modal.preview") %></h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p class="bulletin_slideshow">
|
||||||
|
|
||||||
|
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id ,:preview=>true) %> style="width:1000px;height:300px" >
|
||||||
|
|
||||||
|
</iframe>
|
||||||
|
|
||||||
|
<%# preview_block_ad_images_helper(bulletin).each do |ad_image| -%>
|
||||||
|
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || bulletin.context || " ")) %>
|
||||||
|
<%# end -%>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<script type="text/javascript" src="/static/kernel.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
// $("#bulletin-<%#=bulletin.title.dehumanize%>").on("show", function () {
|
||||||
|
// $("#bulletin-<%#=bulletin.title.dehumanize%>").find(".bulletin_slideshow").cycle({delay: -1000, fx: "<%#= bulletin.ad_fx.nil?? "fade": bulletin.ad_fx %>", timeoutFn: getTimeout });
|
||||||
|
// });
|
||||||
|
$(".modal").on("hidden", function () {
|
||||||
|
$("#show_preview").remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("iframe").load(function(){
|
||||||
|
// Get the body element
|
||||||
|
var frameBody = $("iframe").contents().find("body");
|
||||||
|
|
||||||
|
// Get all links inside the BODY tag
|
||||||
|
$('a', frameBody).click(function(e){
|
||||||
|
//Disable all default actions
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
$('input', frameBody).attr("disabled", true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% end -%>
|
|
@ -0,0 +1,2 @@
|
||||||
|
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_preview',:locals => {:bulletin => @bulletin})) %>");
|
||||||
|
var start_modal_with_id = "bulletin-<%=@bulletin.id%>"
|
|
@ -0,0 +1,55 @@
|
||||||
|
<% if page_context -%>
|
||||||
|
|
||||||
|
<div class="modal hide fade in banner-preview" id="page_context-<%=page_context.id%>" style="width:1024px;height:500px;margin-left:-512px">
|
||||||
|
<div class="modal-header">
|
||||||
|
<a class="close" data-dismiss="modal">×</a>
|
||||||
|
<h3><%= t("modal.preview") %></h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p class="page_context_slideshow">
|
||||||
|
|
||||||
|
<iframe src=<%= panel_page_content_back_end_view_path(page_context.page_id, :category_id => page_context.page_context_category.id ,:preview=>true) %> style="width:1000px;height:300px" >
|
||||||
|
|
||||||
|
</iframe>
|
||||||
|
|
||||||
|
<%# preview_block_ad_images_helper(page_context).each do |ad_image| -%>
|
||||||
|
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => page_context.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || page_context.context || " ")) %>
|
||||||
|
<%# end -%>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
|
||||||
|
|
||||||
|
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<script type="text/javascript" src="/static/kernel.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
// $("#page_context-<%#=page_context.title.dehumanize%>").on("show", function () {
|
||||||
|
// $("#page_context-<%#=page_context.title.dehumanize%>").find(".page_context_slideshow").cycle({delay: -1000, fx: "<%#= page_context.ad_fx.nil?? "fade": page_context.ad_fx %>", timeoutFn: getTimeout });
|
||||||
|
// });
|
||||||
|
$(".modal").on("hidden", function () {
|
||||||
|
$("#show_preview").remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("iframe").load(function(){
|
||||||
|
// Get the body element
|
||||||
|
var frameBody = $("iframe").contents().find("body");
|
||||||
|
|
||||||
|
// Get all links inside the BODY tag
|
||||||
|
$('a', frameBody).click(function(e){
|
||||||
|
//Disable all default actions
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
$('input', frameBody).attr("disabled", true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% end -%>
|
|
@ -0,0 +1,2 @@
|
||||||
|
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_preview',:locals => {:page_context => @page_context})) %>");
|
||||||
|
var start_modal_with_id = "page_context-<%=@page_context.id%>"
|
Reference in New Issue