complete preview for both new and announcement
This commit is contained in:
1 parent
8bd5481b3f
commit
6044857fea
24 files changed
+301
-67
No files matched your search
+24
-8
@@ -13,10 +13,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
|
||||
|
||||
def preview
|
||||
debugger
|
||||
a=1
|
||||
|
||||
@bulletin = Bulletin.new_preview(params[:bulletin])
|
||||
#@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
|
||||
bulletin = Bulletin.new params
|
||||
@preview_obj = bulletin.to_preview
|
||||
@preview_obj.save
|
||||
render '/shared/preview/preview.js.erb'
|
||||
end
|
||||
|
||||
def index
|
||||
@@ -75,8 +76,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||
# GET /bulletins/new
|
||||
# GET /bulletins/new.xml
|
||||
def new
|
||||
@bulletin = Bulletin.new(:postdate => DateTime.now)
|
||||
|
||||
if(session[:in_validate_object].blank?)
|
||||
@bulletin = Bulletin.new(:postdate => DateTime.now)
|
||||
else
|
||||
@bulletin = session[:in_validate_object]
|
||||
session[:in_validate_object] = {}
|
||||
end
|
||||
|
||||
@link_url = panel_announcement_back_end_bulletins_path
|
||||
get_tags
|
||||
respond_to do |format|
|
||||
@@ -139,10 +145,20 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||
|
||||
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.create_bulletin_success')) }
|
||||
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
|
||||
format.js
|
||||
# format.js
|
||||
format.js {
|
||||
@info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
|
||||
flash[:notice] = t('bulletin.create_bulletin_success')
|
||||
render "/shared/preview/after_create.js.erb"
|
||||
}
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
|
||||
format.js {
|
||||
@info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
|
||||
session[:in_validate_object] = @bulletin
|
||||
render "/shared/preview/after_create.js.erb"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -344,7 +360,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
|
||||
|
||||
def get_tags
|
||||
module_app = ModuleApp.first(:conditions => {:key => 'announcement'})
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
|
||||
end
|
||||
|
||||
end
|
||||
+2
-1
@@ -69,7 +69,8 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||
end
|
||||
|
||||
def preview_content
|
||||
@bulletin = Bulletin.find params[:id]
|
||||
@bulletin = Bulletin.find params[:id] rescue nil
|
||||
@bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil?
|
||||
get_categorys
|
||||
end
|
||||
|
||||
|
||||
@@ -197,6 +197,18 @@ class Bulletin
|
||||
tags.order_by(I18n.locale, :asc)
|
||||
end
|
||||
|
||||
|
||||
def to_preview
|
||||
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_announcement_front_end_bulletin_path",:object_class_type=>"Bulletin")
|
||||
|
||||
self.bulletin["bulletin_files_attributes"].each_with_index do |atr,idx|
|
||||
preview_object.preview_files.build(:file=>self.bulletin["bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_files',:file_in_array=>true)
|
||||
end unless self.bulletin["bulletin_files_attributes"].nil?
|
||||
preview_object.object = self.bulletin.except("bulletin_files_attributes")
|
||||
preview_object
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def check_deadline
|
||||
@@ -223,4 +235,5 @@ class Bulletin
|
||||
self.tag_ids.delete('')
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Vendored
+5
-3
@@ -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 %>
|
||||
|
||||
@@ -238,8 +240,8 @@
|
||||
</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' %>
|
||||
<%= button_tag t("preview"), :name=>"commit",:class=>'btn post_preview two_btn',:type=>:button,:url=>preview_panel_announcement_back_end_bulletins_path %>
|
||||
<%= f.submit t('submit'), :class=>'btn btn-primary two_btn' %>
|
||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||
</div>
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
<div id="poststuff">
|
||||
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %>
|
||||
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path,:html=>{ :class=>"nccu_ajax_form"} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
</div>
|
||||
Vendored
+14
-7
@@ -11,7 +11,11 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||
end
|
||||
|
||||
def preview
|
||||
@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
|
||||
#@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
|
||||
news_bulletin = NewsBulletin.new params
|
||||
@preview_obj = news_bulletin.to_preview
|
||||
@preview_obj.save
|
||||
render '/shared/preview/preview.html.erb', :layout=>false
|
||||
end
|
||||
|
||||
def index
|
||||
@@ -88,9 +92,12 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||
# GET /news_bulletins/new
|
||||
# GET /news_bulletins/new.xml
|
||||
def new
|
||||
|
||||
@news_bulletin = NewsBulletin.new
|
||||
|
||||
if(session[:in_validate_object].blank?)
|
||||
@news_bulletin = NewsBulletin.new
|
||||
else
|
||||
@news_bulletin = session[:in_validate_object]
|
||||
session[:in_validate_object] = {}
|
||||
end
|
||||
@link_url = panel_news_back_end_news_bulletins_path
|
||||
|
||||
# @news_bulletin.news_bulletin_files.build
|
||||
@@ -120,7 +127,6 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||
# POST /news_bulletins
|
||||
# POST /news_bulletins.xml
|
||||
def create
|
||||
binding.pry
|
||||
get_tags
|
||||
|
||||
if params[:news_bulletin_link]
|
||||
@@ -161,7 +167,8 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
|
||||
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('news_bulletin.create_news_bulletin_success')) }
|
||||
format.xml { render :xml => @news_bulletin, :status => :created, :location => @news_bulletin }
|
||||
format.js
|
||||
format.js
|
||||
#format.json {render :json => {"success"=>"true","redirect_url"=>panel_news_back_end_news_bulletins_url,"notice" => t('news_bulletin.create_news_bulletin_success')}}
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @news_bulletin.errors, :status => :unprocessable_entity }
|
||||
@@ -379,7 +386,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
|
||||
|
||||
def get_tags
|
||||
module_app = ModuleApp.first(:conditions => {:key => 'news'})
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
|
||||
end
|
||||
|
||||
end
|
||||
@@ -237,6 +237,18 @@ class NewsBulletin
|
||||
def sorted_tags
|
||||
tags.order_by(I18n.locale, :asc)
|
||||
end
|
||||
|
||||
def to_preview
|
||||
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
|
||||
preview_object.preview_files.build(:file=>self.news_bulletin["image"],:field_name_for_rebuild=>'image')
|
||||
|
||||
|
||||
self.news_bulletin["news_bulletin_files_attributes"].each_with_index do |atr,idx|
|
||||
preview_object.preview_files.build(:file=>self.news_bulletin["news_bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'news_bulletin_files',:file_in_array=>true)
|
||||
end unless self.news_bulletin["news_bulletin_files_attributes"].nil?
|
||||
preview_object.object = self.news_bulletin.except("news_bulletin_files_attributes","image")
|
||||
preview_object
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@@ -260,4 +272,6 @@ class NewsBulletin
|
||||
self.tag_ids.delete('')
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
+4
-6
@@ -4,7 +4,6 @@
|
||||
<% end -%>
|
||||
<!--Widget start-->
|
||||
<%= f.error_messages %>
|
||||
|
||||
<div id="sub-wiget">
|
||||
<div id="widget-picture" class="widget-box">
|
||||
<div class="widget-action clear">
|
||||
@@ -15,7 +14,6 @@
|
||||
<div class="control-group">
|
||||
<!-- <img class="pull-left upload-picture" src="/assets/default-img.png" /> -->
|
||||
<div class="upload-picture">
|
||||
<!--請程式務必將圖片尺寸加入到行內裡-->
|
||||
<% if @news_bulletin.image %>
|
||||
<%= image_tag @news_bulletin.image rescue ''%>
|
||||
<% else %>
|
||||
@@ -132,7 +130,7 @@
|
||||
|
||||
<div id="post-body">
|
||||
<div id="post-body-content" class="clear">
|
||||
|
||||
<%= alert_block_tag(t("activerecord.errors.template.body"),session[:in_validate_object].errors.messages) unless session[:in_validate_object].blank? %>
|
||||
<%= f.label :unit_list_for_anc,t('news.news_bulletin.unit_name')%>
|
||||
<%= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title, t.id ]}, {:prompt => t("news.news_bulletin.ut_prompt")}, :class => "input-medium" %>
|
||||
|
||||
@@ -279,10 +277,10 @@
|
||||
</div>
|
||||
<!--Post End-->
|
||||
</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' %>
|
||||
<%= button_tag t("preview"), :name=>"commit", :class=>'btn post_preview two_btn',:type=>:button, :url=>preview_panel_news_back_end_news_bulletins_path %>
|
||||
<%= f.submit t('submit'), :class=>'btn btn-primary two_btn' %>
|
||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||
</div>
|
||||
|
||||
|
||||
Vendored
-47
@@ -1,47 +0,0 @@
|
||||
<div class="modal hide fade in banner-preview" id="<%= @preview_obj.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=<%= @preview_obj.get_preview_link %> 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>
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
<div id="poststuff">
|
||||
<%= form_for @news_bulletin, :url => panel_news_back_end_news_bulletins_path do |f| %>
|
||||
<%= form_for @news_bulletin, :url => panel_news_back_end_news_bulletins_path,:html=>{ :class=>"nccu_ajax_form"} do |f| %>
|
||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
||||
<% end %>
|
||||
</div>
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
$('#show_preview').html('<%=escape_javascript(render :partial=>"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");
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
<h1 class="h1"><%= @news_bulletin.title %></h1>
|
||||
<div class="info">
|
||||
<div class="info1">
|
||||
<span class="pull-right"><%= dislpay_view_count(@news_bulletin) %></span>
|
||||
<span class="date"><%= display_date(@news_bulletin.postdate) %></span>
|
||||
<span class="pull-right"><%= dislpay_view_count(@news_bulletin) rescue ""%></span>
|
||||
<span class="date"><%= display_date(@news_bulletin.postdate) rescue "" %></span>
|
||||
<% unit = @news_bulletin.unit_list_for_anc.title rescue nil %>
|
||||
<%= " | " if unit %>
|
||||
<%= link_to unit, panel_news_front_end_index_news_bulletins_by_unit_path(:name=>@news_bulletin.unit_list_for_anc_id) unless unit.blank?%>
|
||||
|
||||
Vendored
+1
-1
@@ -21,7 +21,7 @@
|
||||
<li>
|
||||
<div class="news_img"><%= link_to image_tag(post.image.url, :size => "290x130"), panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></div>
|
||||
<h3 class="h3 news_title"><%= link_to post.title, panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></h3>
|
||||
<p class="news_wrap"><%= post.subtitle.html_safe rescue '' %></p>
|
||||
<p class="news_wrap"><%= truncate((post.subtitle rescue '') ,:length => 200).html_safe %></p>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||
before_filter :authenticate_user!
|
||||
# before_filter :for_app_manager,:except => [:index,:show]
|
||||
before_filter :for_app_sub_manager,:except => [:index]
|
||||
before_filter :only => [ :new,:edit,:update] do |controller|
|
||||
before_filter :only => [ :new,:edit,:update,:create] do |controller|
|
||||
controller.get_categorys('WebLinkCategory')
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||
# POST /web_links.xml
|
||||
def create
|
||||
@web_link = WebLink.new(params[:web_link])
|
||||
|
||||
get_tags
|
||||
@web_link.create_user_id = current_user.id
|
||||
@web_link.update_user_id = current_user.id
|
||||
|
||||
@@ -159,7 +159,7 @@ class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController
|
||||
|
||||
def get_tags
|
||||
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id})
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}) rescue []
|
||||
end
|
||||
|
||||
end
|
||||
+1
-1
@@ -52,7 +52,7 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
|
||||
|
||||
def get_tags
|
||||
module_app = ModuleApp.first(:conditions => {:key => 'web_resource'})
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id})
|
||||
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}) rescue []
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user