forked from dauxio/daux.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace tipuesearch's jQuery with a mix of JS and preact
- Loading branch information
Showing
27 changed files
with
3,073 additions
and
803 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ node_modules | |
static | ||
|
||
/vendor | ||
|
||
/prettier.config.js | ||
/.eslintrc.js | ||
/stylelint.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,58 @@ | ||
|
||
module.exports = { | ||
browsers: "> 0.25%, Edge >= 15, Safari >= 10, iOS >= 10, Chrome >= 56, Firefox >= 51, IE >= 11, not op_mini all", | ||
browsers: | ||
"> 0.25%, Edge >= 15, Safari >= 10, iOS >= 10, Chrome >= 56, Firefox >= 51, IE >= 11, not op_mini all", | ||
presets: [ | ||
"@swissquote/crafty-preset-postcss", | ||
"@swissquote/crafty-runner-gulp" | ||
"@swissquote/crafty-preset-babel", | ||
"@swissquote/crafty-runner-rollup", | ||
"@swissquote/crafty-preset-postcss", | ||
"@swissquote/crafty-runner-gulp" | ||
], | ||
destination_css: "themes", | ||
destination_js: ".", | ||
stylelint_pattern: [ | ||
"themes/daux/scss/**/*.scss", | ||
"themes/daux_singlepage/scss/**/*.scss", | ||
"!*.min.css", | ||
"!**/vendor/**/*.scss" | ||
"themes/daux/scss/**/*.scss", | ||
"themes/daux_singlepage/scss/**/*.scss", | ||
"!*.min.css", | ||
"!**/vendor/**/*.scss" | ||
], | ||
stylelint: { | ||
rules: { | ||
"swissquote/no-type-outside-scope": null, | ||
"plugin/no-unsupported-browser-features": null | ||
} | ||
rules: { | ||
"swissquote/no-type-outside-scope": null, | ||
"plugin/no-unsupported-browser-features": null | ||
} | ||
}, | ||
js: { | ||
search: { | ||
runner: "rollup", | ||
source: "src/js/search/index.js", | ||
destination: "search/search.min.js" | ||
} | ||
}, | ||
css: { | ||
"theme_blue": { | ||
source: "themes/daux/scss/theme-blue.scss", | ||
destination: "daux/css/theme-blue.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
"theme_green": { | ||
source: "themes/daux/scss/theme-green.scss", | ||
destination: "daux/css/theme-green.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
"theme_navy": { | ||
source: "themes/daux/scss/theme-navy.scss", | ||
destination: "daux/css/theme-navy.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
"theme_red": { | ||
source: "themes/daux/scss/theme-red.scss", | ||
destination: "daux/css/theme-red.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
"daux_singlepage": { | ||
source: "themes/daux_singlepage/scss/main.scss", | ||
destination: "daux_singlepage/css/main.min.css", | ||
watch: ["themes/daux_singlepage/scss/**"] | ||
} | ||
theme_blue: { | ||
source: "themes/daux/scss/theme-blue.scss", | ||
destination: "daux/css/theme-blue.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
theme_green: { | ||
source: "themes/daux/scss/theme-green.scss", | ||
destination: "daux/css/theme-green.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
theme_navy: { | ||
source: "themes/daux/scss/theme-navy.scss", | ||
destination: "daux/css/theme-navy.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
theme_red: { | ||
source: "themes/daux/scss/theme-red.scss", | ||
destination: "daux/css/theme-red.min.css", | ||
watch: ["themes/daux/scss/**"] | ||
}, | ||
daux_singlepage: { | ||
source: "themes/daux_singlepage/scss/main.scss", | ||
destination: "daux_singlepage/css/main.min.css", | ||
watch: ["themes/daux_singlepage/scss/**"] | ||
} | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import preact from "preact"; | ||
import { textLinkPrevious, textLinkNext } from "./translation"; | ||
/** @jsx preact.h */ | ||
|
||
export default function Pagination({ counter, start, settings, onPageSelect }) { | ||
const pages = Math.ceil(counter / settings.show); | ||
const page = start / settings.show; | ||
|
||
let displayedPages; | ||
if (page <= 2) { | ||
// Display max three pages | ||
displayedPages = Math.min(pages, 3); | ||
} else { | ||
// Display two more pages, but don't overflow | ||
displayedPages = Math.min(pages, page + 2); | ||
} | ||
|
||
const items = []; | ||
|
||
for (let f = 0; f < displayedPages; f++) { | ||
if (f === page) { | ||
items.push(<li className="current">{f + 1}</li>); | ||
} else { | ||
items.push( | ||
<li> | ||
<a | ||
className="SearchResults__footer__link" | ||
onClick={() => onPageSelect(f * settings.show)} | ||
> | ||
{f + 1} | ||
</a> | ||
</li> | ||
); | ||
} | ||
} | ||
|
||
return ( | ||
<div className="SearchResults__footer"> | ||
<ul className="SearchResults__footer__links Pager"> | ||
{start > 0 && ( | ||
<li className="Pager--prev"> | ||
<a | ||
className="SearchResults__footer__link" | ||
onClick={() => onPageSelect(start - settings.show)} | ||
> | ||
{textLinkPrevious} | ||
</a> | ||
</li> | ||
)} | ||
{items} | ||
{page + 1 !== pages && ( | ||
<li className="Pager--next"> | ||
<a | ||
className="SearchResults__footer__link" | ||
onClick={() => onPageSelect(start + settings.show)} | ||
> | ||
{textLinkNext} | ||
</a> | ||
</li> | ||
)} | ||
</ul> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import preact from "preact"; | ||
/** @jsx preact.h */ | ||
|
||
// TODO :: restore highlight | ||
/*function highlightText(search, text) { | ||
if (settings.highlightTerms) { | ||
var pattern = new RegExp( | ||
`(${search})`, | ||
settings.highlightEveryTerm ? "gi" : "i" | ||
); | ||
text = text.replace( | ||
pattern, | ||
'<span class="SearchResults__highlight">$1</span>' | ||
); | ||
} | ||
return text; | ||
}*/ | ||
|
||
export default function Result({ settings, item }) { | ||
let description; | ||
if (item.desc) { | ||
description = item.desc | ||
.split(" ") | ||
.slice(0, settings.descriptiveWords) | ||
.join(" "); | ||
if ( | ||
item.desc.length < description.length && | ||
description.charAt(description.length - 1) !== "." | ||
) { | ||
description += " ..."; | ||
} | ||
} | ||
|
||
return ( | ||
<div className="SearchResult"> | ||
<div className="SearchResults__title"> | ||
<a href={settings.base_url + item.url}>{item.title}</a> | ||
</div> | ||
{settings.debug && ( | ||
<div className="SearchResults__debug">Score: {item.score}</div> | ||
)} | ||
{settings.showURL && ( | ||
<div className="SearchResults__url"> | ||
<a href={settings.base_url + item.url}> | ||
{item.url.toLowerCase().replace(/https?:\/\//g, "")} | ||
</a> | ||
</div> | ||
)} | ||
{description.desc && ( | ||
<div className="SearchResults__text">{description}</div> | ||
)} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.