Skip to content

Commit 3e7fb71

Browse files
committed
Release v1.2.9
1 parent 13a179c commit 3e7fb71

File tree

12 files changed

+407
-400
lines changed

12 files changed

+407
-400
lines changed

docs/v1.1/Docs/Customization/config.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ window.cnblogsConfig = {
215215
}
216216
```
217217
218-
日/夜间模式配置。
218+
日/夜间模式配置。页面使用日/夜间模式优先级:用户设置 > 自动切换 > 默认。
219219
220220
```javascript
221221
window.cnblogsConfig = {
@@ -669,6 +669,30 @@ window.cnblogsConfig = {
669669
}
670670
```
671671
672+
### essayCode - 代码框统一样式设置
673+
674+
?> 版本 >= v1.2.9
675+
676+
* 类型:```Object```
677+
* 默认值:
678+
679+
```json
680+
{
681+
fontFamily: "'Ubuntu Mono',monospace", // 代码框字体
682+
fontSize: "14px" // 代码框字体大小
683+
}
684+
```
685+
686+
代码框统一样式设置,目前只有字体设置,看需求后续可能会增加配置项。
687+
688+
```javascript
689+
window.cnblogsConfig = {
690+
essayCode: {
691+
fontSize: "16px",
692+
},
693+
}
694+
```
695+
672696
### 使用博客园默认代码样式
673697
674698
#### essayCodeHighlightingType
@@ -866,7 +890,7 @@ window.cnblogsConfig = {
866890
867891
* 类型:```Boolean```
868892
* 相关文档:[版本映射](https://bndong.github.io/Cnblogs-Theme-SimpleMemory/v1.1/#/Docs/Guide/versionMapping)
869-
* 默认值:```"false"```
893+
* 默认值:```false```
870894
871895
是否开启版本映射,默认关闭。
872896

docs/v1.1/Docs/GettingStarted/install.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ CSS代码位置:```/src/style/base.min.css``` 拷贝此文件代码至页面
7171
```html
7272
<script type="text/javascript">
7373
window.cnblogsConfig = {
74-
GhVersions : 'v1.2.8', // 版本
74+
GhVersions : 'v1.2.9', // 版本
7575
blogUser : "userName", // 用户名
7676
blogAvatar : "https://xxxx.png", // 用户头像
7777
blogStartDate : "2016-11-17", // 入园时间,年-月-日。入园时间查看方法:鼠标停留园龄时间上,会显示入园时间
7878
}
7979
</script>
80-
<script src="https://cdn.jsdelivr.net/gh/BNDong/[email protected].8/src/script/simpleMemory.min.js"></script>
80+
<script src="https://cdn.jsdelivr.net/gh/BNDong/[email protected].9/src/script/simpleMemory.min.js"></script>
8181
```
8282

8383
!> 注意:引入的文件 simpleMemory.min.js 版本需要与配置 window.cnblogsConfig.GhVersions 一致!

docs/v1.1/Docs/changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## 2020.04.06 - v1.2.9
2+
* 增加夜间模式样式适配
3+
* 现在夜间模式可以保存用户选择的状态了(4小时)
4+
* 加快顶部底部跳转的速度
5+
* 调整了文章标题样式结构
6+
* 现在点击文章目录不会更改页面 URL 了
7+
* 代码字体配置:```essayCode```
8+
* 新的评论样式
9+
* 更新基础 css 文件
10+
* 修复了 v1.2.8 版本配置代码高度限制不生效的问题
11+
112
## 2020.03.24 - v1.2.8
213
* 统一代码框、行内代码字体
314
* 统一代码框圆角大小、字体大小

src/script/articleTitle.js

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
$(document).ready(function () {
22
const cparent = 'cnblogs_post_body',
3-
s = $('#' + cparent);
3+
s = $('#' + cparent),
4+
tools = new myTools;
45

56
if (s.length === 0) return;
67
const h = s.find(':header');
@@ -28,7 +29,8 @@ $(document).ready(function () {
2829
}
2930

3031
function setTh1(th1) {
31-
var th1Text = HTMLEncode(th1.text());
32+
th1.attr('tid', 'tid-' + tools.randomString(6));
33+
var th1Text = tools.HTMLEncode(th1.text());
3234

3335
if (!th1set) th1set = true;
3436

@@ -56,8 +58,8 @@ $(document).ready(function () {
5658
}
5759

5860
function setTh2(th2, index) {
59-
60-
var th2Text = HTMLEncode(th2.text());
61+
th2.attr('tid', 'tid-' + tools.randomString(6));
62+
var th2Text = tools.HTMLEncode(th2.text());
6163

6264
th2.wrap('<span title-type="h2" class="header__span"></span>');
6365
th2.text('');
@@ -99,15 +101,4 @@ $(document).ready(function () {
99101
}
100102
) ;
101103
}
102-
103-
/**
104-
* @return {string}
105-
*/
106-
function HTMLEncode(html) {
107-
var temp = document.createElement("div");
108-
(temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
109-
var output = temp.innerHTML;
110-
temp = null;
111-
return output;
112-
}
113104
});

src/script/base.js

Lines changed: 57 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ function Base() {
311311
if (ac === 'down') {
312312
var docHeight = $(document).height();
313313
var windowHeight = $(window).height();
314-
tools.actScroll(docHeight - windowHeight, 2000)
314+
tools.actScroll(docHeight - windowHeight, 900)
315315
} else {
316-
tools.actScroll(0, 2000)
316+
tools.actScroll(0, 900)
317317
}
318318
}
319319
}
@@ -410,12 +410,21 @@ function Base() {
410410
* 日/夜间模式控制
411411
*/
412412
this.setDayNightControl = function () {
413-
var h = parseInt(new Date().getHours()),head = $('head'),
414-
daySwitch = window.cnblogsConfig.switchDayNight.auto.enable ?
415-
(h >= window.cnblogsConfig.switchDayNight.auto.nightHour ? '' :
416-
(h >= window.cnblogsConfig.switchDayNight.auto.dayHour ? 'daySwitch' : '')
417-
) : 'daySwitch',
418-
html = '<div id="dayNightSwitch" class="generalWrapper">' +
413+
var h = parseInt(new Date().getHours()),head = $('head'), cookieKey = 'cnblogs_config_isNight', exp = 4 * 3600, daySwitch;
414+
415+
switch (tools.getCookie(cookieKey)) {
416+
case 'day':
417+
daySwitch = 'daySwitch'; break;
418+
case 'night':
419+
daySwitch = ''; break;
420+
default:
421+
daySwitch = window.cnblogsConfig.switchDayNight.auto.enable ?
422+
(h >= window.cnblogsConfig.switchDayNight.auto.nightHour ? '' :
423+
(h >= window.cnblogsConfig.switchDayNight.auto.dayHour ? 'daySwitch' : '')
424+
) : 'daySwitch'; break;
425+
}
426+
427+
var html = '<div id="dayNightSwitch" class="generalWrapper">' +
419428
' <div class="onOff '+ daySwitch +'">' +
420429
' <div class="star star1"></div>' +
421430
' <div class="star star2"></div>' +
@@ -437,10 +446,12 @@ function Base() {
437446
if (!daySwitch) head.append('<link type="text/css" id="baseDarkCss" rel="stylesheet" href="'+getJsDelivrUrl('base.dark.css')+'">');
438447

439448
$('#dayNightSwitch .onOff').click(function () {
440-
if ($(this).hasClass('daySwitch')) {
449+
if ($(this).hasClass('daySwitch')) { // 夜间
450+
tools.setCookie(cookieKey, 'night', exp);
441451
$(this).removeClass('daySwitch');
442452
head.append('<link type="text/css" id="baseDarkCss" rel="stylesheet" href="'+getJsDelivrUrl('base.dark.css')+'">');
443-
} else {
453+
} else { // 日间
454+
tools.setCookie(cookieKey, 'day', exp);
444455
$(this).addClass('daySwitch');
445456
$('head link#baseDarkCss').remove();
446457
}
@@ -1215,8 +1226,6 @@ function Base() {
12151226
hltype = window.cnblogsConfig.essayCodeHighlightingType.toLowerCase(),
12161227
hltheme = window.cnblogsConfig.essayCodeHighlighting.toLowerCase();
12171228

1218-
if (window.cnblogsConfig.codeMaxHeight) pre.css('max-height', '70vh');
1219-
12201229
switch (hltype) {
12211230
case 'highlightjs':
12221231
setCodeBefore(1);
@@ -1324,7 +1333,10 @@ function Base() {
13241333
}
13251334

13261335
function setCodeBefore(type) {
1327-
pre.css('cssText', "font-family:'Ubuntu Mono',monospace !important; font-size: 14px !important;");
1336+
var cssText = "font-family:"+ window.cnblogsConfig.essayCode.fontFamily +" !important; font-size: "+ window.cnblogsConfig.essayCode.fontSize +" !important;";
1337+
if (window.cnblogsConfig.codeMaxHeight) cssText += 'max-height: 70vh;';
1338+
pre.css('cssText', cssText);
1339+
13281340
$.each(pre, function (i) {
13291341
var obj = $(this), pid = 'pre-' + tools.randomString(6), codeLine, html = '';
13301342

@@ -1385,72 +1397,42 @@ function Base() {
13851397
};
13861398

13871399
/**
1388-
* 设置评论框样式
1400+
* 设置评论样式
13891401
*/
13901402
this.setCommentStyle = function() {
1391-
1392-
var commentList = $('.blog_comment_body[id!=tbCommentBodyPreviewBody]'),
1393-
commentPlaceholder = $('#blog-comments-placeholder');
1394-
1395-
$('#comment_form_container .comment_textarea').css({
1396-
width:'100%',
1397-
height: '100%'
1398-
});
1399-
1400-
commentAvatar(commentList);
1401-
commentList.addClass('hvr-bob');
1402-
1403-
//气泡效果
14041403
timeIds.commentTId = window.setInterval(function(){
1405-
if (commentPlaceholder.html() != '' || $("#comments_pager_bottom").length > 0) {
1406-
CommentBubble();
1407-
bndongJs.clearIntervalTimeId(timeIds.commentTId);
1408-
}
1409-
},1000);
1410-
1411-
function commentAvatar(commentList) {
1412-
commentList.each(function (i) {
1413-
var p = $(commentList[i]).attr('id').split('_'),
1414-
html = '';
1415-
if (p.length > 0) {
1416-
var idIndex = p.length - 1;
1417-
var id = p[idIndex];
1418-
var idTmp = id.toString().match(/[0-9]/g);
1419-
if ($.isArray(idTmp)) id = idTmp.join('');
1420-
var op = $('#comment_'+id+'_avatar');
1421-
if (op.length > 0 && op.text() != '') {
1422-
var patch = op.text();
1423-
html += '<img class="comment-avatar" src="'+patch+'"/>';
1424-
} else {
1425-
html += '<img class="comment-avatar" src="https://cdn.jsdelivr.net/gh/BNDong/Cnblogs-Theme-SimpleMemory@master/img/webp/default_avatar.webp"/>';
1404+
if ($('.feedbackItem').length > 0) {
1405+
setComment();
1406+
bndongJs.clearIntervalTimeId(timeIds.commentTId);
1407+
}
1408+
},1000);
1409+
1410+
function setComment() {
1411+
var feedbackItem = $('.feedbackItem');
1412+
if (feedbackItem.length > 0) {
1413+
$.each(feedbackItem, function (i) {
1414+
var obj = $(this), feedbackCon = obj.find('.feedbackCon'), feedbackListSubtitle = obj.find('.feedbackListSubtitle'),
1415+
commentBody = feedbackCon.length ? feedbackCon.find('.blog_comment_body') : [], avatarHtml = '',
1416+
idInfo = commentBody.length ? commentBody.attr('id').split('_') : undefined;
1417+
if (idInfo && idInfo.length > 0) {
1418+
var id = idInfo[idInfo.length - 1], idTmp = id.toString().match(/[0-9]/g);
1419+
if ($.isArray(idTmp)) id = idTmp.join('');
1420+
var op = $('#comment_' + id + '_avatar'), patch = op.length > 0 ? $.trim(op.text())
1421+
: 'https://cdn.jsdelivr.net/gh/BNDong/Cnblogs-Theme-SimpleMemory@master/img/webp/default_avatar.webp';
1422+
var ac = $('#a_comment_author_' + id), ah = ac.length ? ac.attr('href') : 'javascropt:void(0);';
1423+
avatarHtml = '<div class="feedbackAvatar"><a href="' + ah + '" target="_blank"><img src="'+patch+'"/></a></div>';
1424+
obj.prepend(avatarHtml);
14261425
}
1427-
$(commentList[i]).before(html);
1428-
}
1429-
});
1430-
}
1431-
1432-
function CommentBubble() {
1433-
var w1 = '<div class="list">' +
1434-
'<table class="out" border="0" cellspacing="0" cellpadding="0"> ' +
1435-
'<tr>' +
1436-
'<td align="left" valign="bottom" class="q">' +
1437-
'<table border="0" cellpadding="0" cellspacing="0" style=""> ' +
1438-
'<tr><td class="topleft"></td><td class="top"></td><td class="topright"></td></tr> ' +
1439-
'<tr><td class="left"></td> <td align="left" class="conmts"><p>';
1440-
1441-
1442-
var w2 = '</p> </td> <td class="right"></td></tr> ' +
1443-
'<tr><td class="bottomleft"></td><td class="bottom"></td><td class="bottomright"></td></tr> ' +
1444-
'</table>' +
1445-
'</td> ' +
1446-
'</tr> ' +
1447-
'</table> ' +
1448-
'</div>';
1449-
1450-
$.each($(".blog_comment_body"), function(i, t) {
1451-
$(t).html(w1 + $(t).html() + w2);
1452-
});
1453-
$(".louzhu").closest(".feedbackItem").find(".out").removeClass("out").addClass("inc");
1426+
if (feedbackListSubtitle.length && feedbackListSubtitle.find('.louzhu').length) {
1427+
feedbackListSubtitle.addClass('feedbackListSubtitle-louzhu');
1428+
}
1429+
});
1430+
$(feedbackItem[0]).css('padding-top', '0');
1431+
$(feedbackItem[feedbackItem.length - 1]).css('padding-bottom', '0');
1432+
var cssText = "font-family:"+ window.cnblogsConfig.essayCode.fontFamily +" !important; font-size: "+ window.cnblogsConfig.essayCode.fontSize +" !important; border-radius: 5px;padding: 10px;";
1433+
if (window.cnblogsConfig.essayCodeHighlightingType === 'cnblogs') cssText += 'color: #000;';
1434+
$('head').append('<style>.feedbackCon pre {'+cssText + 'background-color: ' + $('.postBody pre').css('background-color') + ' !important;'+'}</style>');
1435+
}
14541436
}
14551437
};
14561438

src/script/config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ require.config({
6565
classie: {
6666
deps: ['snapSvg'],
6767
},
68+
title: {
69+
deps: ['tools'],
70+
},
6871
main4: {
6972
deps: ['snapSvg','classie', 'css!'+getJsDelivrUrl('menu_bubble.css')]
7073
},
@@ -95,7 +98,7 @@ require.config({
9598
base: {
9699
deps: [
97100
'tools',
98-
'css!//at.alicdn.com/t/font_543384_nt78v73wgg8.css', // 阿里云字体图标
101+
'css!//at.alicdn.com/t/font_543384_6z41jpa1ptb.css', // 阿里云字体图标
99102
'css!'+getJsDelivrUrl('google-fonts.css'), // 谷歌字体
100103
]
101104
},

0 commit comments

Comments
 (0)