From 68bd1098319f4388cd8b821b0664f419a2af63e0 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 29 Jan 2016 17:26:28 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=AF=B9=E5=AD=90=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=89=B9=E5=87=86=E7=9A=84=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/setting.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index b9b2f9b4c..a91a079ef 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -58,6 +58,11 @@
http:// .trustie.net申请 + <% if @organization.domain.present? %> + (已批准) + <% elsif OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).count > 0 %> + (您申请了子域名<%= OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content %>,还未批准) + <% end %>

From 125f00689b2cad67214ded459487fd6652565cc2 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 29 Jan 2016 17:49:20 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E6=8A=8A=E7=BB=84=E7=BB=87=E6=9C=AA?= =?UTF-8?q?=E8=AF=BB=E6=B6=88=E6=81=AF=E5=8A=A0=E5=85=A5=E9=93=83=E9=93=9B?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index d89f2f57a..a74c20751 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -345,7 +345,8 @@ class User < Principal user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count system_messages_count = SystemMessage.where("created_at >?", User.current.onclick_time.onclick_time).count at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", User.current.id, 0, User.current.onclick_time.onclick_time).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", User.current.id,0, User.current.onclick_time.onclick_time).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count end # 查询指派给我的缺陷记录 From b7f1177938198fcf63eadb7732ba1b73f064311b Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 29 Jan 2016 18:11:16 +0800 Subject: [PATCH 3/9] =?UTF-8?q?1.=E8=A7=A3=E5=86=B3=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=AD=E5=88=A0=E9=99=A4=E5=8F=91=E9=80=81?= =?UTF-8?q?=E8=BF=87=E6=9D=A5=E7=9A=84=E5=B8=96=E5=AD=90=E6=8A=A5404?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B2.=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E7=8A=B6=E6=80=81=E8=83=BD=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 ++ app/helpers/users_helper.rb | 3 ++- app/views/organizations/_org_subfield_message.html.erb | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 22b58fe49..12f112345 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -192,11 +192,13 @@ class UsersController < ApplicationController forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0) user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0) forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0) + org_querys = OrgMessage.where("user_id=? and viewed=0", user) if User.current.id == @user.id course_querys.update_all(:viewed => true) forge_querys.update_all(:viewed => true) user_querys.update_all(:viewed => true) forum_querys.update_all(:viewed => true) + org_querys.update_all(:viewed => true) end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index bfc01a102..4edfed578 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -89,10 +89,11 @@ module UsersHelper def unviewed_message(user) course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count + org_count = OrgMessage.where("user_id =? and viewed =?", user, 0).count user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count at_count = user.at_messages.where(viewed: false).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count end def user_mail_notification_options(user) diff --git a/app/views/organizations/_org_subfield_message.html.erb b/app/views/organizations/_org_subfield_message.html.erb index a14138903..5feed27f2 100644 --- a/app/views/organizations/_org_subfield_message.html.erb +++ b/app/views/organizations/_org_subfield_message.html.erb @@ -57,8 +57,10 @@ ) if activity.org_subfield_editable_by?(User.current) %>
  • - <%= delete_link( + <%= link_to( + l(:button_delete), {:controller => 'messages', :action => 'destroy', :id => activity, :board_id => activity.board_id}, + :method => 'post', :data => {:confirm => l(:text_are_you_sure)}, :class => 'postOptionLink' ) if activity.org_subfield_editable_by?(User.current) %> From 7b56dc7f8eaef447620827479fb6eb83874bd379 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 29 Jan 2016 18:43:14 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E8=A7=A3=E5=86=B3=E7=BC=96=E8=BE=91=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 550642120..18d8905db 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,6 +46,7 @@ RedmineApp::Application.routes.draw do end end member do + get 'edit' get 'setting'#, :action => 'settings', :as => 'settings' get 'clear_org_avatar_temp' put 'set_homepage' From 50bac16d7c27803367b13ad458470c9e71c2cd13 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 29 Jan 2016 20:05:04 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=AD=90=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E7=94=B3=E8=AF=B7=E4=BF=A1=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/setting.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index a91a079ef..f2e4d5631 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -58,7 +58,7 @@
    http:// .trustie.net申请 - <% if @organization.domain.present? %> + <% if @organization.domain.present? and OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content == @organization.domain %> (已批准) <% elsif OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).count > 0 %> (您申请了子域名<%= OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content %>,还未批准) From 8b9bcb4719b883cca76af9b9a7f356fa2c9cd2da Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 1 Feb 2016 10:04:07 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=A2=98=E5=BA=93?= =?UTF-8?q?=E7=9A=84=E6=90=9C=E7=B4=A2=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 12f112345..9eabc95f2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -458,9 +458,9 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") #全部 visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" - @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'} and (name like '%#{search}%')").order("created_at desc") + @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc") elsif params[:type] == "2" #课程资源 - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc") + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc") end @type = params[:type] @limit = 15 From 4d048ec5964cc13d746ba1a2af21f0247a6d1091 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 1 Feb 2016 11:12:04 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E7=A8=8B=E5=88=97=E8=A1=A8=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E4=B8=BA0=E7=9A=84=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_recommendation.html.erb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/courses/_recommendation.html.erb b/app/views/courses/_recommendation.html.erb index 2b890ca5d..f26c5fd41 100644 --- a/app/views/courses/_recommendation.html.erb +++ b/app/views/courses/_recommendation.html.erb @@ -8,8 +8,13 @@

    <%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %>

    - <%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>) - <%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)

    + <% if e_course.attachments.count > 0 %> + <%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>) + <% end %> + <% if e_course.homework_commons.count > 0 %> + <%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>) + <% end %> +

  • From ea8e73ad54931382763141976d0eb1696839bf7c Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 2 Feb 2016 15:47:12 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=BC=B9=E6=A1=86=E7=9A=84=E6=8B=96?= =?UTF-8?q?=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_show_user_homeworks.html.erb | 2 +- app/views/users/user_import_homeworks.js.erb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/users/_show_user_homeworks.html.erb b/app/views/users/_show_user_homeworks.html.erb index 9f90a633f..d2b3f286d 100644 --- a/app/views/users/_show_user_homeworks.html.erb +++ b/app/views/users/_show_user_homeworks.html.erb @@ -1,4 +1,4 @@ -
    +
    选用题库中的题目
    公共题库 diff --git a/app/views/users/user_import_homeworks.js.erb b/app/views/users/user_import_homeworks.js.erb index 3be46e119..d1cb29faa 100644 --- a/app/views/users/user_import_homeworks.js.erb +++ b/app/views/users/user_import_homeworks.js.erb @@ -1,4 +1,5 @@ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_homeworks') %>'); showModal('ajax-modal', '1040px'); $('#ajax-modal').siblings().remove(); -$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed").css("border","3px solid #269ac9"); \ No newline at end of file +$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed").css("border","3px solid #269ac9"); +$('#ajax-modal').css("margin","15px"); From d42f144f23be556cf9c9f7851143d70ca13af05b Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 2 Feb 2016 15:50:28 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E3=80=81=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E5=B8=96=E5=AD=90=E6=8F=8F=E8=BF=B0=E6=A1=86=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A2=9E=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_common/edit.html.erb | 8 +- app/views/homework_common/index.html.erb | 8 +- app/views/org_document_comments/edit.html.erb | 22 +-- app/views/org_document_comments/new.html.erb | 25 ++-- app/views/users/_user_homework_form.html.erb | 128 ++++++++++++++++- app/views/users/user_homeworks.html.erb | 8 +- public/javascripts/des_kindEditor.js | 136 ++++++++++++++++++ 7 files changed, 303 insertions(+), 32 deletions(-) create mode 100644 public/javascripts/des_kindEditor.js diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb index ac772171d..f95739f26 100644 --- a/app/views/homework_common/edit.html.erb +++ b/app/views/homework_common/edit.html.erb @@ -5,7 +5,11 @@ $("#homework_end_time").val(""); $("#course_id").val($("#option_select").val()); $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>"); - homework_description_editor.html(""); + //homework_description_editor.html(""); + $("#homework_name_span").text(""); + $("#homework_end_time_span").text(""); + $("#homework_end_time_span").text(""); + $("#homework_course_id_span").text(""); $("#homework_editor").toggle(); } function cancel_edit(){ @@ -26,7 +30,7 @@
    -
    +
    <%= form_for @homework do |f| %> diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 5c91a37fc..ac4ac9853 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -6,7 +6,11 @@ document.getElementById("anonymous_comment").checked = true; $("#course_id").val($("#option_select").val()); $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true})%>"); - homework_description_editor.html(""); + //homework_description_editor.html(""); + $("#homework_name_span").text(""); + $("#homework_end_time_span").text(""); + $("#homework_end_time_span").text(""); + $("#homework_course_id_span").text(""); $("#homework_editor").toggle(); } @@ -44,7 +48,7 @@ <% if @is_teacher%> -
    +
    <%= labelled_form_for @new_homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
    <%= render :partial => 'users/user_homework_form', :locals => { :homework => @new_homework,:f => f,:edit_mode => false,:select_course => false } %> diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index 1b807220d..b17ae0e75 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -1,9 +1,13 @@ <%= content_for(:header_tags) do %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> + <%= javascript_include_tag "des_KindEditor" %> <% end %> -<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %> -
    -
    +
    + <%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %> +
    -
    -
    +
    +
    +
    - <%= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %> + + <%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %>

    @@ -49,12 +55,11 @@
    - 确定 + 确定 - 取消 + 取消
    -
    + <% end %>
    -<% end %> \ No newline at end of file diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index cc7e4bb8e..7a5bd8f27 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -23,6 +23,119 @@ $("#anonymous_comment").val(0); } } + function nh_reset_homework_form(params){ + if(params.textarea.html() != "") { + cancel_edit(); + } else { + params.form[0].reset(); + params.textarea.empty(); + if(params.editor != undefined){ + params.editor.html(params.textarea.html()); + } + } + } + function init_homework_form(params){ + params.form.submit(function(){ + var flag = false; + if(params.form.attr('data-remote') != undefined ){ + flag = true + } + var is_checked = false; + checked_val(); + if(!regex_homework_name()){ + $("#homework_name").focus(); + } + else if(!regex_homework_end_time()){ + $("#homework_end_time").focus(); + } + else if(!regex_homework_end_publish_time()){ + $("#homework_end_time").focus(); + } + else if(!regex_course_id()){ + $("#course_id").focus(); + } + else{ + params.textarea.html(params.editor.html()); + params.editor.sync(); + is_checked = true; + } + /*var is_checked = nh_check_field({ + issubmit:true, + content:params.editor, + contentmsg:params.contentmsg, + textarea:params.textarea + });*/ + if(is_checked){ + if(flag){ + return true; + }else{ + $(this)[0].submit(); + return false; + } + } + return false; + }); + } + function init_homework_editor(params){ + params.textarea.removeAttr('placeholder'); + var editor = params.kindutil.create(params.textarea, { + resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px", + items : ['code','emoticons','fontname', + 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|', + 'formatblock', 'fontsize', '|','indent', 'outdent', + '|','imagedirectupload','table', 'media', 'preview',"more" + ], + afterChange:function(){//按键事件 + var edit = this.edit; + var body = edit.doc.body; + //paramsHeight = params.kindutil.removeUnit(this.height); + edit.iframe.height(150); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150)); + }, + afterCreate:function(){ + //init + var edit = this.edit; + var body = edit.doc.body; + edit.iframe[0].scroll = 'no'; + body.style.overflowY = 'hidden'; + //reset height + var edit = this.edit; + var body = edit.doc.body; + edit.html(params.textarea.innerHTML); + //paramsHeight = params.kindutil.removeUnit(this.height); + edit.iframe.height(150); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); + + } + }).loadPlugin('paste'); + return editor; + } + KindEditor.ready(function(K){ + $("div[nhname='homework_common_form']").each(function(){ + var params = {}; + params.kindutil = K; + params.div_form = $(this); + params.form = $("form",params.div_form); + if(params.form==undefined || params.form.length==0){ + return; + } + params.textarea = $("textarea[nhname='homework_textarea']",params.div_form); + params.cancel_btn = $("#new_message_cancel_btn"); + params.submit_btn = $("#new_message_submit_btn"); + if(params.textarea.data('init') == undefined) { + params.editor = init_homework_editor(params); + init_homework_form(params); + params.submit_btn.click(function () { + params.form.submit(); + }); + params.cancel_btn.click(function () { + reset_homework(); + nh_reset_homework_form(params); + }); + params.textarea.data('init', 1); + } + }); + }); <% end %> @@ -70,10 +183,12 @@
    <% if edit_mode %> - <%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %> + + <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %> <% else %> <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %> - <%= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px",at_id: homework.id, at_type: homework.class.to_s %> + + <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px",at_id: homework.id, at_type: homework.class.to_s %> <% end %>
    @@ -89,17 +204,16 @@ <%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type != 2), :has_group=>(!(edit_mode && homework.homework_type != 3))&& homework.student_works.empty?,:show_member => true} %>
    -
    <% if edit_mode %> - 确定 + 确定 <%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%> - 取消 + 取消 <% else %> - 发送 + 发送 - 取消 + 取消 <% end %>
    diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 7be803720..d0adb291f 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -5,7 +5,11 @@ $("#homework_end_time").val(""); $("#course_id").val($("#option_select").val()); $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new,:has_program => true,:has_group => true })%>"); - homework_description_editor.html(""); + //homework_description_editor.html(""); + $("#homework_name_span").text(""); + $("#homework_end_time_span").text(""); + $("#homework_end_time_span").text(""); + $("#homework_course_id_span").text(""); $("#homework_editor").toggle(); } @@ -29,7 +33,7 @@ <% if @is_teacher%> -
    +
    <% homework = HomeworkCommon.new %> <% homework.homework_detail_manual = HomeworkDetailManual.new%> <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %> diff --git a/public/javascripts/des_kindEditor.js b/public/javascripts/des_kindEditor.js new file mode 100644 index 000000000..1b952672a --- /dev/null +++ b/public/javascripts/des_kindEditor.js @@ -0,0 +1,136 @@ +function init_des_editor(params){ + // var minHeight; //最小高度 + var paramsHeight = params.height; //设定的高度 + var paramsWidth = params.width == undefined ? "100%" : params.width; + + var editor = params.kindutil.create(params.textarea, { + resizeType : 1,minWidth:"1px",width:paramsWidth, + height:"30px",// paramsHeight == undefined ? "30px":paramsHeight+"px", + minHeight:"30px",// paramsHeight == undefined ? "30px":paramsHeight+"px", + items : ['code','emoticons','fontname', + 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|', + 'formatblock', 'fontsize', '|','indent', 'outdent', + '|','imagedirectupload','table', 'media', 'preview',"more" + ], + afterChange:function(){//按键事件 + //nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); + var edit = this.edit; + var body = edit.doc.body; + edit.iframe.height(paramsHeight); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, paramsHeight)); + }, + afterCreate:function(){ + //init + var edit = this.edit; + var body = edit.doc.body; + edit.iframe[0].scroll = 'no'; + body.style.overflowY = 'hidden'; + //reset height + var edit = this.edit; + edit.html(params.textarea.innerHTML); + var body = edit.doc.body; + paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight; + edit.iframe.height(paramsHeight); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight), paramsHeight)); + + } + }).loadPlugin('paste'); + return editor; +} + +function nh_check_field(params){ + var result=true; + if(!check_org_title()) { + result=false; + return result; + } + if(params.content!=undefined){ + if(params.content.isEmpty()){ + result=false; + } + if(params.content.html()!=params.textarea.html() || params.issubmit==true){ + params.textarea.html(params.content.html()); + params.content.sync(); + + if(params.content.isEmpty()){ + params.contentmsg.html('内容不能为空'); + params.contentmsg.css({color:'#ff0000'}); + }else{ + params.contentmsg.html('填写正确'); + params.contentmsg.css({color:'#008000'}); + } + } + } + return result; +} +function init_form(params){ + params.form.submit(function(){ + var flag = false; + if(params.form.attr('data-remote') != undefined ){ + flag = true + } + var is_checked = nh_check_field({ + issubmit:true, + //title:params.texttitle, + content:params.editor, + //titlemsg:params.titlemsg, + contentmsg:params.contentmsg, + textarea:params.textarea + }); + if(is_checked){ + if(flag){ + return true; + }else{ + $(this)[0].submit(); + return false; + } + } + return false; + }); +} +function nh_reset_form(params){ + params.form[0].reset(); + params.texttitle.empty(); + params.textarea.empty(); + if(params.editor != undefined){ + params.editor.html(params.textarea.html()); + } + params.contentmsg.hide(); + params.titlemsg.html(""); +} +//第二个参数是高度,可以传,可以不传 +function init_des_data(){ + var height = arguments[0] ? arguments[0] : undefined; + var width = arguments[1] ? arguments[1] : undefined; + KindEditor.ready(function (K) { + $("div[nhname='new_topic_form']").each(function () { + var params = {}; + params.kindutil = K; + params.div_form = $(this); + params.form = $("form", params.div_form); + if (params.form == undefined || params.form.length == 0) { + return; + } + //params.texttitle = $("#document_title", params.div_form); + params.textarea = $("textarea[nhname='description_textarea']", params.div_form); + //params.titlemsg = $("#doc_title_hint", params.div_form); + params.contentmsg = $("#homework_course_id_span", params.div_form); + params.cancel_btn = $("#new_topic_cancel_btn"); + params.submit_btn = $("#new_topic_submit_btn"); + params.height = height; + params.width = width; + if (params.textarea.data('init') == undefined) { + params.editor = init_des_editor(params); + init_form(params); + params.cancel_btn.click(function () { + nh_reset_form(params); + }); + params.submit_btn.click(function () { + params.form.submit(); + }); + params.textarea.data('init', 1); + $(this).show(); + } + }); + }); +} \ No newline at end of file