jsonConfig.jsp
7.95 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/mobilemode/admin/init.jsp"%>
<%
String topMenu = Util.null2String(request.getParameter("topMenu"));
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>模拟数据</title>
<link rel="stylesheet" type="text/css" href="./scriptlib/scriptLib.css" />
<style type="text/css">
.wrapper .main {
margin-left:0px;
}
.r0 > label {
line-height: 30px;
font-size: 14px;
}
.main .fn-config{
padding: 10px 15px;
}
</style>
</head>
<body class="lang<%=user.getLanguage()%>">
<div class="wrapper">
<div class='main active'>
<div class="fn-config">
<div class="temp-container">
<h4><span id="fn-title"></span> <%=SystemEnv.getHtmlLabelName(500338, user.getLanguage())%></h4> <!--示例说明 -->
<form class="r0">
<label>
<% if(user.getLanguage() == 7){ %>
使用模拟数据快速配置列表进行展示,模拟数据为json数组格式,可参照示例json配置。</br>在列表展示中通过<b>{字段名}</b>获取字段值。</br>例如在列表中显示示例json中的name,配置为<b>{name}</b>
<% }else if(user.getLanguage() == 8){ %>
Quick Configuration using mock data for list display, the analog data is json array format, can be arranged with reference to exemplary json. </Br> Obtain the value by <b> {field name} </b> in the list display. </Br> For example json display example of the list name configured to <b> {name} </b>
<% }else if(user.getLanguage() == 9){ %>
使用模擬數據快速配置列表進行展示,模擬數據為json數組格式,可參照示例json配置。</br>在列表展示中通過<b>{字段名}</b>獲取字段值。</br>例如在列表中顯示示例json中的name,配置為<b>{name}</b>
<% } %>
</label>
</form>
</div>
<div class="fn-example">
<h4><%=SystemEnv.getHtmlLabelName(82159, user.getLanguage())%></h4> <!-- 示例 -->
<div id="example">
<div class="wrapper">
<pre>
[
{ "id": "1", "name": "杨文元", "age": "43", "birthday": "1976-02-20"},
{ "id": "2", "name": "刘长庚", "age": "45", "birthday": "1978-03-26"},
{ "id": "3", "name": "付蕾", "age": "34", "birthday": "1985-08-09"}
]
</pre>
</div>
</div>
</div>
<div class="config-shrink"></div>
</div>
<div class="scriptCode">
<div id="scriptCode" name="scriptCode"></div>
</div>
</div>
</div>
<script type="text/javascript">
// 传参 作为全局变量使用
var isTopMenu = "<%=topMenu%>" === "true";
var mec = top.require('mec');
(function(){
// 模板管理
var template = {
defConfig: {// 存放元素.fn-config的高度和padding高度
height: 0,
padHeight: 0
},
calcHeight: function() { // 重新计算fn-config, scriptCode的高度
var $form = $(".temp-container").find("form"),
$pre = $("#example").find("pre"),
maxHeight = Math.max($pre.outerHeight(), $form.outerHeight() );
confHeight = maxHeight + template.defConfig.height;
$(".fn-config").height(confHeight);
$(".scriptCode").css("padding-top", confHeight + template.defConfig.padHeight);
// 重置编辑器的高度
setTimeout(function() {
editor.resize();
}, 300); // 动画时间
}
};
// 初始化编辑器
var defer = top.$ && top.$.Deferred();
require(['htmlEditor'], function(htmlEditor) {
var scriptCode = document.querySelector('#scriptCode');
var val = top.mockJsonData;
window.editor = htmlEditor.editor('scriptCode', 'json');
//自动换行,设置为off关闭
editor.setOption("wrap", "free")
editor.setValue(val, true);
scriptCode.style.visibility = "visible";
defer && defer.resolve(window.editor);
});
window.getEditor = function(cb) {
defer && defer.then(function(editor) {
cb && cb(editor, window);
});
};
// 初始化快捷键
var appdesigner = top.appdesigner;
var canInitMenu = appdesigner && isTopMenu;
require(["shortcut"], function(shortcut) {
var handler = onOK;
if(canInitMenu) {
handler = appdesigner.save;
}
shortcut.init({
container: document,
shortcuts: {
"ctrl+s": {
preventDefault: true,
handler: handler
}
}
});
})
// 初始化右键菜单
require(['contextMenu'], function (contextMenu) {
if (canInitMenu) {
appdesigner.rightMenu(document.body, contextMenu, true);
$("body").on("mousedown.contextmenu", function () {
var doc = top.document;
var $contextmenu = $(doc).find(".context-menu");
if (!$contextmenu.length) return;
$contextmenu[0].contextmenu.toggle(false);
});
}
contextMenu.init({
items: [{
icon: "icon-save",
name: SystemEnv.getHtmlNoteName(3515), // 保存
shortcut: "Ctrl+S",
handler: onOK
}, {
icon: "icon-cancel",
name: SystemEnv.getHtmlNoteName(3787), // 关闭
handler: onCancel
}, {}, {
icon: "icon-sourceUrl",
name: SystemEnv.getHtmlNoteName(4695), // 页面地址
handler: function () {
window.prompt(SystemEnv.getHtmlNoteName(4695), location.href);
}
}]
});
});
// 供外部调用 重新刷新当前菜单
window.renderRightMenu = function() {
if(canInitMenu) {
require(['contextMenu'], function (contextMenu) {
appdesigner.rightMenu(document.body, contextMenu, true);
});
}
}
require(['components/common'], function(common) {
var $funcs = $(".funcs"),
funcs = [],
store = common.store;
Common = common; // 供外部调用
//初始化config默认高度值
var $fnConfig = $(".fn-config");
template.defConfig = {
height: 38,
padHeight: $fnConfig.outerHeight() - $fnConfig.height()
};
// 为fn-config绑定calcHeight,可供外部或模板内调用
$fnConfig.on("calcHeight", template.calcHeight);
// 初始化配置示例
var val = top.mockJsonData || "";
$(".config-shrink").addClass("config-down");
// 计算高度
setTimeout(function() {
template.calcHeight();
}, 100);
// 收缩函数列表
$(".arrow").on("click", function() {
$(".wrapper").toggleClass("toggle");
$(this).toggleClass("right");
setTimeout(function() { // 动画
window.editor && window.editor.resize();
}, 250);
});
// 收缩函数配置和函数示例
$(".config-shrink").on("click", function() {
var $this = $(this),
$config = $(".fn-config"),
height = $config.outerHeight();
if($this.hasClass('config-down')){
$this.removeClass('config-down');
template.calcHeight();
$config.css('margin-top','-'+height+'px');
$(".scriptCode").css("padding-top", '10px');
}else{
$this.addClass('config-down');
$config.css('margin-top','0px');
template.calcHeight();
}
});
// 模板内公共操作的回调
var operations = {
add: function(tmplId){
var $opEl = $(this),
$parent = $opEl.parent(),
temp = $("#"+tmplId).html();
$(temp).insertAfter($parent);
},
addParams: function() {
operations.add.call(this, "fn-params");
},
delParams: function() {
$(this).parent().remove();
},
addMenus: function(){
operations.add.call(this, "menu-params");
}
};
// 为模板绑定公共的操作事件
$(".main").on("click.operation", "[data-operation]", function() {
var operation = $(this).data("operation"),
cb = operations[operation];
cb && cb.call(this);
template.calcHeight();
});
});
})();
function getScriptCode(){
return editor.getValue();
}
function onOK(){
if(top && top.callTopDlgHookFn){
var result = {
"scriptCode" : getScriptCode()
};
top.callTopDlgHookFn(result);
}
onCancel();
}
function onCancel(){
top.closeTopDialog();
}
</script>
</body>
</html>