提交 86500abd 编写于 作者: C Catouse

* delay 700ms to load page content.

上级 76d1a8f4
...@@ -987,71 +987,73 @@ ...@@ -987,71 +987,73 @@
var lastShowDataCall; var lastShowDataCall;
var pageSh var pageSh
loadData(section.url, function(data){ setTimeout(function(){
var showData = function(){ loadData(section.url, function(data){
if(marked && section.targetType === 'markdown') { var showData = function(){
var $article = $(); if(marked && section.targetType === 'markdown') {
var $markdown = $(marked(data)); var $article = $();
var $lastSection, checkFirstH1 = true; var $markdown = $(marked(data));
var hasH2 = $markdown.filter('h2').length > 0; var $lastSection, checkFirstH1 = true;
$markdown.each(function(){ var hasH2 = $markdown.filter('h2').length > 0;
var $tag = $(this); $markdown.each(function(){
var tagName = $tag.prop('tagName'); var $tag = $(this);
if(tagName === 'STYLE' || tagName === 'SCRIPT') { var tagName = $tag.prop('tagName');
$article = $article.add($tag); if(tagName === 'STYLE' || tagName === 'SCRIPT') {
return; $article = $article.add($tag);
} return;
if(checkFirstH1) {
if(tagName === 'H1') {
$pageHeader.find('h2 > .name').text($tag.html());
}
checkFirstH1 = false;
return;
}
if((hasH2 && (tagName === 'H1' || tagName === 'H2')) || (!hasH2 && tagName === 'H3')) {
if($lastSection) {
$article = $article.add($lastSection);
} }
$lastSection = $('<section><header><h3>' + $tag.html() + '</h3></header><article></article></section>'); if(checkFirstH1) {
} else { if(tagName === 'H1') {
if(hasH2) { $pageHeader.find('h2 > .name').text($tag.html());
if(tagName === 'H3') {
$tag = $('<h4>').html($tag.html());
} else if(tagName === 'H4') {
$tag = $('<h5>').html($tag.html());
} else if(tagName === 'H5') {
$tag = $('<h6>').html($tag.html());
} }
checkFirstH1 = false;
return;
} }
if(!$lastSection) { if((hasH2 && (tagName === 'H1' || tagName === 'H2')) || (!hasH2 && tagName === 'H3')) {
$lastSection = $('<article></article>'); if($lastSection) {
} $article = $article.add($lastSection);
if($lastSection.prop('tagName') === 'ARTICLE') { }
$lastSection.append($tag); $lastSection = $('<section><header><h3>' + $tag.html() + '</h3></header><article></article></section>');
} else { } else {
$lastSection.children('article').append($tag); if(hasH2) {
if(tagName === 'H3') {
$tag = $('<h4>').html($tag.html());
} else if(tagName === 'H4') {
$tag = $('<h5>').html($tag.html());
} else if(tagName === 'H5') {
$tag = $('<h6>').html($tag.html());
}
}
if(!$lastSection) {
$lastSection = $('<article></article>');
}
if($lastSection.prop('tagName') === 'ARTICLE') {
$lastSection.append($tag);
} else {
$lastSection.children('article').append($tag);
}
} }
});
if($lastSection) {
$article = $article.add($lastSection);
} }
}); $pageContent.empty().append($article);
if($lastSection) { } else {
$article = $article.add($lastSection); $pageContent.html(data);
} }
$pageContent.empty().append($article); $pageBody.scrollTop(0);
showPageTopic(topic);
handlePageLoad();
$pageAttrs.show();
}
if($page.hasClass('openning')) {
if(lastShowDataCall) clearTimeout(lastShowDataCall);
lastShowDataCall = setTimeout(showData, 320);
} else { } else {
$pageContent.html(data); showData();
} }
$pageBody.scrollTop(0); });
showPageTopic(topic); }, 700)
handlePageLoad();
$pageAttrs.show();
}
if($page.hasClass('openning')) {
if(lastShowDataCall) clearTimeout(lastShowDataCall);
lastShowDataCall = setTimeout(showData, 320);
} else {
showData();
}
});
if($body.hasClass('page-open')) { if($body.hasClass('page-open')) {
if(debug) console.log('open section in open page', section); if(debug) console.log('open section in open page', section);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册