提交 bf69f1ea 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

style: Format code

上级 3a08c20b
a.fancybox
clearAStyle()
cursor: zoom-in
.post-gallery
display: grid
grid-template-columns: repeat(3, auto)
grid-gap: 10px 10px
......@@ -2,6 +2,7 @@
@import './reward.styl' if (hexo-config('reward.enable'))
@import './back2top.styl' if (hexo-config('back2top.enable'))
@import './external-link.styl' if (hexo-config('external_link.icon.enable'))
@import './fancybox.styl' if (hexo-config('fancybox'))
@import './recent-posts.styl'
@import './pagination.styl'
@import './comments.styl'
......
$(document).ready(function test () {
$(document).ready(function () {
var CODEBLOCK_CLASS_NAME = 'highlight';
var $codeBlocks = $('figure.highlight');
$codeBlocks.each(function test (index, item) {
if (!$(item).find('figcaption')[0]) {
var lang = item
$codeBlocks.each(function () {
if (!$(this).find('figcaption')[0]) {
var lang = this
.getAttribute('class')
.split(/\s/)
.filter(function (e) { return e !== CODEBLOCK_CLASS_NAME; });
......@@ -14,7 +14,7 @@ $(document).ready(function test () {
'</figcaption>'
)[0];
item.insertBefore(codeHeader, $(item).children().first()[0]);
this.insertBefore(codeHeader, $(this).children().first()[0]);
}
});
......
......@@ -63,7 +63,8 @@ $(document).ready(function () {
// based on the scrolling of heading in the article.
function autoSpreadToc () {
var $postBody = $('.post-body');
var $firsetChild = $postBody.find('h1,h2,h3,h4,h5,h6').first();
var $headings = $postBody.find('h1,h2,h3,h4,h5,h6');
var $firsetChild = $headings.first();
// All heading are not to the top.
if ($postBody[0] && (!!$firsetChild[0] &&
......@@ -73,9 +74,9 @@ $(document).ready(function () {
return;
}
$postBody.find('h1,h2,h3,h4,h5,h6').each(function (index, item) {
if (item && item.getBoundingClientRect().top < 0) {
currHeading = $(item).attr('id');
$headings.each(function () {
if (this.getBoundingClientRect().top < 0) {
currHeading = $(this).attr('id');
}
});
......@@ -106,12 +107,14 @@ $(document).ready(function () {
}
if (isTocScroll) {
$currLink.velocity('stop').velocity('scroll', {
container: $toc,
offset: -($toc.height() / 2),
duration: 500,
easing: 'easeOutQuart'
});
$currLink
.velocity('stop')
.velocity('scroll', {
container: $toc,
offset: -($toc.height() / 2),
duration: 500,
easing: 'easeOutQuart'
});
}
}
......@@ -170,7 +173,8 @@ $(document).ready(function () {
// Update the reading progress lines of post.
function readProgress () {
var $post = $('.content');
var scrollH = ($post[0] && $post[0].getBoundingClientRect().top * -1) || 0;
var scrollH = ($post[0] &&
$post[0].getBoundingClientRect().top * -1) || 0;
var percent = parseInt((scrollH /
Math.abs($post.height() - $(window).height())) * 100);
......
......@@ -2,7 +2,7 @@ $(document).ready(function () {
CONFIG.shortcuts.switch_post && Stun.utils.registerSwitchPost();
CONFIG.back2top && Stun.utils.back2Top();
CONFIG.reward && Stun.utils.registerShowReward();
CONFIG.fancybox && CONFIG.utils.wrapImageWithFancyBox();
CONFIG.fancybox && Stun.utils.wrapImageWithFancyBox();
if (CONFIG.external_link.icon) {
var EXTERNAL_LINK_CONTAINER = '.content, #footer';
......
......@@ -152,24 +152,24 @@ Stun.utils = Stun.$u = {
},
// Adjust the size of images by the parameter "size".
adjustImageSize: function () {
$('img').each(function (index, img) {
if (img.src.includes('?size=')) {
var size = img.src.split('?size=')[1] &&
img.src.split('?size=')[1].toLowerCase();
$('img').each(function () {
if (this.src.includes('?size=')) {
var size = this.src.split('?size=')[1] &&
this.src.split('?size=')[1].toLowerCase();
var w = size.split('x')[0];
var h = size.split('x')[1];
$(img).css('width', w);
$(img).css('height', h);
$(this).css('width', w);
$(this).css('height', h);
}
});
},
/**
* Add a mark icon to the link with `target="_blank"` attribute.
* @param {String} selector Any Jquery selector.
* @param {String} wrapper Any Jquery wrapper.
*/
addIconToExternalLink: function (selector) {
if (!$(selector)[0]) return;
addIconToExternalLink: function (wrapper) {
if (!$(wrapper)[0]) return;
var $icon = $(
'<i class="external-link fa fa-' +
......@@ -177,10 +177,10 @@ Stun.utils = Stun.$u = {
'"></i>'
);
// Insert icon after link.
// $icon.insertAfter($(selector).find('a[target="_blank"]'));
// $icon.insertAfter($(wrapper).find('a[target="_blank"]'));
// Insert icon inner link.
$(selector).find('a[target="_blank"]').append($icon);
$(wrapper).find('a[target="_blank"]').append($icon);
},
// Back the page to top.
back2Top: function () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册