课程相关模块添加编辑器
This commit is contained in:
parent
073ef00bb7
commit
ceb6af7365
|
@ -41,7 +41,7 @@ module Mobile
|
|||
mount Apis::Comments
|
||||
|
||||
#add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'})
|
||||
#add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
|
||||
add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
class CommentsController < ApplicationController
|
||||
default_search_scope :news
|
||||
include ApplicationHelper
|
||||
model_object News
|
||||
before_filter :find_model_object
|
||||
before_filter :find_project_from_association
|
||||
|
@ -26,9 +27,11 @@ class CommentsController < ApplicationController
|
|||
raise Unauthorized unless @news.commentable?
|
||||
|
||||
@comment = Comment.new
|
||||
@comment.safe_attributes = params[:comment]
|
||||
@comment.comments = params[:comment]
|
||||
@comment.author = User.current
|
||||
if @news.comments << @comment
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
end
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ class ForumsController < ApplicationController
|
|||
respond_to do |format|
|
||||
if @memo.save
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids ,@memo.id,1
|
||||
update_kindeditor_assets_owner ids ,@memo.id,OwnerTypeHelper::MEMO
|
||||
#end
|
||||
format.html { redirect_to (forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id))), notice: "#{l :label_memo_create_succ}" }
|
||||
format.json { render json: @memo, status: :created, location: @memo }
|
||||
|
@ -171,7 +171,7 @@ class ForumsController < ApplicationController
|
|||
# Description after save后需要进行资源记录的更新
|
||||
# owner_type = 2 对应的是 forum
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids ,@forum.id,2
|
||||
update_kindeditor_assets_owner ids ,@forum.id,OwnerTypeHelper::FORUM
|
||||
#end
|
||||
respond_to do |format|
|
||||
|
||||
|
|
|
@ -86,6 +86,10 @@ class MessagesController < ApplicationController
|
|||
if request.post?
|
||||
@message.save_attachments(params[:attachments])
|
||||
if @message.save
|
||||
# 更新kindeditor上传的图片资源所有者
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE
|
||||
|
||||
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
|
||||
render_attachment_warning_if_needed(@message)
|
||||
redirect_to board_message_url(@board, @message)
|
||||
|
@ -117,6 +121,8 @@ class MessagesController < ApplicationController
|
|||
@topic.children << @reply
|
||||
#@topic.update_attribute(:updated_on, Time.now)
|
||||
if !@reply.new_record?
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@reply.id,OwnerTypeHelper::MESSAGE
|
||||
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
||||
attachments = Attachment.attach_files(@reply, params[:attachments])
|
||||
render_attachment_warning_if_needed(@reply)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
class NewsController < ApplicationController
|
||||
layout 'base_projects'# by young
|
||||
include ApplicationHelper
|
||||
before_filter :authorize1, :only => [:show]
|
||||
default_search_scope :news
|
||||
model_object News
|
||||
|
@ -136,6 +137,8 @@ class NewsController < ApplicationController
|
|||
@news.safe_attributes = params[:news]
|
||||
@news.save_attachments(params[:attachments])
|
||||
if @news.save
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS
|
||||
render_attachment_warning_if_needed(@news)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to course_news_index_url(@course)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# encoding: utf-8
|
||||
#####leave message fq
|
||||
class WordsController < ApplicationController
|
||||
|
||||
include ApplicationHelper
|
||||
before_filter :find_user, :only => [:new, :create, :destroy, :more, :back]
|
||||
def create
|
||||
if params[:new_form][:user_message].size>0
|
||||
|
@ -209,6 +209,8 @@ class WordsController < ApplicationController
|
|||
message = params[:new_form][:course_message]
|
||||
feedback = Course.add_new_jour(user, message, params[:id])
|
||||
if(feedback.errors.empty?)
|
||||
ids = params[:asset_id].split(',')
|
||||
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
|
||||
redirect_to course_feedback_url(params[:id]), notice: l(:label_feedback_success)
|
||||
else
|
||||
flash[:error] = feedback.errors.full_messages[0]
|
||||
|
|
|
@ -53,6 +53,10 @@ module ApplicationHelper
|
|||
# Author lizanle
|
||||
# Description after save后需要进行资源记录的更新
|
||||
# owner_type = 1 对应的是 memo
|
||||
# owner_type = 2 对应的是forum
|
||||
# owner_type = 3 对应的是message
|
||||
# owner_type = 4 对应的是news
|
||||
# owner_type = 5 对应的是comment
|
||||
def update_kindeditor_assets_owner ids,owner_id,owner_type
|
||||
ids.each do |id|
|
||||
asset = Kindeditor::Asset.find(id.to_i)
|
||||
|
|
|
@ -17,7 +17,8 @@ class Bid < ActiveRecord::Base
|
|||
HomeworkProject = 2
|
||||
attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
include ApplicationHelper
|
||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
||||
belongs_to :course
|
||||
has_many :biding_projects, :dependent => :destroy
|
||||
|
@ -47,7 +48,7 @@ class Bid < ActiveRecord::Base
|
|||
validate :validate_user
|
||||
validate :validate_reward_type
|
||||
after_create :act_as_activity
|
||||
|
||||
after_destroy :delete_kindeditor_assets
|
||||
scope :visible, lambda {|*args|
|
||||
nil
|
||||
}
|
||||
|
@ -157,5 +158,10 @@ class Bid < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# Time 2015-04-01 14:19:06
|
||||
# Author lizanle
|
||||
# Description 删除对应课程通知的图片资源
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::BID
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,8 +17,18 @@
|
|||
|
||||
class Comment < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include ApplicationHelper
|
||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
belongs_to :commented, :polymorphic => true, :counter_cache => true
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :commented, :author, :comments
|
||||
safe_attributes 'comments'
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
# Time 2015-03-31 09:15:06
|
||||
# Author lizanle
|
||||
# Description 删除对应评论的图片资源
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::COMMENT
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,7 +53,7 @@ class Forum < ActiveRecord::Base
|
|||
# Author lizanle
|
||||
# Description 删除论坛后删除对应的资源
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,2
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::FORUM
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
class JournalsForMessage < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
include ApplicationHelper
|
||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
safe_attributes "jour_type", # 留言所属类型
|
||||
"jour_id", # 留言所属类型的id
|
||||
"notes", # 留言内容
|
||||
|
@ -16,7 +18,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
"m_reply_id" # 回复某留言的留言id(a留言回复了b留言,这是b留言的id)
|
||||
"is_comprehensive_evaluation" # 1 教师评论、2 匿评、3 留言
|
||||
acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC"
|
||||
|
||||
after_destroy :delete_kindeditor_assets
|
||||
belongs_to :project,
|
||||
:foreign_key => 'jour_id',
|
||||
:conditions => "#{self.table_name}.jour_type = 'Project' "
|
||||
|
@ -163,5 +165,10 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# Time 2015-04-01 14:15:06
|
||||
# Author lizanle
|
||||
# Description 删除对应课程留言的图片资源
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,7
|
||||
end
|
||||
end
|
||||
|
|
|
@ -176,6 +176,6 @@ class Memo < ActiveRecord::Base
|
|||
# Author lizanle
|
||||
# Description 从硬盘上删除资源
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,1
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MEMO
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
class Message < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
include UserScoreHelper
|
||||
include ApplicationHelper
|
||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
belongs_to :board
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||
|
@ -62,7 +64,7 @@ class Message < ActiveRecord::Base
|
|||
|
||||
after_create :add_author_as_watcher, :reset_counters!
|
||||
after_update :update_messages_board
|
||||
after_destroy :reset_counters!,:down_user_score
|
||||
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
|
||||
|
||||
# fq
|
||||
after_create :act_as_activity,:be_user_score,:act_as_forge_activity
|
||||
|
@ -208,5 +210,10 @@ class Message < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
# Time 2015-03-31 09:15:06
|
||||
# Author lizanle
|
||||
# Description 删除对应消息的图片资源
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
class News < ActiveRecord::Base
|
||||
include Redmine::SafeAttributes
|
||||
belongs_to :project
|
||||
include ApplicationHelper
|
||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
#added by nwb
|
||||
belongs_to :course
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
|
@ -49,6 +51,7 @@ class News < ActiveRecord::Base
|
|||
# fq
|
||||
after_create :act_as_activity,:act_as_forge_activity
|
||||
# end
|
||||
after_destroy :delete_kindeditor_assets
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
||||
|
@ -105,4 +108,11 @@ class News < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# Time 2015-03-31 13:50:54
|
||||
# Author lizanle
|
||||
# Description 删除news后删除对应的资源
|
||||
def delete_kindeditor_assets
|
||||
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::NEWS
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,13 @@
|
|||
</li>
|
||||
<li class="ml45">
|
||||
<label class="fl" > <%= l(:field_quote)%> :</label>
|
||||
<textarea name="bid[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl"><%= bid.description%></textarea>
|
||||
<!--<textarea name="bid[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl"></textarea>-->
|
||||
<% if edit_mode %>
|
||||
<%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID %>
|
||||
<% else %>
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor' %>
|
||||
<% end %>
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml21">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<%= labelled_form_for @bid do |f| %>
|
||||
<%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}"} %>
|
||||
<%= render :partial => 'new_homework_form', :locals => { :bid => @bid, :bid_id => "edit_bid_#{@bid.id}",:f=>f,:edit_mode => true} %>
|
||||
<% end %>
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
<% if @project %>
|
||||
<%= render :partial => 'project_show', locals: {project: @project} %>
|
||||
<% elsif @course %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<div class="msg_box" id='leave-message'>
|
||||
<%# reply_allow = JournalsForMessage.create_by_user? User.current %>
|
||||
<h4><%= l(:label_leave_message) %></h4>
|
||||
|
@ -11,11 +11,12 @@
|
|||
</div>
|
||||
<% else %>
|
||||
<%= form_for('new_form', :method => :post,
|
||||
:url => {:controller => 'words', :action => 'leave_course_message'}) do |f|%>
|
||||
<%= f.text_area 'course_message',:id => "leave_meassge",:style => "resize: none;",
|
||||
:placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250%>
|
||||
:url => {:controller => 'words', :action => 'leave_course_message'},:html => {:id=>'leave_message_form'}) do |f|%>
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<%= f.kindeditor 'course_message',:editor_id => 'leave_message_editor',:input_html=>{:id => "leave_meassge",:style => "resize: none;",
|
||||
:placeholder => "#{l(:label_welcome_my_respond)}",:maxlength => 250}%>
|
||||
<a href="#" class="grey_btn fr ml10">取 消</a>
|
||||
<a href="#" onclick='$("#leave_meassge").parent().submit();' class="blue_btn fr"> <%= l(:button_leave_meassge)%></a>
|
||||
<a href="#" onclick='leave_message_editor.sync();$("#leave_message_form").submit();' class="blue_btn fr"> <%= l(:button_leave_meassge)%></a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</script>
|
||||
<div id="bid_description_<%= bid.id%>" class="news_description mt5">
|
||||
<div id="bid_description_<%= bid.id%>_content">
|
||||
<%= textilizable bid, :description %>
|
||||
<%= textAreailizable bid, :description %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="news_foot c_red" id="bid_show_more_des_button<%= bid.id%>" onclick="bid_show_more_des(<%= bid.id%>);" style="cursor:pointer;display: none;">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<%= labelled_form_for @homework, :url => {:controller => 'bids', :action => 'create_homework',:course_id => "#{params[:id] || params[:course_id]}"} do |f| %>
|
||||
<%= render :partial => 'bids/new_homework_form', :locals => { :bid => @homework,:bid_id => "new_bid" } %>
|
||||
<%= render :partial => 'bids/new_homework_form', :locals => { :bid => @homework,:bid_id => "new_bid",:f => f,:edit_mode => false } %>
|
||||
<% end %>
|
|
@ -1,3 +1,34 @@
|
|||
<script type="text/javascript">
|
||||
// var flag = false;
|
||||
// jQuery(document).ready(function($) {
|
||||
// transpotUrl('#content');
|
||||
// });
|
||||
// function submit_message_replay()
|
||||
// {
|
||||
// regexContent();//onkeyup传给kindeditor用不上了,所以只能放在这里
|
||||
// if(flag)
|
||||
// {
|
||||
// message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
|
||||
// $("#message_form").submit();
|
||||
// }
|
||||
// }
|
||||
// function regexContent()
|
||||
// {
|
||||
// var content = message_content_editor.html();//$.trim($("#message_content").val());
|
||||
// if(content.length ==0)
|
||||
// {
|
||||
// $("#message_content_span").text("<%= l(:label_reply_empty) %>");
|
||||
// $("#message_content_span").css('color','#ff0000');
|
||||
// flag = false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $("#message_content_span").text("<%= l(:label_field_correct) %>");
|
||||
// $("#message_content_span").css('color','#008000');
|
||||
// flag = true;
|
||||
// }
|
||||
// }
|
||||
</script>
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2"><%= l(:label_board) %></h2>
|
||||
</div>
|
||||
|
@ -24,7 +55,7 @@
|
|||
:class => 'talk_edit fr'
|
||||
) if @message.course_destroyable_by?(User.current) %>
|
||||
<div class="cl"></div>
|
||||
<div class="talk_info mb10"><%= textilizable(@topic, :content) %></div>
|
||||
<div class="talk_info mb10"><%= textAreailizable(@topic, :content) %></div>
|
||||
<div class="talk_info mb10"><%= link_to_attachments_course @topic, :author => false %></div>
|
||||
<!-- <a href="#" class=" link_file ml60">附件:爱覅俄方if.zip(27.5kB)</a>-->
|
||||
<div class="cl"></div>
|
||||
|
@ -52,7 +83,7 @@
|
|||
<%= link_to_user_header message.author,false,:class => 'c_blue fb fl mb10 ' %>
|
||||
<span class="c_grey fr"><%= format_time(message.created_on) %></span>
|
||||
<div class="cl"></div>
|
||||
<p><%= textilizable message,:content,:attachments => message.attachments %></p>
|
||||
<p><%= textAreailizable message,:content,:attachments => message.attachments %></p>
|
||||
<%= link_to_attachments_course message, :author => false %>
|
||||
</div>
|
||||
<div class="ping_disfoot">
|
||||
|
@ -87,7 +118,7 @@
|
|||
<div id="reply" style="display:none;">
|
||||
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %>
|
||||
<%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %>
|
||||
<a href="#" onclick="submit_message_replay();"class="blue_btn fl c_white" style="margin-left: 50px;"><%= l(:button_submit)%></a>
|
||||
<%= link_to l(:button_submit),"#",:onclick => 'course_board_submit_message_replay();' ,:class => "blue_btn fl c_white" ,:style=>"margin-left: 50px;"%>
|
||||
<% end %>
|
||||
<div id="preview" class="wiki"></div>
|
||||
</div>
|
||||
|
@ -97,32 +128,3 @@
|
|||
</ul>
|
||||
<% html_title @topic.subject %>
|
||||
|
||||
<script type="text/javascript">
|
||||
var flag = false;
|
||||
jQuery(document).ready(function($) {
|
||||
transpotUrl('#content');
|
||||
});
|
||||
function submit_message_replay()
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
$("#message_form").submit();
|
||||
}
|
||||
}
|
||||
function regexContent()
|
||||
{
|
||||
var content = $.trim($("#message_content").val());
|
||||
if(content.length ==0)
|
||||
{
|
||||
$("#message_content_span").text("<%= l(:label_reply_empty) %>");
|
||||
$("#message_content_span").css('color','#ff0000');
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#message_content_span").text("<%= l(:label_field_correct) %>");
|
||||
$("#message_content_span").css('color','#008000');
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -1,3 +1,4 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<%= error_messages_for 'message' %>
|
||||
<% replying ||= false %>
|
||||
<% extra_option = replying ? { readonly: true} : { maxlength: 200 } %>
|
||||
|
@ -28,7 +29,25 @@
|
|||
<div id="message_quote" class="wiki" style="width: 100%;word-break: break-all;word-wrap: break-word;"></div>
|
||||
<label class="fl" ><span class="c_red">*</span> <%= l(:field_description) %> :</label>
|
||||
<%= text_area :quote,:quote,:style => 'display:none' %>
|
||||
<%= f.text_area :content, :class => 'talk_text fl', :id => 'message_content', :onkeyup => "regexContent();", :maxlength => 5000,:placeholder => "最多3000个汉字(或6000个英文字符)" %>
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<% if replying %>
|
||||
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
|
||||
:width => '89%',
|
||||
:height => 300,
|
||||
:input_html => { :id => 'message_content',
|
||||
:class => 'talk_text fl',
|
||||
:maxlength => 5000 }%>
|
||||
<% else %>
|
||||
<%= f.kindeditor :content, :editor_id => 'message_content_editor',
|
||||
:owner_id => @message.nil? ? 0: @message.id,
|
||||
:owner_type => OwnerTypeHelper::MESSAGE,
|
||||
:width => '91%',
|
||||
:height => 300,
|
||||
:class => 'talk_text fl',
|
||||
:input_html => { :id => 'message_content',
|
||||
:class => 'talk_text fl',
|
||||
:maxlength => 5000 }%>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
<p id="message_content_span" class="ml55"></p>
|
||||
</li>
|
||||
|
|
|
@ -1,12 +1,21 @@
|
|||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<li class="ml45">
|
||||
<label><span class="c_red">*</span> <%= l(:field_title) %> :</label>
|
||||
<input type="text" name="news[title]" class="hwork_input" id="news_title" size="60" onkeyup="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>">
|
||||
<p id="title_notice_span" class="ml55"></p>
|
||||
</li>
|
||||
<li class="ml45">
|
||||
<label class="fl" ><span class="c_red">*</span> <%= l(:field_description) %> :</label>
|
||||
<textarea id="news_description" name="news[description]" placeholder="最多3000个汉字(或6000个英文字符)" class="hwork_text fl" onkeyup="regexDescription();" maxlength="6000"><%= is_new ? '' : @news.description %></textarea>
|
||||
<p id="description_notice_span" class="ml55"></p>
|
||||
<% if is_new %>
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<label class="fl" ><span class="c_red">*</span> <%= l(:field_description) %> :</label>
|
||||
<%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor' %>
|
||||
<p id="description_notice_span" class="ml55"></p>
|
||||
<% else %>
|
||||
<label class="fl" ><span class="c_red">*</span> <%= l(:field_description) %> :</label>
|
||||
<%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor',:owner_id => @news.id,:owner_type => OwnerTypeHelper::NEWS %>
|
||||
<p id="description_notice_span" class="ml55"></p>
|
||||
<% end %>
|
||||
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
<li class="ml45">
|
||||
|
@ -19,7 +28,7 @@
|
|||
<%= link_to l(:button_create), "#", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %>
|
||||
<%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %>
|
||||
<% else %>
|
||||
<%= link_to l(:button_save), "#", :onclick => 'submitNews();',:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %>
|
||||
<%= link_to l(:button_save), "#", :onclick => "submitNews();",:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<%= link_to_user_header(news.author,false,{:class=> 'problem_name c_orange fl'}) if news.respond_to?(:author) %>
|
||||
<span class="fl"> <%= l(:label_release_news) %>:</span><%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %><br />
|
||||
<div class="cl mb5"></div>
|
||||
<p id="news_description_<%= news.id %>" class="news_description mt5"><%= news.description %><br /> <%= l(:label_create_time) %> :<%= format_time(news.created_on) %></p>
|
||||
<p id="news_description_<%= news.id %>" class="news_description mt5"><%= textAreailizable news.description %><br /> <%= l(:label_create_time) %> :<%= format_time(news.created_on) %></p>
|
||||
<div class="news_foot" style="display: none;" onclick="news_show_more_des(<%= news.id %>);" id="news_foot_<%= news.id %>"><%= l(:label_expend_information) %> <span class="g-arr-down"><img src="/images/jiantou.jpg" width="12" height="6" /></span></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
function submitNews()
|
||||
{
|
||||
news_description_editor.sync();
|
||||
if(regexTitle() && regexDescription())
|
||||
{
|
||||
$("#news-form").submit();
|
||||
|
@ -51,6 +52,7 @@
|
|||
}
|
||||
function submitComment()
|
||||
{
|
||||
comment_editor.sync();
|
||||
$("#add_comment_form").submit();
|
||||
}
|
||||
function clearMessage()
|
||||
|
@ -58,7 +60,7 @@
|
|||
$("#comment_comments").val("");
|
||||
}
|
||||
</script>
|
||||
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2"><%= l(:label_course_news) %></h2>
|
||||
</div>
|
||||
|
@ -84,7 +86,7 @@
|
|||
:onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %>
|
||||
<%= delete_link(news_path(@news),:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %>
|
||||
<div class="cl"></div>
|
||||
<div class="mb5"><%= textilizable(@news, :description) %><br /> <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %></div>
|
||||
<div class="mb5"><%= textAreailizable(@news, :description) %><br /> <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %></div>
|
||||
<%= link_to_attachments_course @news %>
|
||||
<!--<a href="#" class=" link_file">附件:爱覅俄方if.zip(27.5kB)</a> -->
|
||||
</div>
|
||||
|
@ -95,8 +97,9 @@
|
|||
<div class="msg_box">
|
||||
<h4><%= l(:label_comment_add) %></h4>
|
||||
<%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %>
|
||||
<div class="box">
|
||||
<%= text_area 'comment', 'comments', :placeholder=>"最多250个字"%>
|
||||
<div class="box" >
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<%= kindeditor_tag :comment, '',:height=>'100',:editor_id =>'comment_editor', :placeholder=>"最多250个字"%>
|
||||
</div>
|
||||
<p>
|
||||
<a href="#" class="grey_btn fr ml10" onclick="clearMessage();"><%= l(:label_cancel_with_space) %></a>
|
||||
|
@ -106,6 +109,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% comments = @comments.reverse %>
|
||||
<% comments.each do |comment| %>
|
||||
<% next if comment.new_record? %>
|
||||
|
@ -115,7 +119,7 @@
|
|||
<div class="ping_distop">
|
||||
<%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %><span class="c_grey fr"><%= format_time(comment.created_on) %></span>
|
||||
<div class="cl"></div>
|
||||
<p><%= textilizable(comment.comments) %></p>
|
||||
<p><%= textAreailizable(comment.comments) %></p>
|
||||
</div>
|
||||
<div class="ping_disfoot"><%= link_to_if_authorized_course image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
|
||||
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
|
||||
|
|
|
@ -3,9 +3,17 @@ if defined?(ActiveRecord)
|
|||
def self.has_many_kindeditor_assets(*args)
|
||||
options = args.extract_options!
|
||||
asset_name = args[0] ? args[0].to_s : 'assets'
|
||||
has_many asset_name.to_sym, :class_name => 'Kindeditor::Asset', :foreign_key => 'owner_id', :dependent => options[:dependent]
|
||||
|
||||
class_name = self.name
|
||||
# Time 2015-04-01 14:20:32
|
||||
# Author lizanle
|
||||
# Description 对象类型对应的数值,kindeditor_assets表里owner_type的值
|
||||
|
||||
has_many asset_name.to_sym,
|
||||
:class_name => 'Kindeditor::Asset',
|
||||
:conditions => "owner_type = #{('OwnerTypeHelper::'+class_name.upcase).constantize}",
|
||||
:foreign_key => 'owner_id', :dependent => options[:dependent]
|
||||
|
||||
|
||||
Kindeditor::Asset.class_eval do
|
||||
belongs_to :owner, :class_name => class_name, :foreign_key => 'owner_id'
|
||||
end
|
||||
|
|
|
@ -20,7 +20,11 @@ module RailsKindeditor
|
|||
def kindeditor_upload_json_path(*args)
|
||||
options = args.extract_options!
|
||||
owner_id_query_string = options[:owner_id] ? "?owner_id=#{options[:owner_id]}" : ''
|
||||
owner_type_query_string = options[:owner_type] ? owner_id_query_string + "&owner_type=#{options[:owner_type]}" : owner_id_query_string
|
||||
if owner_id_query_string.blank?
|
||||
owner_type_query_string = options[:owner_type] ? "?owner_type=#{options[:owner_type]}" : ""
|
||||
else
|
||||
owner_type_query_string = options[:owner_type] ? owner_id_query_string + "&owner_type=#{options[:owner_type]}" : owner_id_query_string
|
||||
end
|
||||
"#{main_app_root_url}kindeditor/upload#{owner_type_query_string}"
|
||||
end
|
||||
|
||||
|
|
|
@ -257,14 +257,10 @@ K.options = {
|
|||
minHeight : 100,
|
||||
minChangeSize : 50,
|
||||
zIndex : 811213,
|
||||
items : [
|
||||
'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code',
|
||||
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
|
||||
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
|
||||
'superscript', 'quickformat', 'fullscreen','|', '/',
|
||||
'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
|
||||
'anchor', 'link', '|'
|
||||
items : ['emoticons',
|
||||
'source','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', '|',
|
||||
'formatblock', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
|
||||
'italic', 'underline', 'removeformat', '|', 'image', 'table', 'link', '|', 'fullscreen'
|
||||
],
|
||||
noDisableItems : ['source', 'fullscreen'],
|
||||
colorTable : [
|
||||
|
|
|
@ -129,7 +129,7 @@ function regexSubject()
|
|||
}
|
||||
function regexContent()
|
||||
{
|
||||
var content = $.trim($("#message_content").val());
|
||||
var content = message_content_editor.html();
|
||||
if(content.length ==0)
|
||||
{
|
||||
$("#message_content_span").text("描述不能为空");
|
||||
|
@ -146,6 +146,7 @@ function regexContent()
|
|||
}
|
||||
function submitCoursesBoard()
|
||||
{
|
||||
message_content_editor.sync();
|
||||
if(regexSubject()&®exContent()){$("#message-form").submit();}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
@ -177,7 +178,7 @@ function regexTitle()
|
|||
|
||||
function regexDescription()
|
||||
{
|
||||
var name = $("#news_description").val();
|
||||
var name = news_description_editor.html();
|
||||
if(name.length ==0)
|
||||
{
|
||||
$("#description_notice_span").text("描述不能为空");
|
||||
|
@ -185,6 +186,12 @@ function regexDescription()
|
|||
$("#description_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else if(name.length >=6000){
|
||||
$("#description_notice_span").text("描述最多3000个汉字(或6000个英文字符)");
|
||||
$("#description_notice_span").css('color','#ff0000');
|
||||
$("#description_notice_span").focus();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#description_notice_span").text("填写正确");
|
||||
|
@ -193,10 +200,12 @@ function regexDescription()
|
|||
}
|
||||
}
|
||||
|
||||
function submitNews()
|
||||
function submitNews(is_new)
|
||||
{
|
||||
alert(is_new)
|
||||
if(regexTitle() && regexDescription())
|
||||
{
|
||||
news_description_editor.sync();
|
||||
$("#news-form").submit();
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +214,31 @@ function submitFocus(obj)
|
|||
{
|
||||
$(obj).focus();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////课程讨论区
|
||||
function course_board_submit_message_replay()
|
||||
{
|
||||
if(MessageReplayVevify())
|
||||
{
|
||||
message_content_editor.sync();//提交内容之前要sync,不然服务器端取不到值
|
||||
$("#message_form").submit();
|
||||
}
|
||||
}
|
||||
function MessageReplayVevify() {
|
||||
var content = message_content_editor.html();//$.trim($("#message_content").val());
|
||||
if (content.length == 0) {
|
||||
$("#message_content_span").text("<%= l(:label_reply_empty) %>");
|
||||
$("#message_content_span").css('color', '#ff0000');
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$("#message_content_span").text("<%= l(:label_field_correct) %>");
|
||||
$("#message_content_span").css('color', '#008000');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////
|
||||
//验证搜索时输入名字
|
||||
|
@ -336,6 +370,7 @@ function submit_new_bid(id)
|
|||
{
|
||||
if(regex_bid_name()&®ex_evaluation_num())
|
||||
{
|
||||
bid_description_editor.sync();
|
||||
$("#"+id).submit();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue