From 8d58d494b75e91487636d8a4fa73a98e30eccfa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= Date: Wed, 8 Aug 2018 00:32:52 +0800 Subject: [PATCH] Fix Specifics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了多项小细节,包括无文章提示、文字溢出、目录树叠字... --- archive.php | 4 ++ comments.php | 2 + css/kico.css | 109 +++++++++-------------------- css/single.css | 182 +++++++++++++++++++++++++++---------------------- footer.php | 2 +- functions.php | 2 +- index.php | 2 +- js/kico.js | 33 +++++---- js/single.js | 141 +++++++++++++++++++------------------- 9 files changed, 228 insertions(+), 249 deletions(-) diff --git a/archive.php b/archive.php index ceb3350..791fb1a 100644 --- a/archive.php +++ b/archive.php @@ -13,6 +13,7 @@ is('category')) : ?>getDescription(); ?>
+have()): ?> next()): ?>

title() ?>

@@ -31,6 +32,9 @@
+ +

没有找到结果 (QWQ)

+
pageNav('«', '»'); ?> diff --git a/comments.php b/comments.php index a618ff0..645a021 100644 --- a/comments.php +++ b/comments.php @@ -59,6 +59,8 @@ + +

博主关闭了评论...

have()): ?> listComments(); ?> diff --git a/css/kico.css b/css/kico.css index 8cfdf14..50169fb 100644 --- a/css/kico.css +++ b/css/kico.css @@ -2,9 +2,9 @@ /* ---- -# Kico Style 1.5.4 +# Kico Style 2 # By: Dreamer-Paul -# Last Update: 2018.4.22 +# Last Update: 2018.8.5 一个简洁、有趣的开源响应式框架,仅包含基础样式,需按照一定规则进行二次开发。 @@ -30,27 +30,17 @@ body{ } @media screen and (max-width: 500px){ - html[resize] body{ - font-size: 14px; - } + body.resizable{ font-size: 14px } } @media screen and (min-width: 1930px){ - html[resize] body{ - font-size: 18px; - } + body.resizable{ font-size: 18px } } -*, *:before, *:after{ - box-sizing: border-box; -} +*, *:before, *:after{ box-sizing: border-box } /* - 部分老式浏览器的更正 */ -article, aside, -header, footer, -nav, section, main{ - display: block; -} +aside, article, section, figure, figcaption, header, main, footer, nav{ display: block } /* - 选择内容 */ ::-moz-selection{ @@ -99,32 +89,20 @@ body::-webkit-scrollbar-track:hover{ /* 1 - 容器 -------------------------------- */ .wrap{ - margin-left:auto; + margin-left: auto; margin-right: auto; max-width: 1200px; padding: 0 1.25em; box-sizing: content-box; } -.wrap.min{ - max-width: 800px; -} -.wrap.mid{ - max-width: 1000px; -} -.wrap.max{ - max-width: 1400px; -} +.wrap.min{ max-width: 800px } +.wrap.mid{ max-width: 1000px } +.wrap.max{ max-width: 1400px } +.wrap.full{ max-width: 100% } -.wrap.full{ - max-width: 100%; -} -.wrap.thin{ - padding: 0 .75em; -} -.wrap.thick{ - padding: 0 1.5em; -} +.wrap.thin{ padding: 0 .75em } +.wrap.thick{ padding: 0 1.5em } .wrap.clear{ padding-left: 0; padding-right: 0; @@ -136,10 +114,6 @@ body::-webkit-scrollbar-track:hover{ display: block; } -.overflow{ - overflow: auto; -} - /* 2 - 元素 -------------------------------- */ h1{ @@ -155,7 +129,7 @@ h1:last-child, h2:last-child, h3:last-child, h4:last-child, h5:last-child, h6:la } p{ - line-height: 1.8em; + line-height: 1.8; margin-bottom: 1em; } @@ -193,33 +167,19 @@ kbd{ font-family: 'Consolas', 'Courier New', monospace, "微软雅黑"; } -img, svg{ - height: auto; -} img, svg, audio, video{ max-width: 100%; vertical-align: middle; } /* - 文章 */ -article{ - word-break: break-all; -} +article{ word-break: break-all } -article > *{ - margin-bottom: 1em; -} -article > *:last-child{ - margin-bottom: 0; -} +article > *{ margin-bottom: 1em } +article > *:last-child{ margin-bottom: 0 } -article h1, article h2, article h3{ - font-size: 1.2em; -} -article h4, article h5, article h6{ - font-size: 1.1em; - font-weight: bold; -} +article h1, article h2, article h3{ font-size: 1.2em } +article h4, article h5, article h6{ font-size: 1.1em } /* - 按钮 */ .btn{ @@ -265,18 +225,18 @@ article h4, article h5, article h6{ } /* -- 按钮颜色 */ -.btn.red, .btn.yellow, .btn.blue, .btn.green{ color: #fff; } +.btn.red, .btn.yellow, .btn.blue, .btn.green, .btn.red:hover, .btn.yellow:hover, .btn.blue:hover, .btn.green:hover{ color: #fff; } -.btn.red{ background: #c40b00; } -.btn.yellow{ background: #ffb03a; } -.btn.blue{ background: #3498db; } -.btn.green{ background: #27a17e; } +.btn.red{ background: #c40b00 } +.btn.yellow{ background: #ffb03a } +.btn.blue{ background: #3498db } +.btn.green{ background: #27a17e } -.btn.red:active{ background: #b00000; } -.btn.yellow:active{ background: #eb9c26; } -.btn.blue:active{ background: #2084c7; } -.btn.green:active{ background: #138d6a; } +.btn.red:active{ background: #b00000 } +.btn.yellow:active{ background: #eb9c26 } +.btn.blue:active{ background: #2084c7 } +.btn.green:active{ background: #138d6a } /* - 代码 */ pre, code{ @@ -284,9 +244,7 @@ pre, code{ font-family: 'Consolas', 'Courier New', monospace, "微软雅黑"; } -pre{ - word-wrap: normal; -} +pre{ word-wrap: normal } code{ color: #c40b00; @@ -310,17 +268,13 @@ pre > code{ } /* - 项目列表 */ -ul, ol{ - margin-left: 1.25em; -} +ul, ol{ margin-left: 1.25em } ul.clear{ margin-left: 0; list-style: none; } -dl dd{ - margin-left: 1.5em; -} +dl dd{ margin-left: 1.5em } dl dd:before{ content: "--"; margin-right: .25em; @@ -337,6 +291,7 @@ a, .btn{ /* - 引用*/ blockquote{ margin: 0 0 1em; + line-height: 1.8; font-style: oblique; background: #f5fafd; padding: 1em 1em 1em 2em; diff --git a/css/single.css b/css/single.css index e5f10ad..5169675 100644 --- a/css/single.css +++ b/css/single.css @@ -4,7 +4,7 @@ # Single Theme # By: Dreamer-Paul -# Last Update: 2018.4.27 +# Last Update: 2018.8.8 一个简洁大气,含夜间模式的 Typecho 博客模板。 @@ -26,22 +26,22 @@ body{ width: 8px; height: 8px; } -::-webkit-scrollbar-thumb{ background: #6f9fc7; } -::-webkit-scrollbar-thumb:hover{ background: #9fcff7; } +::-webkit-scrollbar-thumb{ background: #6f9fc7 } +::-webkit-scrollbar-thumb:hover{ background: #9fcff7 } body::-webkit-scrollbar{ border-left: 1px solid #eee; background: rgba(255, 255, 255, .6); } -a{ color: #6f9fc7; } -a:hover{ color: #9fcff7; } +a{ color: #6f9fc7 } +a:hover{ color: #9fcff7 } -h1, h2, h3, h4, h5, h6{ font-weight: normal; } +h1, h2, h3, h4, h5, h6{ font-weight: normal } -hr{ border-color: #eee; } +hr{ border-color: #eee } -em{ background: #6f9fc7; } +em{ background: #6f9fc7 } .btn{ color: #fff; @@ -61,7 +61,7 @@ blockquote{ border-color: #6f9fc7; } -input, textarea{ background: #fff; } +input, textarea{ background: #fff } input, textarea, code, hr, blockquote{ transition: border .3s, background .3s; } @@ -77,17 +77,17 @@ body.neon::-webkit-scrollbar{ background: rgba(255, 255, 255, .2); } -body.neon a{ color: #c9861d; } -body.neon a:hover{ color: #eb9c26; } +body.neon a{ color: #c9861d } +body.neon a:hover{ color: #eb9c26 } body.neon img{ filter: brightness(60%); -webkit-filter: brightness(60%); } -body.neon pre code{ border: 1px solid #555; } +body.neon pre code{ border: 1px solid #555 } -body.neon code, body.neon iframe, body.neon em{ opacity: .6; } +body.neon code, body.neon iframe, body.neon em{ opacity: .6 } body.neon blockquote{ color: #c9861d; @@ -95,7 +95,7 @@ body.neon blockquote{ background: rgba(255, 255, 255, .05); } -body.neon input, body.neon textarea, body.neon .btn, body.neon .link-friends .item{ +body.neon input, body.neon textarea, body.neon .btn{ color: inherit; border-color: #555; background: #404040; @@ -115,15 +115,15 @@ body.neon .head-search input{ background: #666; border-color: transparent; } -body.neon .head-search input::-webkit-input-placeholder{ color: #bbb; } +body.neon .head-search input::-webkit-input-placeholder{ color: #bbb } -body.neon header li a{ color: #aaa; } -body.neon header li a:hover{ color: #ddd; } +body.neon header li a{ color: #aaa } +body.neon header li a:hover{ color: #ddd } /* -- 目录树 */ body.neon main .article-list{ - background: none; border-color: #555; + background: #3f3f3f; } /* -- 边框颜色 */ @@ -163,7 +163,7 @@ header{ text-align: center; } @media screen and (min-width: 600px){ - .head-title{ display: none; } + .head-title{ display: none } } /* - 头部菜单 */ @@ -187,7 +187,7 @@ header{ display: block; cursor: pointer; } -.head-menu li a:hover{ color: #ffa628; } +.head-menu li a:hover{ color: #ffa628 } .head-menu li.has-child > a:after{ float: right; @@ -234,12 +234,12 @@ header{ line-height: 2em; margin-right: 1em; } - .head-menu > li:last-child{ margin-right: 0; } + .head-menu > li:last-child{ margin-right: 0 } } /* - 子菜单 */ -.head-menu .sub-menu{ transition: background 0.3s; } -.head-menu .sub-menu a{ line-height: 2em; } +.head-menu .sub-menu{ transition: background 0.3s } +.head-menu .sub-menu a{ line-height: 2em } /* -- 电脑版 */ @media screen and (min-width: 599px){ @@ -264,7 +264,7 @@ header{ transition: opacity .15s, visibility .15s; } - .toggle-btn{ display: none; } + .toggle-btn{ display: none } } .toggle-btn, .light-btn, .search-btn{ @@ -278,8 +278,8 @@ header{ transition: color 0.3s, background 0.3s; } -.toggle-btn{ margin-right: 0; } -.search-btn{ float: right; } +.toggle-btn{ margin-right: 0 } +.search-btn{ float: right } .toggle-btn:hover, .light-btn:hover, .search-btn:hover{ background: rgba(0, 0, 0, .05); @@ -291,9 +291,9 @@ header{ font: 1em/2em "FontAwesome"; } -.toggle-btn:before{ content: "\f0c9"; } -.light-btn:before{ content: "\f0eb"; } -.search-btn:before{ content: "\f002"; } +.toggle-btn:before{ content: "\f0c9" } +.light-btn:before{ content: "\f0eb" } +.search-btn:before{ content: "\f002" } .head-search{ z-index: 1; @@ -324,7 +324,7 @@ header{ margin-right: 3.5em; } - .head-search input{ width: 100%; } + .head-search input{ width: 100% } } /* 2 - 正文 @@ -334,12 +334,15 @@ main{ margin-top: 3.2em; } -main img{ transition: filter .3s; } +main img{ + height: auto; + transition: filter .3s; +} /* - 高分屏支持 */ @media screen and (min-width: 1930px){ - body{ font-size: 18px; } - .wrap{ max-width: 1000px !important; } + body{ font-size: 18px } + .wrap{ max-width: 1000px !important } } /* - 首页大标题 */ @@ -349,7 +352,7 @@ main img{ transition: filter .3s; } animation: fade-in-bottom .3s both; -webkit-animation: fade-in-bottom .3s both; } -.home-title h1{ color: #6e8aad; } +.home-title h1{ color: #6e8aad } .home-title span{ display: block; @@ -366,28 +369,31 @@ main img{ transition: filter .3s; } } /* - 社交链接 */ -.home-title .home-social{ cursor: default; } +.home-title .home-social{ cursor: default } .home-title .home-social a{ color: inherit; display: inline-block; } -.home-title .home-social i{ padding: .5em; } +.home-title .home-social i{ padding: .5em } /* - 文章简要 */ -.post-item{ margin-bottom: 3em; } -.post-item:last-child{ margin-bottom: 0; } +.post-item{ + margin-bottom: 3em; + word-break: break-all; +} +.post-item:last-child{ margin-bottom: 0 } /* -- 动画 */ -.post-item:nth-child(1){ animation: fade-in-top .3s .2s both; -webkit-animation: fade-in-top .3s .2s both; } -.post-item:nth-child(2){ animation: fade-in-top .3s .3s both; -webkit-animation: fade-in-top .3s .3s both; } -.post-item:nth-child(3){ animation: fade-in-top .3s .4s both; -webkit-animation: fade-in-top .3s .4s both; } -.post-item:nth-child(4){ animation: fade-in-top .3s .5s both; -webkit-animation: fade-in-top .3s .5s both; } -.post-item:nth-child(5){ animation: fade-in-top .3s .6s both; -webkit-animation: fade-in-top .3s .6s both; } -.post-item:nth-child(6){ animation: fade-in-top .3s .7s both; -webkit-animation: fade-in-top .3s .7s both; } +.post-item:nth-child(1){ animation: fade-in-top .3s .2s backwards; -webkit-animation: fade-in-top .3s .2s backwards; } +.post-item:nth-child(2){ animation: fade-in-top .3s .3s backwards; -webkit-animation: fade-in-top .3s .3s backwards; } +.post-item:nth-child(3){ animation: fade-in-top .3s .4s backwards; -webkit-animation: fade-in-top .3s .4s backwards; } +.post-item:nth-child(4){ animation: fade-in-top .3s .5s backwards; -webkit-animation: fade-in-top .3s .5s backwards; } +.post-item:nth-child(5){ animation: fade-in-top .3s .6s backwards; -webkit-animation: fade-in-top .3s .6s backwards; } +.post-item:nth-child(6){ animation: fade-in-top .3s .7s backwards; -webkit-animation: fade-in-top .3s .7s backwards; } -.post-item h2{ margin-bottom: .5em; } +.post-item h2{ margin-bottom: .5em } .post-item h2 a{ line-height: 2em; @@ -402,14 +408,14 @@ main img{ transition: filter .3s; } } /* - 文章属性 */ -.post-meta a{ color: inherit; } +.post-meta a{ color: inherit } .post-meta span, .post-meta time{ margin-right: .8em; display: inline-block; } -.post-meta > *:last-child{ margin: 0; } +.post-meta > *:last-child{ margin: 0 } .post-meta > *:before{ font-size: inherit; @@ -418,10 +424,10 @@ main img{ transition: filter .3s; } font-family: "FontAwesome"; } -.post-meta .date:before{ content: "\f017"; } -.post-meta .category:before{ content: "\f07b"; } -.post-meta .tags:before{ content: "\f02c"; } -.post-meta .comments:before{ content: "\f086"; } +.post-meta .date:before{ content: "\f017" } +.post-meta .category:before{ content: "\f07b" } +.post-meta .tags:before{ content: "\f02c" } +.post-meta .comments:before{ content: "\f086" } /* - 换页 */ .page-navigator{ @@ -438,7 +444,7 @@ main img{ transition: filter .3s; } display: inline-block; } -.page-navigator li.current a{ color: inherit; } +.page-navigator li.current a{ color: inherit } .page-navigator li a{ display: block; padding: .25em .3em; @@ -459,7 +465,7 @@ main img{ transition: filter .3s; } display: inline-block; } -.page-title h2{ margin-bottom: 0; } +.page-title h2{ margin-bottom: 0 } /* - 编辑文章 */ .post-item .edit-link, .page-title .edit-link, .post-title .edit-link{ @@ -467,8 +473,16 @@ main img{ transition: filter .3s; } } /* - 阅读页正文 */ -.post-content, .page-content{ animation: fade-in-top .3s .2s both; -webkit-animation: fade-in-top .3s .2s both; } -.post-content, .page-content, .post-near, .post-author{ margin-bottom: 3em; } +.post-content, .page-content{ animation: fade-in-top .3s .2s backwards; -webkit-animation: fade-in-top .3s .2s backwards; } +.post-content, .page-content, .post-near, .post-author{ margin-bottom: 3em } + +.post-content h2, .page-content h2{ font-size: 1.15em } +.post-content h3, .page-content h3{ font-size: 1.10em } +.post-content h4, .page-content h4{ font-size: 1.05em } +.post-content h5, .page-content h5{ font-size: 1em } +.post-content h6, .page-content h6{ font-size: .9em } + +.post-content h4, .post-content h5, .post-content h6{ font-weight: normal } .post-content h1:before, .page-content h1:before, .post-content h2:before, .page-content h2:before, @@ -477,8 +491,9 @@ main img{ transition: filter .3s; } content: "#"; margin-right: .3em; } +.post-content h1:before, .page-content h1:before{ font-weight: bold } -.post-near{ animation: fade-in-top .3s .3s both; -webkit-animation: fade-in-top .3s .3s both; } +.post-near{ animation: fade-in-top .3s .3s backwards; -webkit-animation: fade-in-top .3s .3s backwards; } /* - 阅读页作者信息 */ .post-author{ @@ -488,7 +503,7 @@ main img{ transition: filter .3s; } border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; transition: border 0.3s, filter 0.3s; - animation: fade-in-top .3s .4s both; -webkit-animation: fade-in-top .3s .4s both; + animation: fade-in-top .3s .4s backwards; -webkit-animation: fade-in-top .3s .4s backwards; } .post-author figure{ @@ -512,7 +527,7 @@ main img{ transition: filter .3s; } } /* - 阅读页评论 */ -.post-comments{ animation: fade-in-top .3s .5s both; -webkit-animation: fade-in-top .3s .5s both; } +.post-comments{ animation: fade-in-top .3s .5s backwards; -webkit-animation: fade-in-top .3s .5s backwards; } .post-comments input, .post-comments textarea{ width: 100%; @@ -520,16 +535,16 @@ main img{ transition: filter .3s; } } /* -- 评论列表 */ -.post-comments{ word-break: break-all; } +.post-comments{ word-break: break-all } -.post-comments form{ margin-bottom: 3em; } +.post-comments form{ margin-bottom: 3em } .post-comments .comment-list{ margin-left: 0; list-style: none; margin-bottom: 2em; } -.post-comments .comment-list:last-child{ margin-bottom: 0; } +.post-comments .comment-list:last-child{ margin-bottom: 0 } .comment-list li{ position: relative; @@ -541,7 +556,7 @@ main img{ transition: filter .3s; } clear: both; display: block; } -.comment-list li:last-child{ margin-bottom: 0; } +.comment-list li:last-child{ margin-bottom: 0 } /* --- 评论头像 */ .comment-list .avatar{ @@ -577,10 +592,10 @@ main img{ transition: filter .3s; } } /* --- 评论内容 */ -.comment-children{ margin-top: 1.5em; } +.comment-children{ margin-top: 1.5em } -.comment-list .comment-reply a{ color: #aaa; } -.comment-list .comment-reply a:hover{ color: #555; } +.comment-list .comment-reply a{ color: #aaa } +.comment-list .comment-reply a:hover{ color: #555 } .comment-list .cancel-comment-reply{ display: block; @@ -609,13 +624,13 @@ main img{ transition: filter .3s; } visibility: visible; background: rgba(255, 255, 255, .95); } -.article-list::-webkit-scrollbar{ width: 0; height: 0; } +.article-list::-webkit-scrollbar{ width: 0; height: 0 } .article-list a{ display: block; margin-bottom: .5em; } -.article-list a:last-child{ margin-bottom: 0; } +.article-list a:last-child{ margin-bottom: 0 } .article-list a.item-2:before, .article-list a.item-3:before, @@ -625,11 +640,11 @@ main img{ transition: filter .3s; } margin-right: .5em; } -.article-list a.item-2:before{ content: "-"; } -.article-list a.item-3:before{ content: "--"; } -.article-list a.item-4:before{ content: "---"; } -.article-list a.item-5:before{ content: "----"; } -.article-list a.item-6:before{ content: "-----"; } +.article-list a.item-2:before{ content: "-" } +.article-list a.item-3:before{ content: "--" } +.article-list a.item-4:before{ content: "---" } +.article-list a.item-5:before{ content: "----" } +.article-list a.item-6:before{ content: "-----" } @media screen and (min-width: 800px){ body.has-trees{ @@ -645,7 +660,7 @@ main img{ transition: filter .3s; } /* - 错误页面 */ .error-page{ text-align: center; - animation: fade-in-bottom .3s both; -webkit-animation: fade-in-bottom .3s both; + animation: fade-in-bottom .3s backwards; -webkit-animation: fade-in-bottom .3s backwards; } .error-page h1{ @@ -653,7 +668,7 @@ main img{ transition: filter .3s; } line-height: 1em; } -.error-page img{ width: 400px; } +.error-page img{ width: 400px } /* 3 - 页尾 -------------------------------- */ @@ -679,7 +694,7 @@ footer .to-top, footer .toggle-list{ transform: translateX(5em); transition: color .3s, border .3s, background .3s, transform .3s; } -footer .to-top.active{ transform: translateX(0); } +footer .to-top.active{ transform: translateX(0) } footer .to-top:before, footer .toggle-list:before{ width: 1.5em; display: block; @@ -691,7 +706,7 @@ footer .toggle-list{ display: none; margin-top: .5em; } -footer .toggle-list:before{ content: '\f00b'; } +footer .toggle-list:before{ content: '\f00b' } @media screen and (max-width: 800px){ footer .toggle-list{ @@ -700,7 +715,7 @@ footer .toggle-list:before{ content: '\f00b'; } } } -footer .widget{ padding: 2em 0; } +footer .widget{ padding: 2em 0 } footer .title-comments:after, footer .title-recent:after, @@ -710,9 +725,9 @@ footer .title-date:after{ font-family: "FontAwesome"; } -footer .title-comments:after{ content: "\f0e6"; } -footer .title-recent:after{ content: "\f040"; } -footer .title-date:after{ content: "\f017"; } +footer .title-comments:after{ content: "\f0e6" } +footer .title-recent:after{ content: "\f040" } +footer .title-date:after{ content: "\f017" } footer .widget ul{ margin: 0; @@ -720,7 +735,10 @@ footer .widget ul{ } footer .widget ul li{ + overflow: hidden; margin-bottom: .5em; + white-space: nowrap; + text-overflow: ellipsis; } footer .widget ul li:before{ content: "\f105"; @@ -733,6 +751,4 @@ footer .sub-footer{ text-align: center; } -footer .sub-footer p{ - font-size: .875em; -} \ No newline at end of file +footer .sub-footer p{ font-size: .875em } \ No newline at end of file diff --git a/footer.php b/footer.php index fcb9e38..18f0efe 100644 --- a/footer.php +++ b/footer.php @@ -43,7 +43,7 @@ options->custom_script): ?> - +options->custom_script() ?> diff --git a/functions.php b/functions.php index d228654..a687380 100644 --- a/functions.php +++ b/functions.php @@ -20,7 +20,7 @@ function paul_update($name, $version){ echo ""; } - paul_update("Single", "1.8"); + paul_update("Single", "1.8.5"); // 自定义站点图标 $favicon_small = new Typecho_Widget_Helper_Form_Element_Text('favicon_small', NULL, NULL, _t('站点图标'), _t('在这里填入一张 png 图片地址(32x32px),不填则使用默认图标')); diff --git a/index.php b/index.php index d8b7cba..ff6599e 100644 --- a/index.php +++ b/index.php @@ -4,7 +4,7 @@ * * @package Single Theme * @author Dreamer-Paul - * @version 1.8 + * @version 1.8.5 * @link https://paugram.com */ diff --git a/js/kico.js b/js/kico.js index 9b0d40c..b6d91e6 100644 --- a/js/kico.js +++ b/js/kico.js @@ -1,8 +1,8 @@ /* ---- -# Kico Style 1.5.4 +# Kico Style 2 # By: Dreamer-Paul -# Last Update: 2018.4.27 +# Last Update: 2018.7.1 一个简洁、有趣的开源响应式框架,仅包含基础样式,需按照一定规则进行二次开发。 @@ -11,7 +11,7 @@ ---- */ -function kico_style () { +function Kico_Style () { var kico = {}; var that = this; @@ -33,6 +33,15 @@ function kico_style () { // 选择对象 this.select = function (obj) { + if(typeof obj === 'object'){ + return obj; + } + else if(typeof obj === 'string'){ + return document.querySelector(obj); + } + }; + + this.selectAll = function (obj) { if(typeof obj === 'object'){ return obj; } @@ -68,7 +77,6 @@ function kico_style () { } if(attr && attr.color){item.classList.add(attr.color);} - if(attr && attr.time && attr.overlay === true){bk_overlay({time: attr.time});} function notice_remove() { item.classList.add("remove"); @@ -76,6 +84,7 @@ function kico_style () { setTimeout(function () { try{ kico.notice_list.removeChild(item); + item = null; } catch(err) {} @@ -96,18 +105,15 @@ function kico_style () { setTimeout(overlay_remove, attr.time); } else{ - kico.overlay.addEventListener("click", function () { - overlay_remove(); - }); + kico.overlay.onclick = function (){ overlay_remove() }; } if(attr && attr.code){ - kico.overlay.addEventListener("click", function () { - attr.code(); - }); + kico.overlay.onclick = function (){ overlay_remove(); attr.code() } } function overlay_remove() { + kico.overlay.onclick = null; kico.overlay.classList.add("remove"); setTimeout(function () { @@ -125,7 +131,7 @@ function kico_style () { kico.image_box.appendChild(kico.image_single); this.image = function bk_image(selector) { - var get_images = that.select(selector); + var get_images = that.selectAll(selector); function item(obj) { obj.setAttribute("bk-image", "active"); @@ -155,7 +161,6 @@ function kico_style () { // Show Version console.log("%c Kico Style %c https://www.binkic.com ","color: #fff; margin: 1em 0; padding: 5px 0; background: #3498db;","margin: 1em 0; padding: 5px 0; background: #efefef;"); -}; +} -var ks = new kico_style(); -var $$ = ks.select; \ No newline at end of file +var ks = new Kico_Style(); \ No newline at end of file diff --git a/js/single.js b/js/single.js index 572e1ab..328bbbf 100644 --- a/js/single.js +++ b/js/single.js @@ -2,7 +2,7 @@ # Single Theme # By: Dreamer-Paul -# Last Update: 2018.4.27 +# Last Update: 2018.8.5 一个简洁大气,含夜间模式的 Typecho 博客模板。 @@ -11,72 +11,65 @@ ---- */ -var body = document.body; - -// 菜单按钮 -function head_menu() { - var btn = document.getElementsByClassName("toggle-btn")[0]; - var menu = document.getElementsByClassName("head-menu")[0]; +var single = new function () { + var body = document.body; + var content = document.getElementsByClassName("post-content")[0] || document.getElementsByClassName("page-content")[0]; - btn.addEventListener("click", function () { - menu.classList.toggle("active"); - }) -} -head_menu(); + // 菜单按钮 + this.header = function () { + var toggle = document.getElementsByClassName("toggle-btn")[0]; + var menu = document.getElementsByClassName("head-menu")[0]; -// 搜索按钮 -function search_btn() { - var btn = document.getElementsByClassName("search-btn")[0]; - var bar = document.getElementsByClassName("head-search")[0]; + toggle.addEventListener("click", function () { + menu.classList.toggle("active"); + }); - btn.addEventListener("click", function () { - bar.classList.toggle("active"); - }) -} -search_btn(); + var search = document.getElementsByClassName("search-btn")[0]; + var bar = document.getElementsByClassName("head-search")[0]; -// 关灯切换 -function single_night() { - var neon_btn = document.getElementsByClassName("light-btn")[0]; + search.addEventListener("click", function () { + bar.classList.toggle("active"); + }) + }; - if (localStorage.style === "neon") { - body.classList.add("neon"); - } + // 关灯切换 + this.night = function () { + var light = document.getElementsByClassName("light-btn")[0]; - neon_btn.addEventListener("click", function () { - if(body.classList.contains("neon")){ - body.classList.remove("neon"); - localStorage.style = null; - } - else{ + if (localStorage.style === "neon") { body.classList.add("neon"); - localStorage.style = "neon"; } - }); -} -single_night(); -// 目录树 -function single_tree() { - var wrap = document.getElementsByClassName("wrap")[0]; - var content = document.getElementsByClassName("post-content")[0] || document.getElementsByClassName("page-content")[0]; + light.addEventListener("click", function () { + if(body.classList.contains("neon")){ + body.classList.remove("neon"); + localStorage.style = null; + } + else{ + body.classList.add("neon"); + localStorage.style = "neon"; + } + }); + }; - if(content){ + // 目录树 + this.tree = function () { + var wrap = document.getElementsByClassName("wrap")[0]; var headings = content.querySelectorAll("h1, h2, h3, h4, h5, h6"); if(headings.length > 0){ body.classList.add("has-trees"); var trees = document.createElement("aside"); - trees.className = "article-list"; - trees.innerHTML += "

文章目录:

"; + trees.className = "article-list"; + trees.innerHTML += "

文章目录:

"; for(var i = 0; i < headings.length; i++){ headings[i].id = headings[i].innerText; var item = document.createElement("a"); - item.innerText = headings[i].innerText; - item.href = "#" + headings[i].innerText; + item.innerText = headings[i].innerText; + item.href = "#" + headings[i].innerText; switch (headings[i].tagName){ case "H2": item.className = "item-2"; break; @@ -103,41 +96,45 @@ function single_tree() { } toggle_tree(); } - } -} -single_tree(); + }; -// 自动添加外链 -function single_links() { - var content = document.getElementsByClassName("post-content")[0] || document.getElementsByClassName("page-content")[0]; - var comment = document.getElementsByClassName("comment-list")[0]; + // 自动添加外链 + this.links = function () { + var comment = document.getElementsByClassName("comment-list")[0]; - function add(selector) { - if(selector){ - var links = selector.getElementsByTagName("a"); + function add(selector) { + if(selector){ + var links = selector.getElementsByTagName("a"); - for(var i = 0; i < links.length; i++){ - links[i].target = "_blank"; + for(var i = 0; i < links.length; i++){ + links[i].target = "_blank"; + } } } - } - add(content); - add(comment); -} -single_links(); + add(content); + add(comment); + }; -// 返回页首 -function to_top() { - var btn = document.getElementsByClassName("to-top")[0]; - var scroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; + // 返回页首 + this.to_top = function () { + var btn = document.getElementsByClassName("to-top")[0]; + var scroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; - scroll >= window.innerHeight / 2 ? btn.classList.add("active") : btn.classList.remove("active"); -} + scroll >= window.innerHeight / 2 ? btn.classList.add("active") : btn.classList.remove("active"); + }; + + this.night(); + this.header(); + + if(content){ + this.tree(); + this.links(); + } -window.addEventListener("scroll", function () { - to_top(); -}); + // 返回页首 + window.addEventListener("scroll", this.to_top); +}; // 图片缩放 ks.image(".post-content img, .page-content img");