diff --git a/app/assets/javascripts/lib/modal-preview.js b/app/assets/javascripts/lib/modal-preview.js index 475e5639..df59cd87 100644 --- a/app/assets/javascripts/lib/modal-preview.js +++ b/app/assets/javascripts/lib/modal-preview.js @@ -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(""); // 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; - var url = attrs['url']; - // url = url.replace("url=",""); - $("form.previewable").ajaxSubmit({ - beforeSubmit: function(a,f,o){ - $("#main-wrap").after(""); - o.dataType = 'script'; - o.url = url.nodeValue; - o.type = 'post'; - },success: function(msg) { } +// /panel/announcement/back_end/bulletins/preview + $('#main-wrap').on(clickEvent, '.post_preview, .preview_trigger', function(e) { + $("#main-wrap").after(""); + if($(this).hasClass('post_preview')) { + var attrs = e.target.attributes; + var url = attrs['url']; + $("form.previewable").ajaxSubmit({ + beforeSubmit: function(a,f,o){ + o.dataType = 'script'; + o.url = url.nodeValue; + o.type = 'post'; + },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(""); + // $.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(""); - $.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; - }); }); \ No newline at end of file diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index ef3d77bf..63314529 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -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 diff --git a/app/views/shared/preview/_modal_preview.html.erb b/app/views/shared/preview/_modal_preview.html.erb index 2722d198..98f5f149 100644 --- a/app/views/shared/preview/_modal_preview.html.erb +++ b/app/views/shared/preview/_modal_preview.html.erb @@ -4,37 +4,32 @@
- -
+