[그누보드] cheditor 자동 줄 늘리기

에디터 사용시 글 입력시 자동으로 늘어 나게 하는 함수 입니다 


textarea에 text-overflow:ellipsis를 이용하시면 자동늘어나는데 
에디터 같은경우는 iframe 을 써서 자동으로 늘어나기 힘들지요. 

먼저 에디터있는곳에 아래은 스크립트를 넣어 주십니다 
wr_content 는 각 에디터 이름이니 바꾸시면 됩니다 
min_height 최소 높이 입니다 
jQuery 에서 
ie 에서는 div 로 값이 나오는데 
나머지 브라우저에서는 p로 되야 값이 나옵니다 

//------------------------------------ 
function checker() 

var min_height = 210; 
var height = 0 ; 
jQuery("#wr_content_td iframe").contents().find("body > div").each(function (){ 
height += jQuery(this).height(); 
}); 
jQuery("#wr_content_td iframe").contents().find("body > p").each(function (){ 
height += jQuery(this).height(); 
}); 
if(height > min_height) { 
jQuery("#wr_content_td iframe").height(height+40); 
} else { 
jQuery("#wr_content_td iframe").height(min_height+40); 




그리고 cheditor5/cheditor.js 을 여시고 doOnkeyUp 을 찾으신후 
아래와 같이  parent.checker(); 를 넣어 주십니다 

doOnKeyUp : function () { 
//------------------ 
//줄변환 함수 
parent.checker(); 
//------------------ 
    this.config.keyUpCount++; 
}, 

글자 입력시 높이를 변경이 됩니다.

출처 : http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=29964
처음 1 2 3 4 다음 맨끝
글쓰기