个人中心 留言界面 编辑框自适应高度

This commit is contained in:
lizanle 2015-09-09 13:44:23 +08:00
parent 4ad139e6fd
commit b2afe18ccd
2 changed files with 11 additions and 8 deletions

View File

@ -1,16 +1,18 @@
function init_editor(params){
var minHeight;
var minHeight; //最小高度
var paramsHeight = params.height; //设定的高度
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",
height:params.height == undefined ? "30px":params.height+"px",
minHeight:params.height == undefined ? "30px":params.height+"px",
height:paramsHeight == undefined ? "30px":paramsHeight+"px",
minHeight:paramsHeight == undefined ? "30px":paramsHeight+"px",
items:['emoticons'],
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(minHeight);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + (params.height == undefined ? 30:params.height), minHeight));
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + (paramsHeight == undefined ? 30:paramsHeight), minHeight));
},
afterCreate:function(){
var toolbar = $("div[class='ke-toolbar']",params.div_form);
@ -24,9 +26,9 @@ function init_editor(params){
//reset height
var edit = this.edit;
var body = edit.doc.body;
minHeight = params.kindutil.removeUnit(this.height);
minHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
edit.iframe.height(minHeight);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ (params.height == undefined ? 30:params.height) , minHeight));
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ (paramsHeight == undefined ? 30:paramsHeight) , minHeight));
}
}).loadPlugin('paste');
@ -82,6 +84,7 @@ function nh_reset_form(params){
params.textarea.empty();
if(params.editor != undefined){
params.editor.html(params.textarea.html());
params.editor.edit.doc.body.offsetHeight = 0;
}
params.contentmsg.hide();
}

View File

@ -8,7 +8,7 @@ $(function(){
params.div_form = $("div[nhname='div_form']",params.container);
params.form = $("form",params.div_form);
params.textarea = $("textarea[name='user_notes']",params.div_form);
params.textarea.prev('div').css("height","60px");
//params.textarea.prev('div').css("height","60px");
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.cancel_btn = $("a[nhname='cancel_btn']",params.div_form);
@ -43,7 +43,7 @@ $(function(){
params.div_form = $("div[nhname='sub_div_form']",params.container);
params.form = $("form",params.div_form);
params.textarea = $("textarea[name='user_notes']",params.div_form);
params.textarea.prev('div').css("height","60px");
//params.textarea.prev('div').css("height","60px");
params.contentmsg = $("p[nhname='sub_contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='sub_toolbar_container']",params.div_form);
params.cancel_btn = $("a[nhname='sub_cancel_btn']",params.div_form);