通过 kindeditor_tag f.kindeditor生产的编辑框可以自动长高缩短

课程模块的通知,讨论区,留言都可以自动的长高,缩短
guange_homework
lizanle 10 years ago
parent faf5f1eab5
commit 95f66a304c

@ -10,11 +10,11 @@
div.respond-form .reply_btn{margin-left:565px;margin-top:5px;} div.respond-form .reply_btn{margin-left:565px;margin-top:5px;}
div.recall_con{width:570px;} div.recall_con{width:570px;}
div.recall_con .reply_btn{margin-left:525px;margin-top:5px;} div.recall_con .reply_btn{margin-left:525px;margin-top:5px;}
.ke-container{height: 80px !important;} /*.ke-container{height: 80px !important;}*/
</style> </style>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %>
<script > <script >
init_KindEditor_data(''); init_KindEditor_data('',80);
</script> </script>
<div class="msg_box fl mb10" id='leave-message'> <div class="msg_box fl mb10" id='leave-message'>
<h4><%= l(:label_leave_message) %></h4> <h4><%= l(:label_leave_message) %></h4>
@ -62,6 +62,7 @@
params.contentmsg = $("p[nhname='contentmsg']",params.div_form); params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form); params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
params.height = 55;
if(params.textarea.data('init') == undefined){ if(params.textarea.data('init') == undefined){
params.editor = init_editor(params); params.editor = init_editor(params);
init_form(params); init_form(params);

@ -1,14 +1,16 @@
function init_editor(params){ function init_editor(params){
var minHeight; var minHeight;
var editor = params.kindutil.create(params.textarea, { var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",height:"30px",minHeight:"30px", resizeType : 1,minWidth:"1px",width:"100%",
height:params.height == undefined ? "30px":params.height+"px",
minHeight:params.height == undefined ? "30px":params.height+"px",
items:['emoticons'], items:['emoticons'],
afterChange:function(){//按键事件 afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
var edit = this.edit; var edit = this.edit;
var body = edit.doc.body; var body = edit.doc.body;
edit.iframe.height(minHeight); edit.iframe.height(minHeight);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 30, minHeight)); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + (params.height == undefined ? 30:params.height), minHeight));
}, },
afterCreate:function(){ afterCreate:function(){
var toolbar = $("div[class='ke-toolbar']",params.div_form); var toolbar = $("div[class='ke-toolbar']",params.div_form);
@ -24,7 +26,7 @@ function init_editor(params){
var body = edit.doc.body; var body = edit.doc.body;
minHeight = params.kindutil.removeUnit(this.height); minHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(minHeight); edit.iframe.height(minHeight);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ 30 , minHeight)); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ (params.height == undefined ? 30:params.height) , minHeight));
} }
}).loadPlugin('paste'); }).loadPlugin('paste');
@ -85,6 +87,7 @@ function nh_reset_form(params){
} }
function init_KindEditor_data(id){ function init_KindEditor_data(id){
var height = arguments[1] ? arguments[1] : undefined;
KindEditor.ready(function (K) { KindEditor.ready(function (K) {
$("div[nhname='new_message_" + id + "']").each(function () { $("div[nhname='new_message_" + id + "']").each(function () {
var params = {}; var params = {};
@ -99,7 +102,7 @@ function init_KindEditor_data(id){
params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form); params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form);
params.cancel_btn = $("#new_message_cancel_btn_" + id); params.cancel_btn = $("#new_message_cancel_btn_" + id);
params.submit_btn = $("#new_message_submit_btn_" + id); params.submit_btn = $("#new_message_submit_btn_" + id);
params.height = height;
if (params.textarea.data('init') == undefined) { if (params.textarea.data('init') == undefined) {
params.editor = init_editor(params); params.editor = init_editor(params);
init_form(params); init_form(params);

Loading…
Cancel
Save