-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdemo.html
More file actions
218 lines (217 loc) · 7.44 KB
/
demo.html
File metadata and controls
218 lines (217 loc) · 7.44 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
<!DOCTYPE HTML>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no" />
<!--<link rel="stylesheet" href="http://webmap3.map.bdimg.com/yyfm/tinyDialog/1.0.0/css/tinyDialog.min.css" />-->
<link rel="stylesheet" href="tinyDialog.css">
<title>tinyDialog demo</title>
<style>
#wide_and_long{
width:3000px;
height:3000px;
}
.float{
float: left;
width: 45%;
border:1px solid #000;
padding:10px;
margin:10px;
/*box-sizing:border-box;*/
}
#code{
overflow: auto;
width: 95%;
min-height: 341px;
display: block;
}
</style>
</head>
<body>
<div class="float">
<b>快捷方式:</b>
<button id="default" data-code="tinyDialog()">default</button>
<button id="alert" data-code="tinyDialog.alert('alert',function(){alert('点了确认')})">alert</button>
<button id="confirm" data-code="tinyDialog.confirm('confirm',function(){alert('点了确认')},function(){alert('点了取消')})">confirm</button>
<button id="prompt" data-code="tinyDialog.prompt('prompt','defaultPrompt',function(e,tinyDialogObjectInstance,userInput){alert('点了确认,输入的是:'+userInput)},function(e,tinyDialogObjectInstance,userInput){alert('点了取消,输入的是:'+userInput)})">prompt</button>
<hr>
<b>定制:</b>
<table id="custom_table" border="1" style="border-collapse:collapse;">
<tr>
<th>项</th>
<th>值</th>
</tr>
<tr>
<td>id</td>
<td><input type="text" value="" class="opt" data-key="id" title="任意html字符串"></td>
</tr>
<tr>
<td>标题</td>
<td><input type="text" value="消息" class="opt" data-key="title" title="任意html字符串"></td>
</tr>
<tr>
<td>内容</td>
<td><input type="text" value="<i>消息内容</i>" class="opt" data-key="content" title="任意html字符串"></td>
</tr>
<tr>
<td>宽度</td>
<td><input type="number" value="200" class="opt" data-key="width" title="任意自然数,单位像素"></td>
</tr>
<tr>
<td>高度</td>
<td><input type="number" value="150" class="opt" data-key="height" title="任意自然数,单位像素"></td>
</tr>
<tr>
<td>是否背景遮罩</td>
<td><input type="checkbox" checked="checked" class="opt" data-key="mask"></td>
</tr>
<tr>
<td>是否有右上角关闭按钮</td>
<td><input type="checkbox" class="opt" data-key="closeX"></td>
</tr>
<tr>
<td>按钮</td>
<td>
<table class="opt_button">
<tr><td>文字:<td><td><input class="opt_button_value" value="确定" title="任意文本,不含html字符"></td></tr>
<tr><td>类型:<td><td><input class="opt_button_type" title="任意文本,不含html字符" /></td></tr>
<tr><td>点击是否关闭dialog:<td><td><input class="opt_button_click" type="checkbox" checked="checked"/></td></tr>
</table>
</td>
</tr>
<tr>
<td>未加入表格的配置项,具体请参阅文档</td>
<td>
<ol>
<li>autoShow:初始化完成后是否自动显示</li>
<li>clickCloseX:点击“×”(叉叉)后的回调函数</li>
<li>init:初始化完成后的回调函数</li>
<li>warpperCssClass:对话框最外层DOM的css样式类</li>
<li>titleCssClass:对话框标题DOM的css样式类</li>
<li>contentOuterCssClass:对话框内容外层DOM的css样式类</li>
<li>contentCssClass:对话框内容内层DOM的css样式类</li>
<li>buttonsAreaCssClass:对话框按钮区域外层DOM的css样式类</li>
<li>buttonCssClass:对话框各按钮DOM的css样式类</li>
<li>otherTypeButtonCssClassPrefix:对话框自定义类别按钮DOM的css样式类的前缀</li>
<li>lastButtonCssClass:对话框最后一个按钮DOM的css样式类</li>
<li>closeXCssClass:对话框中“×”(叉叉)DOM的css样式类</li>
</ol>
</td>
</tr>
</table>
<button id="add_button">增加一个按钮</button><br/>
<hr>
<button id="custom_code">生成代码</button>
</div>
<div class="float">
<b>代码:</b>
<!-- 调试代码备份 -->
<!-- 调试有输入框的content -->
<!--
tinyDialog({
content:'<input>'
})
-->
<!-- tinyDialog({
width:'50%',
height:'200'
}) -->
<textarea id="code">
tinyDialog({
content:'1<br/>2<br/>3<br/>4<br/>1<br/>2<br/>3<br/>4<br/>1<br/>2<br/>3<br/>4<br/>1<br/>2<br/>3<br/>4<br/>1<br/>2<br/>3<br/>4<br/>'
})
</textarea>
<hr>
<button id="custom_run">运行</button>
</div>
<div id="wide_and_long"></div>
<script src="http://webmap2.map.bdimg.com/yyfm/jQuery_1.x/1.10.2/js/jQuery_1.x.min.js"></script>
<!-- <script src="http://webmap2.map.bdimg.com/yyfm/zepto_default/1.1.2/js/zepto_default.min.js"></script> -->
<!-- <script src="http://bcs.duapp.com/jieyou-storage/consoleEnable.js"></script> -->
<script src="tinyDialog.js"></script>
<!-- <script src="http://webmap3.map.bdimg.com/yyfm/tinyDialog/1.0.0/js/tinyDialog.min.js"></script> -->
<script>
$(function(){
var $code = $('#code')
function removeJsPunctuation(str){
return (typeof(str)=='string')?str.replace(/[\(\)\[\]\{\}\,\.\'\"]/g,''):str
}
$.each(['default','alert','confirm','prompt'],function(i,e){
var $this = $('#'+e)
$this.on('click',function(){
$code.val($this.data('code'))
})
})
$('#custom_code').on('click',function(){
var tmp = ['tinyDialog({'],
$opts = $('.opt'),
len = $opts.length,
$optButtons = $('.opt_button'),
btnCount = $optButtons.length
$opts.each(function(i){
var $this = $opts.eq(i),
type = $this.attr('type'),
val
if(type == 'checkbox'){
val = !!$this.prop('checked')
}else if(type == 'number'){
val = $this.val()
}else{
val = '\''+removeJsPunctuation($this.val())+'\''
}
tmp.push('\''+$this.data('key')+'\':'+val)
if(len != (i+1)){
tmp.push(',')
}
})
if(btnCount != 0){
tmp.push(',\'buttons\':[')
$optButtons.each(function(i){
var $this = $optButtons.eq(i),
valueVal = removeJsPunctuation($this.find('.opt_button_value').val()),
typeVal = removeJsPunctuation($this.find('.opt_button_type').val()),
close = !!$this.find('.opt_button_click').prop('checked'),
_tmp = []
tmp.push('{')
if(valueVal){
_tmp.push('\'value\':\''+valueVal+'\'')
}
if(typeVal){
_tmp.push('\'type\':\''+typeVal+'\'')
}
if(!close){
_tmp.push('\'click\':function(){return false}')
}
tmp.push(_tmp.join(','))
tmp.push('}')
if(btnCount != (i+1)){
tmp.push(',')
}
})
tmp.push(']')
}
tmp.push('})')
$code.val(tmp.join(''))
})
$('#add_button').on('click',function(){
$('#custom_table').append(
'<tr>'
+'<td>按钮</td>'
+'<td>'
+'<table class="opt_button">'
+'<tr><td>文字:<td><td><input class="opt_button_value" value="取消" title="任意文本,不含html字符"></td></tr>'
+'<tr><td>类型:<td><td><input class="opt_button_type" value="secondary" title="任意文本,不含html字符" /></td></tr>'
+'<tr><td>点击是否关闭dialog:<td><td><input class="opt_button_click" type="checkbox" checked="checked"/></td></tr>'
+'</table>'
+'</td>'
+'</tr>'
)
})
$('#custom_run').on('click',function(){
eval($code.val())
})
// alert(document.body.style["-webkit-overflow-scrolling"] !== undefined)
})
</script>
</body>
</html>