From c8e612b888cf3bb16ac4b6f7f1ea911f98a6afc3 Mon Sep 17 00:00:00 2001 From: Dillon Date: Wed, 29 Jan 2020 22:16:50 +0800 Subject: [PATCH] feat(aplayer): add dark-mode for APlayer and fix Typeit bug --- assets/css/_partial/_post/_code.scss | 117 +++++++++++----------- assets/css/lib/aplayer/Aplayer.dark.scss | 114 +++++++++++++++++++++ assets/css/style.scss | 3 +- assets/js/blog.js | 7 +- assets/js/lib/VERSION | 2 +- assets/js/lib/typeit/typeit.min.js | 10 ++ assets/js/lib/typeit/typeit.modern.min.js | 10 -- exampleSite/config.toml | 2 +- layouts/partials/scripts.html | 6 +- layouts/shortcodes/typeit.html | 2 +- 10 files changed, 197 insertions(+), 76 deletions(-) create mode 100644 assets/css/lib/aplayer/Aplayer.dark.scss create mode 100644 assets/js/lib/typeit/typeit.min.js delete mode 100644 assets/js/lib/typeit/typeit.modern.min.js diff --git a/assets/css/_partial/_post/_code.scss b/assets/css/_partial/_post/_code.scss index 1b30216b..d43d256f 100644 --- a/assets/css/_partial/_post/_code.scss +++ b/assets/css/_partial/_post/_code.scss @@ -117,9 +117,11 @@ p > code { background-color: darken($code-background-color-dark, 5%); } } - /* P */ .chroma .p { color: #A9A9B3 } +} - /* Keyword */ .k { color: #859900 } +.code { + /* Parentheses */ .p { color: #A9A9B3 } + /* Keyword */ .k { color: #859900 } /* KeywordConstant */ .kc { color: #859900; font-weight: bold } /* KeywordDeclaration */ .kd { color: #859900 } /* KeywordNamespace */ .kn { color: #dc322f; font-weight: bold } @@ -193,60 +195,61 @@ p > code { .dark-theme & { background: $code-background-color-dark; - /* Keyword */ .chroma .k { color: #D371E3 } - /* KeywordConstant */ .chroma .kc { color: #D371E3 } - /* KeywordDeclaration */ .chroma .kd { color: #D371E3 } - /* KeywordNamespace */ .chroma .kn { color: #D371E3 } - /* KeywordPseudo */ .chroma .kp { color: #D371E3 } - /* KeywordReserved */ .chroma .kr { color: #D371E3 } - /* KeywordType */ .chroma .kt { color: #8be9fd } - /* NameAttribute */ .chroma .na { color: #41B1F5 } - /* NameBuiltin */ .chroma .nb { color: #8be9fd; font-style: italic } - /* NameClass */ .chroma .nc { color: #E5BF78 } - /* NameFunction */ .chroma .nf { color: #19B8C0 } - /* NameX */ .chroma .nx { color: #F16473 } - /* NameLabel */ .chroma .nl { color: #8be9fd; font-style: italic } - /* NameTag */ .chroma .nt { color: #D371E3 } - /* NameVariable */ .chroma .nv { color: #8be9fd; font-style: italic } - /* NameVariableClass */ .chroma .vc { color: #8be9fd; font-style: italic } - /* NameVariableGlobal */ .chroma .vg { color: #8be9fd; font-style: italic } - /* NameVariableInstance */ .chroma .vi { color: #8be9fd; font-style: italic } - /* LiteralString */ .chroma .s { color: #8BC56F } - /* LiteralStringAffix */ .chroma .sa { color: #8BC56F } - /* LiteralStringBacktick */ .chroma .sb { color: #8BC56F } - /* LiteralStringChar */ .chroma .sc { color: #8BC56F } - /* LiteralStringDelimiter */ .chroma .dl { color: #8BC56F } - /* LiteralStringDoc */ .chroma .sd { color: #8BC56F } - /* LiteralStringDouble */ .chroma .s2 { color: #8BC56F } - /* LiteralStringEscape */ .chroma .se { color: #8BC56F } - /* LiteralStringHeredoc */ .chroma .sh { color: #8BC56F } - /* LiteralStringInterpol */ .chroma .si { color: #8BC56F } - /* LiteralStringOther */ .chroma .sx { color: #8BC56F } - /* LiteralStringRegex */ .chroma .sr { color: #8BC56F } - /* LiteralStringSingle */ .chroma .s1 { color: #8BC56F } - /* LiteralStringSymbol */ .chroma .ss { color: #8BC56F } - /* LiteralNumber */ .chroma .m { color: #bd93f9 } - /* LiteralNumberBin */ .chroma .mb { color: #bd93f9 } - /* LiteralNumberFloat */ .chroma .mf { color: #bd93f9 } - /* LiteralNumberHex */ .chroma .mh { color: #bd93f9 } - /* LiteralNumberInteger */ .chroma .mi { color: #bd93f9 } - /* LiteralNumberIntegerLong */ .chroma .il { color: #bd93f9 } - /* LiteralNumberOct */ .chroma .mo { color: #bd93f9 } - /* Operator */ .chroma .o { color: #D371E3 } - /* OperatorWord */ .chroma .ow { color: #D371E3 } - /* Comment */ .chroma .c { color: #7E848F } - /* CommentHashbang */ .chroma .ch { color: #7E848F } - /* CommentMultiline */ .chroma .cm { color: #7E848F } - /* CommentSingle */ .chroma .c1 { color: #7E848F } - /* CommentSpecial */ .chroma .cs { color: #7E848F } - /* CommentPreproc */ .chroma .cp { color: #D371E3 } - /* CommentPreprocFile */ .chroma .cpf { color: #D371E3 } - /* GenericDeleted */ .chroma .gd { color: #8b080b } - /* GenericEmph */ .chroma .ge { text-decoration: underline } - /* GenericHeading */ .chroma .gh { font-weight: bold } - /* GenericInserted */ .chroma .gi { font-weight: bold } - /* GenericOutput */ .chroma .go { color: #44475a } - /* GenericSubheading */ .chroma .gu { font-weight: bold } - /* GenericUnderline */ .chroma .gl { text-decoration: underline } + /* Parentheses */ .p { color: #A9A9B3 } + /* Keyword */ .k { color: #D371E3 } + /* KeywordConstant */ .kc { color: #D371E3 } + /* KeywordDeclaration */ .kd { color: #D371E3 } + /* KeywordNamespace */ .kn { color: #D371E3 } + /* KeywordPseudo */ .kp { color: #D371E3 } + /* KeywordReserved */ .kr { color: #D371E3 } + /* KeywordType */ .kt { color: #8be9fd } + /* NameAttribute */ .na { color: #41B1F5 } + /* NameBuiltin */ .nb { color: #8be9fd; font-style: italic } + /* NameClass */ .nc { color: #E5BF78 } + /* NameFunction */ .nf { color: #19B8C0 } + /* NameX */ .nx { color: #F16473 } + /* NameLabel */ .nl { color: #8be9fd; font-style: italic } + /* NameTag */ .nt { color: #D371E3 } + /* NameVariable */ .nv { color: #8be9fd; font-style: italic } + /* NameVariableClass */ .vc { color: #8be9fd; font-style: italic } + /* NameVariableGlobal */ .vg { color: #8be9fd; font-style: italic } + /* NameVariableInstance */ .vi { color: #8be9fd; font-style: italic } + /* LiteralString */ .s { color: #8BC56F } + /* LiteralStringAffix */ .sa { color: #8BC56F } + /* LiteralStringBacktick */ .sb { color: #8BC56F } + /* LiteralStringChar */ .sc { color: #8BC56F } + /* LiteralStringDelimiter */ .dl { color: #8BC56F } + /* LiteralStringDoc */ .sd { color: #8BC56F } + /* LiteralStringDouble */ .s2 { color: #8BC56F } + /* LiteralStringEscape */ .se { color: #8BC56F } + /* LiteralStringHeredoc */ .sh { color: #8BC56F } + /* LiteralStringInterpol */ .si { color: #8BC56F } + /* LiteralStringOther */ .sx { color: #8BC56F } + /* LiteralStringRegex */ .sr { color: #8BC56F } + /* LiteralStringSingle */ .s1 { color: #8BC56F } + /* LiteralStringSymbol */ .ss { color: #8BC56F } + /* LiteralNumber */ .m { color: #bd93f9 } + /* LiteralNumberBin */ .mb { color: #bd93f9 } + /* LiteralNumberFloat */ .mf { color: #bd93f9 } + /* LiteralNumberHex */ .mh { color: #bd93f9 } + /* LiteralNumberInteger */ .mi { color: #bd93f9 } + /* LiteralNumberIntegerLong */ .il { color: #bd93f9 } + /* LiteralNumberOct */ .mo { color: #bd93f9 } + /* Operator */ .o { color: #D371E3 } + /* OperatorWord */ .ow { color: #D371E3 } + /* Comment */ .c { color: #7E848F } + /* CommentHashbang */ .ch { color: #7E848F } + /* CommentMultiline */ .cm { color: #7E848F } + /* CommentSingle */ .c1 { color: #7E848F } + /* CommentSpecial */ .cs { color: #7E848F } + /* CommentPreproc */ .cp { color: #D371E3 } + /* CommentPreprocFile */ .cpf { color: #D371E3 } + /* GenericDeleted */ .gd { color: #8b080b } + /* GenericEmph */ .ge { text-decoration: underline } + /* GenericHeading */ .gh { font-weight: bold } + /* GenericInserted */ .gi { font-weight: bold } + /* GenericOutput */ .go { color: #44475a } + /* GenericSubheading */ .gu { font-weight: bold } + /* GenericUnderline */ .gl { text-decoration: underline } } } diff --git a/assets/css/lib/aplayer/Aplayer.dark.scss b/assets/css/lib/aplayer/Aplayer.dark.scss new file mode 100644 index 00000000..92de45ae --- /dev/null +++ b/assets/css/lib/aplayer/Aplayer.dark.scss @@ -0,0 +1,114 @@ +.aplayer { + .dark-theme & { + background: #212121; + + &.aplayer-withlist { + .aplayer-info { + border-bottom-color: #5c5c5c; + } + } + + &.aplayer-fixed { + .aplayer-list { + border-color: #5c5c5c; + } + } + + .aplayer-body { + background-color: #212121; + } + + .aplayer-info { + border-top-color: #212121; + } + + .aplayer-info { + .aplayer-music { + .aplayer-title { + color: #fff; + } + + .aplayer-author { + color: #fff; + } + } + + .aplayer-controller { + .aplayer-time { + color: #eee; + + .aplayer-icon { + path { + fill: #eee; + } + } + } + } + } + + .aplayer-list { + background-color: #212121; + + &::-webkit-scrollbar-thumb { + background-color: #999; + } + + &::-webkit-scrollbar-thumb:hover { + background-color: #bbb; + } + + li { + color: #fff; + border-top-color: #666; + + &:hover { + background: #4e4e4e; + } + + &.aplayer-list-light { + background: #6c6c6c; + } + + .aplayer-list-index { + color: #ddd; + } + + .aplayer-list-author { + color: #ddd; + } + } + } + + .aplayer-lrc { + text-shadow: -1px -1px 0 #666; + + &:before { + background: -moz-linear-gradient(top, rgba(33,33,33,1) 0%, rgba(255,255,255,0) 100%); + background: -webkit-linear-gradient(top, rgba(33,33,33,1) 0%,rgba(255,255,255,0) 100%); + background: linear-gradient(to bottom, rgba(33,33,33,1) 0%,rgba(255,255,255,0) 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#212121', endColorstr='#00212121',GradientType=0 ); + } + + &:after { + background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(33,33,33,0.8) 100%); + background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(33,33,33,0.8) 100%); + background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(33,33,33,0.8) 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00212121', endColorstr='#cc212121',GradientType=0 ); + } + + p { + color: #fff; + } + } + + .aplayer-miniswitcher { + background: #484848; + + .aplayer-icon { + path { + fill: #eee; + } + } + } + } +} diff --git a/assets/css/style.scss b/assets/css/style.scss index 8b89ae7c..d3f4d0a8 100644 --- a/assets/css/style.scss +++ b/assets/css/style.scss @@ -1,4 +1,3 @@ -@import "_custom"; @import "_variables"; @import "_core/normalize"; @@ -12,3 +11,5 @@ @import "_partial/pagination"; @import "_core/media"; + +@import "_custom"; diff --git a/assets/js/blog.js b/assets/js/blog.js index 4387e0ee..be869656 100644 --- a/assets/js/blog.js +++ b/assets/js/blog.js @@ -269,15 +269,16 @@ jQuery(function($) { if (window.typeitArr) { for (let i = 0; i < typeitArr.length; i++) { const group = typeitArr[i]; - (function typeone (i) { + (function typeone(i) { + const content = document.getElementById(`r${group[i]}`).innerHTML; if (i === group.length - 1) { new TypeIt(`#${group[i]}`, { - strings: document.getElementById(`r${group[i]}`).innerHTML, + strings: content, }).go(); return; } let instance = new TypeIt(`#${group[i]}`, { - strings: document.getElementById(`r${group[i]}`).innerHTML, + strings: content, afterComplete: () => { instance.destroy(); typeone(i + 1); diff --git a/assets/js/lib/VERSION b/assets/js/lib/VERSION index 6317b4fc..77dc0ee5 100644 --- a/assets/js/lib/VERSION +++ b/assets/js/lib/VERSION @@ -5,7 +5,7 @@ lazysizes@5.1.2 katex@0.11.1 mermaid@8.4.2 echarts@4.5.0 -typeit@6.1.1 +typeit@6.0.3 jquery-countdown@2.2.0 aplayer@1.10.1 meting@2.0.1 diff --git a/assets/js/lib/typeit/typeit.min.js b/assets/js/lib/typeit/typeit.min.js new file mode 100644 index 00000000..3e49dc3d --- /dev/null +++ b/assets/js/lib/typeit/typeit.min.js @@ -0,0 +1,10 @@ +/*! + * + * typeit - The most versatile animated typing utility on the planet. + * Author: Alex MacArthur (https://macarthur.me) + * Version: v6.0.3 + * URL: https://typeitjs.com + * License: GPL-2.0 + * + */ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TypeIt=e():t.TypeIt=e()}(this,function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";n.r(e);var i={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:null,html:!0,waitUntilVisible:!1,beforeString:!1,afterString:!1,beforeStep:!1,afterStep:!1,afterComplete:!1};function r(t){var e=t.getBoundingClientRect();return!(e.right>window.innerWidth||e.bottom>window.innerHeight)&&!(e.top<0||e.left<0)}function o(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))}function s(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=document.createElement("style");n.id=e,n.appendChild(document.createTextNode(t)),document.head.appendChild(n)}var a=function(t,e){for(var n=Object(t),i=1;i-1},l=function(t){return Array.isArray(t)?t.slice(0):t.split("
")};function c(t){return t.replace(/&(.+);/,function(t){var e=document.createElement("textarea");return e.innerHTML=t,e.value})}function f(t){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var h="{%}";var p=function(t){var e=function(t){var e=(new DOMParser).parseFromString(t,"text/html"),n=[].slice.call(e.body.querySelectorAll("*"));return(n=n.filter(function(e){return!(e.outerHTML.indexOf(">-1&&(t=t.replace(e.outerHTML,""),1))})).forEach(function(e){t=t.replace(new RegExp("<".concat(e.tagName,"(.*?)/?>((.*?))?"),"i"),h)}),{string:t,nodes:n}}(t),n=e.string,i=e.nodes,r=c(n).split(""),o=[];return r.forEach(function(t,e){if(r.slice(e,e+3).join("")===h){var n=e,s=i.shift(),a=c(s.innerHTML).split(""),u=[].slice.call(s.attributes).map(function(t){return{name:t.name,value:t.nodeValue}});a.length?a.forEach(function(t,i){o.push({tag:s.tagName,attributes:u,content:t,isFirstCharacter:n===e,isLastCharacter:i+1===a.length}),n++}):o.push({tag:s.tagName,attributes:u,content:null})}else o.push(t)}),o=function(t){for(var e=!0;e;)t.some(function(e,n){return!("object"!==f(e)||!e.isLastCharacter&&null!==e.content||"%}"!==t.slice(n+1,n+3).join("")||(t.splice(n+1,2),0))})||(e=!1);return t}(o)},d=function(t){var e=t.tag,n=t.attributes,i=void 0===n?[]:n,r=t.content,o=void 0===r?"":r,s=document.createElement(e);return void 0!==i&&i.forEach(function(t){s.setAttribute(t.name,t.value)}),o&&(s.innerHTML=o),s.outerHTML},y=function(t){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?t.value="":[].slice.call(t.childNodes).forEach(function(e){void 0!==e.classList&&e.classList.contains("ti-wrapper")&&(t.innerHTML="")})};function v(t){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function g(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.executed=[],this.waiting=e,!e.length&&n&&this.add(n)}var e,n,i;return e=t,(n=[{key:"add",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.waiting[e?"unshift":"push"](t),this}},{key:"delete",value:function(t){return this.waiting.splice(t,1),this}},{key:"reset",value:function(){return this.waiting=[].concat(g(this.executed),g(this.waiting)),this.executed=[],this}}])&&m(e.prototype,n),i&&m(e,i),t}();function w(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:{},n=e.element,r=e.id,o=e.options,s=e.queue,c=void 0===s?[]:s;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.status={started:!1,complete:!1,frozen:!1,destroyed:!1},this.timeouts=[],this.id=r,this.$e=n,this.isInput=u(n),this.opts=a({},i,o),this.opts.strings=l(this.opts.strings),this.opts.html=!this.isInput&&this.opts.html,this.queue=new b(c,[this.pause,this.opts.startDelay]),y(n,this.isInput),this.prepareDelay("nextStringDelay"),this.prepareDelay("loopDelay");var f=this.$e.innerHTML;this.prepDOM(),this.handleHardCoded(f),this.opts.strings=this.opts.strings.map(function(t){return t.replace(/<\!--.*?-->/g,"")}),!this.opts.strings.length||this.queue.waiting.length>1||this.generateQueue()}var e,n,c;return e=t,(n=[{key:"reset",value:function(){return this.queue.reset(),new t({element:this.$e,id:this.id,options:this.opts,queue:this.queue.waiting})}},{key:"init",value:function(){var t=this;if(!this.status.started){if(this.cursor(),!this.opts.waitUntilVisible||r(this.$e))return this.status.started=!0,this.fire();window.addEventListener("scroll",function e(){r(t.$e)&&!t.status.started&&(t.fire(),window.removeEventListener("scroll",e))})}}},{key:"fire",value:function(){for(var t=this,e=this.queue.waiting.slice(),n=Promise.resolve(),i=function(i){var r=e[i],o=[r,t.queue,t];n=n.then(function(){return new Promise(function(e,n){if(t.status.frozen)return n();var i,s;(t.setPace(),r[2]&&r[2].isFirst&&t.opts.beforeString)&&(i=t.opts).beforeString.apply(i,o);t.opts.beforeStep&&(s=t.opts).beforeStep.apply(s,o);r[0].call(t,r[1],r[2]).then(function(){var n,i,s=t.queue.waiting.shift();if(r[2]&&r[2].isPhantom)return e();r[2]&&r[2].isLast&&t.opts.afterString&&(n=t.opts).afterString.apply(n,o);t.opts.afterStep&&(i=t.opts).afterStep.apply(i,o);return t.queue.executed.push(s),e()})})})},r=0;r\n \n \n '),this.$e.setAttribute("data-typeit-id",this.id),this.$eContainer=this.$e.querySelector(".ti-container"),this.$eWrapper=this.$e.querySelector(".ti-wrapper"),s("\n .".concat(this.$eContainer.className,":before {\n content: '.';\n display: inline-block;\n width: 0;\n visibility: hidden;\n }\n ")))}},{key:"setContents",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.isInput?this.$e.value=t:this.$eContainer[this.opts.html?"innerHTML":"innerText"]=t}},{key:"getRaw",value:function(){return this.isInput?this.$e.value:this.opts.html?this.$eContainer.innerHTML:this.$eContainer.innerText}},{key:"getNoderized",value:function(){return this.maybeNoderize(this.getRaw())}},{key:"prepareDelay",value:function(t){var e=this.opts[t];if(e){var n=Array.isArray(e),i=n?null:e/2;this.opts[t]={before:n?e[0]:i,after:n?e[1]:i,total:n?e[0]+e[1]:e}}}},{key:"generateQueue",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;e&&this.queue.add(e),this.opts.strings.forEach(function(e,n){t.queueString(e);var i=t.queue.waiting.length;if(n+1!==t.opts.strings.length){if(t.opts.breakLines)return t.queue.add([t.type,"
"]),void t.addSplitPause(i);t.queueDeletions(e),t.addSplitPause(i,e.length)}})}},{key:"queueDeletions",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e="string"==typeof t?this.maybeNoderize(t).length:t,n=0;n1&&void 0!==arguments[1]?arguments[1]:1;this.queue.waiting.splice(t,0,[this.pause,this.opts.nextStringDelay.before]),this.queue.waiting.splice(t+e+1,0,[this.pause,this.opts.nextStringDelay.after])}},{key:"cursor",value:function(){if(!this.isInput){var t="display: none;";this.opts.cursor&&(s("\n @keyframes blink-".concat(this.id," {\n 0% {opacity: 0}\n 49% {opacity: 0}\n 50% {opacity: 1}\n }\n\n [data-typeit-id='").concat(this.id,"'] .ti-cursor {\n animation: blink-").concat(this.id," ").concat(this.opts.cursorSpeed/1e3,"s infinite;\n }\n "),this.id),t=""),this.$eWrapper.insertAdjacentHTML("beforeend",'').concat(this.opts.cursorChar,""))}}},{key:"insert",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.isInput?this.$e.value="".concat(this.$e.value).concat(t):((e?this.$eContainer.lastChild:this.$eContainer).insertAdjacentHTML("beforeend",t),this.setContents(this.getRaw().split("").join("")))}},{key:"handleHardCoded",value:function(t){return!!t.length&&(this.opts.startDelete?(this.insert(t),this.queue.add([this.delete,!0]),void this.addSplitPause(1)):void(this.opts.strings=[].concat(w(l(t.trim())),w(this.opts.strings))))}},{key:"wait",value:function(t,e){this.timeouts.push(setTimeout(t,e))}},{key:"setPace",value:function(){var t=this.opts.speed,e=null!==this.opts.deleteSpeed?this.opts.deleteSpeed:this.opts.speed/3,n=t/2,i=e/2;this.typePace=this.opts.lifeLike?o(t,n):t,this.deletePace=this.opts.lifeLike?o(e,i):e}},{key:"pause",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(function(n,i){t.wait(function(){return n()},e||t.opts.nextStringDelay.total)})}},{key:"type",value:function(t){var e=this;return new Promise(function(n,i){e.wait(function(){return"string"==typeof t?(e.insert(t),n()):t.isFirstCharacter||null===t.content?(e.insert(d({tag:t.tag,attributes:t.attributes,content:t.content})),n()):(e.insert(t.content,!0),n())},e.typePace)})}},{key:"empty",value:function(){var t=this;return new Promise(function(e){return t.setContents(""),e()})}},{key:"delete",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(function(n,i){t.wait(function(){var i=t.getNoderized();return i.splice(-1,1),i=function(t){return(t=t.map(function(e,n){if("object"===v(e)&&(e.isFirstCharacter||null===e.content)){for(var i=n,r=[e.content],o=!1;!o;){var s=t[++i];void 0!==s&&r.push(s.content),(void 0===s||s.isLastCharacter)&&(o=!0)}return d({tag:e.tag,attributes:e.attributes,content:r.join("")})}return e})).filter(function(t){return"object"!==v(t)})}(i),t.setContents(i.join("")),e&&i.length>0?t.delete(!0).then(function(){return n()}):n()},t.deletePace)})}},{key:"setOptions",value:function(t){var e=this;return new Promise(function(n){return e.opts=a({},e.opts,t),n()})}}])&&S(e.prototype,n),c&&S(e,c),t}(),C=function(t){return"string"==typeof t?t=document.querySelectorAll(t):t instanceof NodeList||(t=[t]),[].slice.call(t)};function j(t,e){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.each(function(r){for(var o="string"!=typeof t,s=o?t:r[t],a=o?e:n,u=0;u0&&void 0!==arguments[0]?arguments[0]:"";return this.each(function(e){return e.queueString(t)}),this}},{key:"delete",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.queueUp("delete",null===t,null===t?1:t),this}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return this.queueUp("pause",t),this}},{key:"break",value:function(){return this.queueUp("type","
"),this}},{key:"options",value:function(t){return this.queueUp("setOptions",t),this}},{key:"exec",value:function(t){return this.queueUp(t),this}},{key:"destroy",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.each(function(e){e.timeouts.forEach(function(t){clearTimeout(t)}),e.timeouts=[];var n=e.isInput?null:e.$eWrapper.querySelector(".ti-cursor");t&&e.opts.cursor&&null!==n&&e.$eWrapper.removeChild(n),e.status.destroyed=!0})}},{key:"empty",value:function(){return this.queueUp("empty"),this}},{key:"reset",value:function(){return this.destroy(),this.instances=this.instances.map(function(t){return t.reset()}),this}},{key:"go",value:function(){return this.each(function(t){t.init()}),this}}])&&j(e.prototype,n),i&&j(e,i),t}()}]).default}); \ No newline at end of file diff --git a/assets/js/lib/typeit/typeit.modern.min.js b/assets/js/lib/typeit/typeit.modern.min.js deleted file mode 100644 index c0bf24c0..00000000 --- a/assets/js/lib/typeit/typeit.modern.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/*! - * - * TypeIt - The most versatile animated typing utility on the planet. - * Author: Alex MacArthur (https://macarthur.me) - * Version: v6.1.1 - * License: GPL-2.0 - * URL: https://typeitjs.com - * - */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.TypeIt=e():t.TypeIt=e()}(this,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=0)}([function(t,e,i){"use strict";i.r(e);var n={strings:[],speed:100,cursor:!0,cursorChar:"|",cursorSpeed:1e3,deleteSpeed:null,lifeLike:!0,breakLines:!0,startDelay:250,startDelete:!1,nextStringDelay:750,loop:!1,loopDelay:750,html:!0,waitUntilVisible:!1,beforeString:()=>{},afterString:()=>{},beforeStep:()=>{},afterStep:()=>{},afterComplete:()=>{}},s=function(){var t=this;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.insert=(t,e)=>{this.waiting.splice(t,0,e)},this.add=function(e){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return Array.isArray(e[0])?(t.waiting=t.waiting.concat(e),t):(t.waiting[i?"unshift":"push"](e),t)},this.delete=t=>(this.waiting.splice(t,1),this),this.reset=()=>(this.waiting=this.executed.concat(this.waiting),this.executed=[],this),this.executed=[],this.waiting=e,!e.length&&i&&this.add(i)},r=t=>document.createElement(t);function o(t,e){return Math.abs(Math.random()*(t+e-(t-e))+(t-e))}function u(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=r("style");i.id=e,i.appendChild(document.createTextNode(t)),document.head.appendChild(i)}var l=t=>["textarea","input"].indexOf(t.tagName.toLowerCase())>-1,a=t=>Array.isArray(t)?t:[t],h=t=>[].slice.call(t);const c=(t,e)=>{let i=t.nextSibling;return!!i&&!i.isEqualNode(e)};var p=(t,e)=>{let i=e;if(l(t))return void(t.value="".concat(t.value).concat(i));let n=h(t.childNodes).filter(t=>t.classList&&t.classList.contains("ti-cursor"));if(n=n.length?n[0]:null,"object"==typeof e&&!(e instanceof HTMLElement)){let s=e.ancestorTree.slice(0).reverse().join(" "),o=h(t.querySelectorAll("".concat(s))),u=o[o.length-1];if(u&&((t,e)=>{if(!t)return!1;let i=!1,n=[],s=t;for(;!i;)n.push(c(s,e)),(s=s.parentNode)&&!s.hasAttribute("data-typeit-id")||(i=!0);return!n.some(t=>t)})(u,n))t=u,i=e.content;else if(i=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=r(t);return e.forEach(t=>{n.setAttribute(t.name,t.value)}),n.innerHTML=i,n}(e.ancestorTree[0],e.attributes,e.content),e.ancestorTree.length>1){let i=h(t.querySelectorAll(e.ancestorTree[1]));t=i[i.length-1]}}i="object"==typeof i?i:document.createTextNode(i),t.insertBefore(i,n&&t.hasAttribute("data-typeit-id")?n:null)},d=t=>{let e=[];return e.concat.apply(e,t)},f=t=>{let e=document.implementation.createHTMLDocument("");return e.body.innerHTML=t,e.body};const y=t=>h(t.attributes).map(t=>({name:t.name,value:t.nodeValue})),g=t=>h(t.childNodes).map(t=>3===t.nodeType?t.nodeValue.split(""):t),m=(t,e,i)=>({ancestorTree:e,attributes:y(t),content:i}),b=(t,e)=>{let i=m(t,e,""),n=g(t).map((i,n)=>Array.isArray(i)?i.map((i,n)=>m(t,e,i)):i);return n.unshift(i),d(n)},v=t=>t instanceof HTMLElement&&"BR"!==t.tagName,w=function t(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=e.map(t=>{if(v(t)){if(!i)return h(t.childNodes);let e=t.parentNode,n=[t.tagName];for(;["BODY","HTML"].indexOf(e.tagName)<0;)n.push(e.tagName),e=e.parentNode;return b(t,n)}return t});return(n=d(n)).some(t=>v(t))?t(n,i):n};function S(t){let e=f(t),i=g(e);return w(i)}function q(t){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?S(t):t.split("")}var x=(t,e)=>{e?t.value="":t.querySelector(".ti-cursor")&&(t.innerHTML="")},T=function(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!Array.isArray(t),s=t.length;return(t=n?new Array(t).fill(0):t).map((t,r)=>{if(n)return e;let o=[e,t];return i&&(0===r&&o.push({isFirst:!0}),r+1===s&&o.push({isLast:!0})),o})},A=t=>{t.parentNode.removeChild(t)};const N=t=>3!==t.nodeType&&"BR"!==t.tagName&&!t.firstChild,L=t=>t.some(t=>N(t));var M=t=>{let e=h(t.querySelectorAll("*")),i=L(e);for(;e.length&&i;){let n=!1;e.forEach(t=>{N(t)&&(A(t),n=!0)}),n&&(e=h(t.querySelectorAll("*"))),i=L(e)}return e},D=t=>(Array.isArray(t)||(t=[t/2,t/2]),{before:t[0],after:t[1],total:t[0]+t[1]}),$=function(t,e,i){let n=(e=null!==e?e:t/3)/2;return i?[o(t,t/2),o(e,n)]:[t,e]};function j(){var t=this;let{typeIt:e,element:i,id:o,options:c,queue:d=[],isAReset:y=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const g=()=>{let t=h(this.$e.childNodes).filter(t=>!t.isEqualNode(L));return w(t,!1)},m=function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=t.opts.nextStringDelay;t.queue.insert(e,[t.pause,n.before]),t.queue.insert(e+i+1,[t.pause,n.after])},b=()=>{!E&&this.opts.cursor&&(u("@keyframes blink-".concat(o," { 0% {opacity: 0} 49% {opacity: 0} 50% {opacity: 1} }[data-typeit-id='").concat(o,"'] .ti-cursor { animation: blink-").concat(o," ").concat(this.opts.cursorSpeed/1e3,"s infinite; }"),o),(L=r("span")).innerHTML=f(this.opts.cursorChar).innerHTML,L.className="ti-cursor",L.setAttribute("style","display:inline;position:relative;font:inherit;color:inherit;line-height:inherit;"),this.$e.appendChild(L))};this.wait=function(t,e){this.timeouts.push(setTimeout(t,e))};const v=()=>{this.opts.strings.forEach((t,e)=>{let i=q(t,this.opts.html);this.queue.add(T(i,this.type,!0));let n=this.queue.waiting.length;if(e+1!==this.opts.strings.length){if(this.opts.breakLines)return this.queue.add([this.type,r("BR")]),void m(n);this.queue.add(T(i,this.delete)),m(n,t.length)}})},N=t=>{this.queue.reset().delete(0).add([this.pause,t.before],!0);for(let t=0;t0&&void 0!==arguments[0]&&arguments[0];return new Promise((e,i)=>{this.wait(()=>e(),t||this.opts.nextStringDelay.total)})},this.reset=function(){return this.queue.reset(),new j({typeIt:e,element:this.$e,id:o,options:this.opts,queue:this.queue.waiting,isAReset:!0})},this.init=function(){if(this.status.started)return;if(b(),!this.opts.waitUntilVisible)return this.status.started=!0,this.fire();new IntersectionObserver((t,e)=>{t.forEach(t=>{t.isIntersecting&&(this.fire(),e.unobserve(this.$e))})},{threshold:1}).observe(this.$e)},this.fire=function(){let t=this.queue.waiting.slice(),i=Promise.resolve();for(let n=0;nnew Promise((t,e)=>{if(this.status.frozen)return e();this.pace=$(this.opts.speed,this.opts.deleteSpeed,this.opts.lifeLike),s[2]&&s[2].isFirst&&this.opts.beforeString(...r),this.opts.beforeStep(...r),s[0].call(this,s[1],s[2]).then(()=>{let e=this.queue.waiting.shift();return s[2]&&s[2].isPhantom?t():(s[2]&&s[2].isLast&&this.opts.afterString(...r),this.opts.afterStep(...r),this.queue.executed.push(e),t())})}))}i.then(()=>{if(this.opts.loop){let t=this.opts.loopDelay?this.opts.loopDelay:this.opts.nextStringDelay;this.wait(()=>{N(t),this.fire()},t.after)}this.status.completed=!0,this.opts.afterComplete(e)}).catch(()=>{})},this.type=function(t){return"object"!=typeof t||t.content?new Promise(e=>{this.wait(()=>(p(this.$e,t),e()),this.pace[0])}):(p(this.$e,t),Promise.resolve())},this.empty=function(){return new Promise(t=>(E?this.$e.value="":h(this.$e.childNodes).forEach(t=>{L.isEqualNode(t)||A(t)}),t()))},this.delete=function(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return new Promise(e=>{this.wait(()=>{let i=g();return i.length&&A(i[i.length-1]),M(this.$e),t&&i.length-1>0?this.delete(!0).then(()=>e()):e()},this.pace[1])})},this.setOptions=function(t){return new Promise(e=>(this.opts=Object.assign({},this.opts,t),e()))};let L=null,E=l(i);this.status={started:!1,complete:!1,frozen:!1,destroyed:!1},this.$e=i,this.timeouts=[],this.opts=Object.assign({},n,c),this.opts.html=!E&&this.opts.html,this.opts.nextStringDelay=D(this.opts.nextStringDelay),this.opts.loopDelay=D(this.opts.loopDelay),this.queue=new s(d,[this.pause,this.opts.startDelay]),this.$e.setAttribute("data-typeit-id",o),u("[data-typeit-id]:before {content: '.'; display: inline-block; width: 0; visibility: hidden;}"),x(i,E);let O=a(this.opts.strings);O=(t=>{let e=this.$e.innerHTML;return e?(this.$e.innerHTML="",this.opts.startDelete?(S(e).forEach(t=>{p(this.$e,t)}),this.queue.add([this.delete,!0]),m(1),t):[e.trim()].concat(t)):t})(O),this.opts.strings=O.map(t=>t.replace(/<\!--.*?-->/g,"")),this.opts.strings.length&&!y&&v()}var E=function(t,e,i){return!!t.length&&!t.some((function(t){return t.status[e]!==i}))},O=function(t){return"string"==typeof t?t=document.querySelectorAll(t):t.forEach||(t=[t]),h(t)};function P(t,e){var i=this;this.instances=O(t).map(t=>new j({typeIt:this,element:t,id:Math.random().toString(36).substring(2,15),options:e,queue:[],isAReset:!1}));const n=t=>{this.instances.forEach(e=>{t.call(this,e)})},s=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;n(n=>{let r="string"!=typeof t,o=r?t:n[t],u=T(s,[o,r?i:e]);n.queue.add(u)})};this.is=function(t){return E(this.instances,t,!0)},this.freeze=function(){n(t=>{t.status.frozen=!0})},this.unfreeze=function(){n(t=>{t.status.frozen&&(t.status.frozen=!1,t.fire())})},this.type=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return n(e=>{let i=q(t,e.opts.html);e.queue.add(T(i,e.type,!0))}),this},this.delete=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return s("delete",null===t,null===t?1:t),this},this.pause=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return s("pause",t),this},this.break=function(){return s("type",r("BR")),this},this.options=function(t){return s("setOptions",t),this},this.exec=function(t){return s(t),this},this.destroy=function(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.instances=this.instances.map(e=>{if(e.timeouts.forEach(t=>{clearTimeout(t)}),e.timeouts=[],t){let t=e.isInput?null:e.$e.querySelector(".ti-cursor");t&&e.$e.removeChild(t)}return e.status.destroyed=!0,e})},this.empty=function(){return s("empty"),this},this.reset=function(){return this.destroy(),this.instances=this.instances.map(t=>t.reset()),this},this.go=function(){return n(t=>{t.init()}),this}}i.d(e,"default",(function(){return P}))}]).default})); \ No newline at end of file diff --git a/exampleSite/config.toml b/exampleSite/config.toml index a64c68dd..532195c9 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -226,7 +226,7 @@ unsafe = true placeholder = "Your comment ..." visitor = true recordIP = true - + [params.facebook] # Facebook Comment Config (https://developers.facebook.com/docs/plugins/comments) enable = false width = "100%" diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 0ecb50cd..3c3063ea 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -77,7 +77,7 @@ {{ if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.typeit_js }} {{ $typeit = .Site.Params.cdn.typeit_js }} {{ else }} - {{ $res := resources.Get "js/lib/typeit/typeit.modern.min.js" | resources.Minify }} + {{ $res := resources.Get "js/lib/typeit/typeit.min.js" | resources.Minify }} {{ $typeit = printf "" $res.RelPermalink }} {{ end }} @@ -96,6 +96,8 @@ {{ $res := resources.Get "css/lib/aplayer/APlayer.min.css" | resources.Minify }} {{ $aplayer_css = printf "" $res.RelPermalink }} {{ end }} +{{ $res := resources.Get "css/lib/aplayer/APlayer.dark.scss" | resources.ToCSS | resources.Minify }} +{{ $aplayer_dark_css := printf "" $res.RelPermalink }} {{ $aplayer_js := "" }} {{ if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.aplayer_js }} {{ $aplayer_js = .Site.Params.cdn.aplayer_js }} @@ -103,7 +105,7 @@ {{ $res := resources.Get "js/lib/aplayer/APlayer.min.js" | resources.Minify }} {{ $aplayer_js = printf "" $res.RelPermalink }} {{ end }} -{{ $aplayer := delimit (slice $aplayer_css $aplayer_js) "" }} +{{ $aplayer := delimit (slice $aplayer_css $aplayer_dark_css $aplayer_js) "" }} {{ $meting := "" }} {{ if eq (getenv "HUGO_ENV") "production" | and .Site.Params.cdn.meting_js }} diff --git a/layouts/shortcodes/typeit.html b/layouts/shortcodes/typeit.html index 9ecb84c5..110589f6 100644 --- a/layouts/shortcodes/typeit.html +++ b/layouts/shortcodes/typeit.html @@ -10,7 +10,7 @@
{{ else if .Get "code" }} - {{ $content = highlight $content (.Get "code") "linenos=" }} + {{ $content = highlight $content (.Get "code") "linenos=false" }} {{ $content = replaceRE `
]*>(?s)(.*)
` "$1" $content }}