forked from baixing/puerh
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjavascript.html
More file actions
710 lines (643 loc) · 31.1 KB
/
javascript.html
File metadata and controls
710 lines (643 loc) · 31.1 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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>JavaScript Plugins > Puerh - 百姓网 UI 库</title>
<link rel="stylesheet" href="stylesheets/base.css" />
<link rel="stylesheet" href="style.css" />
<!--[if lt IE 9]>
<script type="text/javascript">
// html5shiv MIT @rem remysharp.com/html5-enabling-script
// iepp v1.6.2 MIT @jon_neal iecss.com/print-protector
/*@cc_on(function(a,b){function r(a){var b=-1;while(++b<f)a.createElement(e[b])}if(!(!window.attachEvent||!b.createStyleSheet||!function(){var a=document.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}())){a.iepp=a.iepp||{};var c=a.iepp,d=c.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",e=d.split("|"),f=e.length,g=new RegExp("(^|\\s)("+d+")","gi"),h=new RegExp("<(/*)("+d+")","gi"),i=/^\s*[\{\}]\s*$/,j=new RegExp("(^|[^\\n]*?\\s)("+d+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),k=b.createDocumentFragment(),l=b.documentElement,m=l.firstChild,n=b.createElement("body"),o=b.createElement("style"),p=/print|all/,q;c.getCSS=function(a,b){if(a+""===undefined)return"";var d=-1,e=a.length,f,g=[];while(++d<e){f=a[d];if(f.disabled)continue;b=f.media||b,p.test(b)&&g.push(c.getCSS(f.imports,b),f.cssText),b="all"}return g.join("")},c.parseCSS=function(a){var b=[],c;while((c=j.exec(a))!=null)b.push(((i.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(g,"$1.iepp_$2")+c[4]);return b.join("\n")},c.writeHTML=function(){var a=-1;q=q||b.body;while(++a<f){var c=b.getElementsByTagName(e[a]),d=c.length,g=-1;while(++g<d)c[g].className.indexOf("iepp_")<0&&(c[g].className+=" iepp_"+e[a])}k.appendChild(q),l.appendChild(n),n.className=q.className,n.id=q.id,n.innerHTML=q.innerHTML.replace(h,"<$1font")},c._beforePrint=function(){o.styleSheet.cssText=c.parseCSS(c.getCSS(b.styleSheets,"all")),c.writeHTML()},c.restoreHTML=function(){n.innerHTML="",l.removeChild(n),l.appendChild(q)},c._afterPrint=function(){c.restoreHTML(),o.styleSheet.cssText=""},r(b),r(k);if(c.disablePP)return;m.insertBefore(o,m.firstChild),o.media="print",o.className="iepp-printshim",a.attachEvent("onbeforeprint",c._beforePrint),a.attachEvent("onafterprint",c._afterPrint)}})(this,document)@*/
</script>
<![endif]-->
</head>
<body class="javascript">
<div class="container clearfix">
<div id="header" class="grid grid-20">
<div class="grid grid-4 first">
<h1 id="logo">Puerh</h1>
<strong id="tagline">百姓网 UI 库</strong>
</div>
<div class="grid grid-11 navi">
<a href="./index.html" id="index">HOME</a>
<a href="./css.html" id="css">CSS</a>
<a href="./javascript.html" id="javascript">JavaScript</a>
<a href="./getting-start.html" id="getting-start">Getting Start</a>
</div>
<div class="grid grid-5 last navi">Feedback:
<a href="http://arch.baixing.com/Puerh/faq.html">FAQ</a>
<a href="mailto:sundengjia@baixing.com">@登甲</a>
<a href="mailto:linjianfeng@baixing.com">@小鱼</a>
</div>
</div> <!-- #header -->
<p class="grid grid-20">
目前 Puerh 的大部分组件都使用 Twitter Bootstrap 库的自定义 Javascript 插件。删除了其中网站不常用的 Carousel 等组件,修改 Tips、Modals 等插件以适合百姓网需求,增加 Validator 和 Linkage 组件。
</p>
<table class="document-table" id="plugin-table">
<tr>
<th><a href="#Modals">Modals(弹出层)</a></th>
<th><a href="#Dropdowns">Dropdowns(下拉菜单)</a></th>
<th><a href="#Tabs">Tabs(标签切换)</a></th>
<th><a href="#Tips">Tips(浮层提示条)</a></th>
</tr>
<tr>
<th><a href="#Alert">Alert(可关闭消息)</a></th>
<th><a href="#Typeahead">Typeahead(自动完成)</a></th>
<th><a href="#Scrollspy">Scrollspy(滚动生成)</a></th>
<th><a href="#Collapse">Collapse(折叠)</a></th>
</tr>
<tr>
<th><a href="#Validator">Validator(表单验证)</a></th>
<th>Linkage(联动操作)</th>
<th></th>
<th></th>
</tr>
<tr>
<td colspan="4" class="table-ps"><small>注:API 接口使用可以参考:http://twitter.github.com/bootstrap/javascript.html</small></td>
</tr>
</table>
<div id="document" class="grid grid-20">
<div class="document-cell">
<h3 id="Modals" class="typo-h3"># Modals(弹出层)</h3>
<div class="document-cell-box typo">
<h4 class="typo-h4">一、如何使用:</h4>
<pre class="prettyprint">
$('#myModal').modal(Options);
</pre>
<p><strong>演示:</strong><button data-toggle="modal" data-target="#myModal">demo</button></p>
<h4 class="typo-h4">二、Options 对象</h4>
<p>Modal 只有唯一的方法:<code>.modal(Options)</code>。传入的 Options 可以是对象,也可以是字符串。当传入的 Options 是对象时,使用下面的属性:</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>type</th>
<th>default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>backdrop</td>
<td>boolean</td>
<td>true</td>
<td>当 options 中设置 <code>backdrop: 'static'</code> 时,点击背景的时候,不会关掉弹出框。设置为 <code>false</code> 的时候是不显示背景,不要混淆。</td>
</tr>
<tr>
<td>keyboard</td>
<td>boolean</td>
<td>true</td>
<td>是否允许用 Esc 键来关掉弹出框。</td>
</tr>
<tr>
<td>show</td>
<td>boolean</td>
<td>true</td>
<td>初始化时显示弹出框。</td>
</tr>
</tbody>
</table>
<p>当传入的 Options 是字符串时,传入内容的用法如下:</p>
<table>
<thead>
<tr>
<th>{String} Name</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>toggle</td>
<td>反复手动触发弹出层的打开/关闭。</td>
</tr>
<tr>
<td>hide</td>
<td>手动隐藏弹出层。</td>
</tr>
<tr>
<td>show</td>
<td>手动打开弹出层。</td>
</tr>
</tbody>
</table>
<h4 class="typo-h4">三、HTML 标记:</h4>
<p>在触发弹出框的元素添加 <code>data-toggle="modal"</code>,添加 <code>data-target="#弹出框ID"</code> 或 <code>href="弹出框ID"</code> 来指定弹出框。如:</p>
<pre class="prettyprint">
<button data-toggle="modal" data-target="#myModal">demo</button>
// 目标
<div class="fade hide" id="myModal">
<a data-dismiss="modal" class="close">×</a>
hello world
</div>
</pre>
<p>如果想让弹出框有动画效果,只需要给目标元素添加 <code>.fade</code> 这个 class,如上代码所示。</p>
<h4 class="typo-h4">四、支持事件</h4>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>使用 <code>show</code> 显示弹出层的时候,事件被触发。</td>
</tr>
<tr>
<td>shown</td>
<td>当弹出层可见的时候,事件被触发。不一定是由 <code>show</code> 触发,可能是 <code>toggle</code></td>
</tr>
<tr>
<td>hide</td>
<td>使用 <code>hide</code> 隐藏弹出层的时候,事件被触发。</td>
</tr>
<tr>
<td>hidden</td>
<td>当弹出层不可见的时候,事件被触发。不一定是由 <code>hide</code> 触发,可能是 <code>toggle</code></td>
</tr>
</tbody>
</table>
<pre class="prettyprint">
// 事件示例代码
$('#myModal').on('hidden', function () {
// do something…
})
</pre>
</div>
</div> <!-- .document-cell #Modals-->
<div class="document-cell">
<h3 id="Dropdowns" class="typo-h3"># Dropdowns(下拉菜单)</h3>
<div class="document-cell-box typo">
<h4 class="typo-h4">一、如何使用:</h4>
<p>有两种方法,一种是使用 javascript 来设置:</p>
<pre class="prettyprint">
$('.dropdown-toggle').dropdown()
</pre>
<p>另一种方法是,使用 html 标记来直接设置:</p>
<div class="topbar clearfix">
<div class="topbar-left">
text place on the left side
</div> <!-- topbar-left -->
<div class="topbar-right">
<a href="#">注册</a> |
<a href="#">登录</a> -
<a href="#">用户中心</a>
<div class="dropdown dropdown-unibody" id="mydropdown2">
<a href="#mydropdown2" hidefocus data-toggle="dropdown" class="dropdown-trigger dropdown-trigger-active">消息<cite>8</cite><i class="arrow arrow-down"></i></a>
<ul class="dropdown-menu clearfix">
<li class="dropdown-menu-item"><cite>5</cite>条留言信息</li>
<li class="dropdown-menu-item"><cite>3</cite>条出价信息</li>
</ul>
</div>
<a href="#">付费推广</a> -
<a href="#">帮助</a> -
<a href="#">手机版</a>
</div> <!-- topbar-right -->
</div> <!-- .topbar -->
<h4 class="typo-h4">二、HTML 标记:</h4>
<p>在触发下拉框需要添加 <code>data-target="#下拉框ID"</code> 或 <code>href="下拉框ID"</code> 来指定下拉框。如:</p>
<pre class="prettyprint">
<ul>
<li id="#myDropdown"><button data-toggle="dropdown" data-target="#myDropdown">dropdown</button>
<ul class="dropdown-menu">
<li><a href="#">item 1</a></li>
<li><a href="#">item 2</a></li>
<li><a href="#">item 3</a></li>
</ul>
</li>
</ul>
</pre>
</div>
</div> <!-- .document-cell #Dropdowns-->
<div class="document-cell">
<h3 id="Tabs" class="typo-h3"># Tabs(标签切换)</h3>
<div class="document-cell-box typo">
<h4 class="typo-h4">一、如何使用:</h4>
<pre class="prettyprint">
// javascript 方式触发
$('#myTab').tab('show')
</pre>
<p><strong>演示:</strong></p>
<!-- demo start -->
<div class="tab">
<ul class="tab-title clearfix">
<li class="tab-title-item"><a href="#" data-toggle="tab">全部</a></li>
<li class="tab-title-item active"><a href="#" data-toggle="tab">个人</a></li>
<li class="tab-title-item tab-title-item-last"><a href="#" data-toggle="tab">商家</a></li>
</ul>
</div> <!-- .tab -->
<!-- demo end -->
<h4 class="typo-h4">二、HTML 标记:</h4>
<p>在触发点添加 <code>data-toggle="tab"</code> 自动触发 Tab,添加 <code>data-target="#对应Tab内容的ID"</code> 或者 <code>href="#对应Tab内容的ID"</code> 来指定对应的 Tab 内容显示。</p>
<pre class="prettyprint">
<ul class="tab-title">
<li class="active"><a href="#home">Home</a></li>
<li><a href="#profile">Profile</a></li>
<li><a href="#messages">Messages</a></li>
<li><a href="#settings">Settings</a></li>
</ul>
<div class="tab-content">
<div class="tab-content-pane active" id="home">...</div>
<div class="tab-content-pane" id="profile">...</div>
<div class="tab-content-pane" id="messages">...</div>
<div class="tab-content-pane" id="settings">...</div>
</div>
</pre>
<p>也可以不使用 <code>data-toggle</code> 来触发,而是使用 javascript 手动触发。</p>
<h4 class="typo-h4">三、支持事件</h4>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>显示一个新的 tab 前触发此事件。可以用 <code>event.target</code> 和 <code>event.relatedTarget</code> 来追踪激活的 tab 和被关闭的 tab (如果有的话) 。</td>
</tr>
<tr>
<td>shown</td>
<td>显示一个新的 tab 后触发引事件。可以用 <code>event.target</code> 和 <code>event.relatedTarget</code> 来追踪激活的 tab 和被关闭的 tab (如果有的话) 。</td>
</tr>
</tbody>
</table>
<pre class="prettyprint">
// 事件示例代码
$('a[data-toggle="tab"]').on('shown', function (e) {
e.target // 被激活的 tab
e.relatedTarget // 上一个激活(已经关闭)的 tab
})
</pre>
</div>
</div> <!-- .document-cell #Tabs-->
<div class="document-cell">
<h3 id="Tips" class="typo-h3"># Tips(浮层提示条)</h3>
<div class="document-cell-box typo">
<h4 class="typo-h4">一、如何使用:</h4>
<pre class="prettyprint">
// javasript 手动触发
$('#tips').popover(options)
</pre>
<p><strong>演示:</strong><button id="tips" data-content="Tips 的内容" title="标题">demo</button></p>
<h4 class="typo-h4">二、Options 对象</h4>
<p>Tips 只有唯一的方法:.popover(Options)。传入的 Options 可以是对象,也可以是字符串。当传入的 Options 是对象时,使用下面的属性:</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>type</th>
<th>default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>animation</td>
<td>boolean</td>
<td>true</td>
<td>应用 CSS 动画</td>
</tr>
<tr>
<td>placement</td>
<td>string|function</td>
<td>'right'</td>
<td>显示的位置,可以是:top | bottom | left | right</td>
</tr>
<tr>
<td>selector</td>
<td>string</td>
<td>false</td>
<td>如果设定选择器,那 Tips 则只在该选择器上生效。</td>
</tr>
<tr>
<td>trigger</td>
<td>string</td>
<td>'hover'</td>
<td>触发 Tips 的事件,可以是:hover | focus | manual</td>
</tr>
<tr>
<td>title</td>
<td>string | function</td>
<td>''</td>
<td>如果没有 <code>title</code> 标签时默认值。</td>
</tr>
<tr>
<td>content</td>
<td>string | function</td>
<td>''</td>
<td>如果没有设置 <code>data-content</code> 时的默认值。</td>
</tr>
<tr>
<td>delay</td>
<td>number | object</td>
<td>0</td>
<td>
<p>显示和隐藏 Tips 的过渡时间,以 ms 为单位</p>
<p>如何只设定一个 {number},则会同时应用到 <code>show/hide</code> 上。</p>
<p>可以以对象方式传值: <code>delay: { show: 500, hide: 100 }</code></p>
</td>
</tr>
</tbody>
</table>
<p>当 Options 是一个字条串的时候,如下使用:</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>显示 Tips</td>
</tr>
<tr>
<td>hide</td>
<td>隐藏 Tips</td>
</tr>
<tr>
<td>toggle</td>
<td>反复显示/隐藏 Tips</td>
</tr>
</tbody>
</table>
<h4 class="typo-h4">三、HTML 标记:</h4>
<pre class="prettyprint">
<button id="tips" data-content="Tips 的内容" title="标题">demo</button>
</pre>
</div>
</div> <!-- .document-cell #Tips-->
<div class="document-cell">
<h3 class="typo-h3" id="Alert"># Alert(可关闭消息)</h3>
<div class="document-cell-box typo">
<h4 class="typo-h4">一、如何使用:</h4>
<pre class="prettyprint">
// 如果不使用选择器,则直接关掉 <code>.close</code> 用 <code>class="alert"</code> 的标签
$(".alert").alert(Options)
</pre>
<p class="alert fade in">
<a class="close" data-dismiss="alert" href="#">×</a>
<strong>演示:</strong>hello world
</p>
<h4 class="typo-h4">二、Options 对象</h4>
<p>Modal 只有唯一的方法:<code>.modal(Options)</code>。传入的 Options 是字符串时,关闭这个 Alert Message。代码如下:</p>
<pre class="prettyprint">$(".alert").alert('close');
</pre>
<h4 class="typo-h4">三、HTML 标记:</h4>
<p>添加关闭按钮:</p>
<pre class="prettyprint"><a class="close" data-dismiss="alert" href="#">×</a>
// 目标:使用 javascript 指定目标,或者直接作为 <code>.close</code> 的父元素,添加 <code>class="alert"</code>
<p class="alert fade in">
<a class="close" data-dismiss="alert" href="#">×</a>
<strong>演示:</strong>hello world
</p>
</pre>
<p>如果想让弹出框有动画效果,只需要给目标元素添加 <code>.fade</code> 这个 class,如上代码所示。</p>
<h4 class="typo-h4">四、支持事件</h4>
<table>
<thead>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>close</td>
<td>在块被关闭的瞬间触发。</td>
</tr>
<tr>
<td>closed</td>
<td>在块关闭,CSS 动画完成后触发。</td>
</tr>
</tbody>
</table>
<pre class="prettyprint">// 事件示例代码
$('#my-alert').bind('closed', function () {
// do something…
})
</pre>
</div>
</div> <!-- #Alert -->
<div class="document-cell">
<h3 id="Typeahead" class="typo-h3"># Typeahead(自动完成)</h3>
<div class="document-cell-box typo">
<h4 class="typo-h4">一、如何使用:</h4>
<pre class="prettyprint">$('.typeahead').typeahead();
</pre>
<p><strong>演示:</strong> <input data-provide="typeahead" data-items="4" data-source='["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Dakota","North Carolina","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming"]'></p>
<!-- demo end -->
<h4 class="typo-h4">二、Options 对象</h4>
<p>Typeahead 只有唯一的方法:<code>.typeahead(Options)</code>。传入的 Options 对象有以下属性/方法:</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>type</th>
<th>default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>source</td>
<td>array</td>
<td>[ ]</td>
<td>自动完成的数据。</td>
</tr>
<tr>
<td>items</td>
<td>number</td>
<td>8</td>
<td>自动完成显示的最大数目。</td>
</tr>
<tr>
<td>matcher</td>
<td>function</td>
<td>case insensitive</td>
<td>匹配自动完成项。接受唯一的参数 <code>item</code> 以匹配当前完成的内容。可以使用 <code>this.query</code> 来得到当前自动完成的项。如果匹配到相应的选择,则返回一个布尔值:<code>true</code>。</td>
</tr>
<tr>
<td>sorter</td>
<td>function</td>
<td>exact match,<br> case sensitive,<br> case insensitive</td>
<td>用以排序自动完成项的方法。接受一个参数 <code>items</code>,可以使用 <code>this.query</code> 来得到当前自动完成的项。</td>
</tr>
<tr>
<td>highlighter</td>
<td>function</td>
<td>highlights all default matches</td>
<td>用以高亮匹配项的方法。接受一个参数 <code>item</code>。必须返回 html。</td>
</tr>
</tbody>
</table>
<h4 class="typo-h4">三、HTML 标记:</h4>
<p>添加 <code>data-provide="typeahead"</code> 来获得自动完成。可以使用 <code>data-source="数组"</code> 来提供自动完成的项。也可以在 Options 中提供。</p>
<pre class="prettyprint">
<input type="text" data-provide="typeahead" />
</pre>
</div>
</div> <!-- .document-cell #Typeahead-->
<div class="document-cell">
<h3 id="Collapse" class="typo-h3"># Collapse(折叠)</h3>
<div class="document-cell-box typo">
<h4 class="typo-h4">一、如何使用:</h4>
<pre class="prettyprint">$(".collapse").collapse();
</pre>
<p><strong>演示:</strong></p>
<div id="accordion2">
<div class="accordion">
<div class="accordion-heading">
<a href="#collapseOne" data-parent="#accordion2" data-toggle="collapse" class="collapse-toggle">
Collapsible Group Item #1
</a>
</div>
<div class="accordion-body collapse in" id="collapseOne">
<p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
<div class="accordion">
<div class="accordion-heading">
<a href="#collapseTwo" data-parent="#accordion2" data-toggle="collapse" class="collapse-toggle">
Collapsible Group Item #2
</a>
</div>
<div class="accordion-body collapse" id="collapseTwo">
<p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
<div class="accordion">
<div class="accordion-heading">
<a href="#collapseThree" data-parent="#accordion2" data-toggle="collapse" class="collapse-toggle">
Collapsible Group Item #3
</a>
</div>
<div class="accordion-body collapse" id="collapseThree">
<p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<!-- demo end -->
<h4 class="typo-h4">二、Options 对象</h4>
<p>Typeahead 只有唯一的方法:<code>.typeahead(Options)</code>。传入的 Options 对象有以下属性/方法:</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>type</th>
<th>default</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>parent</td>
<td>selector</td>
<td>false</td>
<td>对于指定同一个父节点的多个折叠标签,当其中一个显示,则其他的都会关闭。</td>
</tr>
<tr>
<td>toggle</td>
<td>boolean</td>
<td>true</td>
<td>交替显示/隐藏</td>
</tr>
</tbody>
</table>
<h4 class="typo-h4">三、HTML 标记:</h4>
<p>在触发点上添加 <code>data-toggle="collapse"</code> 和 <code>data-target</code> 将会自动添加折叠控制。<code>data-target</code> 接受一个 CSS selector(jQuery),指向要折叠的内容,记得在所指向的标签添加 <code>class="collapse"</code>。如果想让折叠的内容默认打开,可以添加额外的 class <code>in</code>。可以通过设置 <code>data-parent="#selector"</code> 来指定所属组,详见 Options 中的 <code>parent</code></p>
<pre class="prettyprint">
<button class="btn btn-danger" data-toggle="collapse" data-target="#demo">
simple collapsible
</button>
<div id="demo" class="collapse in"> … </div>
</pre>
<h4 class="typo-h4">四、方法:<code>.collapse(options)</code></h4>
<p>可以用于激活一个可折叠元素。接受传入一个 Object:</p>
<pre class="prettyprint">
$('#myCollapsible').collapse({
toggle: false
})
</pre>
<strong>Note: Options 也可以是一个字符串</strong>
<table>
<thead>
<tr>
<td>参数</td>
<td>描述</td>
</tr>
</thead>
<tbody>
<tr>
<td>toggle</td>
<td>交替显示/隐藏一个元素</td>
</tr>
<tr>
<td>show</td>
<td>显示一个折叠元素</td>
</tr>
<tr>
<td>hide</td>
<td>隐藏一个折叠元素</td>
</tr>
</tbody>
</table>
<h4 class="typo-h4">四、支持事件:</h4>
<pre class="prettyprint">
$('#myCollapsible').on('hidden', function () {
// do something…
})
</pre>
<table>
<thead>
<tr>
<th style="width: 150px;">Event</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>折叠被打开的时候同时触发 <code>show</code> 事件</td>
</tr>
<tr>
<td>shown</td>
<td>折叠已经完全打开,触发此事件</td>
</tr>
<tr>
<td>hide</td>
<td>
折腾被关闭时触发此事件
</td>
</tr>
<tr>
<td>hidden</td>
<td>折腾已经完全关闭,触发此事件</td>
</tr>
</tbody>
</table>
</div>
</div> <!-- .document-cell #Collapse-->
</div> <!-- #document -->
<div id="footer" class="grid grid-20">
<small>版权所有: 客齐集网络信息技术服务(上海)有限公司</small>
</div>
</div> <!-- .container -->
<div class="modal fade hide" id="myModal">
<h4 class="modal-title">本操作需要您先注册百姓网</h4>
<a class="close" data-dismiss="modal" href="###">×</a>
<div class="modal-content">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div> <!-- .modal -->
<script type="text/javascript" src="./javascripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="./javascripts/plugins.js"></script>
<script type="text/javascript" src="instant.js"></script>
</body>
</html>