jekyll-text-theme 2.2.4 → 2.2.5

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 (149) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +29 -17
  3. data/README.md +7 -4
  4. data/_data/locale.yml +138 -93
  5. data/_data/navigation.yml +47 -10
  6. data/_data/variables.yml +4 -2
  7. data/_includes/analytics-providers/custom.html +3 -0
  8. data/_includes/article-footer.html +55 -0
  9. data/_includes/article-header.html +1 -1
  10. data/_includes/article-info.html +2 -2
  11. data/_includes/article-list.html +11 -7
  12. data/_includes/article-section-navigator.html +2 -2
  13. data/_includes/{article-footer → article/footer}/author-profile.html +0 -0
  14. data/_includes/article/footer/custom.html +3 -0
  15. data/_includes/{article-footer → article/footer}/license.html +1 -1
  16. data/_includes/article/footer/subscribe.html +6 -0
  17. data/_includes/article/top/custom.html +3 -0
  18. data/_includes/author-links.html +59 -31
  19. data/_includes/comments-providers/custom.html +3 -0
  20. data/_includes/comments-providers/gitalk.html +8 -1
  21. data/_includes/comments-providers/valine.html +15 -2
  22. data/_includes/footer.html +15 -18
  23. data/_includes/head.html +3 -25
  24. data/_includes/head/custom.html +3 -0
  25. data/_includes/head/favicon.html +26 -0
  26. data/_includes/header.html +10 -6
  27. data/_includes/main/bottom/custom.html +3 -0
  28. data/_includes/main/top/custom.html +3 -0
  29. data/_includes/pageview-providers/custom/home.html +3 -0
  30. data/_includes/pageview-providers/custom/post.html +3 -0
  31. data/_includes/pageview-providers/leancloud/leancloud.js +3 -2
  32. data/_includes/pageview-providers/leancloud/post.html +1 -1
  33. data/_includes/paginator.html +1 -1
  34. data/_includes/scripts/article.js +1 -1
  35. data/_includes/scripts/aside/affix.js +1 -1
  36. data/_includes/scripts/aside/toc.js +1 -1
  37. data/_includes/scripts/common.js +1 -1
  38. data/_includes/scripts/components/search.js +86 -0
  39. data/_includes/scripts/components/sidebar.js +1 -2
  40. data/_includes/scripts/home.js +1 -1
  41. data/_includes/scripts/lib/affix.js +1 -1
  42. data/_includes/scripts/lib/gallery.js +123 -20
  43. data/_includes/scripts/lib/lazyload.js +1 -1
  44. data/_includes/scripts/lib/modal.js +9 -7
  45. data/_includes/scripts/lib/scroll-to.js +1 -1
  46. data/_includes/scripts/lib/swiper.js +28 -6
  47. data/_includes/scripts/lib/throttle.js +1 -1
  48. data/_includes/scripts/lib/toc.js +1 -1
  49. data/_includes/scripts/page.js +1 -1
  50. data/_includes/scripts/utils/imagesLoad.js +1 -1
  51. data/_includes/scripts/utils/utils.js +1 -5
  52. data/_includes/scripts/variables.html +1 -1
  53. data/_includes/search-providers/custom/search.html +3 -0
  54. data/_includes/{scripts/components/search → search-providers/default}/search-data.js +2 -2
  55. data/_includes/search-providers/default/search.html +18 -0
  56. data/_includes/{scripts/components/search → search-providers/default}/search.js +13 -69
  57. data/_includes/search-providers/google-custom-search-engine/search.html +21 -0
  58. data/_includes/search-providers/google-custom-search-engine/search.js +33 -0
  59. data/_includes/search.html +17 -19
  60. data/_includes/sharing-providers/custom.html +3 -0
  61. data/_includes/sharing.html +2 -0
  62. data/_includes/snippets/get-article-title.html +1 -1
  63. data/_includes/snippets/get-locale-string.html +12 -0
  64. data/_includes/snippets/{locale-to-string.html → get-string-from-locale-config.html} +0 -0
  65. data/_includes/svg/icon/social/medium.svg +3 -0
  66. data/_layouts/archive.html +22 -4
  67. data/_layouts/article.html +4 -51
  68. data/_layouts/home.html +23 -5
  69. data/_layouts/landing.html +22 -1
  70. data/_layouts/page.html +3 -7
  71. data/_sass/additional/_alert.scss +1 -1
  72. data/_sass/additional/_photo-frame.scss +1 -1
  73. data/_sass/additional/_tag.scss +1 -1
  74. data/_sass/animate/_fade-in-down.scss +1 -1
  75. data/_sass/animate/_fade-in-up.scss +1 -1
  76. data/_sass/animate/_fade-in.scss +1 -1
  77. data/_sass/common/_classes.scss +7 -5
  78. data/_sass/common/_function.scss +1 -1
  79. data/_sass/common/_print.scss +1 -1
  80. data/_sass/common/_reset.scss +18 -14
  81. data/_sass/common/_variables.scss +5 -8
  82. data/_sass/common/classes/_animation.scss +1 -1
  83. data/_sass/common/classes/_clearfix.scss +1 -1
  84. data/_sass/common/classes/_clickable.scss +10 -1
  85. data/_sass/common/classes/_grid.scss +1 -1
  86. data/_sass/common/classes/_horizontal-rules.scss +1 -1
  87. data/_sass/common/classes/_link.scss +10 -1
  88. data/_sass/common/classes/_media.scss +1 -1
  89. data/_sass/common/classes/_overflow.scss +1 -1
  90. data/_sass/common/classes/_pseudo.scss +1 -1
  91. data/_sass/common/classes/_shadow.scss +1 -1
  92. data/_sass/common/classes/_spacing.scss +1 -1
  93. data/_sass/common/classes/_split-line.scss +1 -1
  94. data/_sass/common/classes/_text.scss +1 -1
  95. data/_sass/common/classes/_transform.scss +1 -1
  96. data/_sass/common/classes/_transition.scss +1 -1
  97. data/_sass/common/classes/_user-select.scss +1 -1
  98. data/_sass/common/components/_button.scss +3 -7
  99. data/_sass/common/components/_card.scss +2 -2
  100. data/_sass/common/components/_gallery.scss +8 -8
  101. data/_sass/common/components/_hero.scss +1 -1
  102. data/_sass/common/components/_image.scss +1 -1
  103. data/_sass/common/components/_item.scss +2 -2
  104. data/_sass/common/components/_menu.scss +1 -1
  105. data/_sass/common/components/_modal.scss +1 -1
  106. data/_sass/common/components/_swiper.scss +1 -1
  107. data/_sass/common/components/_toc.scss +61 -53
  108. data/_sass/components/_article-footer.scss +17 -0
  109. data/_sass/components/_article-header.scss +4 -1
  110. data/_sass/components/_article-list.scss +8 -1
  111. data/_sass/components/_author-links.scss +16 -10
  112. data/_sass/components/_author-profile.scss +2 -1
  113. data/_sass/components/_extensions.scss +1 -1
  114. data/_sass/components/_footer.scss +2 -7
  115. data/_sass/components/_header.scss +34 -18
  116. data/_sass/components/_lightbox.scss +2 -2
  117. data/_sass/components/_main.scss +1 -1
  118. data/_sass/components/_search.scss +22 -2
  119. data/_sass/components/_tags.scss +1 -1
  120. data/_sass/custom.scss +3 -0
  121. data/_sass/layout/_404.scss +1 -1
  122. data/_sass/layout/_article.scss +26 -41
  123. data/_sass/layout/_articles.scss +1 -1
  124. data/_sass/layout/_base.scss +1 -1
  125. data/_sass/layout/_home.scss +1 -1
  126. data/_sass/layout/_landing.scss +1 -1
  127. data/_sass/layout/_page.scss +120 -122
  128. data/_sass/skins/_chocolate.scss +7 -5
  129. data/_sass/skins/_dark.scss +7 -5
  130. data/_sass/skins/_default.scss +7 -5
  131. data/_sass/skins/_forest.scss +7 -5
  132. data/_sass/skins/_ocean.scss +7 -5
  133. data/_sass/skins/_orange.scss +7 -5
  134. data/_sass/skins/highlight/_tomorrow-night-blue.scss +1 -1
  135. data/_sass/skins/highlight/_tomorrow-night-bright.scss +1 -1
  136. data/_sass/skins/highlight/_tomorrow-night-eighties.scss +1 -1
  137. data/_sass/skins/highlight/_tomorrow-night.scss +1 -1
  138. data/_sass/skins/highlight/_tomorrow.scss +1 -1
  139. data/_sass/skins/highlight/tomorrow/_default.scss +1 -1
  140. data/_sass/skins/highlight/tomorrow/_highlight.scss +1 -1
  141. data/_sass/skins/highlight/tomorrow/_night-blue.scss +1 -1
  142. data/_sass/skins/highlight/tomorrow/_night-bright.scss +1 -1
  143. data/_sass/skins/highlight/tomorrow/_night-eighties.scss +1 -1
  144. data/_sass/skins/highlight/tomorrow/_night.scss +1 -1
  145. data/assets/css/main.scss +2 -3
  146. data/assets/search.js +1 -1
  147. metadata +42 -21
  148. data/_includes/article-footer/custom.html +0 -1
  149. data/_includes/pageview-providers/custom.html +0 -0
@@ -140,4 +140,4 @@
140
140
  }
141
141
  };
142
142
  })(this.document);
143
- })();
143
+ })();
@@ -5,12 +5,13 @@
5
5
  var $pageRoot = $('.js-page-root'), $pageMain = $('.js-page-main');
6
6
  var activeCount = 0;
7
7
  function modal(options) {
8
- var $root = this, visible, onChange;
8
+ var $root = this, visible, onChange, hideWhenWindowScroll = false;
9
9
  var scrollTop;
10
10
  function setOptions(options) {
11
11
  var _options = options || {};
12
12
  visible = _options.initialVisible === undefined ? false : show;
13
13
  onChange = _options.onChange;
14
+ hideWhenWindowScroll = _options.hideWhenWindowScroll;
14
15
  }
15
16
  function init() {
16
17
  setState(visible);
@@ -21,19 +22,19 @@
21
22
  }
22
23
  visible = isShow;
23
24
  if (visible) {
24
- activeCount ++;
25
+ activeCount++;
25
26
  scrollTop = $(window).scrollTop() || $pageMain.scrollTop();
26
27
  $root.addClass('modal--show');
27
28
  $pageMain.scrollTop(scrollTop);
28
29
  activeCount === 1 && ($pageRoot.addClass('show-modal'), $body.addClass('of-hidden'));
29
- $window.on('scroll', hide);
30
+ hideWhenWindowScroll && window.hasEvent('touchstart') && $window.on('scroll', hide);
30
31
  $window.on('keyup', handleKeyup);
31
32
  } else {
32
- activeCount > 0 && activeCount --;
33
+ activeCount > 0 && activeCount--;
33
34
  $root.removeClass('modal--show');
34
35
  $window.scrollTop(scrollTop);
35
36
  activeCount === 0 && ($pageRoot.removeClass('show-modal'), $body.removeClass('of-hidden'));
36
- $window.off('scroll', hide);
37
+ hideWhenWindowScroll && window.hasEvent('touchstart') && $window.off('scroll', hide);
37
38
  $window.off('keyup', handleKeyup);
38
39
  }
39
40
  onChange && onChange(visible);
@@ -54,9 +55,10 @@
54
55
  init();
55
56
  return {
56
57
  show: show,
57
- hide: hide
58
+ hide: hide,
59
+ $el: $root
58
60
  };
59
61
  }
60
62
  $.fn.modal = modal;
61
63
  });
62
- })();
64
+ })();
@@ -10,4 +10,4 @@
10
10
  }
11
11
  $.fn.scrollToAnchor = scrollToAnchor;
12
12
  });
13
- })();
13
+ })();
@@ -2,18 +2,21 @@
2
2
  var SOURCES = window.TEXT_VARIABLES.sources;
3
3
  window.Lazyload.js(SOURCES.jquery, function() {
4
4
  function swiper(options) {
5
- var $window = $(window), $root = this, $swiperWrapper, $swiperButtonPrev, $swiperButtonNext,
6
- initialSlide, animation,
7
- rootWidth, count, curIndex, translateX, CRITICAL_ANGLE = Math.PI / 3;
5
+ var $window = $(window), $root = this, $swiperWrapper, $swiperSlides, $swiperButtonPrev, $swiperButtonNext,
6
+ initialSlide, animation, onChange, onChangeEnd,
7
+ rootWidth, count, preIndex, curIndex, translateX, CRITICAL_ANGLE = Math.PI / 3;
8
8
 
9
9
  function setOptions(options) {
10
10
  var _options = options || {};
11
11
  initialSlide = _options.initialSlide || 0;
12
12
  animation = _options.animation === undefined && true;
13
+ onChange = onChange || _options.onChange;
14
+ onChangeEnd = onChangeEnd || _options.onChangeEnd;
13
15
  }
14
16
 
15
17
  function init() {
16
18
  $swiperWrapper = $root.find('.swiper__wrapper');
19
+ $swiperSlides = $root.find('.swiper__slide');
17
20
  $swiperButtonPrev = $root.find('.swiper__button--prev');
18
21
  $swiperButtonNext = $root.find('.swiper__button--next');
19
22
  animation && $swiperWrapper.addClass('swiper__wrapper--animation');
@@ -32,7 +35,7 @@
32
35
  }
33
36
 
34
37
  var calc = (function() {
35
- var preAnimation;
38
+ var preAnimation, $swiperSlide, $preSwiperSlide;
36
39
  return function (needPreCalc, params) {
37
40
  needPreCalc && preCalc();
38
41
  var _animation = (params && params.animation !== undefined) ? params.animation : animation;
@@ -40,6 +43,21 @@
40
43
  preAnimation = _animation ? $swiperWrapper.addClass('swiper__wrapper--animation') :
41
44
  $swiperWrapper.removeClass('swiper__wrapper--animation');
42
45
  }
46
+ if (preIndex !== curIndex) {
47
+ ($preSwiperSlide = $swiperSlides.eq(preIndex)).removeClass('active');
48
+ ($swiperSlide = $swiperSlides.eq(curIndex)).addClass('active');
49
+ onChange && onChange(curIndex, $swiperSlides.eq(curIndex), $swiperSlide, $preSwiperSlide);
50
+ if (onChangeEnd) {
51
+ if (_animation) {
52
+ setTimeout(function() {
53
+ onChangeEnd(curIndex, $swiperSlides.eq(curIndex), $swiperSlide, $preSwiperSlide);
54
+ }, 400);
55
+ } else {
56
+ onChangeEnd(curIndex, $swiperSlides.eq(curIndex), $swiperSlide, $preSwiperSlide);
57
+ }
58
+ }
59
+ preIndex = curIndex;
60
+ }
43
61
  $swiperWrapper.css('transform', 'translate(' + translateX + 'px, 0)');
44
62
  if (count > 1) {
45
63
  if (curIndex <= 0) {
@@ -61,6 +79,7 @@
61
79
  }
62
80
 
63
81
  function moveToIndex(index ,params) {
82
+ preIndex = curIndex;
64
83
  curIndex = index;
65
84
  translateX = getTranslateXFromCurIndex();
66
85
  calc(false, params);
@@ -85,6 +104,7 @@
85
104
 
86
105
  setOptions(options);
87
106
  init();
107
+ preIndex = curIndex;
88
108
 
89
109
  $swiperButtonPrev.on('click', function(e) {
90
110
  e.stopPropagation();
@@ -95,7 +115,6 @@
95
115
  move('next');
96
116
  });
97
117
  $window.on('resize', function() {
98
- translateX = getTranslateXFromCurIndex();
99
118
  calc(true, { animation: false });
100
119
  });
101
120
 
@@ -109,6 +128,9 @@
109
128
  preTranslateX = translateX;
110
129
  }
111
130
  function handleTouchmove(e) {
131
+ if (e.touches && e.touches.length > 1) {
132
+ return;
133
+ }
112
134
  var point = e.touches ? e.touches[0] : e;
113
135
  var deltaX = point.pageX - pageX;
114
136
  var deltaY = point.pageY - pageY;
@@ -178,4 +200,4 @@
178
200
  }
179
201
  $.fn.swiper = swiper;
180
202
  });
181
- })();
203
+ })();
@@ -25,4 +25,4 @@
25
25
  return result;
26
26
  };
27
27
  };
28
- })();
28
+ })();
@@ -104,4 +104,4 @@
104
104
  }
105
105
  $.fn.toc = toc;
106
106
  });
107
- })();
107
+ })();
@@ -1,3 +1,3 @@
1
1
  /*(function () {
2
2
 
3
- })();*/
3
+ })();*/
@@ -25,4 +25,4 @@
25
25
  }
26
26
  };
27
27
  };
28
- })();
28
+ })();
@@ -6,10 +6,6 @@
6
6
  return typeof val === 'string';
7
7
  };
8
8
 
9
- window.decodeUrl = function(str) {
10
- return str ? decodeURIComponent(str.replace(/\+/g, '%20')) : '';
11
- };
12
-
13
9
  window.hasEvent = function(event) {
14
10
  return 'on'.concat(event) in window.document;
15
11
  };
@@ -40,4 +36,4 @@
40
36
  }
41
37
  };
42
38
  })();
43
- })();
39
+ })();
@@ -7,7 +7,7 @@
7
7
  <script>
8
8
  (function() {
9
9
  var TEXT_VARIABLES = {
10
- version: '2.2.4',
10
+ version: '2.2.5',
11
11
  sources: {
12
12
  font_awesome: '{{ _sources.font_awesome }}',
13
13
  jquery: '{{ _sources.jquery }}',
@@ -0,0 +1,3 @@
1
+ <!-- start custom search snippet -->
2
+
3
+ <!-- end custom search snippet -->
@@ -4,10 +4,10 @@ window.TEXT_SEARCH_DATA={
4
4
  '{{ _collection.label }}':[
5
5
  {%- for _article in _collection.docs -%}
6
6
  {%- unless forloop.first -%},{%- endunless -%}
7
- {'title':'{{ _article.title | url_encode }}',
7
+ {'title':{{ _article.title | jsonify }},
8
8
  {%- include snippets/prepend-baseurl.html path=_article.url -%}
9
9
  {%- assign _url = __return -%}
10
- 'url':'{{ _url | url_encode }}'}
10
+ 'url':{{ _url | jsonify }}}
11
11
  {%- endfor -%}
12
12
  ]
13
13
  {%- endfor -%}
@@ -0,0 +1,18 @@
1
+ <div class="search search--dark">
2
+ <div class="main">
3
+ <div class="search__header">{{ _locale_search }}</div>
4
+ <div class="search-bar">
5
+ <div class="search-box js-search-box">
6
+ <div class="search-box__icon-search"><i class="fas fa-search"></i></div>
7
+ <input type="text" />
8
+ <div class="search-box__icon-clear js-icon-clear">
9
+ <a><i class="fas fa-times"></i></a>
10
+ </div>
11
+ </div>
12
+ <button class="button button--theme-dark button--pill search__cancel js-search-toggle">
13
+ {{ _locale_cancel }}</button>
14
+ </div>
15
+ <div class="search-result js-search-result"></div>
16
+ </div>
17
+ </div>
18
+ <script>{%- include search-providers/default/search.js -%}</script>
@@ -1,7 +1,8 @@
1
1
  var SOURCES = window.TEXT_VARIABLES.sources;
2
2
  var PAHTS = window.TEXT_VARIABLES.paths;
3
3
  window.Lazyload.js([SOURCES.jquery, PAHTS.search_js], function() {
4
- var searchData = window.TEXT_SEARCH_DATA ? initData(window.TEXT_SEARCH_DATA) : {};
4
+ var search = (window.search || (window.search = {}));
5
+ var searchData = window.TEXT_SEARCH_DATA || {};
5
6
 
6
7
  function memorize(f) {
7
8
  var cache = {};
@@ -12,21 +13,6 @@ window.Lazyload.js([SOURCES.jquery, PAHTS.search_js], function() {
12
13
  };
13
14
  }
14
15
 
15
- function initData(data) {
16
- var _data = [], i, j, key, keys, cur;
17
- keys = Object.keys(data);
18
- for (i = 0; i < keys.length; i++) {
19
- key = keys[i], _data[key] = [];
20
- for (j = 0; j < data[key].length; j++) {
21
- cur = data[key][j];
22
- cur.title = window.decodeUrl(cur.title);
23
- cur.url = window.decodeUrl(cur.url);
24
- _data[key].push(cur);
25
- }
26
- }
27
- return _data;
28
- }
29
-
30
16
  /// search
31
17
  function searchByQuery(query) {
32
18
  var i, j, key, keys, cur, _title, result = {};
@@ -71,60 +57,21 @@ window.Lazyload.js([SOURCES.jquery, PAHTS.search_js], function() {
71
57
  }
72
58
 
73
59
  // search box
74
- var $searchBox = $('.js-search-box');
75
- var $searchInput = $searchBox.children('input');
76
- var $searchClear = $searchBox.children('.js-icon-clear');
77
60
  var $result = $('.js-search-result'), $resultItems;
78
61
  var lastActiveIndex, activeIndex;
79
62
 
80
- function searchBoxEmpty() {
81
- $searchBox.removeClass('not-empty'); $result.html(null);
63
+ function clear() {
64
+ $result.html(null);
82
65
  $resultItems = $('.search-result__item'); activeIndex = 0;
83
66
  }
84
-
85
- $searchInput.on('input', window.throttle(function() {
86
- var val = $(this).val();
87
- if (val === '' || typeof val !== 'string') {
88
- searchBoxEmpty();
89
- } else {
90
- $searchBox.addClass('not-empty'); $result.html(render(searchByQuery(val)));
91
- $resultItems = $('.search-result__item'); activeIndex = 0;
92
- $resultItems.eq(0).addClass('active');
93
- }
94
- }, 400));
95
- $searchInput.on('focus', function() {
96
- $(this).addClass('focus');
97
- });
98
- $searchInput.on('blur', function() {
99
- $(this).removeClass('focus');
100
- });
101
- $searchClear.on('click', function() {
102
- $searchInput.val(''); searchBoxEmpty();
103
- });
104
-
105
- // search panel
106
- var $searchModal = $('.js-page-search-modal');
107
- var $searchToggle = $('.js-search-toggle');
108
- var modalVisible = false;
109
-
110
- var searchModal = $searchModal.modal({ onChange: handleModalChange });
111
-
112
- function handleModalChange(visible) {
113
- modalVisible = visible;
114
- if (visible) {
115
- $searchInput[0].focus();
116
- } else {
117
- $searchInput[0].blur();
118
- setTimeout(function() {
119
- $searchInput.val(''); searchBoxEmpty();
120
- window.pageAsideAffix && window.pageAsideAffix.refresh();
121
- }, 400);
122
- }
67
+ function onInputNotEmpty(val) {
68
+ $result.html(render(searchByQuery(val)));
69
+ $resultItems = $('.search-result__item'); activeIndex = 0;
70
+ $resultItems.eq(0).addClass('active');
123
71
  }
124
72
 
125
- $searchToggle.on('click', function() {
126
- modalVisible ? searchModal.hide() : searchModal.show();
127
- });
73
+ search.clear = clear;
74
+ search.onInputNotEmpty = onInputNotEmpty;
128
75
 
129
76
  function updateResultItems() {
130
77
  lastActiveIndex >= 0 && $resultItems.eq(lastActiveIndex).removeClass('active');
@@ -144,8 +91,9 @@ window.Lazyload.js([SOURCES.jquery, PAHTS.search_js], function() {
144
91
  }
145
92
  }
146
93
 
147
- // Char Code: 13 Enter, 37 ⬅, 38 ⬆, 39 ➡, 40 ⬇, 83 S, 191 /
94
+ // Char Code: 13 Enter, 37 ⬅, 38 ⬆, 39 ➡, 40
148
95
  $(window).on('keyup', function(e) {
96
+ var modalVisible = search.getModalVisible && search.getModalVisible();
149
97
  if (modalVisible) {
150
98
  if (e.which === 38) {
151
99
  modalVisible && moveActiveIndex('up');
@@ -154,10 +102,6 @@ window.Lazyload.js([SOURCES.jquery, PAHTS.search_js], function() {
154
102
  } else if (e.which === 13) {
155
103
  modalVisible && $resultItems && activeIndex >= 0 && $resultItems.eq(activeIndex).children('a')[0].click();
156
104
  }
157
- } else {
158
- if (!window.isFormElement(e.target || e.srcElement) && (e.which === 83 || e.which === 191)) {
159
- modalVisible || searchModal.show();
160
- }
161
105
  }
162
106
  });
163
107
 
@@ -165,4 +109,4 @@ window.Lazyload.js([SOURCES.jquery, PAHTS.search_js], function() {
165
109
  var itemIndex = $(this).parent().data('index');
166
110
  itemIndex >= 0 && (lastActiveIndex = activeIndex, activeIndex = itemIndex, updateResultItems());
167
111
  });
168
- });
112
+ });
@@ -0,0 +1,21 @@
1
+ {%- if site.search.google.custom_search_engine_id -%}
2
+ <div class="search search--dark search--google-custom-search-engine">
3
+ <div class="main">
4
+ <div class="content js-gcse">
5
+ <!-- <gcse:search enableAutoComplete="true" gname="search-box"></gcse:search>
6
+ <gcse:searchresults-only gname="results"></gcse:searchresults-only> -->
7
+ </div>
8
+ </div>
9
+ </div>
10
+ <script>
11
+ var gcse = document.getElementsByClassName('js-gcse')[0];
12
+ var gcseSearch = document.createElement('gcse:search');
13
+ gcseSearch.setAttribute('enableAutoComplete', 'true');
14
+ gcseSearch.setAttribute('gname', 'search-box');
15
+ var gcseSearchresults = document.createElement('gcse:searchresults-only');
16
+ gcseSearchresults.setAttribute('gname', 'results');
17
+ gcse.appendChild(gcseSearch);
18
+ gcse.appendChild(gcseSearchresults);
19
+ </script>
20
+ <script>{%- include search-providers/google-custom-search-engine/search.js -%}</script>
21
+ {%- endif -%}
@@ -0,0 +1,33 @@
1
+ var SOURCES = window.TEXT_VARIABLES.sources;
2
+ window.Lazyload.js(SOURCES.jquery, function() {
3
+ /* global google */
4
+ var search = (window.search || (window.search = {}));
5
+ var searchBox, searchInput, clearIcon, searchModal;
6
+
7
+ search.clear = function() {
8
+ searchBox && searchBox.clearAllResults();
9
+ };
10
+ search.onShow = function() {
11
+ searchInput && searchInput.focus();
12
+ };
13
+ search.onHide = function() {
14
+ searchInput && searchInput.blur();
15
+ };
16
+
17
+ window.__gcse = {
18
+ callback: function() {
19
+ searchBox = google.search.cse.element.getElement('search-box');
20
+ searchInput = document.getElementById('gsc-i-id1');
21
+ clearIcon = document.getElementById('gs_cb50');
22
+ searchModal = search.searchModal;
23
+ searchModal && searchModal.$el && searchModal.$el.on('click', function(e) {
24
+ (e.target === this || e.target === clearIcon || e.target.className === 'gs-title') && searchModal.hide();
25
+ });
26
+ }
27
+ };
28
+ var cx = '{{ site.search.google.custom_search_engine_id }}'; // Insert your own Custom Search Engine ID here
29
+ var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true;
30
+ gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
31
+ '//cse.google.com/cse.js?cx=' + cx;
32
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s);
33
+ });
@@ -1,22 +1,20 @@
1
- {%- include snippets/locale-to-string.html locale=site.data.locale.CANCEL -%}
1
+ {%- include snippets/get-locale-string.html key='CANCEL' -%}
2
2
  {%- assign _locale_cancel = __return -%}
3
- {%- include snippets/locale-to-string.html locale=site.data.locale.SEARCH -%}
3
+ {%- include snippets/get-locale-string.html key='SEARCH' -%}
4
4
  {%- assign _locale_search = __return -%}
5
5
 
6
- <div class="search search--dark">
7
- <div class="main">
8
- <div class="search__header">{{ _locale_search }}</div>
9
- <div class="search-bar">
10
- <div class="search-box js-search-box">
11
- <div class="search-box__icon-search"><i class="fas fa-search"></i></div>
12
- <input type="text" />
13
- <div class="search-box__icon-clear js-icon-clear">
14
- <a><i class="fas fa-times"></i></a>
15
- </div>
16
- </div>
17
- <button class="button button--theme-dark button--pill search__cancel js-search-toggle">
18
- {{ _locale_cancel }}</button>
19
- </div>
20
- <div class="search-result js-search-result"></div>
21
- </div>
22
- </div>
6
+ {%- if site.search.provider == 'google' -%}
7
+ <script>window.useDefaultSearchBox = false;</script>
8
+ {%- endif -%}
9
+
10
+ {%- if site.search.provider -%}
11
+ <script>{%- include scripts/components/search.js -%}</script>
12
+ {%- endif -%}
13
+
14
+ {%- if site.search.provider == 'default' -%}
15
+ {%- include search-providers/default/search.html -%}
16
+ {%- elsif site.search.provider == 'google' -%}
17
+ {%- include search-providers/google-custom-search-engine/search.html -%}
18
+ {%- elsif site.search.provider == 'custom' -%}
19
+ {%- include search-providers/custom/search.html -%}
20
+ {%- endif -%}