[build] 4.0.1 next

This commit is contained in:
qingwei.li 2017-05-30 06:34:35 +08:00
commit 3db4841da3
No known key found for this signature in database
GPG key ID: B6DDC2F7AE80B2F4
5 changed files with 36 additions and 36 deletions

View file

@ -47,13 +47,12 @@ function genIndex (path, content, router) {
var tokens = window.marked.lexer(content);
var slugify = window.Docsify.slugify;
var toURL = router.toURL;
var index = {};
var slug;
tokens.forEach(function (token) {
if (token.type === 'heading' && token.depth <= 2) {
slug = toURL(path, { id: slugify(token.text) });
slug = router.toURL(path, { id: slugify(token.text) });
index[slug] = { slug: slug, title: token.text, body: '' };
} else {
if (!slug) { return }
@ -169,13 +168,12 @@ function init$1 (config, vm) {
});
}
var dom;
var NO_DATA_TEXT = '';
function style () {
var code = "\n.sidebar {\n padding-top: 0;\n}\n\n.search {\n margin-bottom: 20px;\n padding: 6px;\n border-bottom: 1px solid #eee;\n}\n\n.search .results-panel {\n display: none;\n}\n\n.search .results-panel.show {\n display: block;\n}\n\n.search input {\n outline: none;\n border: none;\n width: 100%;\n padding: 7px;\n line-height: 22px;\n font-size: 14px;\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n}\n\n.search h2 {\n font-size: 17px;\n margin: 10px 0;\n}\n\n.search a {\n text-decoration: none;\n color: inherit;\n}\n\n.search .matching-post {\n border-bottom: 1px solid #eee;\n}\n\n.search .matching-post:last-child {\n border-bottom: 0;\n}\n\n.search p {\n font-size: 14px;\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n}\n\n.search p.empty {\n text-align: center;\n}";
var style = dom.create('style', code);
dom.appendTo(dom.head, style);
var style = Docsify.dom.create('style', code);
Docsify.dom.appendTo(Docsify.dom.head, style);
}
function tpl (opts, defaultValue) {
@ -185,16 +183,16 @@ function tpl (opts, defaultValue) {
"<input type=\"search\" value=\"" + defaultValue + "\" />" +
'<div class="results-panel"></div>' +
'</div>';
var el = dom.create('div', html);
var aside = dom.find('aside');
var el = Docsify.dom.create('div', html);
var aside = Docsify.dom.find('aside');
dom.toggleClass(el, 'search');
dom.before(aside, el);
Docsify.dom.toggleClass(el, 'search');
Docsify.dom.before(aside, el);
}
function doSearch (value) {
var $search = dom.find('div.search');
var $panel = dom.find($search, '.results-panel');
var $search = Docsify.dom.find('div.search');
var $panel = Docsify.dom.find($search, '.results-panel');
if (!value) {
$panel.classList.remove('show');
@ -213,22 +211,23 @@ function doSearch (value) {
}
function bindEvents () {
var $search = dom.find('div.search');
var $input = dom.find($search, 'input');
var $search = Docsify.dom.find('div.search');
var $input = Docsify.dom.find($search, 'input');
var timeId;
// Prevent to Fold sidebar
dom.on($search, 'click',
Docsify.dom.on($search, 'click',
function (e) { return e.target.tagName !== 'A' && e.stopPropagation(); });
dom.on($input, 'input', function (e) {
Docsify.dom.on($input, 'input', function (e) {
clearTimeout(timeId);
timeId = setTimeout(function (_) { return doSearch(e.target.value.trim()); }, 100);
});
}
function updatePlaceholder (text, path) {
var $input = dom.getNode('.search input[type="search"]');
var $input = Docsify.dom.getNode('.search input[type="search"]');
if (!$input) { return }
if (typeof text === 'string') {
$input.placeholder = text;
} else {
@ -247,7 +246,6 @@ function updateNoData (text, path) {
}
function init$$1 (opts, vm) {
dom = Docsify.dom;
var keywords = vm.router.parse().query.s;
style();