view for preview

This commit is contained in:
Matthew K. Fu JuYuan 2012-09-04 09:24:12 +08:00
parent fc4e2ceba5
commit ae1595a008
7 changed files with 80 additions and 1 deletions

View File

@ -3,6 +3,26 @@
// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%>
$(document).ready(function() {
$("a.post_preview").click(function(e){
$("#main-wrap").after("<span id='show_preview'></span>");
e.preventDefault();
var form = $(this).parents("form").first()
//var cont = form["content"].value;
$.ajax({
type: 'POST',
url: $(this).attr("href")+'?preview=true',
data: form.serialize(),
dataType: "script",
success: function (msg) {
$("#"+start_modal_with_id).modal('show'); },
error: function(){
alert("ERROR");
}
});
return false
});
$("a.preview_trigger").click(function(){
$("#main-wrap").after("<span id='show_preview'></span>");
$.ajax({

View File

@ -238,6 +238,7 @@
</div>
<div class="form-actions">
<%= link_to t('preview'),panel_announcement_back_end_bulletin_preview_path, :class=>"btn" %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>

View File

@ -15,6 +15,7 @@ Rails.application.routes.draw do
get 'load_quick_edit'
end
collection do
post "preview"
get 'delete'
end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add

View File

@ -1,5 +1,7 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "inc/modal-preview" %>
<% end -%>
<!--Widget start-->
<%= f.error_messages %>
@ -279,6 +281,7 @@
</div>
<div class="form-actions">
<%= link_to t('preview'),preview_panel_news_back_end_news_bulletins_path, :class=>"btn post_preview",:method=>:post , :remote => true%>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>

View File

@ -0,0 +1,47 @@
<div class="modal hide fade in banner-preview" id="<%= news_bulletin.id %>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("modal.preview") %></h3>
</div>
<div class="modal-body">
<p class="news_bulletin_slideshow">
<iframe src=<%= panel_news_front_end_news_bulletin_path(news_bulletin, :category_id => (news_bulletin.news_bulletin_category.id rescue ""),:preview=>true) %> style="width:1024px;height:300px" >
</iframe>
<%# preview_block_ad_images_helper(news_bulletin).each do |ad_image| -%>
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => news_bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || news_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() {
// $("#news_bulletin-<%#=news_bulletin.title.dehumanize%>").on("show", function () {
// $("#news_bulletin-<%#=news_bulletin.title.dehumanize%>").find(".news_bulletin_slideshow").cycle({delay: -1000, fx: "<%#= news_bulletin.ad_fx.nil?? "fade": news_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>

View File

@ -0,0 +1,5 @@
$('#show_preview').html('<%=escape_javascript(render :partial=>"modal_preview",:locals=>{:news_bulletin => @preview_news_bulletin}) %>');
var start_modal_with_id = "<%= @preview_news_bulletin.id %>";
$("#"+start_modal_with_id).css("width","1050px");
$("#"+start_modal_with_id).css("height","768px");
$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px");

View File

@ -11,10 +11,12 @@ Rails.application.routes.draw do
match "approve/:news_bulletin_id" => "news_approvals#approve",:as => :approve,:via => :post
match "link_quick_add/:news_bulletin_id" => "news_bulletins#link_quick_add" ,:as => :link_quick_add
match "link_quick_edit/:news_bulletin_id" => "news_bulletins#link_quick_edit" ,:as => :link_quick_edit
member do
get 'load_quick_edit'
end
collection do
post "preview"
get 'delete'
end
match "file_quick_add/:news_bulletin_id" => "news_bulletins#file_quick_add" ,:as => :file_quick_add