|
|
|
@ -1,10 +1,7 @@
|
|
|
|
|
/**
|
|
|
|
|
* Created by Alan on 2015/9/18.
|
|
|
|
|
*/
|
|
|
|
|
function init_editor(params){
|
|
|
|
|
// var minHeight; //最小高度
|
|
|
|
|
var id = arguments[1] ? arguments[1] : undefined;
|
|
|
|
|
var paramsHeight = params.height; //设定的高度
|
|
|
|
|
var id = arguments[1] ? arguments[1] : undefined;
|
|
|
|
|
var paramsWidth = params.width == undefined ? "100%" : params.width;
|
|
|
|
|
|
|
|
|
|
var editor = params.kindutil.create(params.textarea, {
|
|
|
|
@ -13,19 +10,42 @@ function init_editor(params){
|
|
|
|
|
minHeight:"30px",// == 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(paramsHeight);
|
|
|
|
|
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + (paramsHeight == undefined ? 30:paramsHeight), paramsHeight));
|
|
|
|
|
},
|
|
|
|
|
afterBlur:function(){
|
|
|
|
|
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
|
|
|
|
|
if(this.edit.html()=="") {
|
|
|
|
|
this.edit.html('<span id="hint" style="color: #808080">我要回复</span>');
|
|
|
|
|
}
|
|
|
|
|
//params.toolbar_container.hide();
|
|
|
|
|
$('#reply_image_' + id).addClass('imageFuzzy');
|
|
|
|
|
//this.resize("95%", null);
|
|
|
|
|
//params.submit_btn.css("display","none");
|
|
|
|
|
},
|
|
|
|
|
afterFocus: function(){
|
|
|
|
|
var edit = this.edit;
|
|
|
|
|
var body = edit.doc.body;
|
|
|
|
|
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\#\d*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
|
|
|
|
|
edit.html('');
|
|
|
|
|
}
|
|
|
|
|
params.contentmsg.hide();
|
|
|
|
|
// params.toolbar_container.show();
|
|
|
|
|
$('#reply_image_' + id).removeClass('imageFuzzy');
|
|
|
|
|
//edit.iframe.width(paramsWidth);
|
|
|
|
|
this.resize(paramsWidth, null);
|
|
|
|
|
params.submit_btn.show();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
afterCreate:function(){
|
|
|
|
|
params.submit_btn.css("display","none");
|
|
|
|
|
var toolbar = $("div[class='ke-toolbar']",params.div_form);
|
|
|
|
|
toolbar.css('width',24);
|
|
|
|
|
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
|
|
|
|
|
params.toolbar_container.append(toolbar);
|
|
|
|
|
params.toolbar_container.style.display = 'none';
|
|
|
|
|
//init
|
|
|
|
|
var edit = this.edit;
|
|
|
|
|
var body = edit.doc.body;
|
|
|
|
@ -36,20 +56,10 @@ function init_editor(params){
|
|
|
|
|
var body = edit.doc.body;
|
|
|
|
|
paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
|
|
|
|
|
edit.iframe.height(paramsHeight);
|
|
|
|
|
edit.html('<span id="hint" style="color: #808080">我要回复</span>');
|
|
|
|
|
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ (paramsHeight == undefined ? 30:paramsHeight) , paramsHeight));
|
|
|
|
|
// params.toolbar_container.hide();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
afterFocus:function(){
|
|
|
|
|
$('#reply_image_' + id).removeClass('imageFuzzy');
|
|
|
|
|
//edit.iframe.width(paramsWidth);
|
|
|
|
|
this.resize(paramsWidth, null);
|
|
|
|
|
params.submit_btn.css('display','inline-block');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
afterBlur:function(){
|
|
|
|
|
$('#reply_image_' + id).addClass('imageFuzzy');
|
|
|
|
|
this.resize("95%", null);
|
|
|
|
|
params.submit_btn.css("display","none");
|
|
|
|
|
}
|
|
|
|
|
}).loadPlugin('paste');
|
|
|
|
|
return editor;
|
|
|
|
@ -64,7 +74,7 @@ function nh_check_field(params){
|
|
|
|
|
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
|
|
|
|
|
params.textarea.html(params.content.html());
|
|
|
|
|
params.content.sync();
|
|
|
|
|
if(params.content.isEmpty()){
|
|
|
|
|
if(params.content.isEmpty() || /^\&\w*\;\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\#\d*\;\"\&\w*\;[\u4e00-\u9fa5]*\&\w*\;\/\w*\&\w*\;$/.test(params.textarea.html())){
|
|
|
|
|
params.contentmsg.html('内容不能为空');
|
|
|
|
|
params.contentmsg.css({color:'#ff0000'});
|
|
|
|
|
}else{
|
|
|
|
@ -128,7 +138,7 @@ function init_activity_KindEditor_data(id){
|
|
|
|
|
params.height = height;
|
|
|
|
|
params.width = width;
|
|
|
|
|
if (params.textarea.data('init') == undefined) {
|
|
|
|
|
params.editor = init_editor(params, id);
|
|
|
|
|
params.editor = init_editor(params,id);
|
|
|
|
|
init_form(params);
|
|
|
|
|
params.cancel_btn.click(function () {
|
|
|
|
|
nh_reset_form(params);
|
|
|
|
@ -141,4 +151,4 @@ function init_activity_KindEditor_data(id){
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|