diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 31cdf41eb..3deb04f6c 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,7 +1,123 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> <% end %> - + <%= error_messages_for 'message' %>
@@ -25,7 +141,7 @@ <%= text_area :quote,:quote,:style => 'display:none' %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :content, :editor_id => 'message_content_editor', + <%#= f.kindeditor :content, :editor_id => 'message_content_editor', :owner_id => topic.nil? ? 0: topic.id, :owner_type => OwnerTypeHelper::MESSAGE, :width => '100%', @@ -37,8 +153,11 @@ :maxlength => 5000 }, at_id: topic.id, at_type: topic.class.to_s %> +

+

+

@@ -49,11 +168,11 @@
<%if !edit_mode %> - 确定 + 确定 取消 <% else %> - 确定 + 确定 <%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%> <% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 16b4fcd3d..d33b75f82 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -25,11 +25,13 @@ 课程问答区
+
<% if User.current.logged? %> <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :course => @board.course} %> <% end %> <% end %> +
<%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %>
diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index 89fe71c65..324b1edf1 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -12,6 +12,7 @@ <% end %> <% elsif @message.course %> +
<%= form_for @message, { :as => :message, :url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board}, @@ -22,7 +23,7 @@ <%= render :partial => 'boards/course_message_edit', :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %> <% end %> - +
<% elsif @message.board.org_subfield %> <%= form_for @message, { :as => :message, diff --git a/app/views/org_document_comments/_new.html.erb b/app/views/org_document_comments/_new.html.erb index 9e77d3fa8..f462df2c9 100644 --- a/app/views/org_document_comments/_new.html.erb +++ b/app/views/org_document_comments/_new.html.erb @@ -50,6 +50,8 @@

+

+

diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index ed7413850..3ad388bd2 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -39,6 +39,8 @@

+

+

diff --git a/app/views/org_document_comments/new.html.erb b/app/views/org_document_comments/new.html.erb index 2a261bd5f..fea89459b 100644 --- a/app/views/org_document_comments/new.html.erb +++ b/app/views/org_document_comments/new.html.erb @@ -46,6 +46,8 @@

+

+

diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index 14da74a34..8e1a2a546 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -58,6 +58,8 @@ -->

+

+

@@ -198,7 +200,7 @@ //paramsHeight = params.kindutil.removeUnit(this.height); edit.iframe.height(150); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); - + elocalStorage(editor2,'student_work_<%=@work.id %>'); } }).loadPlugin('paste'); return editor; @@ -217,6 +219,7 @@ params.submit_btn = $("#new_message_submit_btn"); if(params.textarea.data('init') == undefined) { params.editor = init_homework_editor(params); + editor2 = params.editor; init_homework_form(params); params.submit_btn.click(function () { params.form.submit(); diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 15958d870..c43482299 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -79,6 +79,10 @@ } } + var KE = { + MDU: "1234455",//当前文章标识符 + }; + function nh_check_field(params){ var result=true; if(!regexStudentWorkName()) { @@ -159,7 +163,7 @@ //paramsHeight = params.kindutil.removeUnit(this.height); edit.iframe.height(150); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); - + elocalStorage(editor2,'student_work_<%=@homework.id %>'); } }).loadPlugin('paste'); return editor; @@ -178,6 +182,7 @@ params.submit_btn = $("#new_message_submit_btn"); if(params.textarea.data('init') == undefined) { params.editor = init_homework_editor(params); + editor2 = params.editor; init_homework_form(params); params.submit_btn.click(function () { params.form.submit(); @@ -250,6 +255,8 @@ -->

+

+

diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index f1f29b0da..f23d01d3c 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -16,7 +16,6 @@ $("#GroupPopupBox a.group_save_btn").click(); <% end %> }); - var homework_description_editor; function checked_val() { if ($("#anonymous_comment").is(":checked")) { $("#anonymous_comment").val(1); @@ -106,7 +105,7 @@ //paramsHeight = params.kindutil.removeUnit(this.height); edit.iframe.height(150); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); - + elocalStorage(homework_description_editor,'homework_<%=User.current.id %>'); } }).loadPlugin('paste'); return editor; @@ -199,6 +198,8 @@ <%= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w709",:value => "请选择发布作业的课程"} %>

+

+

diff --git a/public/javascripts/application.js b/public/javascripts/application.js index fe829f7a8..e481dae32 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1152,3 +1152,50 @@ function disable_down(source, des, hint){ } } + +//自动保存草稿 +var editor2; +function elocalStorage(editor,mdu){ + if (window.sessionStorage){ + editor2 = editor; + var oc = window.sessionStorage.getItem('content'+mdu); + if(oc !== null ){ + var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; + $('#e_tips').html(h); + } + setInterval(function() { + d = new Date(); + var h = d.getHours(); + var m = d.getMinutes(); + var s = d.getSeconds(); + h = h < 10 ? '0' + h : h; + m = m < 10 ? '0' + m : m; + s = s < 10 ? '0' + s : s; + if(!editor.isEmpty()){ + add_data("content",mdu,editor.html()); + $('#e_tip').html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 "); + $('#e_tips').html(""); + } + },10000); + + }else{ + $('.ke-edit').after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); + } +} +function add_data(k,mdu,d){ + window.sessionStorage.setItem(k+mdu,d); +} +function rec_data(k,mdu){ + if(window.sessionStorage.getItem(k+mdu) !== null){ + editor2.html(window.sessionStorage.getItem(k+mdu)); + clear_data(k,mdu); + } +} +function clear_data(k,mdu){ + window.sessionStorage.removeItem(k+mdu); + if(k == 'content'){ + $("#e_tips").html(""); + }else{ + $("#e_tip").html(""); + } +} diff --git a/public/javascripts/des_kindEditor.js b/public/javascripts/des_kindEditor.js index f8aff0be7..3a05c909d 100644 --- a/public/javascripts/des_kindEditor.js +++ b/public/javascripts/des_kindEditor.js @@ -1,3 +1,4 @@ +var editor2; function init_des_editor(params){ // var minHeight; //最小高度 var paramsHeight = params.height; //设定的高度 @@ -32,7 +33,7 @@ function init_des_editor(params){ 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)); - + elocalStorage(editor2,'org_document'); } }).loadPlugin('paste'); return editor; @@ -123,6 +124,7 @@ function init_des_data(){ params.width = width; if (params.textarea.data('init') == undefined) { params.editor = init_des_editor(params); + editor2 = params.editor; init_form(params); params.cancel_btn.click(function () { nh_reset_form(params);