fix new ui announcement preview
This commit is contained in:
		
							parent
							
								
									3a3f913ae6
								
							
						
					
					
						commit
						254f926093
					
				| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
//Ex 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){
 | 
			
		||||
	// 	$("#main-wrap").after("<span id='show_preview'></span>");
 | 
			
		||||
	// 	e.preventDefault();
 | 
			
		||||
| 
						 | 
				
			
			@ -25,21 +25,57 @@ $(document).ready(function() {
 | 
			
		|||
 //        	form.submit();
 | 
			
		||||
	// 	//return false;
 | 
			
		||||
	// });
 | 
			
		||||
	$("button.post_preview").click(function(){
 | 
			
		||||
		var btn = document.getElementById("button_for_preview");
 | 
			
		||||
		var attrs = btn.attributes;
 | 
			
		||||
// /panel/announcement/back_end/bulletins/preview 
 | 
			
		||||
	$('#main-wrap').on(clickEvent, '.post_preview, .preview_trigger', function(e) {
 | 
			
		||||
		$("#main-wrap").after("<span id='show_preview'></span>");
 | 
			
		||||
		if($(this).hasClass('post_preview')) {
 | 
			
		||||
			var attrs = e.target.attributes;
 | 
			
		||||
			var url = attrs['url'];
 | 
			
		||||
		// url = url.replace("url=","");
 | 
			
		||||
			$("form.previewable").ajaxSubmit({
 | 
			
		||||
				beforeSubmit: function(a,f,o){
 | 
			
		||||
				$("#main-wrap").after("<span id='show_preview'></span>");
 | 
			
		||||
					o.dataType = 'script';
 | 
			
		||||
					o.url = url.nodeValue;
 | 
			
		||||
					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({
 | 
			
		||||
 //        beforeSubmit: function(a,f,o) {
 | 
			
		||||
 //        	// 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;
 | 
			
		||||
		});
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			@ -40,9 +40,13 @@ class DefaultWidgetController< OrbitWidgetController
 | 
			
		|||
 | 
			
		||||
  def default_widget
 | 
			
		||||
    @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
 | 
			
		||||
      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
 | 
			
		||||
      @tag_class = nil
 | 
			
		||||
      @default_widget = @page_part.module_app.get_default_widget
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,36 +4,31 @@
 | 
			
		|||
    <h3><%= t(:preview) %></h3>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="modal-body">
 | 
			
		||||
    <p class="">
 | 
			
		||||
      <iframe src=<%= @preview_obj.get_preview_link %> style="width:1024px;height:300px" >
 | 
			
		||||
 | 
			
		||||
        </iframe>
 | 
			
		||||
    </p>
 | 
			
		||||
    <iframe src=<%= @preview_obj.get_preview_link %>></iframe>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="modal-footer">
 | 
			
		||||
    
 | 
			
		||||
    <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div>
 | 
			
		||||
    <script type="text/javascript" src="/static/kernel.js"></script>
 | 
			
		||||
    <script type="text/javascript" src="/assets/kernel.js"></script>
 | 
			
		||||
    <script type="text/javascript">
 | 
			
		||||
      $(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
    $(".modal").on("hidden", function () {
 | 
			
		||||
    $("#show_preview").remove();
 | 
			
		||||
      });
 | 
			
		||||
      
 | 
			
		||||
      $(function() {
 | 
			
		||||
        $("iframe").load(function() {
 | 
			
		||||
          // Get the body element
 | 
			
		||||
          var frameBody = $("iframe").contents().find("body");
 | 
			
		||||
 | 
			
		||||
          var frameBody = $("iframe").contents().find('body');
 | 
			
		||||
          // Get all links inside the BODY tag
 | 
			
		||||
          $('a', frameBody).click(function(e){
 | 
			
		||||
          $("iframe").contents().find('#orbit-bar').hide();
 | 
			
		||||
          
 | 
			
		||||
          frameBody.find('a').click(function(e){
 | 
			
		||||
            //Disable all default actions
 | 
			
		||||
            e.preventDefault();
 | 
			
		||||
          });
 | 
			
		||||
          $('input', frameBody).attr("disabled", true);
 | 
			
		||||
        });
 | 
			
		||||
        $(".modal").on("hidden", function () {
 | 
			
		||||
          $("#show_preview").remove();
 | 
			
		||||
        });
 | 
			
		||||
      });
 | 
			
		||||
    </script>
 | 
			
		||||
  </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,11 +2,8 @@
 | 
			
		|||
<textarea>
 | 
			
		||||
<% end %>
 | 
			
		||||
$('#show_preview').html('<%=escape_javascript(render :partial=>"/shared/preview/modal_preview") %>');
 | 
			
		||||
var start_modal_with_id = "<%= @preview_obj.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");
 | 
			
		||||
$("#"+start_modal_with_id).modal();
 | 
			
		||||
<!-- var start_modal_with_id = "<%= @preview_obj.id %>";  -->
 | 
			
		||||
<!-- $("#"+start_modal_with_id).modal(); -->
 | 
			
		||||
<% if !request.xhr? %>
 | 
			
		||||
</textarea>
 | 
			
		||||
<% end %>
 | 
			
		||||
| 
						 | 
				
			
			@ -60,10 +60,13 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
 | 
			
		|||
  
 | 
			
		||||
  def show
 | 
			
		||||
    @item = Page.find(params[:page_id]) rescue nil
 | 
			
		||||
    if params[:preview] == "true"
 | 
			
		||||
      preview_content
 | 
			
		||||
    else
 | 
			
		||||
      @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)
 | 
			
		||||
        impressionist(@bulletin)
 | 
			
		||||
          delayed_impressionist(@bulletin)
 | 
			
		||||
        else
 | 
			
		||||
          render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe 
 | 
			
		||||
        end
 | 
			
		||||
| 
						 | 
				
			
			@ -73,3 +76,10 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
 | 
			
		|||
    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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,57 +6,78 @@
 | 
			
		|||
    <h3><%= t(:preview) %></h3>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="modal-body">
 | 
			
		||||
    <p class="bulletin_slideshow">
 | 
			
		||||
			<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %> style="width:1024px;height:300px" >
 | 
			
		||||
 | 
			
		||||
				</iframe>
 | 
			
		||||
    </p>
 | 
			
		||||
		<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %>></iframe>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="modal-footer">
 | 
			
		||||
 | 
			
		||||
		<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'clear'} do |f| %>
 | 
			
		||||
		<%= f.label :approval_stat, t('approval.stat') %>
 | 
			
		||||
		<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'form-horizontal'} do |f| %>
 | 
			
		||||
 | 
			
		||||
      <%= content_tag :div,:class => "control-group pull-left" do -%>
 | 
			
		||||
				<%= f.label :approval_stat, t('approval.stat'), :class=>"control-label" %>
 | 
			
		||||
 | 
			
		||||
				<%= content_tag :div,:class => "controls" do -%>
 | 
			
		||||
 | 
			
		||||
					<%= content_tag :label,:class => "radio inline" do -%>
 | 
			
		||||
						<%= 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 -%>
 | 
			
		||||
 | 
			
		||||
				<%= label :is_checked_false, t('approval.not_pass_reason') %>
 | 
			
		||||
			    <%= f.text_field :not_checked_reason %>
 | 
			
		||||
			<%= f.submit t(:submit_approval),:class=>"btn"%>
 | 
			
		||||
				<% end -%>
 | 
			
		||||
 | 
			
		||||
			<% end -%>
 | 
			
		||||
 | 
			
		||||
      <%= content_tag :div,:class => "control-group pull-left reject" do -%>
 | 
			
		||||
				<%= label :is_checked_false, t('approval.not_pass_reason'), :class=>"control-label" %>
 | 
			
		||||
			  <%= 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 %>
 | 
			
		||||
 | 
			
		||||
    <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div>
 | 
			
		||||
  	<script type="text/javascript" src="/static/kernel.js"></script>
 | 
			
		||||
  	<script type="text/javascript" src="/assets/kernel.js"></script>
 | 
			
		||||
		<script type="text/javascript">
 | 
			
		||||
			$(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
		$(".modal").on("hidden", function () {
 | 
			
		||||
	  $("#show_preview").remove();
 | 
			
		||||
			});
 | 
			
		||||
			
 | 
			
		||||
			$(function() {
 | 
			
		||||
	      $("iframe").load(function() {
 | 
			
		||||
	        // Get the body element
 | 
			
		||||
          var frameBody = $("iframe").contents().find("body");
 | 
			
		||||
 | 
			
		||||
	        var frameBody = $("iframe").contents().find('body');
 | 
			
		||||
	        // Get all links inside the BODY tag
 | 
			
		||||
          $('a', frameBody).click(function(e){
 | 
			
		||||
	        $("iframe").contents().find('#orbit-bar').hide();
 | 
			
		||||
	        
 | 
			
		||||
	        frameBody.find('a').click(function(e){
 | 
			
		||||
	          //Disable all default actions
 | 
			
		||||
	          e.preventDefault();
 | 
			
		||||
	        });
 | 
			
		||||
	        $('input', frameBody).attr("disabled", true);
 | 
			
		||||
	      });
 | 
			
		||||
	      $(".modal").on("hidden", function () {
 | 
			
		||||
	        $("#show_preview").remove();
 | 
			
		||||
	      });
 | 
			
		||||
	    });
 | 
			
		||||
		</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>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<% end -%>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@
 | 
			
		|||
    <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div>
 | 
			
		||||
  	<script type="text/javascript" src="/static/kernel.js"></script>
 | 
			
		||||
  	<script type="text/javascript" src="/assets/kernel.js"></script>
 | 
			
		||||
		<script type="text/javascript">
 | 
			
		||||
			$(document).ready(function() {
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,2 @@
 | 
			
		|||
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_approve',:locals => {:bulletin => @bulletin})) %>");
 | 
			
		||||
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");
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +25,7 @@
 | 
			
		|||
    <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div>
 | 
			
		||||
  	<script type="text/javascript" src="/static/kernel.js"></script>
 | 
			
		||||
  	<script type="text/javascript" src="/assets/kernel.js"></script>
 | 
			
		||||
		<script type="text/javascript">
 | 
			
		||||
			$(document).ready(function() {
 | 
			
		||||
	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@
 | 
			
		|||
    <a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
 | 
			
		||||
  </div>
 | 
			
		||||
  <div>
 | 
			
		||||
    <script type="text/javascript" src="/static/kernel.js"></script>
 | 
			
		||||
    <script type="text/javascript" src="/assets/kernel.js"></script>
 | 
			
		||||
    <script type="text/javascript">
 | 
			
		||||
      $(document).ready(function() {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue