FloatButton_wev8.js
14.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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
if(typeof(MEC_NS) == 'undefined'){
MEC_NS = {};
}
MEC_NS.FloatButton = function(typeTmp, idTmp, mecJsonTmp){
this.type = typeTmp;
if(!idTmp){
idTmp = new UUID().toString();
}
this.id = idTmp;
if(!mecJsonTmp){
mecJsonTmp = this.getDefaultMecJson();
}
this.mecJson = mecJsonTmp;
};
/*获取id。 必需的方法*/
MEC_NS.FloatButton.prototype.getID = function(){
return this.id;
};
MEC_NS.FloatButton.prototype.runWhenPageOnLoad = function(){
this.afterDesignHtmlBuild();
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.FloatButton.prototype.getDesignHtml = function(){
return getDesignHtml(this);
};
MEC_NS.FloatButton.prototype.afterDesignHtmlBuild = function(isPageOnload){
var theId = this.id;
var $abbr = $("abbr[id='"+theId+"']");
/*
var offset = $("#content_editor").offset();
var t = offset.top;
var l = offset.left;*/
var top = this.mecJson["top"];
var right = this.mecJson["right"];
var bottom = this.mecJson["bottom"];
var left = this.mecJson["left"];
$("#content_editor").after($abbr);
var style = "";
var positionType = this.mecJson["positionType"];
if(positionType == "left_top"){
style = "left:"+left+";top:"+top+";";
}else if(positionType == "right_top"){
style = "right:"+right+";top:"+top+";";
}else if(positionType == "left_bottom"){
style = "left:"+left+";bottom:"+bottom+";";
}else if(positionType == "right_bottom"){
style = "right:"+right+";bottom:"+bottom+";";
}
$abbr.attr("style", style);
};
/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.FloatButton.prototype.getAttrDlgHtml = function(){
var styleL = "_style" + _userLanguage;
var theId = this.id;
var htm = "<div id=\"MADFloatButton_"+theId+"\">"
+"<div class=\"title\">"
+SystemEnv.getHtmlNoteName(4650) //基本信息
+"</div>"
+"<div class=\"form-group\">"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5024)+"</span>" //内容:
+"<div class=\"col-m-8\" style=\"width:80px;\"><select class=\"form-control\" data-autobind id=\"contentType_"+theId+"\" onchange=\"MADFloatButton_ContentTypeChange('"+theId+"')\">"
+" <option value=\"1\">"+SystemEnv.getHtmlNoteName(4167)+"</option>" //图片
+" <option value=\"2\">"+SystemEnv.getHtmlNoteName(4373)+"</option>" //文字
+"</select></div>"
+ "<div class=\"col-m-8\" style=\"width: calc(100% - 65px - 80px);padding-left:8px;\">"
+ "<div class=\"icon-set-wrap content-v content-v1\" style=\"display:none;\" id=\"img_"+theId+"\" onclick=\"MADFloatButton_PicSet('','"+theId+"');\">"
+ "<div class=\"icon-set-delete\" onclick=\"MADFloatButton_SetPicPath('','"+theId+"','');\"></div>"
+ "<img class=\"icon-set-img\"/>"
+ "<input type=\"hidden\" />"
+ "</div>"
+ "<input data-autobind class=\"form-control content-v content-v2\" style=\"display:none;\" id=\"text_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4177)+"\" "+MLanguage.ATTR+"/>"
+ "</div>"
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5025)+"</span>" //显示位置:
+"<div class=\"col-m-8\"><div class=\"posBox\"> <div data-autobind data-value=\"left_top\">"+SystemEnv.getHtmlNoteName(5026)+"</div> <div data-autobind data-value=\"right_top\">"+SystemEnv.getHtmlNoteName(5027)+"</div> <div data-autobind data-value=\"left_bottom\">"+SystemEnv.getHtmlNoteName(5028)+"</div> <div data-autobind data-value=\"right_bottom\">"+SystemEnv.getHtmlNoteName(5029)+"</div> </div></div>"
+"</div>"
+"<div class=\"row posDetail posDetail-top\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5030)+"</span>" //距上偏移:
+"<div class=\"col-m-8\"><input data-autobind='top' class=\"form-control\" id=\"top_"+theId+"\" type=\"text\" placeholder=\"如10px或者50%\"/></div>"
+"</div>"
+"<div class=\"row posDetail posDetail-right\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5031)+"</span>" //距右偏移:
+"<div class=\"col-m-8\"><input data-autobind='right' class=\"form-control\" id=\"right_"+theId+"\" type=\"text\" placeholder=\"如10px或者50%\"/></div>" //如10px或者50%
+"</div>"
+"<div class=\"row posDetail posDetail-bottom\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5032)+"</span>" //距下偏移:
+"<div class=\"col-m-8\"><input data-autobind='bottom' class=\"form-control\" id=\"bottom_"+theId+"\" type=\"text\" placeholder=\"如10px或者50%\"/></div>" //如10px或者50%
+"</div>"
+"<div class=\"row posDetail posDetail-left\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5033)+"</span>" //距左偏移:
+"<div class=\"col-m-8\"><input data-autobind='left' class=\"form-control\" id=\"left_"+theId+"\" type=\"text\" placeholder=\"如10px或者50%\"/></div>" //如10px或者50%
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5034)+"</span>" //数字提示:
+"<div class=\"col-m-8\" style=\"position: relative;\">"
+ "<span>"
+ "<input type=\"checkbox\" id=\"remind_"+theId+"\" value=\"1\" onclick=\"MADFloatButton_IsremindChange('"+theId+"');\"/>"
+ "</span>"
+ "<input type=\"hidden\" id=\"remindtype_"+theId+"\"/>"
+ "<input type=\"hidden\" id=\"remindsql_"+theId+"\"/>"
+ "<input type=\"hidden\" id=\"reminddatasource_"+theId+"\"/>"
+ "<input type=\"hidden\" id=\"remindjavafilename_"+theId+"\"/>"
+ "<input type=\"hidden\" id=\"remindapiconfig_"+theId+"\"/>"
+ "<div id=\"numremindEditFlag_"+theId+"\" class=\"numremindEditFlag\" style=\"position: absolute;top: -6px;\" onclick=\"MADFloatButton_NumremindEdit('"+theId+"');\"></div>"
+"</div>"
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(4349)+"</span>" //单击事件:
+"<div class=\"col-m-8\">"
+ "<div class='multi-switch'>"
+ "<span onclick=\"MADFloatButton_ChangeClickType(this, '"+theId+"');\">"
+ "<input data-checkbox='false' type=\"checkbox\" name=\"clickType_"+theId+"\" value=\"1\"/><span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(5036)+"</span>" //回到顶部
+ "</span>"
+ "<span style=\"position: relative;\" onclick=\"MADFloatButton_ChangeClickType(this, '"+theId+"');\">"
+ "<input data-checkbox='false' type=\"checkbox\" name=\"clickType_"+theId+"\" value=\"2\"/><span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4634)+"</span>" //脚本
+ "</span>"
+ "<a id=\"clickScriptWrap_"+theId+"\" class=\"click-control hide nhbtn_click_desc\" onclick=\"MADFloatButton_addClickScript('"+theId+"')\">"
+ "<input id=\"clickScript_"+theId+"\" type=\"hidden\" value=\"\">"
+ "</a>"
+ "</div>"
+"</div>"
+"</div>"
+"<div class=\"row\">"
+"<div class=\"tip-control\" style=\"display:block;\">"
+ SystemEnv.getHtmlNoteName(5035) //如果单击事件为 回到顶部,按钮一开始是不会显示的,如果页面向下滚动的距离超过一屏,按钮此时才会显示。
+"</div>"
+"</div>"
+"</div>"
+"<div class=\"bottom\"><div class=\"save-btn\" onclick=\"refreshMecDesign('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3451)+"</div></div>" //确定
+"</div>";
htm += "<div class=\"MAD_Alert\">"+SystemEnv.getHtmlNoteName(4115)+"</div>"; //已生成到布局
return htm;
};
/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.FloatButton.prototype.afterAttrDlgBuild = function(){
var theId = this.id;
var mecHandler = MECHandlerPool.getHandler(theId);
var $attrContainer = $("#MADFloatButton_"+theId);
$("#contentType_"+theId).val(this.mecJson["contentType"]);
MADFloatButton_ContentTypeChange(theId);
MADFloatButton_SetPicPath("", theId, this.mecJson["img"]);
MLanguage.setValue($("#text_" + theId), this.mecJson["text"]);
$(".posBox > div", $attrContainer).click(function(){
if(!$(this).hasClass("active")){
$(this).siblings("div.active").removeClass("active");
$(this).addClass("active");
$(".posDetail", $attrContainer).hide();
var v = $(this).attr("data-value");
var vArr = v.split("_");
for(var i = 0; i < vArr.length; i++){
$(".posDetail-"+vArr[i], $attrContainer).show();
}
}
});
var positionType = this.mecJson["positionType"];
$(".posBox > div[data-value='"+positionType+"']", $attrContainer).click();
$("#top_" + theId).val(this.mecJson["top"]);
$("#right_" + theId).val(this.mecJson["right"]);
$("#bottom_" + theId).val(this.mecJson["bottom"]);
$("#left_" + theId).val(this.mecJson["left"]);
var remind = this.mecJson["remind"];
if(remind == "1"){
$("#remind_"+theId).checked();
}
$("#remindtype_" + theId).val(this.mecJson["remindtype"]);
$("#remindsql_" + theId).val(this.mecJson["remindsql"]);
$("#reminddatasource_" + theId).val(this.mecJson["reminddatasource"]);
$("#remindjavafilename_" + theId).val(this.mecJson["remindjavafilename"]);
$("#remindapiconfig_" + theId).val(Mec_FiexdUndefinedVal(this.mecJson["remindapiconfig"]));
var clickTypeV = this.mecJson["clickType"];
var $clickType = $("input[type='checkbox'][name='clickType_"+theId+"'][value='"+clickTypeV+"']");
if($clickType.length > 0){
$clickType.switched();
}
var scriptCode = Mec_FiexdUndefinedVal(this.mecJson["clickScript"]);
var $clickScript = $("#clickScript_"+theId).val(scriptCode);
SL_ChangeStyle($clickScript.parent(), scriptCode);
$("#MADFloatButton_"+theId).switcher().checkbox({
onClick: function () {
mecHandler.autobind.update();
}
});
};
/*获取JSON*/
MEC_NS.FloatButton.prototype.getMecJson = function(){
var theId = this.id;
this.mecJson["id"] = theId;
this.mecJson["mectype"] = this.type;
var $attrContainer = $("#MADFloatButton_"+theId);
if($attrContainer.length > 0){
this.mecJson["contentType"] = $("#contentType_" + theId).val();
this.mecJson["img"] = $("#img_"+theId + " input").val();
this.mecJson["text"] = MLanguage.getValue($("#text_"+theId));
this.mecJson["positionType"] = $(".posBox > div.active", $attrContainer).attr("data-value");
this.mecJson["top"] = $("#top_" + theId).val();
this.mecJson["right"] = $("#right_" + theId).val();
this.mecJson["bottom"] = $("#bottom_" + theId).val();
this.mecJson["left"] = $("#left_" + theId).val();
this.mecJson["remind"] = $("#remind_"+theId).is(':checked') ? "1" : "0";
this.mecJson["remindtype"] = $("#remindtype_" + theId).val();
this.mecJson["remindsql"] = $("#remindsql_" + theId).val();
this.mecJson["reminddatasource"] = $("#reminddatasource_" + theId).val();
this.mecJson["remindjavafilename"] = $("#remindjavafilename_" + theId).val();
this.mecJson["remindapiconfig"] = $("#remindapiconfig_" + theId).val();
this.mecJson["clickType"] = $("input[type='checkbox'][name='clickType_"+theId+"']:checked").val();
this.mecJson["clickScript"] = $("#clickScript_"+theId).val();
}
return this.mecJson;
};
MEC_NS.FloatButton.prototype.getDefaultMecJson = function(){
var theId = this.id;
var defMecJson = {};
defMecJson["id"] = theId;
defMecJson["mectype"] = this.type;
defMecJson["contentType"] = "1";
defMecJson["img"] = "/mobilemode/piclibrary/03-E9_flat/gotop.png";
defMecJson["text"] = "";
defMecJson["positionType"] = "right_bottom";
defMecJson["top"] = "10px";
defMecJson["right"] = "10px";
defMecJson["bottom"] = "20px";
defMecJson["left"] = "10px";
defMecJson["remind"] = "0";
defMecJson["clickType"] = "1";
defMecJson["clickScript"] = "";
return defMecJson;
};
function MADFloatButton_ChangeClickType(switchInner, mec_id){
var value = $(switchInner).find('input').val();
if(value == "2"){
$("#clickScriptWrap_" + mec_id).show();
} else{
$("#clickScriptWrap_" + mec_id).hide();
}
}
function MADFloatButton_addClickScript(mec_id){
var $btnScript = $("#clickScript_"+mec_id);
SL_AddScriptToField($btnScript);
}
function MADFloatButton_PicSet(prefix, mec_id){
var pic_path = $("#img"+prefix+"_"+mec_id + " input").val();
var params = "pic_path=" + pic_path;
showPicsetModal(params, function(result){
var picPath = result["pic_path"];
MADFloatButton_SetPicPath(prefix, mec_id, picPath);
});
}
function MADFloatButton_SetPicPath(prefix, mec_id, picPath){
var mecHandler = MECHandlerPool.getHandler(mec_id);
var $img = $("#img"+prefix+"_"+mec_id);
$("input", $img).val(picPath);
$(".icon-set-img", $img).attr("src", picPath);
if(picPath == ""){
$img.removeClass("hasValue");
}else{
$img.addClass("hasValue");
}
var e = event || window.event;
if (e){
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble=true;
}
}
mecHandler.autobind && mecHandler.autobind.update();
}
function MADFloatButton_ContentTypeChange(mec_id){
var v = $("#contentType_" + mec_id).val();
var $attrContainer = $("#MADFloatButton_"+mec_id);
$(".content-v", $attrContainer).hide();
$(".content-v"+v, $attrContainer).show();
}
function MADFloatButton_IsremindChange(mec_id){
setTimeout(function(){ //checkbox用了插件,不延时checkbox的checked状态获取不准确
var $numremindEditFlag = $("#numremindEditFlag_"+mec_id);
$("#remind_"+mec_id).is(':checked') ? $numremindEditFlag.show() : $numremindEditFlag.hide();
},100);
}
function MADFloatButton_NumremindEdit(mec_id){
var remindtypeV = $("#remindtype_"+mec_id).val();
var remindsqlV = $("#remindsql_"+mec_id).val();
remindsqlV = $m_encrypt(remindsqlV);// 系统安全编码
var reminddatasourceV = $("#reminddatasource_"+mec_id).val();
var remindjavafilenameV = $("#remindjavafilename_"+mec_id).val();
var remindapiconfigV = compressByLZ($("#remindapiconfig_"+mec_id).val());
var url = "/mobilemode/admin/dialog/numremind.jsp?remindtype="+remindtypeV+"&remindsql="+remindsqlV+"&reminddatasource="+reminddatasourceV+"&remindjavafilename="+remindjavafilenameV+"&remindapiconfig="+remindapiconfigV;
var dlg = top.createTopDialog();//获取Dialog对象
dlg.Model = true;
dlg.Width = 500;//定义长度
dlg.normalDialog = false;
dlg.Height = 290;
dlg.URL = url;
dlg.Title = SystemEnv.getHtmlNoteName(3621); //提示
dlg.show();
dlg.hookFn = function(result){
$("#remindtype_"+mec_id).val(result["remindtype"]);
$("#remindsql_"+mec_id).val(result["remindsql"]);
$("#reminddatasource_"+mec_id).val(result["reminddatasource"]);
$("#remindjavafilename_"+mec_id).val(result["remindjavafilename"]);
$("#remindapiconfig_"+mec_id).val(result["remindapiconfig"]);
};
};