Skip to content

Commit fd57b2b

Browse files
committed
新例子增加标识
1 parent 37dfa71 commit fd57b2b

File tree

5 files changed

+161
-41
lines changed

5 files changed

+161
-41
lines changed

examples/js/example.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.*/
22
$(document).ready(function () {
3-
window.initI18N(function(){
4-
initPage();
5-
bindEvents();
6-
//懒加载
7-
var timeout = setTimeout(function () {
8-
$("img.chart-thumb").lazyload();
9-
}, 1000);
10-
});
3+
window.initI18N(function () {
4+
initPage();
5+
bindEvents();
6+
//懒加载
7+
var timeout = setTimeout(function () {
8+
$("img.chart-thumb").lazyload();
9+
}, 1000);
10+
11+
});
1112
});
1213

1314

@@ -54,7 +55,7 @@ function createGalleryItem(id, config) {
5455
if (title) {
5556
createGalleryItemTitle(id, title).appendTo(categoryLi);
5657
}
57-
58+
5859
if (config.content) {
5960
createSubGalleryItem(config.content, id).appendTo(categoryLi);
6061
}
@@ -106,14 +107,18 @@ function createGalleryChart(example) {
106107
defaultThumb = "../img/thumb.png",
107108
title = utils.getLocalPairs(example, "name"),
108109
href = example.fileName ? example.fileName : "",
109-
thumbnail = example.thumbnail ? thumbLocation + "/img/" + example.thumbnail : "";
110+
thumbnail = example.thumbnail ? thumbLocation + "/img/" + example.thumbnail : "",
111+
version = example.version;
110112

111113
var chartDiv = $("<div class='col-xlg-2 col-lg-3 col-md-4 col-sm-6 col-xs-12'></div>");
112114
var chart = $("<div class='chart'></div>");
113115
var link = $("<a class='chart-link' target='_blank' href='" + target + "#" + href + "'></a>");
114116
var chartTitle = $("<h5 class='chart-title'>" + title + "</h5>");
117+
var newTip = $('<svg class="new-example" style="float: right;width:8px !important;height:8px;"><circle cx="4" cy="4" r="4" fill="#C70022"></circle></svg>');
115118
var thumb = $("<img class='chart-thumb' src='" + defaultThumb + "' data-original='" + thumbnail + "' style='display: inline'>");
116-
119+
if (window.version === version) {
120+
newTip.appendTo(chartTitle);
121+
}
117122
chartTitle.appendTo(link);
118123
thumb.appendTo(link);
119124
link.appendTo(chart);

examples/js/sidebar.js

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ function sidebarScrollFix() {
4848
var activeListOffsetBottom = Math.abs($(window).height() - visibleOffsetTop - $(this).height());
4949
var requireActiveListHeight = $activeList.height();
5050
if (activeListOffsetBottom < requireActiveListHeight) {
51-
$activeList.css({"height": requireActiveListHeight});
51+
$activeList.css({
52+
"height": requireActiveListHeight
53+
});
5254
//滚动条样式
5355
$activeList.addClass('scroll-list');
5456
}
@@ -60,14 +62,18 @@ function sidebarScrollFix() {
6062
//滚动条
6163
$(this).children('ul').removeClass('scroll-list');
6264
//恢复原来的高度
63-
$(this).children('ul').css({"height": "auto"});
65+
$(this).children('ul').css({
66+
"height": "auto"
67+
});
6468
});
6569
$('.main-sidebar').on('scroll', function (evt) {
6670
evt.stopPropagation();
6771
});
6872

6973
$(window).on('resize', function () {
70-
$('.sidebar-menu').css({"height": "100%"})
74+
$('.sidebar-menu').css({
75+
"height": "100%"
76+
})
7177
})
7278
}
7379

@@ -81,13 +87,34 @@ function createSideBarMenuItem(id, config, containAll) {
8187
if (window.isLocal && config.localIgnore) {
8288
return;
8389
}
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+
84111
var title = utils.getLocalPairs(config, "name");
85112
var li = $("<li id='iclient_" + id + "' class='treeview ' title='" + title + "'></li>");
86113
if (config.content) {
87-
createSideBarMenuTitle(id, title, true,config.version).appendTo(li);
114+
createSideBarMenuTitle(id, title, true, config.hasNewExamples).appendTo(li);
88115
createSideBarSecondMenu(config.content, id).appendTo(li);
89116
} else {
90-
createSideBarMenuTitle(id, title, false,config.version).appendTo(li);
117+
createSideBarMenuTitle(id, title, false, config.hasNewExamples).appendTo(li);
91118
}
92119
return li;
93120
}
@@ -100,13 +127,11 @@ function createSideBarSecondMenu(config, name) {
100127
var title = utils.getLocalPairs(configItem, "name") || "【empty title】";
101128
var li = $("<li class='menuTitle ' id='" + key + "' title='" + title + "'></li>");
102129
li.appendTo(ul);
103-
var version = configItem.version;
104-
105130
if (containExample && configItem.content) {
106-
createSideBarMenuSecondTitle(name + '-' + key, title, true,version).appendTo(li);
131+
createSideBarMenuSecondTitle(name + '-' + key, title, true, configItem.hasNewExamples).appendTo(li);
107132
createSideBarThirdMenu(configItem.content).appendTo(li);
108133
} else {
109-
createSideBarMenuSecondTitle(name + '-' + key, title, false,version).appendTo(li);
134+
createSideBarMenuSecondTitle(name + '-' + key, title, false, configItem.hasNewExamples).appendTo(li);
110135
}
111136
}
112137
return ul;
@@ -121,33 +146,34 @@ function createSideBarThirdMenu(examples) {
121146
if (window.isLocal && example.localIgnore) {
122147
continue;
123148
}
124-
var title = utils.getLocalPairs(example, "name")|| "【empty title】";
149+
var title = utils.getLocalPairs(example, "name") || "【empty title】";
125150

126151
var li = $("<li class='menuTitle' id='" + example.fileName + "' title='" + title + "'></li>");
127152
li.appendTo(ul);
128153

129154
if (example.fileName && title) {
130-
createSideBarMenuThirdTitle(example.fileName, title, false).appendTo(li);
155+
createSideBarMenuThirdTitle(example.fileName, title, false,example.version).appendTo(li);
131156
}
132157
}
133158
return ul;
134159
}
135160

136161

137-
function createSideBarMenuTitle(id, title, collapse,version) {
162+
function createSideBarMenuTitle(id, title, collapse, hasNewExamples) {
138163
id = id || "";
139-
var icon = "", iconName = sideBarIconConfig[id];
164+
var icon = "",
165+
iconName = sideBarIconConfig[id];
140166
if (iconName) {
141167
icon = "<i class='fa " + iconName + " iconName'></i>"
142168
}
143169

144170
var div = $("<a href='#" + id + "'>" + icon + "</a>");
145171
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>";
149175
}
150-
var firstMenuTitle = $("<span class='firstMenuTitle'>" + title + newIcon +"</span>");
176+
var firstMenuTitle = $("<span class='firstMenuTitle'>" + title + newIcon + "</span>");
151177
titleBar.append(firstMenuTitle);
152178
if (collapse) {
153179
titleBar.append(createCollapsedIcon());
@@ -157,15 +183,16 @@ function createSideBarMenuTitle(id, title, collapse,version) {
157183
}
158184

159185

160-
function createSideBarMenuSecondTitle(id, title, collapse , version) {
186+
function createSideBarMenuSecondTitle(id, title, collapse, hasNewExamples) {
161187
id = id || "";
162-
var icon = "", iconName = sideBarIconConfig[id];
188+
var icon = "",
189+
iconName = sideBarIconConfig[id];
163190
if (iconName) {
164191
icon = "<i class='fa " + iconName + "'></i>"
165192
}
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>";
169196
}
170197
var div = $(
171198
"<a href='#" + id + "' id='" + id + '-' + id + "'>" + icon +
@@ -178,16 +205,21 @@ function createSideBarMenuSecondTitle(id, title, collapse , version) {
178205
return div;
179206
}
180207

181-
function createSideBarMenuThirdTitle(id, title, collapse) {
208+
function createSideBarMenuThirdTitle(id, title, collapse,version) {
182209
id = id || "";
183-
var icon = "", iconName = sideBarIconConfig[id];
210+
var icon = "",
211+
iconName = sideBarIconConfig[id];
184212
if (iconName) {
185213
icon = "<i class='fa " + iconName + "'></i>"
186214
}
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+
}
187219

188220
var div = $(
189221
"<a href='#" + id + "' id='" + id + "'>" + icon +
190-
"<span class='thirdMenuTitle'>" + title + "</span>" +
222+
"<span class='thirdMenuTitle'>" + title + "</span>" +newIcon+
191223
"</a>");
192224
if (collapse) {
193225
div.append(createCollapsedIcon());

0 commit comments

Comments
 (0)