diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index 8f7f0342f..3673d623c 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -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 diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 9f61306ab..0d1c39104 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -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 diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index c347ba6b8..f59704a62 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -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| diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b50b2720f..2ad388f41 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -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) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 617e56575..27c4aa37f 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -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) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 2fc4fef9a..de2fbc732 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -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] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fd567c1fa..c94108dc1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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) diff --git a/app/models/bid.rb b/app/models/bid.rb index 10476b4d3..ccd6198bb 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -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 diff --git a/app/models/comment.rb b/app/models/comment.rb index 539c62e85..880bf448c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -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 diff --git a/app/models/forum.rb b/app/models/forum.rb index 6843ab678..52417f25e 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -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 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 23d9c7753..6875e6f4a 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -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 diff --git a/app/models/memo.rb b/app/models/memo.rb index eb0c86855..182ea314e 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -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 diff --git a/app/models/message.rb b/app/models/message.rb index 85a87132d..dd1dcf92e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -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 diff --git a/app/models/news.rb b/app/models/news.rb index d2547fc02..116353cf7 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -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 diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 9f3bf30c7..505fc88a8 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -13,7 +13,13 @@
  • - + + <% 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 %>
  • diff --git a/app/views/bids/edit.html.erb b/app/views/bids/edit.html.erb index 80a023ac1..4133a24b2 100644 --- a/app/views/bids/edit.html.erb +++ b/app/views/bids/edit.html.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 6e5888363..81d1288fd 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,3 +1,4 @@ + <% if @project %> <%= render :partial => 'project_show', locals: {project: @project} %> <% elsif @course %> diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index 5f2a67ebb..e79dac59b 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -1,4 +1,4 @@ - +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
    <%# reply_allow = JournalsForMessage.create_by_user? User.current %>

    <%= l(:label_leave_message) %>

    @@ -11,11 +11,12 @@
    <% 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}%> 取  消 - <%= l(:button_leave_meassge)%> + <%= l(:button_leave_meassge)%> <% end %> <% end %> diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index 9317027e2..98440abab 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -32,7 +32,7 @@
    - <%= textilizable bid, :description %> + <%= textAreailizable bid, :description %>
    @@ -87,7 +118,7 @@ @@ -97,32 +128,3 @@ <% html_title @topic.subject %> - \ No newline at end of file diff --git a/app/views/messages/_form_course.html.erb b/app/views/messages/_form_course.html.erb index 8f806ac97..dc350bcb3 100644 --- a/app/views/messages/_form_course.html.erb +++ b/app/views/messages/_form_course.html.erb @@ -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 @@
    <%= 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 %>

  • diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index b32401d7c..5c0fc8274 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -1,12 +1,21 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
  • - - -

    + <% if is_new %> + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + + <%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor' %> +

    + <% else %> + + <%= f.kindeditor :description,:width=>'91%',:editor_id=>'news_description_editor',:owner_id => @news.id,:owner_type => OwnerTypeHelper::NEWS %> +

    + <% end %> +
  • @@ -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 %>
    diff --git a/app/views/news/_course_news.html.erb b/app/views/news/_course_news.html.erb index a9af6551c..c6940ce10 100644 --- a/app/views/news/_course_news.html.erb +++ b/app/views/news/_course_news.html.erb @@ -51,7 +51,7 @@ <%= link_to_user_header(news.author,false,{:class=> 'problem_name c_orange fl'}) if news.respond_to?(:author) %> <%= l(:label_release_news) %>:<%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %>
    -

    <%= news.description %>
    <%= l(:label_create_time) %> :<%= format_time(news.created_on) %>

    +

    <%= textAreailizable news.description %>
    <%= l(:label_create_time) %> :<%= format_time(news.created_on) %>

    diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb index ed6011e29..3334f7c6a 100644 --- a/app/views/news/_course_show.html.erb +++ b/app/views/news/_course_show.html.erb @@ -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(""); } - +<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>

    <%= l(:label_course_news) %>

    @@ -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) %>
    -
    <%= textilizable(@news, :description) %>
    <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    +
    <%= textAreailizable(@news, :description) %>
    <%= l(:label_create_time) %> : <%= format_time(@news.created_on) %>
    <%= link_to_attachments_course @news %> @@ -95,8 +97,9 @@

    <%= l(:label_comment_add) %>

    <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form") do %> -
    - <%= text_area 'comment', 'comments', :placeholder=>"最多250个字"%> +
    + <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> + <%= kindeditor_tag :comment, '',:height=>'100',:editor_id =>'comment_editor', :placeholder=>"最多250个字"%>

    <%= l(:label_cancel_with_space) %> @@ -106,6 +109,7 @@ <% end %>

    <% end %> + <% comments = @comments.reverse %> <% comments.each do |comment| %> <% next if comment.new_record? %> @@ -115,7 +119,7 @@
    <%= link_to_user_header(comment.author,false,:class => 'c_blue fb fl mb10 ') if comment.respond_to?(:author) %><%= format_time(comment.created_on) %>
    -

    <%= textilizable(comment.comments) %>

    +

    <%= textAreailizable(comment.comments) %>

    <%= 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) %> diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb b/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb index 5120acf0a..18e1d57ec 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/active_record.rb @@ -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 diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index db2be85fb..8db3a637e 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -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 diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index e39c6e19e..680899eee 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -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 : [ diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 4ca2c3403..3536478a8 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -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(); } }