From b421b47e18c923cca338989401c35c5d914ca927 Mon Sep 17 00:00:00 2001 From: ppoffice Date: Mon, 8 Feb 2016 20:20:35 +0800 Subject: [PATCH] chore: minor fixes --- .editorconfig | 19 ---------- Gruntfile.js | 46 ------------------------ package.json | 11 ++---- source/js/main.js | 89 ++++++++++++++++++++++++----------------------- 4 files changed, 47 insertions(+), 118 deletions(-) delete mode 100644 .editorconfig delete mode 100644 Gruntfile.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e5a4f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,19 +0,0 @@ -# EditorConfig is awesome: http://EditorConfig.org - -# top-most EditorConfig file -root = true - -# Unix-style newlines with a newline ending every file -[*] -end_of_line = lf -insert_final_newline = true - -# Matches multiple files with brace expansion notation -# Set default charset -[*.{js,py}] -charset = utf-8 - -# 4 space indentation -[{*.json,*.yml,*.styl,*.ejs}] -indent_style = space -indent_size = 2 diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 59fd5df..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,46 +0,0 @@ -module.exports = function(grunt){ - grunt.initConfig({ - gitclone: { - fontawesome: { - options: { - repository: 'https://github.com/FortAwesome/Font-Awesome.git', - directory: 'tmp/fontawesome' - }, - }, - fancybox: { - options: { - repository: 'https://github.com/fancyapps/fancyBox.git', - directory: 'tmp/fancybox' - } - } - }, - copy: { - fontawesome: { - expand: true, - cwd: 'tmp/fontawesome/fonts/', - src: ['**'], - dest: 'source/css/fonts/' - }, - fancybox: { - expand: true, - cwd: 'tmp/fancybox/source/', - src: ['**'], - dest: 'source/fancybox/' - } - }, - _clean: { - tmp: ['tmp'], - fontawesome: ['source/css/fonts'], - fancybox: ['source/fancybox'] - } - }); - - require('load-grunt-tasks')(grunt); - - grunt.renameTask('clean', '_clean'); - - grunt.registerTask('fontawesome', ['gitclone:fontawesome', 'copy:fontawesome', '_clean:tmp']); - grunt.registerTask('fancybox', ['gitclone:fancybox', 'copy:fancybox', '_clean:tmp']); - grunt.registerTask('default', ['gitclone', 'copy', '_clean:tmp']); - grunt.registerTask('clean', ['_clean']); -}; \ No newline at end of file diff --git a/package.json b/package.json index 27d9f88..285fdaa 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,5 @@ { "name": "hexo-theme-icarus", - "version": "0.0.1", - "private": true, - "devDependencies": { - "grunt": "~0.4.2", - "load-grunt-tasks": "~0.2.0", - "grunt-git": "~0.2.2", - "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-copy": "~0.4.1" - } + "version": "0.2.0", + "private": true } diff --git a/source/js/main.js b/source/js/main.js index 752fbd6..bb38c99 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -1,52 +1,53 @@ (function($){ - var toTop = $('#toTop').length ? $('#toTop').offset().top - $(window).height() + 20 : 0; + var toTop = $('#toTop').length ? $('#toTop').offset().top - $(window).height() + 20 : 0; - // Caption - $('.article-entry').each(function(i){ - $(this).find('img').each(function(){ - if ($(this).parent().hasClass('fancybox')) return; + // Caption + $('.article-entry').each(function(i){ + $(this).find('img').each(function(){ + if ($(this).parent().hasClass('fancybox')) { + return; + } + var alt = this.alt; + if (alt) { + $(this).after('' + alt + ''); + } - var alt = this.alt; + $(this).wrap(''); + }); - if (alt) $(this).after('' + alt + ''); - - $(this).wrap(''); + $(this).find('.fancybox').each(function(){ + $(this).attr('rel', 'article' + i); + }); }); - - $(this).find('.fancybox').each(function(){ - $(this).attr('rel', 'article' + i); - }); - }); - - if ($.fancybox){ - $('.fancybox').fancybox(); - } - - // 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(); - }); - - // To Top - $(document).on('scroll', function () { - if ($(document).width() >= 800) { - if($(this).scrollTop() > toTop) { - $('#toTop').addClass('fix'); - $('#toTop').css('left', $('#sidebar').offset().left); - } else { - $('#toTop').removeClass('fix'); - } - } else { - $('#toTop').addClass('fix'); - $('#toTop').css('right', 20); + if ($.fancybox){ + $('.fancybox').fancybox(); } - }).on('click', '#toTop', function () { - $(document).scrollTop(0); - }); + + // 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(); + }); + + // To Top + $(document).on('scroll', function () { + if ($(document).width() >= 800) { + if($(this).scrollTop() > toTop) { + $('#toTop').addClass('fix'); + $('#toTop').css('left', $('#sidebar').offset().left); + } else { + $('#toTop').removeClass('fix'); + } + } else { + $('#toTop').addClass('fix'); + $('#toTop').css('right', 20); + } + }).on('click', '#toTop', function () { + $('body, html').animate({ scrollTop: 0 }, 600); + }); })(jQuery); \ No newline at end of file