├── package ├── tab │ ├── code │ │ ├── 593273894 │ │ │ ├── 1 │ │ │ │ └── index.html │ │ │ └── 2 │ │ │ │ └── index.html │ │ ├── 2319103827 │ │ │ ├── index.html │ │ │ ├── index2.html │ │ │ ├── index3.html │ │ │ └── index4.html │ │ ├── rccoder │ │ │ ├── README.md │ │ │ └── tab1.html │ │ ├── DuXingXia233 │ │ │ ├── img │ │ │ │ ├── 1.png │ │ │ │ ├── 2.png │ │ │ │ ├── 3.png │ │ │ │ ├── 4.png │ │ │ │ ├── 5.png │ │ │ │ ├── 6.png │ │ │ │ ├── 7.png │ │ │ │ └── 8.png │ │ │ ├── css │ │ │ │ └── yahoo reSet.css │ │ │ └── README.md │ │ ├── lijinyao │ │ │ ├── tab-stage1 │ │ │ │ ├── script.js │ │ │ │ └── idnex.html │ │ │ ├── tab-stage2 │ │ │ │ ├── script.js │ │ │ │ └── idnex.html │ │ │ ├── tab-stage3 │ │ │ │ ├── script.js │ │ │ │ └── idnex.html │ │ │ ├── tab-stage4 │ │ │ │ ├── script.js │ │ │ │ └── idnex.html │ │ │ └── style.css │ │ ├── scq000 │ │ │ ├── 1 │ │ │ │ ├── index.js │ │ │ │ ├── index.html │ │ │ │ └── style.css │ │ │ ├── 2 │ │ │ │ ├── style.css │ │ │ │ ├── index.js │ │ │ │ └── index.html │ │ │ ├── 3 │ │ │ │ ├── style.css │ │ │ │ ├── index.html │ │ │ │ └── index.js │ │ │ └── 4 │ │ │ │ ├── style.css │ │ │ │ ├── index.html │ │ │ │ └── index.js │ │ ├── murphywuwu │ │ │ ├── 1 │ │ │ │ ├── index.js │ │ │ │ ├── index.html │ │ │ │ └── style.css │ │ │ ├── 2 │ │ │ │ ├── index.js │ │ │ │ ├── style.css │ │ │ │ └── index.html │ │ │ ├── 3 │ │ │ │ ├── index.js │ │ │ │ ├── style.css │ │ │ │ └── index.html │ │ │ ├── 4 │ │ │ │ ├── index.js │ │ │ │ ├── style.css │ │ │ │ └── index.html │ │ │ └── 5 │ │ │ │ ├── index.js │ │ │ │ ├── style.css │ │ │ │ └── index.html │ │ ├── coolzjy │ │ │ ├── index.html │ │ │ └── style.css │ │ ├── xuexb │ │ │ └── README.md │ │ ├── limingyang2012 │ │ │ ├── 阶段一 │ │ │ │ ├── js │ │ │ │ │ └── main.js │ │ │ │ ├── index.html │ │ │ │ └── css │ │ │ │ │ └── main.css │ │ │ ├── 阶段三 │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ ├── index.html │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ ├── 阶段二 │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ ├── index.html │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ ├── 阶段五 │ │ │ │ ├── css │ │ │ │ │ └── main.css │ │ │ │ ├── index.html │ │ │ │ └── js │ │ │ │ │ └── main.js │ │ │ └── 阶段四 │ │ │ │ ├── css │ │ │ │ └── main.css │ │ │ │ ├── index.html │ │ │ │ └── js │ │ │ │ └── main.js │ │ ├── LastGun │ │ │ ├── stage-2 │ │ │ │ ├── tab.js │ │ │ │ └── tab.html │ │ │ ├── stage-3 │ │ │ │ ├── tab.js │ │ │ │ └── tab.html │ │ │ ├── stage-1 │ │ │ │ ├── tab.js │ │ │ │ └── tab-1.html │ │ │ ├── stage-4 │ │ │ │ ├── tab.js │ │ │ │ └── tab.html │ │ │ └── stage-5 │ │ │ │ ├── tab.js │ │ │ │ └── tab.html │ │ ├── ColdXu │ │ │ ├── 1.html │ │ │ ├── 2.html │ │ │ └── 3.html │ │ ├── Yeahax │ │ │ ├── 1 │ │ │ │ └── index.html │ │ │ └── 2 │ │ │ │ └── index.html │ │ ├── 52cik │ │ │ ├── 1.html │ │ │ ├── 2.html │ │ │ └── 3.html │ │ ├── whatlife │ │ │ └── 1.html │ │ ├── veena233 │ │ │ └── index1.html │ │ ├── langrren │ │ │ └── 1 │ │ │ │ └── index.html │ │ └── zmen │ │ │ └── 1.html │ ├── tab.png │ └── README.md └── dialog │ ├── dialog.png │ ├── code │ ├── fromiris │ │ ├── close.png │ │ ├── dialog.html │ │ ├── dialog.less │ │ ├── css │ │ │ └── dialog.css │ │ └── dialog.js │ ├── lijinyao │ │ ├── close.png │ │ ├── dialog-stage1 │ │ │ ├── index.html │ │ │ └── script.js │ │ ├── dialog-stage2 │ │ │ ├── index.html │ │ │ └── script.js │ │ ├── dialog-stage3 │ │ │ ├── index.html │ │ │ └── script.js │ │ ├── dialog-stage4 │ │ │ └── index.html │ │ └── style.css │ ├── xuexb │ │ ├── 1 │ │ │ └── index.html │ │ ├── mod │ │ │ ├── close.png │ │ │ ├── close@2x.png │ │ │ └── dialog.css │ │ └── README.md │ ├── scq000 │ │ ├── 1 │ │ │ ├── index.js │ │ │ ├── index.html │ │ │ └── styles.css │ │ ├── 2 │ │ │ ├── index.js │ │ │ ├── index.html │ │ │ └── styles.css │ │ ├── 3 │ │ │ ├── index.html │ │ │ ├── index.js │ │ │ └── styles.css │ │ └── 4 │ │ │ ├── index.html │ │ │ ├── styles.css │ │ │ └── index.js │ ├── newraina │ │ ├── 2 │ │ │ ├── index.html │ │ │ ├── main.js │ │ │ └── style.css │ │ ├── 3 │ │ │ ├── index.html │ │ │ ├── main.js │ │ │ └── style.css │ │ ├── 4 │ │ │ ├── index.html │ │ │ ├── style.css │ │ │ └── main.js │ │ └── 5 │ │ │ ├── index.html │ │ │ └── style.css │ ├── limingyang2012 │ │ ├── 阶段二 │ │ │ ├── index.html │ │ │ ├── js │ │ │ │ └── main.js │ │ │ └── css │ │ │ │ └── main.css │ │ ├── 阶段三 │ │ │ ├── index.html │ │ │ ├── css │ │ │ │ └── main.css │ │ │ └── js │ │ │ │ └── main.js │ │ ├── 阶段四 │ │ │ ├── index.html │ │ │ ├── css │ │ │ │ └── main.css │ │ │ └── js │ │ │ │ └── main.js │ │ └── 阶段一 │ │ │ ├── js │ │ │ └── main.js │ │ │ ├── index.html │ │ │ └── css │ │ │ └── main.css │ ├── fanplus │ │ ├── index.html │ │ └── style.css │ ├── LastGun │ │ ├── dialog-stage-1 │ │ │ ├── dialog.js │ │ │ └── dialog.html │ │ ├── dialog-stage-3 │ │ │ ├── dialog.js │ │ │ └── dialog.html │ │ ├── dialog-stage-2 │ │ │ ├── dialog.html │ │ │ └── dialog.js │ │ └── dialog-stage-4 │ │ │ ├── dialog.js │ │ │ └── dialog.html │ ├── coolzjy │ │ ├── dialog.css │ │ └── index.html │ ├── murphywuwu │ │ ├── 1 │ │ │ ├── style.css │ │ │ ├── index.html │ │ │ └── index.js │ │ ├── 2 │ │ │ ├── index.html │ │ │ ├── style.css │ │ │ └── index.js │ │ ├── 3 │ │ │ ├── style.css │ │ │ ├── index.html │ │ │ └── index.js │ │ └── 4 │ │ │ ├── style.css │ │ │ ├── index.html │ │ │ └── index.js │ ├── 52cik │ │ ├── 1.html │ │ ├── 2.html │ │ └── 3.html │ ├── ColdXu │ │ ├── 1.html │ │ └── 2.html │ └── veena233 │ │ └── index5.html │ └── README.md ├── .gitignore ├── README.md └── fork&pullrequests.md /package/tab/code/rccoder/README.md: -------------------------------------------------------------------------------- 1 | #Tab 选项卡 2 |
24 |
25 |
26 | [接受挑战](package/tab/)
27 |
28 | ## Dialog 弹出层
29 |
30 |
31 |
32 | [接受挑战](package/dialog/)
--------------------------------------------------------------------------------
/package/tab/code/limingyang2012/阶段三/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | I am content
\ 13 |
4 |
5 | ## 阶段 1
6 |
7 | 实现上图 JS 效果,CSS样式随意。弹出层要水平垂直居中在屏幕中
8 |
9 | ## 阶段 2
10 |
11 | 封装成一个 `dialog` 函数,提供如下 api :
12 |
13 | **trigger**
14 |
15 | 对话框触发元素,可传递选择器。
16 |
17 | **content**
18 |
19 | 容器的内容,可以是纯字符串、dom对象、jQuery对象、html标签字符串。
20 |
21 |
22 | ```js
23 | dialog({
24 | trigger: '#btn',
25 | content: '哈哈'
26 | })
27 | ```
28 |
29 | ```html
30 |
31 | ```
32 |
33 | 点击 Click me 弹出 **哈哈**
34 |
35 | 可通过参数指定父级DOM、触发DOM、内容DOM。
36 |
37 | ## 阶段3
38 | 可控制显示和关闭的动画效果
39 |
40 | ```js
41 | dialog({
42 | trigger: '#btn',
43 | content: '哈哈',
44 | effectShow: function ($element) {
45 | // 淡入显示
46 | $element.fadeIn(500)
47 | },
48 | effectHide: function ($element) {
49 | // 淡出显示
50 | $element.fadeOut(500)
51 | }
52 | })
53 | ```
54 |
55 | ## 阶段 4
56 | 添加点击关闭时触发的函数,并支持使用键盘 ESC 键关闭弹出层
57 |
58 | ```js
59 | dialog({
60 | trigger: '#btn',
61 | content: '哈哈',
62 | onClose: function (element) {
63 | /*
64 | element 弹出层 DOM 元素
65 | */
66 | }
67 | })
68 | ```
69 | ## 完成挑战
70 |
71 | 添加关闭事件
72 |
73 | 还有更多 API 可以实现,但以上四个阶段已经足够提高你 Dialog 类型组件开发的经验。
74 |
75 | 如果你将以上所有阶段都完成了, Dialog 的挑战就结束了。但我们希望你继续完善这个组件增加更多的 API。
76 |
--------------------------------------------------------------------------------
/package/tab/code/limingyang2012/阶段五/js/main.js:
--------------------------------------------------------------------------------
1 |
2 | function tab(json){
3 | var newtab = document.querySelector(json.element);
4 | var triggers = document.querySelectorAll(json.triggers);
5 | var contents = document.querySelectorAll(json.contents);
6 | var index = json.activeIndex ? json.activeIndex : 0;
7 | var triggerType = json.triggerType ? "onmouseover" : "onclick";
8 | var len = triggers.length;
9 | var active = "triggers active";
10 | var noActive = "triggers";
11 |
12 | triggers[index].className = active;
13 | contents[index].style.display = "block";
14 |
15 | for(var i=0;i
16 |
17 | var dialog1 = dialog({trigger:"#btn", zIndex:10, title:"D1",
18 | content:"这是第一个对话框。这个对话框会覆盖第二个对话框,因为这个对话框设置了 zIndex 属性",
19 | effectShow:function(e){$(e).show("fast")},
20 | effectHide:function(e){$(e).hide("fast")},
21 | onClose:function(e){console.log(e.innerText)}});
22 | var dialog2 = dialog({trigger:"#btn2", title:"D2", content:"这是第二个对话框,这个对话框没有弹出关闭效果!这个对话框会被第一个对话框覆盖。",
23 | onClose:function(e){console.log("dialog 2 is closed")}});
24 |
25 |
26 | 64 | learn-js: 一个 JavaScript 互助学习的项目。接受组件开发的挑战,提交代码让他人评论你的代码以提高。 65 |
66 | 67 | -------------------------------------------------------------------------------- /package/dialog/code/murphywuwu/3/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dialog-3 js file 3 | * @author murphywuwu 4 | */ 5 | 6 | !(function (global) { 7 | /** 8 | * title : string 9 | * content: string 10 | * trigger: string 11 | */ 12 | 13 | function Dialog (opts) { 14 | this.init(opts); 15 | } 16 | 17 | Dialog.prototype = { 18 | init: function (opts) { 19 | this._buildHtml(opts); 20 | this.bindEvent(opts); 21 | }, 22 | _buildHtml: function (opts) { 23 | 24 | // 构造HTML结构 25 | var html = '73 | learn-js: 一个 JavaScript 互助学习的项目。接受组件开发的挑战,提交代码让他人评论你的代码以提高。 74 |
75 | 76 | -------------------------------------------------------------------------------- /package/tab/code/593273894/1/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
4 |
5 | ## 阶段 1
6 |
7 | 实现上图 JS 效果,CSS样式随意。
8 |
9 |
10 | ## 阶段 2
11 |
12 | 封装成一个 `tab` 函数,提供如下 api :
13 |
14 | ```js
15 | tab({
16 | element: '.newtab',
17 | triggers: '.triggers',
18 | contents: '.contents'
19 | })
20 | ```
21 |
22 | ```html
23 | 75 | learn-js: 一个 JavaScript 互助学习的项目。接受组件开发的挑战,提交代码让他人评论你的代码以提高。 76 |
77 | 78 | -------------------------------------------------------------------------------- /package/tab/code/593273894/2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |78 | learn-js: 一个 JavaScript 互助学习的项目。接受组件开发的挑战,提交代码让他人评论你的代码以提高。 79 |
80 | 81 | -------------------------------------------------------------------------------- /package/tab/code/ColdXu/3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |66 | 尘劳回脱事非常,紧把绳头做一场。 67 | 不经一番寒彻骨,那得梅花扑鼻香. 68 |
69 |59 | learn-js: 一个 JavaScript 互助学习的项目。接受组件开发的挑战,提交代码让他人评论你的代码以提高。 60 |
61 | 81 | 82 | -------------------------------------------------------------------------------- /package/tab/code/rccoder/tab1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |