个人留言、课程留言的主留言增加自动保存

This commit is contained in:
cxt 2016-10-26 16:12:51 +08:00
parent 7f99e82181
commit 51e422c1a6
4 changed files with 40 additions and 13 deletions

View File

@ -35,6 +35,8 @@
<div nhname='toolbar_container_' ></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" nhname='new_message_textarea_' name="new_form[course_message]"></textarea>
<p nhname='contentmsg_'></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
<a id="new_message_cancel_btn_" href="javascript:void(0)" class="grey_btn fr mt10 ml10 mb10">取消</a>
<a href="javascript:void(0);" class="blue_btn fr mt10" id="new_message_submit_btn_" >留言</a>
<% end %>
@ -53,7 +55,6 @@
<div style="display:none;"><a href="#" id="nhjump"></a></div>
<script type="text/javascript">
$(function(){
KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){
@ -69,6 +70,7 @@
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
params.height = 55;
params.editor = init_editor(params);
course_feedback_editor = params.editor;
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
@ -89,5 +91,11 @@
});
});
});
</script>
<script type="text/javascript">
$(function(){
setTimeout(function(){
elocalStorage(main_editor,'course_feedback_<%=User.current.id %>_<%=@course.id %>');
}, 10000);
});
</script>

View File

@ -16,5 +16,14 @@
%>
<div class="cl"></div>
<p id="jour_content_span"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</li>
<div class="cl"></div>
<script type="text/javascript">
$(function(){
setTimeout(function(){
elocalStorage(jour_content_editor,'user_newfeedback_<%=User.current.id %>_<%=@user.id %>');
}, 10000);
});
</script>

View File

@ -1277,7 +1277,6 @@ function disable_down(source, des, hint){
des.attr("checked", false);
des.attr("disabled", true);
hint.html("(私有组织不允许游客下载资源)");
}
}
@ -1296,13 +1295,18 @@ function getRootPath(){
}
//自动保存草稿
var editor2;
function elocalStorage(editor,mdu){
function elocalStorage(editor,mdu,id){
if (window.sessionStorage){
editor2 = editor;
var oc = window.sessionStorage.getItem('content'+mdu);
if(oc !== null ){
var h = '您上次有已保存的数据,是否<a style="cursor: pointer;" onclick="rec_data(\'content\',\''+ mdu + '\')">恢复</a> ? / <a style="cursor: pointer;" onclick="clear_data(\'content\',\''+ mdu + '\')">不恢复</a>';
$('#e_tips').html(h);
if(arguments[2]){
var h = '您上次有已保存的数据,是否<a style="cursor: pointer;" onclick="rec_data(\'content\',\''+ mdu + '\',' + id + ')">恢复</a> ? / <a style="cursor: pointer;" onclick="clear_data(\'content\',\''+ mdu + '\',' + id + ')">不恢复</a>';
$("#e_tips_"+id).html(h);
}else{
var h = '您上次有已保存的数据,是否<a style="cursor: pointer;" onclick="rec_data(\'content\',\''+ mdu + '\')">恢复</a> ? / <a style="cursor: pointer;" onclick="clear_data(\'content\',\''+ mdu + '\')">不恢复</a>';
$("#e_tips").html(h);
}
}
setInterval(function() {
d = new Date();
@ -1315,8 +1319,10 @@ function elocalStorage(editor,mdu){
editor.sync();
if(!editor.isEmpty()){
add_data("content",mdu,editor.html());
$('#e_tip').html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 ");
//$('#e_tips').html("");
var id1 = arguments[2] ? "#e_tip_"+id : "#e_tip";
var id2 = arguments[2] ? "#e_tips_"+id : "#e_tips";
$(id1).html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 ");
$(id2).html("");
}
},10000);
@ -1327,18 +1333,20 @@ function elocalStorage(editor,mdu){
function add_data(k,mdu,d){
window.sessionStorage.setItem(k+mdu,d);
}
function rec_data(k,mdu){
function rec_data(k,mdu,id){
if(window.sessionStorage.getItem(k+mdu) !== null){
editor2.html(window.sessionStorage.getItem(k+mdu));
clear_data(k,mdu);
clear_data(k,mdu,id);
}
}
function clear_data(k,mdu){
function clear_data(k,mdu,id){
window.sessionStorage.removeItem(k+mdu);
var id1 = arguments[2] ? "#e_tip_"+id : "#e_tip";
var id2 = arguments[2] ? "#e_tips_"+id : "#e_tips";
if(k == 'content'){
$("#e_tips").html("");
$(id2).html("");
}else{
$("#e_tip").html("");
$(id1).html("");
}
}

View File

@ -1,3 +1,4 @@
var main_editor;
function init_editor(params){
// var minHeight; //最小高度
var paramsHeight = params.height; //设定的高度
@ -34,6 +35,7 @@ function init_editor(params){
}
}).loadPlugin('paste');
main_editor = editor;
return editor;
}