[build] 4.3.7

This commit is contained in:
qingwei.li 2017-10-02 13:27:15 +08:00
commit 7923608bc9
9 changed files with 1390 additions and 622 deletions

View file

@ -22,23 +22,25 @@ var hyphenate = cached(function (str) {
/**
* Simple Object.assign polyfill
*/
var merge = Object.assign || function (to) {
var arguments$1 = arguments;
var merge =
Object.assign ||
function (to) {
var arguments$1 = arguments;
var hasOwn = Object.prototype.hasOwnProperty;
var hasOwn = Object.prototype.hasOwnProperty;
for (var i = 1; i < arguments.length; i++) {
var from = Object(arguments$1[i]);
for (var i = 1; i < arguments.length; i++) {
var from = Object(arguments$1[i]);
for (var key in from) {
if (hasOwn.call(from, key)) {
to[key] = from[key];
for (var key in from) {
if (hasOwn.call(from, key)) {
to[key] = from[key];
}
}
}
}
return to
};
return to
};
/**
* Check if value is primitive
@ -59,33 +61,38 @@ function isFn (obj) {
return typeof obj === 'function'
}
var config = merge({
el: '#app',
repo: '',
maxLevel: 6,
subMaxLevel: 0,
loadSidebar: null,
loadNavbar: null,
homepage: 'README.md',
coverpage: '',
basePath: '',
auto2top: false,
name: '',
themeColor: '',
nameLink: window.location.pathname,
autoHeader: false,
executeScript: null,
noEmoji: false,
ga: '',
mergeNavbar: false,
formatUpdated: '',
externalLinkTarget: '_blank',
routerMode: 'hash',
noCompileLinks: []
}, window.$docsify);
var config = merge(
{
el: '#app',
repo: '',
maxLevel: 6,
subMaxLevel: 0,
loadSidebar: null,
loadNavbar: null,
homepage: 'README.md',
coverpage: '',
basePath: '',
auto2top: false,
name: '',
themeColor: '',
nameLink: window.location.pathname,
autoHeader: false,
executeScript: null,
noEmoji: false,
ga: '',
mergeNavbar: false,
formatUpdated: '',
externalLinkTarget: '_blank',
routerMode: 'hash',
noCompileLinks: []
},
window.$docsify
);
var script = document.currentScript ||
[].slice.call(document.getElementsByTagName('script'))
var script =
document.currentScript ||
[].slice
.call(document.getElementsByTagName('script'))
.filter(function (n) { return /docsify\./.test(n.src); })[0];
if (script) {
@ -119,7 +126,7 @@ function initLifecycle (vm) {
vm._hooks = {};
vm._lifecycle = {};
hooks.forEach(function (hook) {
var arr = vm._hooks[hook] = [];
var arr = (vm._hooks[hook] = []);
vm._lifecycle[hook] = function (fn) { return arr.push(fn); };
});
}
@ -267,14 +274,20 @@ var isMobile = inBrowser && document.body.clientWidth <= 600;
/**
* @see https://github.com/MoOx/pjax/blob/master/lib/is-supported.js
*/
var supportsPushState = inBrowser && (function () {
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
return window.history &&
window.history.pushState &&
window.history.replaceState &&
// pushState isnt reliable on iOS until 5.
!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/)
})();
var supportsPushState =
inBrowser &&
(function () {
// Borrowed wholesale from https://github.com/defunkt/jquery-pjax
return (
window.history &&
window.history.pushState &&
window.history.replaceState &&
// pushState isnt reliable on iOS until 5.
!navigator.userAgent.match(
/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/
)
)
})();
/**
* Render github corner
@ -287,37 +300,40 @@ function corner (data) {
data = data.replace(/^git\+/, '');
return (
"<a href=\"" + data + "\" class=\"github-corner\" aria-label=\"View source on Github\">" +
"<a href=\"" + data + "\" class=\"github-corner\" aria-label=\"View source on Github\">" +
'<svg viewBox="0 0 250 250" aria-hidden="true">' +
'<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>' +
'<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>' +
'<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>' +
'<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>' +
'<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>' +
'<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path>' +
'</svg>' +
'</a>')
'</a>'
)
}
/**
* Render main content
*/
function main (config) {
var aside = (
var aside =
'<button class="sidebar-toggle">' +
'<div class="sidebar-toggle-button">' +
'<span></span><span></span><span></span>' +
'</div>' +
'<div class="sidebar-toggle-button">' +
'<span></span><span></span><span></span>' +
'</div>' +
'</button>' +
'<aside class="sidebar">' +
(config.name
? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>")
: '') +
'<div class="sidebar-nav"><!--sidebar--></div>' +
'</aside>');
(config.name
? ("<h1><a class=\"app-name-link\" data-nosearch>" + (config.name) + "</a></h1>")
: '') +
'<div class="sidebar-nav"><!--sidebar--></div>' +
'</aside>';
return (isMobile ? (aside + "<main>") : ("<main>" + aside)) +
'<section class="content">' +
'<article class="markdown-section" id="main"><!--main--></article>' +
'</section>' +
return (
(isMobile ? (aside + "<main>") : ("<main>" + aside)) +
'<section class="content">' +
'<article class="markdown-section" id="main"><!--main--></article>' +
'</section>' +
'</main>'
)
}
/**
@ -325,14 +341,17 @@ function main (config) {
*/
function cover () {
var SL = ', 100%, 85%';
var bgc = 'linear-gradient(to left bottom, ' +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
var bgc =
'linear-gradient(to left bottom, ' +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 0%," +
"hsl(" + (Math.floor(Math.random() * 255) + SL) + ") 100%)";
return "<section class=\"cover\" style=\"background: " + bgc + "\">" +
return (
"<section class=\"cover\" style=\"background: " + bgc + "\">" +
'<div class="cover-main"></div>' +
'<div class="mask"></div>' +
'</section>'
'</section>'
)
}
/**
@ -437,9 +456,12 @@ function get (url, hasBar) {
if ( error === void 0 ) error = noop;
if (hasBar) {
var id = setInterval(function (_) { return progressbar({
step: Math.floor(Math.random() * 5 + 1)
}); }, 500);
var id = setInterval(
function (_) { return progressbar({
step: Math.floor(Math.random() * 5 + 1)
}); },
500
);
on('progress', progressbar);
on('loadend', function (evt) {
@ -455,12 +477,12 @@ function get (url, hasBar) {
if (target.status >= 400) {
error(target);
} else {
var result = cache[url] = {
var result = (cache[url] = {
content: target.response,
opt: {
updatedAt: xhr.getResponseHeader('last-modified')
}
};
});
success(result.content, result.opt);
}
@ -471,15 +493,15 @@ function get (url, hasBar) {
}
function replaceVar (block, color) {
block.innerHTML = block.innerHTML
.replace(/var\(\s*--theme-color.*?\)/g, color);
block.innerHTML = block.innerHTML.replace(
/var\(\s*--theme-color.*?\)/g,
color
);
}
var cssVars = function (color) {
// Variable support
if (window.CSS &&
window.CSS.supports &&
window.CSS.supports('(--v:red)')) { return }
if (window.CSS && window.CSS.supports && window.CSS.supports('(--v:red)')) { return }
var styleBlocks = findAll('style:not(.inserted),link');[].forEach.call(styleBlocks, function (block) {
if (block.nodeName === 'STYLE') {
@ -2675,7 +2697,10 @@ var re = /[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g;
function slugify (str) {
if (typeof str !== 'string') { return '' }
var slug = str.toLowerCase().trim()
str = /^[\w\s]+$/g.test(str) ? str.toLowerCase() : str;
var slug = str
.trim()
.replace(/<[^>\d]+>/g, '')
.replace(re, '')
.replace(/\s/g, '-')
@ -2683,7 +2708,7 @@ function slugify (str) {
.replace(/^(\d)/, '_$1');
var count = cache$1[slug];
count = cache$1.hasOwnProperty(slug) ? (count + 1) : 0;
count = cache$1.hasOwnProperty(slug) ? count + 1 : 0;
cache$1[slug] = count;
if (count) {
@ -2734,9 +2759,11 @@ function stringifyQuery (obj) {
var qs = [];
for (var key in obj) {
qs.push(obj[key]
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
: encode(key));
qs.push(
obj[key]
? ((encode(key)) + "=" + (encode(obj[key]))).toLowerCase()
: encode(key)
);
}
return qs.length ? ("?" + (qs.join('&'))) : ''
@ -2756,15 +2783,11 @@ var isAbsolutePath = cached(function (path) {
var getParentPath = cached(function (path) {
return /\/$/g.test(path)
? path
: (path = path.match(/(\S*\/)[^\/]+$/))
? path[1]
: ''
: (path = path.match(/(\S*\/)[^\/]+$/)) ? path[1] : ''
});
var cleanPath = cached(function (path) {
return path
.replace(/^\/+/, '/')
.replace(/([^:])\/{2,}/g, '$1/')
return path.replace(/^\/+/, '/').replace(/([^:])\/{2,}/g, '$1/')
});
var cachedLinks = {};
@ -2983,8 +3006,12 @@ function btn (el, router) {
var sidebar = getNode('.sidebar');
isMobile && on(body, 'click', function (_) { return body.classList.contains('close') && toggle(); }
);
isMobile &&
on(
body,
'click',
function (_) { return body.classList.contains('close') && toggle(); }
);
on(sidebar, 'click', function (_) { return setTimeout((function (_) { return getAndActive(router, sidebar, true, true); }, 0)); }
);
}
@ -3016,19 +3043,17 @@ function getAndActive (router, el, isParent, autoTitle) {
var hash = router.toURL(router.getCurrentPath());
var target;
links
.sort(function (a, b) { return b.href.length - a.href.length; })
.forEach(function (a) {
var href = a.getAttribute('href');
var node = isParent ? a.parentNode : a;
links.sort(function (a, b) { return b.href.length - a.href.length; }).forEach(function (a) {
var href = a.getAttribute('href');
var node = isParent ? a.parentNode : a;
if (hash.indexOf(href) === 0 && !target) {
target = a;
toggleClass(node, 'add', 'active');
} else {
toggleClass(node, 'remove', 'active');
}
});
if (hash.indexOf(href) === 0 && !target) {
target = a;
toggleClass(node, 'add', 'active');
} else {
toggleClass(node, 'remove', 'active');
}
});
if (autoTitle) {
$.title = target ? ((target.innerText) + " - " + title) : title;
@ -3146,9 +3171,12 @@ function scrollTo (el) {
end: el.getBoundingClientRect().top + window.scrollY,
duration: 500
})
.on('tick', function (v) { return window.scrollTo(0, v); })
.on('done', function () { enableScrollEvent = true; scroller = null; })
.begin();
.on('tick', function (v) { return window.scrollTo(0, v); })
.on('done', function () {
enableScrollEvent = true;
scroller = null;
})
.begin();
}
function highlight () {
@ -3158,7 +3186,7 @@ function highlight () {
var wrap = find(sidebar, '.sidebar-nav');
var active = find(sidebar, 'li.active');
var doc = document.documentElement;
var top = (doc && doc.scrollTop || document.body.scrollTop) - coverHeight;
var top = ((doc && doc.scrollTop) || document.body.scrollTop) - coverHeight;
var last;
for (var i = 0, len = anchors.length; i < len; i += 1) {
@ -3186,16 +3214,10 @@ function highlight () {
var height = sidebar.clientHeight;
var curOffset = 0;
var cur = active.offsetTop + active.clientHeight + 40;
var isInView = (
active.offsetTop >= wrap.scrollTop &&
cur <= wrap.scrollTop + height
);
var isInView =
active.offsetTop >= wrap.scrollTop && cur <= wrap.scrollTop + height;
var notThan = cur - curOffset < height;
var top$1 = isInView
? wrap.scrollTop
: notThan
? curOffset
: cur - height;
var top$1 = isInView ? wrap.scrollTop : notThan ? curOffset : cur - height;
sidebar.scrollTop = top$1;
}
@ -3225,8 +3247,12 @@ function scrollActiveSidebar (router) {
off('scroll', highlight);
on('scroll', highlight);
on(sidebar, 'mouseover', function () { hoverOver = true; });
on(sidebar, 'mouseleave', function () { hoverOver = false; });
on(sidebar, 'mouseover', function () {
hoverOver = true;
});
on(sidebar, 'mouseleave', function () {
hoverOver = false;
});
}
function scrollIntoView (id) {
@ -3477,15 +3503,15 @@ function getAlias (path, alias, last) {
return re.test(path) && path !== last
})[0];
return match ? getAlias(path.replace(cached$1[match], alias[match]), alias, path) : path
return match
? getAlias(path.replace(cached$1[match], alias[match]), alias, path)
: path
}
function getFileName (path) {
return /\.(md|html)$/g.test(path)
? path
: /\/$/g.test(path)
? (path + "README.md")
: (path + ".md")
: /\/$/g.test(path) ? (path + "README.md") : (path + ".md")
}
var History = function History (config) {
@ -3505,7 +3531,7 @@ History.prototype.getFile = function getFile (path, isRelative) {
path = config.alias ? getAlias(path, config.alias) : path;
path = getFileName(path);
path = path === '/README.md' ? (config.homepage || path) : path;
path = path === '/README.md' ? config.homepage || path : path;
path = isAbsolutePath(path) ? path : getPath(base, path);
if (isRelative) {
@ -3531,9 +3557,7 @@ History.prototype.toURL = function toURL () {};
function replaceHash (path) {
var i = location.href.indexOf('#');
location.replace(
location.href.slice(0, i >= 0 ? i : 0) + '#' + path
);
location.replace(location.href.slice(0, i >= 0 ? i : 0) + '#' + path);
}
var replaceSlug = cached(function (path) {
@ -3554,9 +3578,7 @@ var HashHistory = (function (History$$1) {
var path = window.location.pathname || '';
var base = this.config.basePath;
return /^(\/|https?:)/g.test(base)
? base
: cleanPath(path + '/' + base)
return /^(\/|https?:)/g.test(base) ? base : cleanPath(path + '/' + base)
};
HashHistory.prototype.getCurrentPath = function getCurrentPath () {
@ -3651,9 +3673,7 @@ var HTML5History = (function (History$$1) {
if ( cb === void 0 ) cb = noop;
on('click', function (e) {
var el = e.target.tagName === 'A'
? e.target
: e.target.parentNode;
var el = e.target.tagName === 'A' ? e.target : e.target.parentNode;
if (el.tagName === 'A' && !/_blank/.test(el.target)) {
e.preventDefault();
@ -3956,7 +3976,7 @@ initGlobalAPI();
/**
* Version
*/
Docsify.version = '4.3.6';
Docsify.version = '4.3.7';
/**
* Run Docsify