hexo-theme-amane/source/js/main.js

60 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-02-02 16:19:44 +00:00
(function($){
var toTop = ($('#sidebar').height() - $(window).height()) + 60;
2016-02-08 12:20:35 +00:00
// Caption
$('.article-entry').each(function(i) {
$(this).find('img').each(function() {
if (this.alt) {
$(this).after('<span class="caption">' + this.alt + '</span>');
2016-02-08 12:20:35 +00:00
}
$(this).wrap('<a href="' + this.src + '" title="' + this.alt + '" class="gallery-item"></a>');
2016-02-08 12:20:35 +00:00
});
2016-02-02 16:19:44 +00:00
});
if (lightGallery) {
var options = {
selector: '.gallery-item',
};
lightGallery($('.article-entry')[0], options);
lightGallery($('.article-gallery')[0], options);
2016-02-08 12:20:35 +00:00
}
if (!!$.prototype.justifiedGallery) { // if justifiedGallery method is defined
var options = {
rowHeight: 140,
margins: 4,
lastRow: 'justify'
};
$('.justified-gallery').justifiedGallery(options);
}
2016-02-02 16:19:44 +00:00
2016-02-08 12:20:35 +00:00
// Profile card
$(document).on('click', function () {
$('#profile').removeClass('card');
}).on('click', '#profile-anchor', function (e) {
e.stopPropagation();
$('#profile').toggleClass('card');
}).on('click', '.profile-inner', function (e) {
e.stopPropagation();
2016-02-02 16:19:44 +00:00
});
2016-02-08 12:20:35 +00:00
// To Top
if ($('#sidebar').length) {
$(document).on('scroll', function () {
if ($(document).width() >= 800) {
if(($(this).scrollTop() > toTop) && ($(this).scrollTop() > 0)) {
$('#toTop').fadeIn();
$('#toTop').css('left', $('#sidebar').offset().left);
} else {
$('#toTop').fadeOut();
}
2016-02-08 12:20:35 +00:00
} else {
$('#toTop').fadeIn();
$('#toTop').css('right', 20);
2016-02-08 12:20:35 +00:00
}
}).on('click', '#toTop', function () {
$('body, html').animate({ scrollTop: 0 }, 600);
});
}
2016-02-02 16:19:44 +00:00
})(jQuery);