File tree 11 files changed +40
-39
lines changed
11 files changed +40
-39
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,12 @@ wechat:
17
17
share_desc : 麻麻说:写代码一定要优雅
18
18
---
19
19
20
- <!-- more -->
21
-
22
- # Javascript 中的装饰器
23
-
24
20
## 前言
25
21
26
22
在 ES6 中增加了对类对象的相关定义和操作(比如 ` class ` 和 ` extends ` ),这就使得我们在多个不同类之间共享或者扩展一些方法或者行为的时候,变得并不是那么优雅。这个时候,我们就需要一种更优雅的方法来帮助我们完成这些事情。
27
23
24
+ <!-- more -->
25
+
28
26
## Python 中的装饰器
29
27
30
28
decorators 即 装饰器,这一特性的提出来源于 python 之类的语言,如果你熟悉 python 的话,对它一定不会陌生。那么我们先来看一下 python 里的装饰器是什么样子的吧:
Original file line number Diff line number Diff line change 13
13
{{ header_menu('main-nav') }}
14
14
</ul>
15
15
</nav>
16
- <div class="mod-search">
16
+ <div class="mod-search" id="J_search" >
17
17
<a class="fa fa-search mod-search-ico" id="J_searchTrigger" title="{{ __('menu.search') }}"></a>
18
18
<form id="J_searchForm" method="get" class="mod-search-form" action="/search/">
19
19
<input type="text" name="query" class="mod-search-ipt" id="J_searchInput" placeholder="{{ __('menu.search') }}" />
Original file line number Diff line number Diff line change 1
1
<!-- Post -->
2
2
<article class="post">
3
+ <div class="post-cover"><img src="{{ post_img( post.cover|default(theme.post.cover) ) }}" alt="{{ post.title }}" /></div>
3
4
<header class="post-hd">
4
5
{{seachData()}}
5
- <h2 class="post-tit">{{ post.title }}</h2 >
6
+ <h1 class="post-tit">{{ post.title }}</h1 >
6
7
<div class="post-meta">
7
8
by <a target="_blank" href="https://github.com/{{ author.github_name }}" class="post-author">{{ author.nick|default(author.github_name) }}</a> on <span>{{ date(post.date) }}</span>
8
9
</div>
11
12
{% endif %}
12
13
<span style="display:none;" id="busuanzi_value_page_pv"></span>
13
14
</header>
14
-
15
- <div class="post-cover"><img src="{{ post_img( post.cover|default(theme.post.cover) ) }}" alt="{{ post.title }}" /></div>
16
-
17
15
<div class="post-content">
18
16
{{ page_anchor(post.content) }}
19
17
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ the-transition() {
5
5
}
6
6
7
7
mobile () {
8
- @media (max-width : 989 px ) {
8
+ @media (max-width : 1023 px ) {
9
9
{ block }
10
10
}
11
11
}
@@ -17,7 +17,7 @@ mobile() {
17
17
// }
18
18
19
19
desktop () {
20
- @media (min-width : 990 px ) and (max-width : 1189 px ) {
20
+ @media (min-width : 1014 px ) and (max-width : 1279 px ) {
21
21
{ block }
22
22
}
23
23
}
Original file line number Diff line number Diff line change 2
2
color-default = #64 64 64
3
3
color-accent = #1a bc 9c
4
4
color-grey = #9 9 9
5
+ color-grey-lite = #e e e
5
6
color-border = #d d d
6
7
color-link = #3 3 3
7
8
color-dark = #0 0 0
@@ -16,7 +17,6 @@ color-facebook = #3b5998
16
17
color-pinterest = #cb 20 27
17
18
color-google = #dd 4b 39
18
19
$color-theme = #61 90 e8
19
- $gainsboro = #e e e
20
20
color-primary = $color-theme
21
21
22
22
bg-primary = $color-theme
Original file line number Diff line number Diff line change 66
66
width : 30px
67
67
line-height : 30px
68
68
text-align : center
69
+ color : color-default
70
+ & .active
71
+ .mod-search-ico
72
+ background : color-grey-lite
69
73
& -form
70
74
overflow :hidden
71
75
opacity : 0
82
86
box-sizing : border-box
83
87
border : 1px solid #e e e
84
88
background-color : #fc fc fc
89
+ outline : none
85
90
& :: -webkit- input -placeholder
86
91
font-size : 14px
87
92
88
93
+ mobile () {
89
94
padding : 0 15px
95
+ box-shadow : 0 1px 2px rgba (0 ,0 ,0 ,.1 )
90
96
& -main {
91
97
position : absolute
92
98
top : 60px
Original file line number Diff line number Diff line change 17
17
padding-top : 20px
18
18
+ mobile () {
19
19
// background: #eaeaea
20
+ padding-top : 1px
20
21
}
21
22
22
23
.mod-main
23
24
float :left
24
25
width : 930px
25
26
margin-right : 20px
26
- + mobile () {
27
- float : none
28
- margin-right : 0
29
- width : 100%
30
- }
31
27
+desk to p-large() {
32
28
width : 1230px
33
29
}
34
30
+ desktop () {
35
31
width : 730px
36
32
}
37
-
38
- .mod-side
39
- float : left
40
- width : 240px
41
- box-sizing : border-box
42
- padding : 20px 15px
43
33
+ mobile () {
44
- border-top : 1px solid #e e e
45
34
float : none
35
+ margin-right : 0
46
36
width : 100%
47
37
}
48
38
Original file line number Diff line number Diff line change 1
1
.mod-side
2
2
background : #f f f
3
+ float : left
4
+ width : 240px
5
+ box-sizing : border-box
6
+ padding : 20px 0 20px 15px
3
7
& -sec
4
8
margin-bottom : 30px
5
9
& :last-child
22
26
& -bd
23
27
padding : 10px 15px
24
28
+ mobile () {
29
+ float : none
30
+ width : 100%
25
31
margin-top : 20px
26
32
border-top : 1px solid #d d d
27
33
}
52
58
max-width : 224px
53
59
margin : 0 auto 10px
54
60
& -slogan
55
- text-align : center
56
-
57
-
58
-
59
-
61
+ text-align : center
Original file line number Diff line number Diff line change 51
51
a
52
52
color : $color-theme
53
53
font-size : 14px
54
- box-shadow : 0 1px 2px rgba (0 ,0 ,0 ,0.2 )
54
+ box-shadow : 0 1px 2px rgba (0 ,0 ,0 ,0.1 )
55
55
56
56
Original file line number Diff line number Diff line change 6
6
word-wrap : break-word
7
7
& -hd
8
8
padding : 20px 0
9
- h2
10
- margin-bottom : 5px
11
- color : #3 3 3
12
- font-size : 28px
13
- font-weight : 300
9
+ & -tit
10
+ margin-bottom : 5px
11
+ color : #3 3 3
12
+ // font-size: 28px
13
+ font-weight : 300
14
14
& -meta
15
15
font-size : 12px
16
16
overflow : hidden
40
40
top : 0
41
41
42
42
& -cover
43
- margin : 0 0 20px
43
+ padding-top : 20px
44
44
img
45
45
display : block
46
+ +mobile ()
47
+ width : 100%
48
+ +mobile ()
49
+ padding-top : 0
46
50
47
51
& -revision
48
52
font-size : 12px
71
75
border-bottom : none
72
76
73
77
& -content
74
- padding : 20px 0
78
+ padding : 0 0 20px 0
75
79
& a
76
80
vertical-align : top
77
81
& img
Original file line number Diff line number Diff line change 27
27
28
28
var search = {
29
29
init : function ( ) {
30
+ this . $el = $ ( '#J_search' ) ;
30
31
this . $form = $ ( '#J_searchForm' ) ;
31
32
this . $input = $ ( '#J_searchInput' ) ;
32
33
this . $trigger = $ ( '#J_searchTrigger' ) ;
41
42
} ) ;
42
43
43
44
this . $trigger . on ( 'click' , function ( e ) {
44
- var isShowed = $ ( this ) . data ( 'show' ) ;
45
+ var $this = $ ( this ) ,
46
+ isShowed = $ ( this ) . data ( 'show' ) ;
45
47
if ( ! isShowed ) {
46
48
self . $input . focus ( ) ;
47
49
}
48
50
self . $form . toggleClass ( 'show' ) ;
49
- $ ( this ) . data ( 'show' , ! isShowed ) ;
51
+ self . $el . toggleClass ( 'active' ) ;
52
+ $this . data ( 'show' , ! isShowed ) ;
50
53
} ) ;
51
54
}
52
55
} ;
You can’t perform that action at this time.
0 commit comments