RichText_wev8.js
2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
if(typeof(MEC_NS) == 'undefined'){
MEC_NS = {};
}
MEC_NS.RichText = function(type, id, mecJson){
this.type = type;
if(!id){
id = new UUID().toString();
}
this.id = id;
if(!mecJson){
mecJson = {};
}
this.ckeditor = {};
this.mecJson = mecJson;
var that = this;
require(['mec'], function(mec){
that.remark = function(){
return mec.remark(that.mecJson.text);
};
});
}
/*获取id。 必需的方法*/
MEC_NS.RichText.prototype.getID = function(){
return this.id;
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.RichText.prototype.getDesignHtml = function(){
return getDesignHtml(this);
};
/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.RichText.prototype.getAttrDlgHtml = function(){
var theId = this.id;
var htm = "<div id=\"MADH_"+theId+"\" style=\"height: inherit;\">";
htm += "<div id=\"text_"+theId+"\" class=\"content editor\" style=\"display: none;\"></div>";
htm += "</div>";
return htm;
};
/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.RichText.prototype.afterAttrDlgBuild = function(){
var that = this,
theId = this.id;
var mecHandler = MECHandlerPool.getHandler(theId);
require(['ckEditor'], function(CKEDITOR) {
if(_userLanguage == '8'){
CKEDITOR.config.language = 'en';
} else if(_userLanguage == '9'){
CKEDITOR.config.language = 'zh';
} else {
CKEDITOR.config.language = 'zh-cn';
}
var editorElement = CKEDITOR.document.getById( 'text_' + theId );
editorElement.setHtml(that.mecJson.text || '');
that.ckeditor = CKEDITOR.replace( 'text_' + theId );
that.ckeditor.on('change', function(){
mecHandler.autobind.update();
});
});
};
/*获取JSON*/
MEC_NS.RichText.prototype.getMecJson = function(){
var theId = this.id;
this.mecJson["id"] = theId;
this.mecJson["mectype"] = this.type;
var $attrContainer = $("#MADH_"+theId);
if($attrContainer.length > 0){
this.ckeditor.getData && (this.mecJson["text"] = this.ckeditor.getData());
}
return this.mecJson;
};