bump: 3.6.6
This commit is contained in:
parent
da75d70dee
commit
dacea8a39b
5 changed files with 36 additions and 24 deletions
|
|
@ -178,9 +178,11 @@ function style () {
|
|||
dom.appendTo(dom.head, style);
|
||||
}
|
||||
|
||||
function tpl (opts) {
|
||||
function tpl (opts, defaultValue) {
|
||||
if ( defaultValue === void 0 ) defaultValue = '';
|
||||
|
||||
var html =
|
||||
"<input type=\"search\" />" +
|
||||
"<input type=\"search\" value=\"" + defaultValue + "\" />" +
|
||||
'<div class="results-panel"></div>' +
|
||||
'</div>';
|
||||
var el = dom.create('div', html);
|
||||
|
|
@ -190,26 +192,29 @@ function tpl (opts) {
|
|||
dom.before(aside, el);
|
||||
}
|
||||
|
||||
function doSearch (value) {
|
||||
var $search = dom.find('div.search');
|
||||
var $panel = dom.find($search, '.results-panel');
|
||||
|
||||
if (!value) {
|
||||
$panel.classList.remove('show');
|
||||
$panel.innerHTML = '';
|
||||
return
|
||||
}
|
||||
var matchs = search(value);
|
||||
|
||||
var html = '';
|
||||
matchs.forEach(function (post) {
|
||||
html += "<div class=\"matching-post\">\n<h2><a href=\"" + (post.url) + "\">" + (post.title) + "</a></h2>\n<p>" + (post.content) + "</p>\n</div>";
|
||||
});
|
||||
|
||||
$panel.classList.add('show');
|
||||
$panel.innerHTML = html || ("<p class=\"empty\">" + NO_DATA_TEXT + "</p>");
|
||||
}
|
||||
|
||||
function bindEvents () {
|
||||
var $search = dom.find('div.search');
|
||||
var $input = dom.find($search, 'input');
|
||||
var $panel = dom.find($search, '.results-panel');
|
||||
var doSearch = function (value) {
|
||||
if (!value) {
|
||||
$panel.classList.remove('show');
|
||||
$panel.innerHTML = '';
|
||||
return
|
||||
}
|
||||
var matchs = search(value);
|
||||
|
||||
var html = '';
|
||||
matchs.forEach(function (post) {
|
||||
html += "<div class=\"matching-post\">\n <h2><a href=\"" + (post.url) + "\">" + (post.title) + "</a></h2>\n <p>" + (post.content) + "</p>\n</div>";
|
||||
});
|
||||
|
||||
$panel.classList.add('show');
|
||||
$panel.innerHTML = html || ("<p class=\"empty\">" + NO_DATA_TEXT + "</p>");
|
||||
};
|
||||
|
||||
var timeId;
|
||||
// Prevent to Fold sidebar
|
||||
|
|
@ -243,9 +248,12 @@ function updateNoData (text, path) {
|
|||
|
||||
function init$$1 (opts) {
|
||||
dom = Docsify.dom;
|
||||
var keywords = Docsify.route.parse().query.s;
|
||||
|
||||
style();
|
||||
tpl(opts);
|
||||
tpl(opts, keywords);
|
||||
bindEvents();
|
||||
keywords && setTimeout(function (_) { return doSearch(keywords); }, 500);
|
||||
}
|
||||
|
||||
function update (opts, vm) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue