Skip to content

Commit 8d5b47e

Browse files
committed
Fixed search results not showing up in Firefox/Safari (SimpleJekyllSearch was not being run as script within component template)
1 parent e018adb commit 8d5b47e

File tree

5 files changed

+41
-38
lines changed

5 files changed

+41
-38
lines changed

app/_layouts/default.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@
7474

7575
</template>
7676

77-
<script src="{{ site.baseurl }}/scripts/jekyll-search.min.js" type="text/javascript"></script>
78-
7977
<!-- MathJax -->
8078
<script type="text/javascript"
8179
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">

app/elements/my-search-bar/my-search-bar.html

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
66

77
<dom-module id="my-search-bar">
8-
<!-- TODO: Fix title showing up above this -->
98

109
<style>
1110

@@ -53,10 +52,10 @@
5352
display: block;
5453
}
5554

56-
#search #back-icon {
55+
#search #backIcon {
5756
display: none;
5857
}
59-
#search #search-icon {
58+
#search #searchIcon {
6059
display: block;
6160
}
6261

@@ -77,7 +76,7 @@
7776
-webkit-appearance: none;
7877
}
7978

80-
#results-container {
79+
#resultsContainer {
8180
display: none;
8281
@apply(--paper-font-body1);
8382
color: var(--primary-text-color);
@@ -92,7 +91,7 @@
9291
}
9392

9493
@media (max-width: 639px) {
95-
#results-container {
94+
#resultsContainer {
9695
top: 56px;
9796
height: calc(100vh - 56px);
9897
}
@@ -103,35 +102,18 @@
103102

104103
<template>
105104
<div id="search" opened$="{{opened}}" on-click="toggleSearch">
106-
<paper-icon-button icon="search" id="search-icon"></paper-icon-button>
107-
<paper-icon-button icon="arrow-back" id="back-icon"></paper-icon-button>
105+
<paper-icon-button icon="search" id="searchIcon"></paper-icon-button>
106+
<paper-icon-button icon="arrow-back" id="backIcon"></paper-icon-button>
108107
<input is="iron-input" bind-value="{{searchInput}}" type="search" id="input" autocomplete="off">
109108
</div>
110-
<div class="list" opened$="{{opened}}" id="results-container"></div>
111-
112-
<script type="text/javascript">
113-
/*jshint multistr: true */
114-
// Do search with json file and make results appear
115-
SimpleJekyllSearch({
116-
searchInput: document.getElementById('search-input'),
117-
resultsContainer: document.getElementById('results-container'),
118-
json: '{{searchjson}}',
119-
searchResultTemplate:
120-
'<a href="{url}" class="test"><paper-item> \
121-
<paper-item-body two-line> \
122-
<div>{title}</div> \
123-
<div secondary>{date}</div> \
124-
<paper-ripple></paper-ripple>\
125-
</paper-item-body> \
126-
</paper-item></a><hr/>',
127-
noResultsText: '<p>No posts found</p>',
128-
limit: 20,
129-
fuzzy: true
130-
});
131-
</script>
109+
<div class="list" opened$="{{opened}}" id="resultsContainer"></div>
132110
</template>
133111

112+
<script src="../../bower_components/simple-jekyll-search/dest/jekyll-search.js" type="text/javascript"></script>
134113
<script>
114+
/*jshint multistr: true */
115+
// Do search with json file and make results appear
116+
135117
Polymer({
136118
is: 'my-search-bar',
137119

@@ -148,6 +130,10 @@
148130
type: String,
149131
value: ''
150132
},
133+
searchjson: {
134+
type: String,
135+
value: 'search.json'
136+
},
151137

152138
animationConfig: {
153139
type: Object,
@@ -192,9 +178,9 @@
192178
},
193179

194180
_onAnimationFinish: function() {
195-
var results = document.querySelector('#results-container');
196-
var searchIcon = document.querySelector('#search-icon');
197-
var backIcon = document.querySelector('#back-icon');
181+
var results = this.$.resultsContainer;
182+
var searchIcon = this.$.searchIcon;
183+
var backIcon = this.$.backIcon;
198184
var middleBar = document.querySelector('#middleBar');
199185
var bottomBar = document.querySelector('#bottomBar');
200186
if (!this.opened) {
@@ -214,14 +200,33 @@
214200
},
215201

216202
show: function() {
217-
var results = document.querySelector('#results-container');
203+
var results = this.$.resultsContainer;
218204
results.style.display = 'block';
219205
this.playAnimation('entry');
220206
},
221207

222208
hide: function() {
223209
this.playAnimation('exit');
224210
this.opened = false;
211+
},
212+
213+
ready: function () {
214+
SimpleJekyllSearch({
215+
searchInput: this.$.input,
216+
resultsContainer: this.$.resultsContainer,
217+
json: this.searchjson,
218+
searchResultTemplate:
219+
'<a href="{url}" class="test"><paper-item> \
220+
<paper-item-body two-line> \
221+
<div>{title}</div> \
222+
<div secondary>{date}</div> \
223+
<paper-ripple></paper-ripple>\
224+
</paper-item-body> \
225+
</paper-item></a><hr/>',
226+
noResultsText: '<p>No posts found</p>',
227+
limit: 20,
228+
fuzzy: true
229+
});
225230
}
226231
});
227232
</script>

app/scripts/jekyll-search.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/styles/app-theme.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
@apply(--paper-font-body1);
6767
}
6868

69-
p, ul {
69+
p, ul, ol {
7070
line-height: 24px;
7171
margin: 0 0 20px 0;
7272
}

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"polymer": "Polymer/polymer#^1.2.4",
1818
"fontawesome-iconset": "diego-d5000/fontawesome-iconset#~4.3.0",
1919
"iron-elements": "polymerelements/iron-elements#^1.0.8",
20-
"paper-elements": "polymerelements/paper-elements#^1.0.7"
20+
"paper-elements": "polymerelements/paper-elements#^1.0.7",
21+
"simple-jekyll-search": "^1.1.1"
2122
}
2223
}

0 commit comments

Comments
 (0)