Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一些优化 #39

Merged
merged 8 commits into from
Dec 29, 2014
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ __MACOSX/
public/
.deploy/
_SYNCAPP
metadata.xml
metadata.xml
/.idea
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rss: /atom.xml
# Content
excerpt_link: Read More
fancybox: false
mathjax: false

# Sidebar
sidebar: right
Expand Down
3 changes: 2 additions & 1 deletion languages/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ menu: Menu
rss: RSS
showsidebar: Show Sidebar
hidesidebar: Hide Sidebar
updated: Updated
updated: Updated
totop: totop
3 changes: 2 additions & 1 deletion languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ menu: 菜单
rss: RSS 订阅
showsidebar: 显示侧边栏
hidesidebar: 隐藏侧边栏
updated: 更新日期
updated: 更新日期
totop: 返回顶部
3 changes: 2 additions & 1 deletion languages/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ menu: 菜單
rss: RSS 訂閱
showsidebar: 顯示側邊欄
hidesidebar: 隱藏側邊欄
updated: 更新日期
updated: 更新日期
totop: 返回頂部
5 changes: 5 additions & 0 deletions layout/_partial/after-footer.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<!-- totop start -->
<%- partial('totop') %>
<!-- totop end -->
<% if (theme.duoshuo_shortname){ %>
<!-- 多说公共js代码 start -->
<script type="text/javascript">
Expand Down Expand Up @@ -50,5 +53,7 @@ var duoshuoQuery = {short_name:"<%= theme.duoshuo_shortname %>"};
<%- js('fancybox/jquery.fancybox.pack') %>
<% } %>

<% if (theme.mathjax){ %>
<%- partial('mathjax') %>
<% } %>
<%- js('js/script') %>
3 changes: 3 additions & 0 deletions layout/_partial/totop.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div id="totop">
<a title="<%= __('totop')%>"><img src="/img/scrollup.png"/></a>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 这里的图片路径不正确
  • 增加一下totop的简体和繁体翻译

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.返回顶部的图片我加进去了,只不过要在高度为1000px的时候才显示

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我本地测试的时候,图片挂掉了,需要设置路径为./img/scrollup.png
感谢回复如此之快~

</div>
51 changes: 38 additions & 13 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
<% if(page.layout=='page'){ %>
<% if(page.source.match(/\.md$/)){ %>
<%- partial('_partial/head') %>
<body>
<div id="container">
<div id="wrap">
<%- partial('_partial/header', null, {cache: !config.relative_link}) %>
<div class="outer">
<section id="main"><%- body %></section>
<% if (theme.sidebar && theme.sidebar !== 'bottom'){ %>
<%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %>
<% } %>
</div>
<%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
<div id="container">
<div id="wrap">
<%- partial('_partial/header', null, {cache: !config.relative_link}) %>
<div class="outer">
<section id="main"><%- body %></section>
<% if (theme.sidebar && theme.sidebar !== 'bottom'){ %>
<%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %>
<% } %>
</div>
<%- partial('_partial/mobile-nav', null, {cache: !config.relative_link}) %>
<%- partial('_partial/after-footer') %>
<%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
</div>
<%- partial('_partial/mobile-nav', null, {cache: !config.relative_link}) %>
<%- partial('_partial/after-footer') %>
</div>
</body>
</html>
</html>
<% }else{ %>
<%- page.content %>
<% } %>
<% }else{ %>
<%- partial('_partial/head') %>
<body>
<div id="container">
<div id="wrap">
<%- partial('_partial/header', null, {cache: !config.relative_link}) %>
<div class="outer">
<section id="main"><%- body %></section>
<% if (theme.sidebar && theme.sidebar !== 'bottom'){ %>
<%- partial('_partial/sidebar', null, {cache: !config.relative_link}) %>
<% } %>
</div>
<%- partial('_partial/footer', null, {cache: !config.relative_link}) %>
</div>
<%- partial('_partial/mobile-nav', null, {cache: !config.relative_link}) %>
<%- partial('_partial/after-footer') %>
</div>
</body>
</html>
<% } %>
9 changes: 9 additions & 0 deletions source/css/_partial/totop.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#totop
position fixed
display none
z-index 9999
bottom 5em
right 1em
cursor pointer
@media tabletmax
display none !important
1 change: 1 addition & 0 deletions source/css/style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ if sidebar is left
@import "_partial/footer"
@import "_partial/highlight"
@import "_partial/mobile"
@import "_partial/totop"

if sidebar
@import "_partial/sidebar"
Binary file added source/img/scrollup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions source/js/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
(function($){
/*toTop start*/
// When to show the scroll link
// higher number = scroll link appears further down the page
var upperLimit = 1000;
// Our scroll link element
var scrollElem = $('#totop');
// Scroll to top speed
var scrollSpeed = 500;
// Show and hide the scroll to top link based on scroll position
$(window).scroll(function() {
var scrollTop = $(document).scrollTop();
if (scrollTop > upperLimit) {
$(scrollElem).stop().fadeTo(300, 1); // fade back in
} else {
$(scrollElem).stop().fadeTo(300, 0); // fade out
}
});

// Scroll to top animation on click
$(scrollElem).click(function() {
$('html, body').animate({
scrollTop: 0
}, scrollSpeed);
return false;
});
/*toTop end*/
// Search
var $searchWrap = $('#search-form-wrap'),
isSearchAnim = false,
Expand Down