Skip to content

Commit

Permalink
Merge pull request #39 from myqianlan/master
Browse files Browse the repository at this point in the history
感谢 @myqianlan 的PR
  • Loading branch information
xiangming committed Dec 29, 2014
2 parents 6c9e1a5 + e43b179 commit b2178bf
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 17 deletions.
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>
</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

0 comments on commit b2178bf

Please sign in to comment.