textfield.html.ajax.bak
6.94 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>插入文本框</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="leipi.style.css">
<script type="text/javascript" src="../dialogs/internal.js"></script>
<style>
</style>
</head>
<body>
<div class="content">
<table class="table table-bordered table-striped table-hover">
<tr>
<th><span>控件名称</span><span class="label label-danger">*</span></th>
<th><span>默认值</span> </th>
</tr>
<tr>
<td><input type="text" class="form-control input-sm" id="txtName" placeholder="必填项"></td>
<td><input type="text" class="form-control input-sm" id="txtValue" placeholder="无则不填"></td>
</tr>
<tr>
<th><span>输入框样式</span> </th>
<th><span>可见性</span> </th>
</tr>
<tr>
<td>
宽 <input id="txtWidth" type="text" value="150" size="5"/> px
高 <input id="txtHeight" type="text" value="20" size="5"/> px
</td>
<td> <label><input id="txtHidden" type="checkbox" /> 隐藏 </label> </td>
</tr>
<tr>
<th><span>字体大小</span> </th>
<th><span>对齐方式</span> </th>
</tr>
<tr>
<td> <input id="txtFontSize" type="text" size="5" value="12" /> px</td>
<td>
<select id="txtAlign" class="form-control">
<option value="left" >左对齐</option>
<option value="center">居中对齐</option>
<option value="right">右对齐</option>
</select>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
var oNode = null;
window.onload = function() {
//弹出窗口初始化函数,这里主要是判断是编辑文本框还是新增
//以下这个对象定义在editor.all.js第13259行。
if( UE.plugins['textfield'].editdom ){
oNode = UE.plugins['textfield'].editdom;
$G('txtName').value = oNode.getAttribute('title');
$G('txtValue').value = oNode.getAttribute('value');
var nHidden = oNode.getAttribute('hide');
if ( nHidden == '1' ) {
$G('txtHidden').checked = true ;
} else {
nHidden = '0';
}
var sItemId = oNode.getAttribute('name').substr(5);
var sFontSize = oNode.style.fontSize;
$G('txtFontSize').value = sFontSize.substr(0, sFontSize.length - 2);//这里的substr是为了去掉末尾的'px'
var sSizeWidth = oNode.style.width;
$G('txtWidth').value = sSizeWidth.substr(0, sSizeWidth.length - 2);
var sSizeHeight = oNode.style.height;
$G('txtHeight').value = sSizeHeight.substr(0, sSizeHeight.length - 2);
$G('txtAlign').value = oNode.style.textAlign;
}
}
dialog.oncancel = function () {
if( UE.plugins['textfield'].editdom ) {
delete UE.plugins['textfield'].editdom;
}
};
dialog.onok = function (){
if($G('txtName').value==''){
alert('请输入控件名称');
return false;
}
if( !oNode ) {
var sUrl = '/itemid.html'// parent.getItemUrl;
var nItemId = 0;
ajax.request(sUrl, {method: 'GET',timeout:60000,async: false,onsuccess:function (xhr) {
try {
nItemId = xhr.responseText;
var html = '<input type="text"';
html += ' title = "' + $G('txtName').value + '"';
html += ' name = "data_' + nItemId + '"';
html += ' value = "' + $G('txtValue').value + '"';
if ( $G('txtHidden').checked ) {
html += ' hide = "1"';
} else {
html += ' hide = "0"';
}
html += ' style = "';
if( $G('txtFontSize').value != '' ) {
html += 'font-size:' + $G('txtFontSize').value + 'px;';
}
if( $G('txtAlign').value != '' ) {
html += 'text-align:' + $G('txtAlign').value + ';';
}
if( $G('txtWidth').value != '' ) {
html += 'width:' + $G('txtWidth').value + 'px;';
}
if( $G('txtHeight').value != '' ) {
html += 'height:' + $G('txtHeight').value + 'px;';
}
html += '" />';
editor.execCommand('insertHtml',html);
} catch (e) {
return;
}
},
error:function () {
alert('Request TimeOut');
}
})
} else {
oNode.setAttribute('title', $G('txtName').value);
oNode.setAttribute('value', $G('txtValue').value);
if( $G('txtHidden').checked ) {
oNode.setAttribute('hide', 1);
} else {
oNode.setAttribute('hide', 0);
}
var style = '';
if( $G('txtFontSize').value != '' ) {
style += 'font-size:' + $G('txtFontSize').value + 'px;';
}
if( $G('txtAlign').value != '' ) {
style += 'text-align:' + $G('txtAlign').value + ';';
}
if( $G('txtWidth').value != '' ) {
style += 'width:' + $G('txtWidth').value + 'px;';
}
if( $G('txtHeight').value != '' ) {
style += 'height:' + $G('txtHeight').value + 'px;';
}
oNode.setAttribute('style',style );
delete UE.plugins['textfield'].editdom; //使用后清空这个对象,变回新增模式
}
};
</script>
</body>
</html>