jekyll-text-theme 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -3
  3. data/_includes/blog/article-data.html +40 -38
  4. data/_includes/blog/footer.html +8 -12
  5. data/_includes/blog/header.html +49 -50
  6. data/_includes/blog/license.html +24 -23
  7. data/_includes/blog/tags.html +42 -38
  8. data/_includes/icon/mail.svg +4 -4
  9. data/_includes/icon/menu.svg +2 -2
  10. data/_includes/icon/next.svg +2 -2
  11. data/_includes/icon/previous.svg +2 -2
  12. data/_includes/icon/social/behance.svg +1 -1
  13. data/_includes/icon/social/douban.svg +3 -3
  14. data/_includes/icon/social/facebook.svg +1 -1
  15. data/_includes/icon/social/flicker.svg +3 -3
  16. data/_includes/icon/social/github.svg +1 -1
  17. data/_includes/icon/social/googleplus.svg +1 -1
  18. data/_includes/icon/social/linkedin.svg +1 -1
  19. data/_includes/icon/social/pinterest.svg +1 -1
  20. data/_includes/icon/social/qq.svg +1 -1
  21. data/_includes/icon/social/twitter.svg +1 -1
  22. data/_includes/icon/social/weixin.svg +1 -1
  23. data/_includes/icon/social/zhihu.svg +1 -1
  24. data/_includes/info/follow-me.html +75 -75
  25. data/_includes/snippets/get-lang.html +5 -1
  26. data/_includes/snippets/locale-to-string.html +5 -1
  27. data/_includes/snippets/page-title.html +2 -2
  28. data/_layouts/all.html +122 -106
  29. data/_layouts/blog-base.html +31 -33
  30. data/_layouts/blog-default.html +2 -4
  31. data/_layouts/error-404.html +3 -3
  32. data/_layouts/home.html +108 -94
  33. data/_layouts/page.html +8 -11
  34. data/_layouts/post.html +178 -188
  35. data/_sass/base/_animate.scss +14 -14
  36. data/_sass/base/_base.scss +62 -34
  37. data/_sass/base/_image&icon.scss +9 -6
  38. data/_sass/base/_links.scss +60 -67
  39. data/_sass/base/_text.scss +30 -24
  40. data/_sass/blog/_layout.default.scss +15 -14
  41. data/_sass/blog/_layout.post.scss +56 -55
  42. data/_sass/blog/_page.all.scss +31 -31
  43. data/_sass/blog/_page.error-404.scss +5 -5
  44. data/_sass/blog/_page.index.scss +47 -42
  45. data/_sass/colors/_colors.chocolate.scss +39 -0
  46. data/_sass/colors/_colors.orange.scss +39 -0
  47. data/_sass/components/_article.content.scss +133 -125
  48. data/_sass/components/_article.data.scss +34 -33
  49. data/_sass/components/_follow-me.scss +38 -65
  50. data/_sass/components/_footer.scss +20 -23
  51. data/_sass/components/_header.scss +35 -38
  52. data/_sass/components/_license.scss +23 -23
  53. data/_sass/components/_pagination.scss +5 -5
  54. data/_sass/components/_tags.scss +23 -29
  55. data/_sass/components/_toc.scss +58 -53
  56. data/_sass/components/_wrapper.scss +19 -17
  57. data/_sass/mixins/_link.scss +46 -39
  58. data/_sass/mixins/_media.scss +3 -3
  59. data/_sass/mixins/_prefix.scss +6 -6
  60. data/_sass/settings/_colors.scss +3 -1
  61. data/_sass/settings/_highlighting.scss +63 -64
  62. data/assets/css/blog.scss +0 -1
  63. metadata +4 -3
  64. data/_sass/blog/_layout.page.scss +0 -1
@@ -1,37 +1,35 @@
1
1
  <!DOCTYPE html>
2
2
  {% include snippets/get-lang.html %}
3
3
  <html lang="{{ __return }}">
4
- <head>
5
- {% include common-head.html %}
6
- {% include head-icons-rel.html %}
7
- {% assign __path = '/assets/css/blog.css' %}
8
- {% include snippets/prepend-baseurl.html %}
9
- <link rel="stylesheet" href="{{ __return }}">
10
- <style>
11
- {% if page.picture_frame == 'shadow' %}
12
- .m-article-content img:not(.emoji) {
13
- box-shadow: 0 0 5px rgba(0, 0, 0, .4);
14
- }
15
- {% endif %}
16
- </style>
17
- <script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
18
- {% include utils/mathjax.html %}
19
- </head>
20
- <body>
21
- <div class="m-page-stage js-page-stage">
22
- {{ content }}
23
- </div>
24
- {% include blog/footer.html %}
25
- <script>
26
- $(function() {
27
- // display coding language //
28
- $(".highlight").each(function() {
29
- $(this).attr("data-lang", $(this).find("code").attr("data-lang"));
30
- });
31
- });
32
- </script>
33
- {% if ga_tracking_id and site.isdebug == false %}
34
- {% include utils/google-analytics.html %}
35
- {% endif %}
36
- </body>
4
+ <head>
5
+ {% include common-head.html %}
6
+ {% include head-icons-rel.html %}
7
+ {% assign __path = '/assets/css/blog.css' %}
8
+ {% include snippets/prepend-baseurl.html %}
9
+ <link rel="stylesheet" href="{{ __return }}">
10
+ <style>
11
+ {% if page.picture_frame == 'shadow' %}
12
+ .m-article-content img:not(.emoji) {
13
+ box-shadow: 0 0 5px rgba(0, 0, 0, .4);
14
+ }
15
+ {% endif %}
16
+ </style>
17
+ <script src="//cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
18
+ {% include utils/mathjax.html %}
19
+ </head>
20
+ <body>
21
+ <div class="m-page-stage js-page-stage">{{ content }}</div>
22
+ {% include blog/footer.html %}
23
+ <script>
24
+ $(function() {
25
+ // display coding language
26
+ $(".highlight").each(function() {
27
+ $(this).attr("data-lang", $(this).find("code").attr("data-lang"));
28
+ });
29
+ });
30
+ </script>
31
+ {% if ga_tracking_id and site.isdebug == false %}
32
+ {% include utils/google-analytics.html %}
33
+ {% endif %}
34
+ </body>
37
35
  </html>
@@ -2,8 +2,6 @@
2
2
  layout: blog-base
3
3
  ---
4
4
  <div class="m-page-content">
5
- {% include blog/header.html %}
6
- <div class="m-page-main">
7
- {{ content }}
8
- </div>
5
+ {% include blog/header.html %}
6
+ <div class="m-page-main">{{ content }}</div>
9
7
  </div>
@@ -3,7 +3,7 @@ layout: blog-default
3
3
  title: 404
4
4
  ---
5
5
  <div class="m-error-404">
6
- <div class="main">
7
- <h1>404</h1>
8
- </div>
6
+ <div class="main">
7
+ <h1>404</h1>
8
+ </div>
9
9
  </div>
data/_layouts/home.html CHANGED
@@ -7,102 +7,116 @@ titles:
7
7
  zh-Hant: 博客
8
8
  ---
9
9
  <div class="m-home">
10
- <div class="main">
11
- <div class="m-post-list">
12
- {% for post in paginator.posts %}
13
- <article>
14
- {% assign __path = post.url %}
15
- {% include snippets/prepend-baseurl.html %}
16
- {% assign href = __return %}
17
- <h1><a href="{{ href }}">{{ post.title }}</a></h1>
18
- <div class="m-article-content">
19
- {% if site.excerpt_type == 'html' %}
20
- {{ post.excerpt }}
21
- {% else %}
22
- {{ post.excerpt | strip_html | truncate: 350 }}
23
- {% endif %}
24
- </div>
25
- {% assign __path = post.url %}
26
- {% include snippets/prepend-baseurl.html %}
27
- {% assign __locale = site.data.locale.READMORE %}
28
- {% include snippets/locale-to-string.html %}
29
- <a href="{{ href }}">{{ __return }}</a>
30
- {% include blog/article-data.html %}
31
- </article>
32
- {% endfor %}
33
- </div>
34
- {% if paginator.total_pages > 1 %}
35
- <nav class="m-pagination">
36
- {% assign __locale = site.data.locale.STATISTICS %}
37
- {% include snippets/locale-to-string.html %}
38
- {% assign post_count = site.posts | size %}
39
- {% assign page_count = paginator.total_pages %}
40
- <p>{{ __return | replace: '[POST_COUNT]', post_count | replace: '[PAGE_COUNT]', page_count }}</p>
41
- <ul class="inline-list">
42
- {% if paginator.previous_page %}
43
- {% assign __path = paginator.previous_page_path %}
44
- {% include snippets/prepend-baseurl.html %}
45
- {% assign href = __return %}
46
- <li><a class="round-button" href="{{ href }}">
47
- <div class="icon icon--previous">{% include icon/previous.svg %}</div></a></li>
48
- {% else %}
49
- <li><div class="round-button inactive">
50
- <div class="icon icon--prrevious">{% include icon/previous.svg %}</div></div></li>
51
- {% endif %}
52
- {% for page in (1..paginator.total_pages) %}
53
- {% if page == paginator.page %}
54
- <li><div class="round-button cur">
55
- <span>{{ page }}</span></div></li>
56
- {% elsif page == 1 %}
57
- {% assign __path = '/' %}
58
- {% include snippets/prepend-baseurl.html %}
59
- {% assign href = __return %}
60
- <li><a class="round-button"
61
- href="{{ href }}">
62
- <span>{{ page }}</span></a></li>
63
- {% else %}
64
- {% assign __path = site.paginate_path %}
65
- {% include snippets/prepend-baseurl.html %}
66
- {% assign href = __return %}
67
- <li><a class="round-button" href="{{ href | replace: ':num', page }}">
68
- <span>{{ page }}</span></a></li>
69
- {% endif %}
70
- {% endfor %}
71
- {% if paginator.next_page %}
72
- {% assign __path = paginator.next_page_path %}
73
- {% include snippets/prepend-baseurl.html %}
74
- {% assign href = __return %}
75
- <li><a class="round-button" href="{{ href }}"><div class="icon icon--next">{% include icon/next.svg %}</div></a></li>
76
- {% else %}
77
- <li><div class="round-button inactive"><div class="icon icon--next">{% include icon/next.svg %}</div></div></li>
78
- {% endif %}
79
- </ul>
80
- </nav>
81
- {% endif %}
10
+ <div class="main">
11
+ <div class="m-post-list">
12
+ {% for post in paginator.posts %}
13
+ <article>
14
+ {% assign __path = post.url %}
15
+ {% include snippets/prepend-baseurl.html %}
16
+ {% assign href = __return %}
17
+ <h1><a href="{{ href }}">{{ post.title }}</a></h1>
18
+ <div class="m-article-content">
19
+ {% if site.excerpt_type == 'html' %}
20
+ {{ post.excerpt }}
21
+ {% else %}
22
+ {{ post.excerpt | strip_html | truncate: 350 }}
23
+ {% endif %}
24
+ </div>
25
+ {% assign __path = post.url %}
26
+ {% include snippets/prepend-baseurl.html %}
27
+ {% assign __locale = site.data.locale.READMORE %}
28
+ {% include snippets/locale-to-string.html %}
29
+ <a href="{{ href }}">{{ __return }}</a>
30
+ {% include blog/article-data.html %}
31
+ </article>
32
+ {% endfor %}
82
33
  </div>
34
+ {% if paginator.total_pages > 1 %}
35
+ <nav class="m-pagination">
36
+ {% assign __locale = site.data.locale.STATISTICS %}
37
+ {% include snippets/locale-to-string.html %}
38
+ {% assign post_count = site.posts | size %}
39
+ {% assign page_count = paginator.total_pages %}
40
+ <p>{{ __return | replace: '[POST_COUNT]', post_count | replace: '[PAGE_COUNT]', page_count }}</p>
41
+ <ul class="inline-list">
42
+ {% if paginator.previous_page %}
43
+ {% assign __path = paginator.previous_page_path %}
44
+ {% include snippets/prepend-baseurl.html %}
45
+ {% assign href = __return %}
46
+ <li><a class="round-button" href="{{ href }}">
47
+ <div class="icon icon--previous">{% include icon/previous.svg %}</div></a>
48
+ </li>
49
+ {% else %}
50
+ <li><div class="round-button inactive">
51
+ <div class="icon icon--prrevious">{% include icon/previous.svg %}</div></div>
52
+ </li>
53
+ {% endif %}
54
+ {% for page in (1..paginator.total_pages) %}
55
+ {% if page == paginator.page %}
56
+ <li>
57
+ <div class="round-button cur"><span>{{ page }}</span></div>
58
+ </li>
59
+ {% elsif page == 1 %}
60
+ {% if site.paths.home %}
61
+ {% assign __path = site.paths.home %}
62
+ {% else %}
63
+ {% assign __path = '/' %}
64
+ {% endif %}
65
+ {% include snippets/prepend-baseurl.html %}
66
+ {% assign href = __return %}
67
+ <li>
68
+ <a class="round-button" href="{{ href }}"><span>{{ page }}</span></a>
69
+ </li>
70
+ {% else %}
71
+ {% assign __path = site.paginate_path %}
72
+ {% include snippets/prepend-baseurl.html %}
73
+ {% assign href = __return %}
74
+ <li>
75
+ <a class="round-button" href="{{ href | replace: ':num', page }}"><span>{{ page }}</span></a>
76
+ </li>
77
+ {% endif %}
78
+ {% endfor %}
79
+ {% if paginator.next_page %}
80
+ {% assign __path = paginator.next_page_path %}
81
+ {% include snippets/prepend-baseurl.html %}
82
+ {% assign href = __return %}
83
+ <li>
84
+ <a class="round-button" href="{{ href }}">
85
+ <div class="icon icon--next">{% include icon/next.svg %}</div>
86
+ </a>
87
+ </li>
88
+ {% else %}
89
+ <li><div class="round-button inactive">
90
+ <div class="icon icon--next">{% include icon/next.svg %}</div>
91
+ </div></li>
92
+ {% endif %}
93
+ </ul>
94
+ </nav>
95
+ {% endif %}
96
+ </div>
83
97
  </div>
84
98
  {% if site.leancloud.app_id and site.leancloud.app_key and site.leancloud.app_class and site.isdebug == false %}
85
- <script src="https://cdn1.lncld.net/static/js/av-min-1.2.1.js"></script>
86
- <script>
87
- $(function() {
88
- AV.init({
89
- appId: '{{ site.leancloud.app_id }}',
90
- appKey: '{{ site.leancloud.app_key }}'
91
- });
92
- $(".article-view").each(function() {
93
- var curId = this.id;
94
- var query = new AV.Query('{{ site.leancloud.app_class }}');
95
- query.equalTo('key', curId.substr(9));
96
- query.first().then(function(result) {
97
- if (result) {
98
- $('#' + curId).text(result.attributes.views);
99
- }
100
- }, function(error) {
101
- if (error) {
102
- throw error;
103
- }
104
- });
105
- });
99
+ <script src="https://cdn1.lncld.net/static/js/3.4.1/av-min.js"></script>
100
+ <script>
101
+ $(function() {
102
+ AV.init({
103
+ appId: '{{ site.leancloud.app_id }}',
104
+ appKey: '{{ site.leancloud.app_key }}'
105
+ });
106
+ $(".article-view").each(function() {
107
+ var curId = this.id;
108
+ var query = new AV.Query('{{ site.leancloud.app_class }}');
109
+ query.equalTo('key', curId.substr(9));
110
+ query.first().then(function(result) {
111
+ if (result) {
112
+ $('#' + curId).text(result.attributes.views);
113
+ }
114
+ }, function(error) {
115
+ if (error) {
116
+ throw error;
117
+ }
106
118
  });
107
- </script>
119
+ });
120
+ });
121
+ </script>
108
122
  {% endif %}
data/_layouts/page.html CHANGED
@@ -2,15 +2,12 @@
2
2
  layout: blog-default
3
3
  ---
4
4
  <div class="m-page">
5
- <article class="main">
6
- {% include snippets/page-title.html %}
7
- <h1>{{ __return }}</h1>
8
-
9
- <div class="m-article-content" itemprop="articleBody">
10
- {{ content }}
11
- </div>
12
- {% if page.comment != false %}
13
- <section>{% include utils/comment-disqus.html %}</section>
14
- {% endif %}
15
- </article>
5
+ <article class="main">
6
+ {% include snippets/page-title.html %}
7
+ <h1>{{ __return }}</h1>
8
+ <div class="m-article-content" itemprop="articleBody">{{ content }}</div>
9
+ {% if page.comment != false %}
10
+ <section>{% include utils/comment-disqus.html %}</section>
11
+ {% endif %}
12
+ </article>
16
13
  </div>
data/_layouts/post.html CHANGED
@@ -2,207 +2,197 @@
2
2
  layout: blog-default
3
3
  ---
4
4
  <div class="m-post">
5
- <div class="main js-main">
6
- <div class="col-1">
7
- <article itemscope itemtype="http://schema.org/BlogPosting">
8
- <meta itemprop="mainEntityOfPage" itemscope itemType="https://schema.org/WebPage"/>
9
- <header class="article-header">
10
- {% include snippets/page-title.html %}
11
- <h1 itemprop="headline" itemprop="name headline">{{ __return }}</h1>
12
- {% include blog/article-data.html %}
13
- </header>
14
- <div class="m-article-content js-article-content" itemprop="articleBody">
15
- {{ content }}
16
- </div>
17
- <footer>
18
- {% if page.modify_date %}
19
- {% assign __locale = site.data.locale.LAST_UPDATED %}
20
- {% include snippets/locale-to-string.html %}
21
- <span>{{ __return }}
22
- {% assign __locale = site.data.locale.ARTICLE_DATE_FORMAT %}
23
- {% include snippets/locale-to-string.html %}
24
- <time datetime="{{ page.modify_date | date_to_xmlschema }}" itemprop="dateModified">{{ page.modify_date | date: __return }}</time>
25
- </span>
26
- {% else %}
27
- <meta itemprop="dateModified" content="{{ page.date | date_to_xmlschema }}">
28
- {% endif %}
29
- <div class="article-license">
30
- {% include blog/license.html %}
31
- </div>
32
- </footer>
33
- {% if page.comment != false %}
34
- <section>{% include utils/comment-disqus.html %}</section>
35
- {% endif %}
36
- </article>
37
- </div>
38
- <div class="col-2">
39
- <aside class="js-article-aside">
40
- <div class="m-toc js-toc"></div>
41
- </aside>
42
- </div>
43
- </div>
5
+ <div class="main js-main">
6
+ <div class="col-1">
7
+ <article itemscope itemtype="http://schema.org/BlogPosting">
8
+ <meta itemprop="mainEntityOfPage" itemscope itemType="https://schema.org/WebPage"/>
9
+ <header class="article-header">
10
+ {% include snippets/page-title.html %}
11
+ <h1 itemprop="headline" itemprop="name headline">{{ __return }}</h1>
12
+ {% include blog/article-data.html %}
13
+ </header>
14
+ <div class="m-article-content js-article-content" itemprop="articleBody">{{ content }}</div>
15
+ <footer>
16
+ {% if page.modify_date %}
17
+ {% assign __locale = site.data.locale.ARTICLE_DATE_FORMAT %}
18
+ {% include snippets/locale-to-string.html %}
19
+ {% assign date_format = __return %}
20
+ {% assign __locale = site.data.locale.LAST_UPDATED %}
21
+ {% include snippets/locale-to-string.html %}
22
+ <span>{{ __return }}
23
+ <time datetime="{{ page.modify_date | date_to_xmlschema }}" itemprop="dateModified">{{ page.modify_date | date: date_format }}</time>
24
+ </span>
25
+ {% else %}
26
+ <meta itemprop="dateModified" content="{{ page.date | date_to_xmlschema }}">
27
+ {% endif %}
28
+ <div class="article-license">
29
+ {% include blog/license.html %}
30
+ </div>
31
+ </footer>
32
+ {% if page.comment != false %}
33
+ <section>{% include utils/comment-disqus.html %}</section>
34
+ {% endif %}
35
+ </article>
36
+ </div>
37
+ <div class="col-2">
38
+ <aside class="js-article-aside"><div class="m-toc js-toc"></div></aside>
39
+ </div>
40
+ </div>
44
41
  </div>
45
42
 
46
43
  <script src="//cdn.bootcss.com/toc/0.3.2/toc.min.js"></script>
47
44
  <script type="text/javascript">
48
- window.throttle = function(func, wait) {
49
- var args,
50
- result,
51
- thisArg,
52
- timeoutId,
53
- lastCalled = 0;
45
+ window.throttle = function(func, wait) {
46
+ var args, result, thisArg, timeoutId, lastCalled = 0;
54
47
 
55
- function trailingCall() {
56
- lastCalled = new Date;
57
- timeoutId = null;
58
- result = func.apply(thisArg, args);
59
- }
60
- return function() {
61
- var now = new Date,
62
- remaining = wait - (now - lastCalled);
48
+ function trailingCall() {
49
+ lastCalled = new Date;
50
+ timeoutId = null;
51
+ result = func.apply(thisArg, args);
52
+ }
53
+ return function() {
54
+ var now = new Date,
55
+ remaining = wait - (now - lastCalled);
63
56
 
64
- args = arguments;
65
- thisArg = this;
57
+ args = arguments;
58
+ thisArg = this;
66
59
 
67
- if (remaining <= 0) {
68
- clearTimeout(timeoutId);
69
- timeoutId = null;
70
- lastCalled = now;
71
- result = func.apply(thisArg, args);
72
- }
73
- else if (!timeoutId) {
74
- timeoutId = setTimeout(trailingCall, remaining);
75
- }
76
- return result;
77
- };
78
- }
79
- $(function() {
80
- var $window = $(window);
81
- var $pageStage = $('.js-page-stage');
82
- var $pageMain = $('.js-main');
83
- var $pageFooter = $('.js-page-footer');
84
- var $articleContent = $('.js-article-content');
85
- var $articleAside = $('.js-article-aside');
86
- var $toc = $('.js-toc');
87
- var hasTitle = $articleContent.find('h1, h2, h3').length > 0;
60
+ if (remaining <= 0) {
61
+ clearTimeout(timeoutId);
62
+ timeoutId = null;
63
+ lastCalled = now;
64
+ result = func.apply(thisArg, args);
65
+ } else if (!timeoutId) {
66
+ timeoutId = setTimeout(trailingCall, remaining);
67
+ }
68
+ return result;
69
+ };
70
+ }
71
+ $(function() {
72
+ var $window = $(window);
73
+ var $pageStage = $('.js-page-stage');
74
+ var $pageMain = $('.js-main');
75
+ var $pageFooter = $('.js-page-footer');
76
+ var $articleContent = $('.js-article-content');
77
+ var $articleAside = $('.js-article-aside');
78
+ var $toc = $('.js-toc');
79
+ var hasTitle = $articleContent.find('h1, h2, h3').length > 0;
88
80
 
89
- function asideSticky() {
90
- return $window.outerWidth() > 1150 && $pageStage.hasClass('has-toc');
91
- }
92
- function setTocClass() {
93
- if (hasTitle) {
94
- !$pageStage.hasClass('has-toc') && $pageStage.addClass('has-toc');
95
- }
96
- }
81
+ function asideSticky() {
82
+ return $window.outerWidth() > 1150 && $pageStage.hasClass('has-toc');
83
+ }
97
84
 
98
- setTocClass();
85
+ function setTocClass() {
86
+ if (hasTitle) {
87
+ !$pageStage.hasClass('has-toc') && $pageStage.addClass('has-toc');
88
+ }
89
+ }
99
90
 
100
- function setAsideTOC() {
101
- var asideTop,
102
- asideLeft,
103
- scrollBottom,
104
- asideBottomTop,
105
- lastScrollTop;
91
+ setTocClass();
106
92
 
107
- function init() {
108
- var asideOffset = $articleAside.offset();
109
- var footerOffset = $pageFooter.offset();
110
- var mainOffset = $pageMain.offset();
111
- asideTop = mainOffset.top;
112
- asideHeight = $toc.outerHeight() + parseInt($articleAside.css('padding-top'), 10) + parseInt($articleAside.css('padding-bottom'), 10);
113
- asideLeft = mainOffset.left + $pageMain.outerWidth() - $articleAside.outerWidth() - parseInt($pageMain.css('padding-right'), 10);
114
- scrollBottom = footerOffset.top - asideHeight;
115
- asideBottomTop = scrollBottom - mainOffset.top;
116
- }
117
- function setAside(force) {
118
- force !== true && (force = false);
119
- var scrollTop = $window.scrollTop();
120
- if (scrollTop >= asideTop && scrollTop <= scrollBottom) {
121
- (!force && lastScrollTop >= asideTop && lastScrollTop <= scrollBottom) ||
122
- $articleAside.addClass('fixed').css({
123
- left: asideLeft + 'px',
124
- top: 0
125
- });
126
- } else if (scrollTop < asideTop) {
127
- (!force && lastScrollTop < asideTop) ||
128
- $articleAside.removeClass('fixed').css({
129
- left: 0,
130
- top: 0
131
- });
132
- } else {
133
- (!force && lastScrollTop > scrollBottom) ||
134
- $articleAside.removeClass('fixed').css({
135
- left: 0,
136
- top: asideBottomTop + 'px'
137
- });
138
- }
139
- lastScrollTop = scrollTop;
140
- }
141
- asideSticky() && (init(), setAside());
142
- $window.on('scroll', function() {
143
- asideSticky() && setAside();
144
- });
145
- $window.on('resize', throttle(function() {
146
- setTocClass();
147
- asideSticky() && (init(), setAside(true));
148
- }, 100));
149
- setTimeout(init, 4000);
150
- }
151
- setTimeout(setAsideTOC, 1000);
93
+ function setAsideTOC() {
94
+ var asideTop, asideLeft, scrollBottom, asideBottomTop, lastScrollTop;
152
95
 
153
- $toc.toc({
154
- 'selectors': 'h1,h2,h3',
155
- 'container': '.js-article-content',
156
- });
157
- });
96
+ function init() {
97
+ var asideOffset = $articleAside.offset();
98
+ var footerOffset = $pageFooter.offset();
99
+ var mainOffset = $pageMain.offset();
100
+ asideTop = mainOffset.top;
101
+ asideHeight = $toc.outerHeight() + parseInt($articleAside.css('padding-top'), 10) + parseInt($articleAside.css('padding-bottom'), 10);
102
+ asideLeft = mainOffset.left + $pageMain.outerWidth() - $articleAside.outerWidth() - parseInt($pageMain.css('padding-right'), 10);
103
+ scrollBottom = footerOffset.top - asideHeight;
104
+ asideBottomTop = scrollBottom - mainOffset.top;
105
+ }
106
+
107
+ function setAside(force) {
108
+ force !== true && (force = false);
109
+ var scrollTop = $window.scrollTop();
110
+ if (scrollTop >= asideTop && scrollTop <= scrollBottom) {
111
+ (!force && lastScrollTop >= asideTop && lastScrollTop <= scrollBottom) ||
112
+ $articleAside.addClass('fixed').css({
113
+ left: asideLeft + 'px',
114
+ top: 0
115
+ });
116
+ } else if (scrollTop < asideTop) {
117
+ (!force && lastScrollTop < asideTop) ||
118
+ $articleAside.removeClass('fixed').css({
119
+ left: 0,
120
+ top: 0
121
+ });
122
+ } else {
123
+ (!force && lastScrollTop > scrollBottom) ||
124
+ $articleAside.removeClass('fixed').css({
125
+ left: 0,
126
+ top: asideBottomTop + 'px'
127
+ });
128
+ }
129
+ lastScrollTop = scrollTop;
130
+ }
131
+ asideSticky() && (init(), setAside());
132
+ $window.on('scroll', function() {
133
+ asideSticky() && setAside();
134
+ });
135
+ $window.on('resize', throttle(function() {
136
+ setTocClass();
137
+ asideSticky() && (init(), setAside(true));
138
+ }, 100));
139
+ setTimeout(init, 4000);
140
+ }
141
+ setTimeout(setAsideTOC, 1000);
142
+
143
+ $toc.toc({
144
+ 'selectors': 'h1,h2,h3',
145
+ 'container': '.js-article-content',
146
+ });
147
+ });
158
148
  </script>
159
149
  {% if page.key and site.leancloud.app_id and site.leancloud.app_key and site.leancloud.app_class and site.isdebug == false %}
160
- <script src="https://cdn1.lncld.net/static/js/av-min-1.2.1.js"></script>
161
- <script type="text/javascript">
162
- $(function() {
163
- // 初始化
164
- AV.init({
165
- appId: '{{ site.leancloud.app_id }}',
166
- appKey: '{{ site.leancloud.app_key }}'
167
- });
168
- // 查询
169
- var query = new AV.Query('{{ site.leancloud.app_class }}');
170
- query.equalTo('key', '{{ page.key }}');
171
- query.first().then(function(result) {
172
- if (result) {
173
- addOne(result)
174
- } else {
175
- //新建
176
- var Blog = AV.Object.extend('{{ site.leancloud.app_class }}');
177
- var blog = new Blog();
178
- blog.set('title', '{{ page.title }}');
179
- blog.set('key', '{{ page.key }}');
180
- blog.set('views', 0);
181
- blog.save().then(function(page) {
182
- addOne(page)
183
- }, function(error) {
184
- if (error) {
185
- throw error;
186
- }
187
- });
188
- }
150
+ <script src="https://cdn1.lncld.net/static/js/3.4.1/av-min.js"></script>
151
+ <script type="text/javascript">
152
+ $(function() {
153
+ // 初始化
154
+ AV.init({
155
+ appId: '{{ site.leancloud.app_id }}',
156
+ appKey: '{{ site.leancloud.app_key }}'
157
+ });
158
+ // 查询
159
+ var query = new AV.Query('{{ site.leancloud.app_class }}');
160
+ query.equalTo('key', '{{ page.key }}');
161
+ query.first().then(function(result) {
162
+ if (result) {
163
+ addOne(result)
164
+ } else {
165
+ //新建
166
+ var Blog = AV.Object.extend('{{ site.leancloud.app_class }}');
167
+ var blog = new Blog();
168
+ blog.set('title', '{{ page.title }}');
169
+ blog.set('key', '{{ page.key }}');
170
+ blog.set('views', 0);
171
+ blog.save().then(function(page) {
172
+ addOne(page)
173
+ }, function(error) {
174
+ if (error) {
175
+ throw error;
176
+ }
177
+ });
178
+ }
189
179
 
190
- function addOne(page) {
191
- page.increment('views', 1);
192
- page.fetchWhenSave(true);
193
- page.save().then(function(page) {
194
- $("#post-key-{{ page.key }}").text(page.attributes.views);
195
- }, function(error) {
196
- if (error) {
197
- throw error;
198
- }
199
- });
200
- }
201
- }, function(error) {
202
- if (error) {
203
- throw error;
204
- }
205
- });
206
- });
207
- </script>
180
+ function addOne(page) {
181
+ page.increment('views', 1);
182
+ page.fetchWhenSave(true);
183
+ page.save().then(function(page) {
184
+ $("#post-key-{{ page.key }}").text(page.attributes.views);
185
+ }, function(error) {
186
+ if (error) {
187
+ throw error;
188
+ }
189
+ });
190
+ }
191
+ }, function(error) {
192
+ if (error) {
193
+ throw error;
194
+ }
195
+ });
196
+ });
197
+ </script>
208
198
  {% endif %}