diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-05-22 14:12:44 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-05-22 14:12:44 +0300 |
commit | 1fc68e9daf7320f69920893441894dd16971c933 (patch) | |
tree | c73deac756028ba0fb61fc73d68f011e74283d1a | |
parent | 5b7fb093516bea6bfdd57dc325541c7a002204b5 (diff) |
Run prettier --write assets/**/*.js
-rw-r--r-- | assets/js/controllers/lang.js | 10 | ||||
-rw-r--r-- | assets/js/controllers/search-lunr.js | 14 | ||||
-rw-r--r-- | assets/js/controllers/toc.js | 26 | ||||
-rw-r--r-- | assets/js/helpers/highlight.js | 6 |
4 files changed, 28 insertions, 28 deletions
diff --git a/assets/js/controllers/lang.js b/assets/js/controllers/lang.js index 083acc0..24d69de 100644 --- a/assets/js/controllers/lang.js +++ b/assets/js/controllers/lang.js @@ -1,6 +1,6 @@ -const debug = 0 ? console.log.bind(console, '[lang]') : function() {}; +const debug = 0 ? console.log.bind(console, '[lang]') : function () {}; -const toggleCodeblockVisibility = function(lang, visible) { +const toggleCodeblockVisibility = function (lang, visible) { debug('toggleCodeblockVisibility', lang, visible); document.querySelectorAll(`.highlight code.language-${lang}`).forEach((el) => { let highlight = el.closest('.highlight'); @@ -11,7 +11,7 @@ const toggleCodeblockVisibility = function(lang, visible) { export function newLangController() { return { tabs: [], - changeLanguage: function(index) { + changeLanguage: function (index) { debug('changeLanguage', index); for (let i = 0; i < this.tabs.length; i++) { let isActive = i === index; @@ -20,7 +20,7 @@ export function newLangController() { toggleCodeblockVisibility(this.tabs[i].key, isActive); } }, - initLangs: function(tabs) { + initLangs: function (tabs) { debug('initLangs', tabs); tabs[0].active = true; this.tabs = tabs; @@ -28,6 +28,6 @@ export function newLangController() { return this.$nextTick(() => { this.changeLanguage(0); }); - } + }, }; } diff --git a/assets/js/controllers/search-lunr.js b/assets/js/controllers/search-lunr.js index 9509998..175770b 100644 --- a/assets/js/controllers/search-lunr.js +++ b/assets/js/controllers/search-lunr.js @@ -18,7 +18,7 @@ function nextUntil(elem, selector) { export function newSearchController() { var index; - var buildIndex = function(config) { + var buildIndex = function (config) { var builder = new lunr.Builder(); builder.pipeline.add(lunr.trimmer, lunr.stopWordFilter, lunr.stemmer); @@ -30,7 +30,7 @@ export function newSearchController() { }; function populateIndex() { - index = buildIndex(function() { + index = buildIndex(function () { this.ref('id'); this.field('title', { boost: 10 }); this.field('body'); @@ -44,7 +44,7 @@ export function newSearchController() { this.add({ id: headerEl.id, title: headerEl.textContent, - body: body + body: body, }); }); }); @@ -55,7 +55,7 @@ export function newSearchController() { return { query: '', results: [], - init: function() { + init: function () { return this.$nextTick(() => { populateIndex(); this.$watch('query', () => { @@ -63,7 +63,7 @@ export function newSearchController() { }); }); }, - search: function() { + search: function () { highlight.remove(); let results = index.search(this.query).filter((item) => item.score > 0.0001); @@ -71,13 +71,13 @@ export function newSearchController() { var elem = document.getElementById(item.ref); return { - title: elem.innerText + title: elem.innerText, }; }); if (this.results.length > 0) { highlight.apply(new RegExp(this.query, 'i')); } - } + }, }; } diff --git a/assets/js/controllers/toc.js b/assets/js/controllers/toc.js index 075d3e5..f19f491 100644 --- a/assets/js/controllers/toc.js +++ b/assets/js/controllers/toc.js @@ -1,20 +1,20 @@ 'use strict'; -const debug = 0 ? console.log.bind(console, '[toc]') : function() {}; +const debug = 0 ? console.log.bind(console, '[toc]') : function () {}; const headerEls = () => document.querySelectorAll('.content h1, .content h2, .content h3'); -const setProgress = function(self, el) { +const setProgress = function (self, el) { let mainEl = document.querySelector('.content'); let mainHeight = mainEl.offsetHeight; let mainStart = mainEl.offsetTop; - let progress = Math.round((el.offsetTop - mainStart) / mainHeight * 100); + let progress = Math.round(((el.offsetTop - mainStart) / mainHeight) * 100); self.activeHeading.title = el.innerText; self.activeHeading.progress = progress; }; export function newToCController() { - const setOpenRecursive = function(row, shouldOpen) { + const setOpenRecursive = function (row, shouldOpen) { if (!row.sub) { return false; } @@ -42,29 +42,29 @@ export function newToCController() { return { activeHeading: { title: '', - progress: 0 + progress: 0, }, showHeading: true, rows: [], - load: function(rows) { + load: function (rows) { this.rows = rows; }, - transitions: function() { + transitions: function () { return { 'x-transition:enter.duration.500ms': '', 'x-transition:leave.duration.400ms': '', - 'x-transition.scale.origin.top.left.80': '' + 'x-transition.scale.origin.top.left.80': '', }; }, - rowClass: function(row) { + rowClass: function (row) { return { - class: `toc-h${row.level}${row.active ? ' active' : ''}${row.active_parent ? ' active-parent' : ''}` + class: `toc-h${row.level}${row.active ? ' active' : ''}${row.active_parent ? ' active-parent' : ''}`, }; }, - click: function(row) { + click: function (row) { this.rows.forEach((row2) => { setOpenRecursive(row2, (row3) => { return row === row3; @@ -72,7 +72,7 @@ export function newToCController() { }); }, - onScroll: function() { + onScroll: function () { debug('onScroll'); let scrollpos = window.scrollY; @@ -95,6 +95,6 @@ export function newToCController() { this.activeHeading.progress = 100; } }); - } + }, }; } diff --git a/assets/js/helpers/highlight.js b/assets/js/helpers/highlight.js index 3e37916..71c0e41 100644 --- a/assets/js/helpers/highlight.js +++ b/assets/js/helpers/highlight.js @@ -2,7 +2,7 @@ export class Highlight { constructor( opts = { contentSelector: '.content', - markClass: 'da-highlight-mark' + markClass: 'da-highlight-mark', } ) { this.opts = opts; @@ -22,7 +22,7 @@ export class Highlight { return NodeFilter.FILTER_ACCEPT; } return NodeFilter.FILTER_REJECT; - } + }, }, false ); @@ -71,7 +71,7 @@ export class Highlight { if (node.parentNode && node.parentNode.parentNode) { this.nodeStack.push({ old: node.parentNode, - new: parentClone + new: parentClone, }); node.parentNode.parentNode.replaceChild(parentClone, node.parentNode); } |