Html_wev8.js
2.7 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
82
83
84
85
86
87
88
if(typeof(MEC_NS) == 'undefined'){
MEC_NS = {};
}
MEC_NS.Html = function(type, id, mecJson){
this.type = type;
if(!id){
id = new UUID().toString();
}
this.id = id;
if(!mecJson){
mecJson = {};
}
this.editor = {};
this.mecJson = mecJson;
var that = this;
require(['mec'], function(mec){
that.remark = function(){
return mec.remark(that.mecJson.htm);
};
});
}
/*获取id。 必需的方法*/
MEC_NS.Html.prototype.getID = function(){
return this.id;
};
MEC_NS.Html.prototype.runWhenPageOnLoad = function () {
//页面初始化会过滤掉html中的样式,因为需要重新渲染一次。
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.Html.prototype.getDesignHtml = function(){
return getDesignHtml(this);
};
/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.Html.prototype.getAttrDlgHtml = function(){
var theId = this.id;
var htm = "<div id=\"MADH_"+theId+"\" style=\"height: inherit;\">";
htm += "<div class=\"html-control\" id=\"con_"+theId+"\" >";
htm += "<div id=\"htm_"+theId+"\" class=\"content editor\"></div>";
htm += "</div>";
htm += "<div class=\"bottom\"><div class=\"save-btn\" onclick=\"refreshMecDesign('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3451)+"</div></div>"; //确定
htm += "</div>";
htm += "<div class=\"MAD_Alert\">"+SystemEnv.getHtmlNoteName(4115)+"</div>"; //已生成到布局
return htm;
};
/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.Html.prototype.afterAttrDlgBuild = function(){
var that = this,
theId = this.id;
var mecHandler = MECHandlerPool.getHandler(theId);
$('#' + 'MADH_' + theId).parent().height('100%'); // 将容器设置为100%高度 便于编辑器随容器高变化
require(['htmlEditor'], function(htmlEditor) {
that.editor = htmlEditor.editor('htm_'+theId, 'html', ['Mobile_NS']);
that.editor.setValue(that.mecJson.htm || "", true);
that.editor.getSession().on('change',function(){
mecHandler.autobind.update();
});
$('#htm_' + theId).data('editor', that.editor);
});
};
/*获取JSON*/
MEC_NS.Html.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.editor.getValue && (this.mecJson["htm"] = this.editor.getValue());
}
return this.mecJson;
};
MEC_NS.Html.prototype.getHtm = function(){
return Mec_FiexdUndefinedVal(this.mecJson["htm"]);
};