Skip to content

Commit da59094

Browse files
committed
perf demo
1 parent ba3a5dc commit da59094

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

css/demo.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@ body{margin:0;background-color:#f0f0f0;}
22
h1,h2,h3{margin:1em 0;font-size:2.25rem;line-height:1;}
33
h2{font-size:1.5rem;}
44
h3{font-size:1.25rem;}
5-
65
a{color:#006af9;text-decoration:none;}
76

87
.wrap{box-sizing:border-box;max-width:800px;margin:0 auto;}
8+
.main .wrap{padding:20px 40px;background-color:#fff;}
99

1010
header{background-color:#2d2d2d;color:#fff;}
1111
header .wrap{padding:30px 0;}
1212
header h1{margin:0;}
1313

14-
.main .wrap{padding:20px 40px;background-color:#fff;}
1514
fieldset{margin:1em 0;border-color:#ddd;}
1615
fieldset legend{color:#888;font-size:1rem;line-height:2;}
1716
fieldset input,
@@ -23,5 +22,13 @@ fieldset button{padding:0.5em;}
2322
.about section h2{margin-bottom:0;}
2423
.about a:hover{opacity:0.8;}
2524

25+
.acts{font-size:0.875rem;}
26+
.acts a{display:inline-block;padding:0.5em 1em;border-radius:3px;background-color:#eee;color:#555;
27+
transition-property:background-color, color;
28+
transition-duration:0.2s;
29+
}
30+
.acts a:hover{color:#333;background-color:#ddd;}
31+
.acts .group + .group{margin-top:0.5em;}
32+
2633
#prompt_box{display:none;margin:10px;padding:10px;border:2px solid #ccc;}
2734
#prompt_box label{display:block;margin-bottom:5px;}

index.html

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
<h1>cxDialog 对话框</h1>
1414
</div>
1515
</header>
16-
1716
<div class="main">
1817
<div class="wrap">
1918
<h2>示例</h2>
19+
2020
<form id="example" action="javascript://" method="get">
2121
<fieldset>
2222
<legend>按钮</legend>
@@ -47,11 +47,15 @@ <h2>示例</h2>
4747

4848
<fieldset>
4949
<legend>显示对话框</legend>
50-
<button type="button" name="alert">模拟 alert</button>
51-
<button type="button" name="confirm">模拟 confirm</button>
52-
<button type="button" name="prompt">模拟 prompt</button>
53-
<p id="result_confirm"></p>
54-
<p id="result_prompt"></p>
50+
<section id="acts" class="acts">
51+
<a href="javascript://" rel="alert">模拟 alert</a>
52+
<a href="javascript://" rel="confirm">模拟 confirm</a>
53+
<a href="javascript://" rel="prompt">模拟 prompt</a>
54+
</section>
55+
<section>
56+
<p id="result_confirm"></p>
57+
<p id="result_prompt"></p>
58+
</section>
5559
</fieldset>
5660
</form>
5761

@@ -120,16 +124,17 @@ <h2>协议</h2>
120124
$.extend($.cxDialog.defaults, opts);
121125
};
122126

123-
form.on('click', 'button', function() {
127+
$('#acts').on('click', 'a', function(){
128+
event.preventDefault();
124129
var _this = this;
125-
var _name = _this.name;
130+
var _rel = _this.rel;
126131

127132
setOptions();
128133

129-
if (_name === 'alert') {
134+
if (_rel === 'alert') {
130135
$.cxDialog('Hello World<br>I am cxDialog');
131136

132-
} else if (_name === 'confirm') {
137+
} else if (_rel === 'confirm') {
133138
$.cxDialog({
134139
title: 'cxDialog',
135140
info: '现在开始使用 <strong>cxDialog</strong>',
@@ -141,7 +146,7 @@ <h2>协议</h2>
141146
}
142147
});
143148

144-
} else if (_name === 'prompt') {
149+
} else if (_rel === 'prompt') {
145150
$.cxDialog({
146151
title: 'cxDialog',
147152
info: document.getElementById('prompt_box'),

0 commit comments

Comments
 (0)