fix new ui announcement preview

This commit is contained in:
Spen 2013-10-24 14:46:53 +08:00 committed by saurabhbhatia
parent 3a3f913ae6
commit 254f926093
10 changed files with 156 additions and 111 deletions

View File

@ -2,7 +2,7 @@
//Ex preview trigger: //Ex preview trigger:
// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%> // <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%>
$(document).ready(function() { $(function() {
// $(".post_preview").click(function(e){ // $(".post_preview").click(function(e){
// $("#main-wrap").after("<span id='show_preview'></span>"); // $("#main-wrap").after("<span id='show_preview'></span>");
// e.preventDefault(); // e.preventDefault();
@ -25,21 +25,57 @@ $(document).ready(function() {
// form.submit(); // form.submit();
// //return false; // //return false;
// }); // });
$("button.post_preview").click(function(){ // /panel/announcement/back_end/bulletins/preview
var btn = document.getElementById("button_for_preview"); $('#main-wrap').on(clickEvent, '.post_preview, .preview_trigger', function(e) {
var attrs = btn.attributes; $("#main-wrap").after("<span id='show_preview'></span>");
var url = attrs['url']; if($(this).hasClass('post_preview')) {
// url = url.replace("url=",""); var attrs = e.target.attributes;
$("form.previewable").ajaxSubmit({ var url = attrs['url'];
beforeSubmit: function(a,f,o){ $("form.previewable").ajaxSubmit({
$("#main-wrap").after("<span id='show_preview'></span>"); beforeSubmit: function(a,f,o){
o.dataType = 'script'; o.dataType = 'script';
o.url = url.nodeValue; o.url = url.nodeValue;
o.type = 'post'; o.type = 'post';
},success: function(msg) { } },success: function(msg) {
$('#show_preview .modal').modal()
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
}
}); });
}) } else if($(this).hasClass('preview_trigger')) {
$.ajax({
type: 'PUT',
url: $(this).attr("href"),
data: $(this).parents("form").serialize(),
success: function (msg) {
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
},
error: function(){
alert("ERROR");
}
});
return false;
}
});
// $("a.preview_trigger").on('click',function(){
// $("#main-wrap").after("<span id='show_preview'></span>");
// $.ajax({
// type: 'PUT',
// url:$(this).attr("href"),
// data:$(this).parents("form").serialize(),
// success: function (msg) {
// $("#"+start_modal_with_id).modal('show'); },
// error: function(){
// alert("ERROR");
// }
// });
// return false;
// });
// $("form.nccu_ajax_form").ajaxForm({ // $("form.nccu_ajax_form").ajaxForm({
// beforeSubmit: function(a,f,o) { // beforeSubmit: function(a,f,o) {
// // if(clicked_what.hasClass("post_preview")){ // // if(clicked_what.hasClass("post_preview")){
@ -54,19 +90,4 @@ $(document).ready(function() {
// // } // // }
// } // }
// }) // })
$("a.preview_trigger").on('click',function(){
$("#main-wrap").after("<span id='show_preview'></span>");
$.ajax({
type: 'PUT',
url:$(this).attr("href"),
data:$(this).parents("form").serialize(),
success: function (msg) {
$("#"+start_modal_with_id).modal('show'); },
error: function(){
alert("ERROR");
}
});
return false;
});
}); });

View File

@ -40,9 +40,13 @@ class DefaultWidgetController< OrbitWidgetController
def default_widget def default_widget
@search = params["search_query"].blank? ? false : true @search = params["search_query"].blank? ? false : true
if !params[:id].blank? if !params[:id].blank? and !params["clicked_field_name"].blank?
clicked_field_name = params["clicked_field_name"].to_sym clicked_field_name = params["clicked_field_name"].to_sym
redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}})") redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}})")
elsif !params[:id].blank? and params["preview"]
clicked_field_name = :title
@preview_pages = @page_part.module_app.widget_fields_link_method.find_all{|t| t[1].has_key?(:preview)}.collect{|t| t[0]}
redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {preview: true,inner: #{params[:inner] || true},clicked_field_name: '#{@preview_pages.first.to_s}'})")
else else
@tag_class = nil @tag_class = nil
@default_widget = @page_part.module_app.get_default_widget @default_widget = @page_part.module_app.get_default_widget

View File

@ -4,37 +4,32 @@
<h3><%= t(:preview) %></h3> <h3><%= t(:preview) %></h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class=""> <iframe src=<%= @preview_obj.get_preview_link %>></iframe>
<iframe src=<%= @preview_obj.get_preview_link %> style="width:1024px;height:300px" >
</iframe>
</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a> <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div> </div>
<div> <div>
<script type="text/javascript" src="/static/kernel.js"></script> <script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(function() {
$("iframe").load(function() {
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
$("iframe").load(function(){
// Get the body element // Get the body element
var frameBody = $("iframe").contents().find("body"); var frameBody = $("iframe").contents().find('body');
// Get all links inside the BODY tag // Get all links inside the BODY tag
$('a', frameBody).click(function(e){ $("iframe").contents().find('#orbit-bar').hide();
//Disable all default actions
e.preventDefault(); frameBody.find('a').click(function(e){
//Disable all default actions
e.preventDefault();
}); });
$('input', frameBody).attr("disabled", true); $('input', frameBody).attr("disabled", true);
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
}); });
});
</script> </script>
</div> </div>
</div> </div>

View File

@ -2,11 +2,8 @@
<textarea> <textarea>
<% end %> <% end %>
$('#show_preview').html('<%=escape_javascript(render :partial=>"/shared/preview/modal_preview") %>'); $('#show_preview').html('<%=escape_javascript(render :partial=>"/shared/preview/modal_preview") %>');
var start_modal_with_id = "<%= @preview_obj.id %>"; <!-- var start_modal_with_id = "<%= @preview_obj.id %>"; -->
$("#"+start_modal_with_id).css("width","1050px"); <!-- $("#"+start_modal_with_id).modal(); -->
$("#"+start_modal_with_id).css("height","768px");
$("#"+start_modal_with_id).css("margin","-270px 0 0 -550px");
$("#"+start_modal_with_id).modal();
<% if !request.xhr? %> <% if !request.xhr? %>
</textarea> </textarea>
<% end %> <% end %>

View File

@ -56,20 +56,30 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
delayed_impressionist(@tag) if @tag delayed_impressionist(@tag) if @tag
end end
end end
def show def show
@item = Page.find(params[:page_id]) rescue nil @item = Page.find(params[:page_id]) rescue nil
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first if params[:preview] == "true"
if @bulletin and !@bulletin.disable? and !@bulletin.is_rejected preview_content
if @bulletin.enabled_for_lang(I18n.locale.to_s)
impressionist(@bulletin)
else
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
end
else else
render :nothing => true, :status => 403 @bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
if @bulletin and !@bulletin.disable? and !@bulletin.is_rejected
if @bulletin.enabled_for_lang(I18n.locale.to_s)
delayed_impressionist(@bulletin)
else
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
end
else
render :nothing => true, :status => 403
end
end end
end
def preview_content
@bulletin = Bulletin.find params[:id] rescue nil
@bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil?
end end
end end

View File

@ -6,57 +6,78 @@
<h3><%= t(:preview) %></h3> <h3><%= t(:preview) %></h3>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class="bulletin_slideshow"> <iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %>></iframe>
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %> style="width:1024px;height:300px" >
</iframe>
</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'clear'} do |f| %> <%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'form-horizontal'} do |f| %>
<%= f.label :approval_stat, t('approval.stat') %>
<%= content_tag :label,:class => "radio inline" do -%> <%= content_tag :div,:class => "control-group pull-left" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %> <%= f.label :approval_stat, t('approval.stat'), :class=>"control-label" %>
<%= t('approval.pass') %>
<% end -%> <%= content_tag :div,:class => "controls" do -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (!@bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%> <%= content_tag :label,:class => "radio inline" do -%>
<%= t('approval.not_pass') %> <%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('approval.pass') %>
<% end -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (!@bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%>
<%= t('approval.not_pass') %>
<% end -%>
<% end -%>
<% end -%> <% end -%>
<%= label :is_checked_false, t('approval.not_pass_reason') %> <%= content_tag :div,:class => "control-group pull-left reject" do -%>
<%= f.text_field :not_checked_reason %> <%= label :is_checked_false, t('approval.not_pass_reason'), :class=>"control-label" %>
<%= f.submit t(:submit_approval),:class=>"btn"%> <%= content_tag :div,:class => "controls" do -%>
<%= f.text_field :not_checked_reason, :class=>"input-xlarge" %>
<% end %>
<% end %>
<%= content_tag :div,:class => "control-group pull-right" do -%>
<%= f.submit t(:submit_approval),:class=>"btn"%>
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<% end %>
<% end %> <% end %>
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div> </div>
<div> <div>
<script type="text/javascript" src="/static/kernel.js"></script> <script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(function() {
$("iframe").load(function() {
$(".modal").on("hidden", function () { // Get the body element
$("#show_preview").remove(); var frameBody = $("iframe").contents().find('body');
}); // Get all links inside the BODY tag
$("iframe").contents().find('#orbit-bar').hide();
$("iframe").load(function(){
// Get the body element frameBody.find('a').click(function(e){
var frameBody = $("iframe").contents().find("body"); //Disable all default actions
e.preventDefault();
// Get all links inside the BODY tag });
$('a', frameBody).click(function(e){ $('input', frameBody).attr("disabled", true);
//Disable all default actions });
e.preventDefault(); $(".modal").on("hidden", function () {
}); $("#show_preview").remove();
$('input', frameBody).attr("disabled", true); });
}); });
});
</script> </script>
<script>
$('#show_preview').on(clickEvent, 'input[type="radio"]', function(event) {
if($(this).val() == "true") {
$('.reject').addClass('hide');
} else {
$('.reject').removeClass('hide');
}
});
</script>
</div> </div>
</div> </div>
<% end -%> <% end -%>

View File

@ -25,7 +25,7 @@
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a> <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div> </div>
<div> <div>
<script type="text/javascript" src="/static/kernel.js"></script> <script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {

View File

@ -1,5 +1,2 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_approve',:locals => {:bulletin => @bulletin})) %>"); $('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_approve',:locals => {:bulletin => @bulletin})) %>");
var start_modal_with_id = "bulletin-<%=@bulletin.id%>"; var start_modal_with_id = "bulletin-<%=@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

@ -25,7 +25,7 @@
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a> <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div> </div>
<div> <div>
<script type="text/javascript" src="/static/kernel.js"></script> <script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {

View File

@ -19,7 +19,7 @@
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a> <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div> </div>
<div> <div>
<script type="text/javascript" src="/static/kernel.js"></script> <script type="text/javascript" src="/assets/kernel.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {