@@ -48,7 +48,9 @@ function sidebarScrollFix() {
48
48
var activeListOffsetBottom = Math . abs ( $ ( window ) . height ( ) - visibleOffsetTop - $ ( this ) . height ( ) ) ;
49
49
var requireActiveListHeight = $activeList . height ( ) ;
50
50
if ( activeListOffsetBottom < requireActiveListHeight ) {
51
- $activeList . css ( { "height" : requireActiveListHeight } ) ;
51
+ $activeList . css ( {
52
+ "height" : requireActiveListHeight
53
+ } ) ;
52
54
//滚动条样式
53
55
$activeList . addClass ( 'scroll-list' ) ;
54
56
}
@@ -60,14 +62,18 @@ function sidebarScrollFix() {
60
62
//滚动条
61
63
$ ( this ) . children ( 'ul' ) . removeClass ( 'scroll-list' ) ;
62
64
//恢复原来的高度
63
- $ ( this ) . children ( 'ul' ) . css ( { "height" : "auto" } ) ;
65
+ $ ( this ) . children ( 'ul' ) . css ( {
66
+ "height" : "auto"
67
+ } ) ;
64
68
} ) ;
65
69
$ ( '.main-sidebar' ) . on ( 'scroll' , function ( evt ) {
66
70
evt . stopPropagation ( ) ;
67
71
} ) ;
68
72
69
73
$ ( window ) . on ( 'resize' , function ( ) {
70
- $ ( '.sidebar-menu' ) . css ( { "height" : "100%" } )
74
+ $ ( '.sidebar-menu' ) . css ( {
75
+ "height" : "100%"
76
+ } )
71
77
} )
72
78
}
73
79
@@ -81,13 +87,34 @@ function createSideBarMenuItem(id, config, containAll) {
81
87
if ( window . isLocal && config . localIgnore ) {
82
88
return ;
83
89
}
90
+ if ( config . content ) {
91
+ var hasNewExamples = false ;
92
+ a: for ( var key in config . content ) {
93
+ var examples = config . content [ key ] . content ;
94
+ if ( examples ) {
95
+ for ( let index = 0 ; index < examples . length ; index ++ ) {
96
+ const element = examples [ index ] ;
97
+ if ( element . version === window . version ) {
98
+ config . content [ key ] . hasNewExamples = true ;
99
+ hasNewExamples = true ;
100
+ continue a;
101
+ }
102
+ }
103
+ }
104
+ }
105
+ config . hasNewExamples = hasNewExamples ;
106
+ }
107
+
108
+
109
+
110
+
84
111
var title = utils . getLocalPairs ( config , "name" ) ;
85
112
var li = $ ( "<li id='iclient_" + id + "' class='treeview ' title='" + title + "'></li>" ) ;
86
113
if ( config . content ) {
87
- createSideBarMenuTitle ( id , title , true , config . version ) . appendTo ( li ) ;
114
+ createSideBarMenuTitle ( id , title , true , config . hasNewExamples ) . appendTo ( li ) ;
88
115
createSideBarSecondMenu ( config . content , id ) . appendTo ( li ) ;
89
116
} else {
90
- createSideBarMenuTitle ( id , title , false , config . version ) . appendTo ( li ) ;
117
+ createSideBarMenuTitle ( id , title , false , config . hasNewExamples ) . appendTo ( li ) ;
91
118
}
92
119
return li ;
93
120
}
@@ -100,13 +127,11 @@ function createSideBarSecondMenu(config, name) {
100
127
var title = utils . getLocalPairs ( configItem , "name" ) || "【empty title】" ;
101
128
var li = $ ( "<li class='menuTitle ' id='" + key + "' title='" + title + "'></li>" ) ;
102
129
li . appendTo ( ul ) ;
103
- var version = configItem . version ;
104
-
105
130
if ( containExample && configItem . content ) {
106
- createSideBarMenuSecondTitle ( name + '-' + key , title , true , version ) . appendTo ( li ) ;
131
+ createSideBarMenuSecondTitle ( name + '-' + key , title , true , configItem . hasNewExamples ) . appendTo ( li ) ;
107
132
createSideBarThirdMenu ( configItem . content ) . appendTo ( li ) ;
108
133
} else {
109
- createSideBarMenuSecondTitle ( name + '-' + key , title , false , version ) . appendTo ( li ) ;
134
+ createSideBarMenuSecondTitle ( name + '-' + key , title , false , configItem . hasNewExamples ) . appendTo ( li ) ;
110
135
}
111
136
}
112
137
return ul ;
@@ -121,33 +146,34 @@ function createSideBarThirdMenu(examples) {
121
146
if ( window . isLocal && example . localIgnore ) {
122
147
continue ;
123
148
}
124
- var title = utils . getLocalPairs ( example , "name" ) || "【empty title】" ;
149
+ var title = utils . getLocalPairs ( example , "name" ) || "【empty title】" ;
125
150
126
151
var li = $ ( "<li class='menuTitle' id='" + example . fileName + "' title='" + title + "'></li>" ) ;
127
152
li . appendTo ( ul ) ;
128
153
129
154
if ( example . fileName && title ) {
130
- createSideBarMenuThirdTitle ( example . fileName , title , false ) . appendTo ( li ) ;
155
+ createSideBarMenuThirdTitle ( example . fileName , title , false , example . version ) . appendTo ( li ) ;
131
156
}
132
157
}
133
158
return ul ;
134
159
}
135
160
136
161
137
- function createSideBarMenuTitle ( id , title , collapse , version ) {
162
+ function createSideBarMenuTitle ( id , title , collapse , hasNewExamples ) {
138
163
id = id || "" ;
139
- var icon = "" , iconName = sideBarIconConfig [ id ] ;
164
+ var icon = "" ,
165
+ iconName = sideBarIconConfig [ id ] ;
140
166
if ( iconName ) {
141
167
icon = "<i class='fa " + iconName + " iconName'></i>"
142
168
}
143
169
144
170
var div = $ ( "<a href='#" + id + "'>" + icon + "</a>" ) ;
145
171
var titleBar = $ ( "<span class='sidebar-title-bar'></span>" ) ;
146
- var newIcon = "" ;
147
- if ( window . version === version ) {
148
- newIcon = "<svg style='width:16px;height:16px;padding-left:5px'><circle cx='3' cy='3' r='3' fill='#C70022'></circle>/svg>" ;
172
+ var newIcon = "" ;
173
+ if ( hasNewExamples ) {
174
+ newIcon = "<svg style='width:16px;height:16px;padding-left:5px'><circle cx='3' cy='3' r='3' fill='#C70022'></circle>/svg>" ;
149
175
}
150
- var firstMenuTitle = $ ( "<span class='firstMenuTitle'>" + title + newIcon + "</span>" ) ;
176
+ var firstMenuTitle = $ ( "<span class='firstMenuTitle'>" + title + newIcon + "</span>" ) ;
151
177
titleBar . append ( firstMenuTitle ) ;
152
178
if ( collapse ) {
153
179
titleBar . append ( createCollapsedIcon ( ) ) ;
@@ -157,15 +183,16 @@ function createSideBarMenuTitle(id, title, collapse,version) {
157
183
}
158
184
159
185
160
- function createSideBarMenuSecondTitle ( id , title , collapse , version ) {
186
+ function createSideBarMenuSecondTitle ( id , title , collapse , hasNewExamples ) {
161
187
id = id || "" ;
162
- var icon = "" , iconName = sideBarIconConfig [ id ] ;
188
+ var icon = "" ,
189
+ iconName = sideBarIconConfig [ id ] ;
163
190
if ( iconName ) {
164
191
icon = "<i class='fa " + iconName + "'></i>"
165
192
}
166
- var newIcon = "" ;
167
- if ( window . version === version ) {
168
- newIcon = "<svg style='width:16px;height:16px;padding-left:5px'><circle cx='3' cy='3' r='3' fill='#C70022'></circle>/svg>" ;
193
+ var newIcon = "" ;
194
+ if ( hasNewExamples ) {
195
+ newIcon = "<svg style='width:16px;height:16px;padding-left:5px'><circle cx='3' cy='3' r='3' fill='#C70022'></circle>/svg>" ;
169
196
}
170
197
var div = $ (
171
198
"<a href='#" + id + "' id='" + id + '-' + id + "'>" + icon +
@@ -178,16 +205,21 @@ function createSideBarMenuSecondTitle(id, title, collapse , version) {
178
205
return div ;
179
206
}
180
207
181
- function createSideBarMenuThirdTitle ( id , title , collapse ) {
208
+ function createSideBarMenuThirdTitle ( id , title , collapse , version ) {
182
209
id = id || "" ;
183
- var icon = "" , iconName = sideBarIconConfig [ id ] ;
210
+ var icon = "" ,
211
+ iconName = sideBarIconConfig [ id ] ;
184
212
if ( iconName ) {
185
213
icon = "<i class='fa " + iconName + "'></i>"
186
214
}
215
+ var newIcon = "" ;
216
+ if ( window . version === version ) {
217
+ newIcon = "<svg style='width:16px;height:16px;padding-left:5px'><circle cx='3' cy='3' r='3' fill='#C70022'></circle>/svg>" ;
218
+ }
187
219
188
220
var div = $ (
189
221
"<a href='#" + id + "' id='" + id + "'>" + icon +
190
- "<span class='thirdMenuTitle'>" + title + "</span>" +
222
+ "<span class='thirdMenuTitle'>" + title + "</span>" + newIcon +
191
223
"</a>" ) ;
192
224
if ( collapse ) {
193
225
div . append ( createCollapsedIcon ( ) ) ;
0 commit comments