From 8dae917fc769de4faf6e3dc611a5c844d0bbbe35 Mon Sep 17 00:00:00 2001 From: Jordan GAZEAU Date: Sun, 5 Feb 2023 13:00:05 +0100 Subject: [PATCH] fix: reformat code with prettier --- .bmycconfig.json | 2 +- .github/ISSUE_TEMPLATE/feature.yml | 4 +- .github/ISSUE_TEMPLATE/issue.yml | 4 +- .github/ISSUE_TEMPLATE/question.yml | 4 +- .../pull_request_template.md | 2 +- .github/dependabot.yml | 27 +- .github/release.yml | 2 +- .github/workflows/branches.yml | 20 +- .github/workflows/bumpBmyc.yml | 10 +- .github/workflows/bumpHugo.yml | 10 +- .github/workflows/tags.yml | 2 +- .htmltest.yml | 6 +- .prettierignore | 14 + .prettierrc.json | 10 + README.md | 2 +- assets/js/fencedcodes/mermaid.js | 26 +- assets/js/shortcodes/asyncapi.js | 13 +- assets/js/shortcodes/collapsible.js | 8 +- assets/js/shortcodes/highcharts.js | 57 ++- assets/js/shortcodes/intro.js | 136 ++--- assets/js/shortcodes/openapi.js | 32 +- assets/js/shortcodes/treeview.js | 6 +- assets/js/theme/404_particles.js | 60 +-- assets/js/theme/browserCompatibility.js | 19 +- assets/js/theme/init.js | 56 ++- assets/js/theme/modules/helpers.js | 255 ++++++---- assets/js/theme/modules/helpersGlobal.js | 6 +- assets/js/theme/navbar.js | 18 +- assets/js/theme/print.js | 8 +- assets/js/theme/qrcode.js | 25 +- assets/js/theme/search.js | 475 +++++++++++++----- assets/js/theme/shortcuts.js | 9 +- assets/js/theme/sidebar.js | 155 +++--- assets/js/theme/toc.js | 86 ++-- cypress.config.js | 83 +-- cypress/e2e/global/404Tests.cy.js | 23 +- cypress/e2e/global/bannerTests.cy.js | 18 +- cypress/e2e/global/contentTests.cy.js | 27 +- cypress/e2e/global/logoTests.cy.js | 19 +- cypress/e2e/global/mermaidTests.cy.js | 100 ++-- cypress/e2e/global/multilingualTests.cy.js | 58 ++- cypress/e2e/global/navbarTests.cy.js | 144 +++--- cypress/e2e/global/qrcodeTests.cy.js | 26 +- cypress/e2e/global/searchTests.cy.js | 93 ++-- cypress/e2e/global/shortcutsTests.cy.js | 170 +++---- cypress/e2e/global/sidebarTests.cy.js | 150 +++--- cypress/e2e/global/tocTests.cy.js | 154 +++--- cypress/e2e/pages/homeTests.cy.js | 63 ++- cypress/e2e/shortcodes/alertTests.cy.js | 37 +- cypress/e2e/shortcodes/asyncapiTests.cy.js | 33 +- cypress/e2e/shortcodes/blockquoteTests.cy.js | 19 +- cypress/e2e/shortcodes/collapsibleTests.cy.js | 64 ++- cypress/e2e/shortcodes/highchartsTests.cy.js | 53 +- cypress/e2e/shortcodes/introTests.cy.js | 108 ++-- cypress/e2e/shortcodes/openapiTests.cy.js | 77 ++- cypress/e2e/shortcodes/pagebreakTests.cy.js | 16 +- cypress/e2e/shortcodes/parameterTests.cy.js | 22 +- cypress/e2e/shortcodes/snippetTests.cy.js | 69 ++- cypress/e2e/shortcodes/treeviewTests.cy.js | 83 +-- cypress/fixtures/openapi/example.yaml | 4 +- cypress/support/e2e.js | 5 +- cypress/support/global/navbarCommands.js | 53 +- cypress/support/globalCommands.js | 88 ++-- exampleSite/assets/css/shortcuts.css | 2 +- exampleSite/assets/js/shortcuts.js | 6 +- exampleSite/asyncapi/example.yaml | 2 +- exampleSite/data/dir/exampleTemplate.json | 4 +- exampleSite/i18n/en.yaml | 34 +- exampleSite/i18n/fr.yaml | 34 +- .../layouts/partials/custom/custom-info.html | 94 ++-- exampleSite/openapi/example.yaml | 4 +- .../templates/configuration/i18n.en.yaml | 38 +- .../templates/configuration/i18n.fr.yaml | 6 +- .../templates/configuration/shortcuts.js | 6 +- i18n/en.yaml | 236 ++++----- i18n/fr.yaml | 106 ++-- layouts/404.html | 40 +- layouts/_default/_markup/render-image.html | 7 +- layouts/_default/_markup/render-link.html | 16 +- layouts/_default/index.html | 2 +- layouts/_default/list.html | 2 +- layouts/_default/single.html | 2 +- layouts/_default/taxonomy.html | 2 +- layouts/_default/terms.html | 2 +- layouts/partials/custom/custom-footer.html | 2 +- layouts/partials/custom/custom-head.html | 2 +- layouts/partials/custom/custom-info.html | 2 +- layouts/partials/main.html | 25 +- layouts/partials/theme/banner.html | 10 +- layouts/partials/theme/content-title.html | 2 +- layouts/partials/theme/content.html | 61 +-- layouts/partials/theme/header.html | 8 +- .../partials/theme/helpers/hrefResolver.html | 34 +- layouts/partials/theme/helpers/printMap.html | 38 +- .../partials/theme/helpers/printSlice.html | 16 +- .../theme/helpers/sortedPagesArray.html | 42 +- .../partials/theme/helpers/tocResolver.html | 18 +- layouts/partials/theme/includes-end.html | 231 +++++---- layouts/partials/theme/includes-head.html | 147 +++--- layouts/partials/theme/lang-selector.html | 67 ++- layouts/partials/theme/loading.html | 22 +- layouts/partials/theme/logo.html | 34 +- layouts/partials/theme/meta.html | 30 +- layouts/partials/theme/modal.html | 6 +- layouts/partials/theme/navbar-extend.html | 18 +- layouts/partials/theme/navbar-info.html | 20 +- layouts/partials/theme/navbar-items.html | 98 ++-- layouts/partials/theme/navbar-shortcuts.html | 118 ++--- layouts/partials/theme/navbar.html | 26 +- layouts/partials/theme/search.html | 20 +- layouts/partials/theme/sidebar-content.html | 6 +- layouts/partials/theme/sidebar.html | 46 +- layouts/partials/theme/taxonomy-selector.html | 77 +-- layouts/partials/theme/terms-content.html | 69 ++- layouts/partials/theme/toc.html | 52 +- layouts/partials/theme/version-selector.html | 43 +- layouts/shortcodes/alert.html | 14 +- layouts/shortcodes/asyncapi.html | 23 +- layouts/shortcodes/blockquote.html | 16 +- layouts/shortcodes/collapsible.html | 26 +- layouts/shortcodes/highcharts.html | 38 +- layouts/shortcodes/intro.html | 56 ++- layouts/shortcodes/md.html | 2 +- layouts/shortcodes/openapi.html | 22 +- layouts/shortcodes/pagebreak.html | 2 +- layouts/shortcodes/parameter.html | 84 ++-- layouts/shortcodes/plaintext.html | 4 +- layouts/shortcodes/ref.html | 10 +- layouts/shortcodes/relref.html | 10 +- layouts/shortcodes/snippet.html | 195 ++++--- layouts/shortcodes/tab.html | 94 ++-- layouts/shortcodes/treeview.html | 262 +++++----- package-lock.json | 62 +++ package.json | 4 + peek.yml | 2 +- 135 files changed, 3554 insertions(+), 2835 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.json diff --git a/.bmycconfig.json b/.bmycconfig.json index c19134ee..bfefa0be 100644 --- a/.bmycconfig.json +++ b/.bmycconfig.json @@ -1967,4 +1967,4 @@ }, "currentVersion": "10.2.1" } -] \ No newline at end of file +] diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml index 2e1556e9..9964f0f0 100644 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -1,7 +1,7 @@ name: Feature description: Request a new feature -title: "[feature_request]: " -labels: ["enhancement"] +title: '[feature_request]: ' +labels: ['enhancement'] body: - type: textarea id: request diff --git a/.github/ISSUE_TEMPLATE/issue.yml b/.github/ISSUE_TEMPLATE/issue.yml index b6965952..e2cd9538 100644 --- a/.github/ISSUE_TEMPLATE/issue.yml +++ b/.github/ISSUE_TEMPLATE/issue.yml @@ -1,7 +1,7 @@ name: Bug Report description: Create a bug report -title: "[bug]: " -labels: ["bug"] +title: '[bug]: ' +labels: ['bug'] body: - type: markdown attributes: diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml index 6ad0fd02..ec8e93b4 100644 --- a/.github/ISSUE_TEMPLATE/question.yml +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -1,7 +1,7 @@ name: Question description: Ask a question related to the project -title: "[question]: " -labels: ["question"] +title: '[question]: ' +labels: ['question'] body: - type: textarea id: question diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md index 6f65a240..f5365b4b 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -11,4 +11,4 @@ Fixes # - [ ] Code quality is at least even, ideally greater - [ ] Code commits are following the [Conventional Commits](https://www.conventionalcommits.org/) specification - [ ] Documentation is up-to-date (code comments, project documentation, ...) -- [ ] All tests passed successfully \ No newline at end of file +- [ ] All tests passed successfully diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 85604c9e..fee63a95 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,24 +1,23 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: 'github-actions' + directory: '/' schedule: - interval: "weekly" + interval: 'weekly' commit-message: - prefix: "chore:" - include: "scope" + prefix: 'chore:' + include: 'scope' labels: - - "internal" + - 'internal' open-pull-requests-limit: 1 - - package-ecosystem: "npm" - directory: "/" + - package-ecosystem: 'npm' + directory: '/' schedule: - schedule: - interval: "weekly" + interval: 'weekly' commit-message: - prefix: "chore:" - include: "scope" + prefix: 'chore:' + include: 'scope' labels: - - "internal" + - 'internal' open-pull-requests-limit: 1 - versioning-strategy: increase \ No newline at end of file + versioning-strategy: increase diff --git a/.github/release.yml b/.github/release.yml index f76a89af..84d04e38 100644 --- a/.github/release.yml +++ b/.github/release.yml @@ -23,4 +23,4 @@ changelog: - internal - title: Other Changes labels: - - "*" \ No newline at end of file + - '*' diff --git a/.github/workflows/branches.yml b/.github/workflows/branches.yml index 80feb608..3ba5158e 100644 --- a/.github/workflows/branches.yml +++ b/.github/workflows/branches.yml @@ -9,19 +9,19 @@ on: paths: - '**' env: - HUGO_BASIC_EXAMPLE_REPO: "gohugoio/hugoBasicExample" - HUGO_BIN_NAME: "hugo" - HUGO_CACHE_NAME: "hugo-bin-cache" + HUGO_BASIC_EXAMPLE_REPO: 'gohugoio/hugoBasicExample' + HUGO_BIN_NAME: 'hugo' + HUGO_CACHE_NAME: 'hugo-bin-cache' HUGO_BIN_PATH: ci_hugo_bin - HUGO_VERSION_THRESHOLD: "0.103.0" + HUGO_VERSION_THRESHOLD: '0.103.0' HTMLTEST_BIN_NAME: htmltest - HTMLTEST_CACHE_NAME: "htmltest-bin-cache" + HTMLTEST_CACHE_NAME: 'htmltest-bin-cache' HTMLTEST_BIN_PATH: ci_htmltest_bin - HUGO_TESTS_VERSIONS: "0.91.0 0.108.0" - CYPRESS_CACHE_NAME: "cypress-cache" - CYPRESS_CACHE_PATH: "~/.cache" - NPM_CACHE_NAME: "npm-cache" - NPM_CACHE_PATH: "~/.npm" + HUGO_TESTS_VERSIONS: '0.91.0 0.108.0' + CYPRESS_CACHE_NAME: 'cypress-cache' + CYPRESS_CACHE_PATH: '~/.cache' + NPM_CACHE_NAME: 'npm-cache' + NPM_CACHE_PATH: '~/.npm' jobs: hugo-binaries: name: Manage Hugo binaries diff --git a/.github/workflows/bumpBmyc.yml b/.github/workflows/bumpBmyc.yml index 808290a9..bbbebc09 100644 --- a/.github/workflows/bumpBmyc.yml +++ b/.github/workflows/bumpBmyc.yml @@ -4,8 +4,8 @@ on: schedule: - cron: '30 2 * * 1' env: - NPM_CACHE_NAME: "npm-cache" - NPM_CACHE_PATH: "~/.npm" + NPM_CACHE_NAME: 'npm-cache' + NPM_CACHE_PATH: '~/.npm' jobs: Bmyc: name: Bump thirdparties using Bmyc @@ -22,9 +22,9 @@ jobs: cache: 'npm' - name: Bump thirdparties and create PR env: - LOG_FILE: "workflow.log" - PR_TITLE: "build: bump bmyc assets" - BRANCH_NAME: "build/bump_bmyc_assets" + LOG_FILE: 'workflow.log' + PR_TITLE: 'build: bump bmyc assets' + BRANCH_NAME: 'build/bump_bmyc_assets' GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BMYC_GITHUB_TOKEN: ${{ secrets.BMYC_GITHUB_TOKEN }} run: | diff --git a/.github/workflows/bumpHugo.yml b/.github/workflows/bumpHugo.yml index 8b458201..f917e1a6 100644 --- a/.github/workflows/bumpHugo.yml +++ b/.github/workflows/bumpHugo.yml @@ -4,8 +4,8 @@ on: schedule: - cron: '30 2 * * 1' env: - NPM_CACHE_NAME: "npm-cache" - NPM_CACHE_PATH: "~/.npm" + NPM_CACHE_NAME: 'npm-cache' + NPM_CACHE_PATH: '~/.npm' jobs: Bump: name: Bump Hugo @@ -19,9 +19,9 @@ jobs: token: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} - name: Bump thirdparties and create PR env: - LOG_FILE: "workflow.log" - PR_TITLE: "build: bump Hugo" - BRANCH_NAME: "build/bump_hugo" + LOG_FILE: 'workflow.log' + PR_TITLE: 'build: bump Hugo' + BRANCH_NAME: 'build/bump_hugo' GITHUB_TOKEN: ${{ secrets.WORKFLOW_GITHUB_TOKEN }} run: | minHugoVersion=$(grep -E '^min_version.*$' theme.toml) diff --git a/.github/workflows/tags.yml b/.github/workflows/tags.yml index 537ae664..8884cfb6 100644 --- a/.github/workflows/tags.yml +++ b/.github/workflows/tags.yml @@ -50,4 +50,4 @@ jobs: upload_url: ${{ github.event.release.upload_url }} asset_path: ./${{ steps.changelog.outputs.zip_name }} asset_name: ${{ steps.changelog.outputs.zip_name }} - asset_content_type: application/zip \ No newline at end of file + asset_content_type: application/zip diff --git a/.htmltest.yml b/.htmltest.yml index 92b174eb..ebd8af13 100644 --- a/.htmltest.yml +++ b/.htmltest.yml @@ -1,6 +1,6 @@ -DirectoryPath: "exampleSite/public" +DirectoryPath: 'exampleSite/public' CheckFavicon: true EnforceHTML5: true IgnoreDirs: -- "en" -IgnoreURLs: ["https://emojipedia.org/"] + - 'en' +IgnoreURLs: ['https://emojipedia.org/'] diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..d7d0f46a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,14 @@ +# External assets ignores +assets/bulma/** +**/external/** +# Hugo ignores +public/** +resources/** +# Theme ignores +assets/js/theme/modules/const.js +exampleSite/**/*.md +exampleSite/assets/highcharts/*.json +layouts/_default/index.json +layouts/_default/_markup/render-heading.html +layouts/partials/theme/sidebar-content.html +layouts/partials/theme/taxonomy-content.html diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..86c0adc8 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,10 @@ +{ + "overrides": [ + { "files": ["*.html"], "options": { "parser": "go-template" } }, + { + "files": ["*.html", "*.css", "*.scss", "*.sass"], + "options": { "singleQuote": false } + } + ], + "singleQuote": true +} diff --git a/README.md b/README.md index 43642c73..5dfa4f14 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,4 @@ ## Documentation -To get all the needed information about the theme, visit the [Shadocs documentation website](https://shadocs.netlify.app/) which is built on it. \ No newline at end of file +To get all the needed information about the theme, visit the [Shadocs documentation website](https://shadocs.netlify.app/) which is built on it. diff --git a/assets/js/fencedcodes/mermaid.js b/assets/js/fencedcodes/mermaid.js index 71eb1a99..32079140 100644 --- a/assets/js/fencedcodes/mermaid.js +++ b/assets/js/fencedcodes/mermaid.js @@ -1,8 +1,8 @@ import { addElementToModal, displayModal, - getLoadingHelper -} from '../theme/modules/helpers.min.js' + getLoadingHelper, +} from '../theme/modules/helpers.min.js'; // VARS // // MAIN // @@ -10,9 +10,9 @@ let mermaidConfig = { startOnLoad: true, securityLevel: 'loose', logLevel: 'fatal', - theme: 'dark' + theme: 'dark', }; -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { mermaid.mermaidAPI.initialize(mermaidConfig); renderMermaids(); }); @@ -20,9 +20,11 @@ document.addEventListener('DOMContentLoaded', function() { function renderMermaids() { let divm = document.getElementsByClassName('language-mermaid'); for (let i = 0; i < divm.length; i++) { - const mermaidId = `scMermaid${i}` + const mermaidId = `scMermaid${i}`; const graphDefinition = divm[i].textContent; - divm[i].parentElement.replaceWith(getLoadingHelper('sc-mermaid-wrapper', mermaidId)); + divm[i].parentElement.replaceWith( + getLoadingHelper('sc-mermaid-wrapper', mermaidId) + ); renderMermaid(mermaidId, graphDefinition); } } @@ -35,7 +37,7 @@ function renderMermaid(mermaidId, graphDefinition) { const mermaidSvgExportIcon = document.createElement('i'); mermaidContainer.classList.add('sc-mermaid-container'); mermaidSvgExport.classList.add('is-action-button'); - mermaidSvgExportIcon.classList.add('fa-solid','fa-download'); + mermaidSvgExportIcon.classList.add('fa-solid', 'fa-download'); mermaidSvgExport.id = `${mermaidId}-export-svg`; mermaidSvgExport.title = svgDownloadLabel; mermaidFragment.appendChild(mermaidContainer); @@ -43,18 +45,20 @@ function renderMermaid(mermaidId, graphDefinition) { mermaidSvgExport.appendChild(mermaidSvgExportIcon); mermaidWrapper.appendChild(mermaidFragment); try { - let insertSvg = function(svgCode){ + let insertSvg = function (svgCode) { mermaidContainer.insertAdjacentHTML('afterbegin', svgCode); }; mermaid.mermaidAPI.render(mermaidSvgId, graphDefinition, insertSvg); let mermaidRendered = document.getElementById(mermaidSvgId); - let svgBlob = new Blob([mermaidRendered.outerHTML], {type: 'image/svg+xml;charset=utf-8'}); + let svgBlob = new Blob([mermaidRendered.outerHTML], { + type: 'image/svg+xml;charset=utf-8', + }); URL.revokeObjectURL(mermaidSvgExport.href); mermaidSvgExport.href = URL.createObjectURL(svgBlob); mermaidSvgExport.download = mermaidId; mermaidRendered.classList.toggle('sc-mermaid-svg', true); mermaidRendered.classList.toggle('is-modal', true); - mermaidRendered.addEventListener('click', function(e) { + mermaidRendered.addEventListener('click', function (e) { if (!e.target.closest('a')) { let el = this.cloneNode(true); addElementToModal(el); @@ -72,4 +76,4 @@ function renderMermaid(mermaidId, graphDefinition) { mermaidWrapper.classList.toggle('is-loading', false); mermaidContainer.insertAdjacentElement('afterbegin', ed); } -}; +} diff --git a/assets/js/shortcodes/asyncapi.js b/assets/js/shortcodes/asyncapi.js index 36fc39d0..7d04280a 100644 --- a/assets/js/shortcodes/asyncapi.js +++ b/assets/js/shortcodes/asyncapi.js @@ -1,10 +1,8 @@ -import { - getFirstAncestorByClass -} from '../theme/modules/helpers.min.js' +import { getFirstAncestorByClass } from '../theme/modules/helpers.min.js'; // VARS // // MAIN // -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { renderAllAsyncapi(); }); function renderAllAsyncapi() { @@ -14,7 +12,10 @@ function renderAllAsyncapi() { } } function renderAsyncapi(ac) { - setTimeout(function() { - getFirstAncestorByClass(ac, 'sc-asyncapi-wrapper').classList.toggle('is-loading', false); + setTimeout(function () { + getFirstAncestorByClass(ac, 'sc-asyncapi-wrapper').classList.toggle( + 'is-loading', + false + ); }, 600); } diff --git a/assets/js/shortcodes/collapsible.js b/assets/js/shortcodes/collapsible.js index 42f350db..a9fff0e9 100644 --- a/assets/js/shortcodes/collapsible.js +++ b/assets/js/shortcodes/collapsible.js @@ -1,11 +1,11 @@ // VARS // // MAIN // -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { // Manage collapsibles in content let c = document.getElementsByClassName('sc-collapsible-header'); for (let i = 0; i < c.length; i++) { - c[i].addEventListener('click', function(e) { + c[i].addEventListener('click', function (e) { this.classList.toggle('sc-uncollapsed'); }); - }; -}) \ No newline at end of file + } +}); diff --git a/assets/js/shortcodes/highcharts.js b/assets/js/shortcodes/highcharts.js index 9ac3c728..952a7118 100644 --- a/assets/js/shortcodes/highcharts.js +++ b/assets/js/shortcodes/highcharts.js @@ -1,12 +1,12 @@ import { addFunctionToResizeEvent, getFirstAncestorByClass, - waitFor -} from '../theme/modules/helpers.min.js' + waitFor, +} from '../theme/modules/helpers.min.js'; // VARS // // MAIN // -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { renderAllHighcharts(); }); function renderAllHighcharts() { @@ -18,40 +18,53 @@ function renderAllHighcharts() { } function manageHighchartsResize(cc) { if (cc.length) { - const resizeHighcharts = function() { + const resizeHighcharts = function () { let charts = Highcharts.charts; for (let i = 0; i < charts.length; i++) { charts[i].setSize(null, null, false); } - } + }; addFunctionToResizeEvent(resizeHighcharts); - document.getElementById('sidebarUncollapse').addEventListener('click', () => { - setTimeout(function() {resizeHighcharts();}, 200); - }); + document + .getElementById('sidebarUncollapse') + .addEventListener('click', () => { + setTimeout(function () { + resizeHighcharts(); + }, 200); + }); document.getElementById('sidebarCollapse').addEventListener('click', () => { - setTimeout(function() {resizeHighcharts();}, 200); + setTimeout(function () { + resizeHighcharts(); + }, 200); }); let tc = document.getElementById('tocCollapsible'); if (tc) { - tc.addEventListener('click', () => {resizeHighcharts();}); - }; + tc.addEventListener('click', () => { + resizeHighcharts(); + }); + } } } async function renderHighcharts(hc) { - const highchartsWrapper = getFirstAncestorByClass(hc, 'sc-highcharts-wrapper') + const highchartsWrapper = getFirstAncestorByClass( + hc, + 'sc-highcharts-wrapper' + ); const highchartsPromise = new Promise((resolve) => resolve()); await highchartsPromise .then(() => { const maximumAttempts = 10; const delayAttempts = 600; - return waitForHighcharts(hc, delayAttempts, maximumAttempts).then((isRenderHighcharts) => { - if (isRenderHighcharts) { - highchartsWrapper.classList.toggle('is-loading', false); - return Promise.resolve(); - } else { - throw new Error('{{i18n "highcharts_error"}}'); + return waitForHighcharts(hc, delayAttempts, maximumAttempts).then( + (isRenderHighcharts) => { + if (isRenderHighcharts) { + highchartsWrapper.classList.toggle('is-loading', false); + return Promise.resolve(); + } else { + throw new Error('{{i18n "highcharts_error"}}'); + } } - }) + ); }) .catch((error) => { const ed = document.createElement('div'); @@ -63,17 +76,17 @@ async function renderHighcharts(hc) { }); } -function waitForHighcharts(e, delay, maxCount, count=0) { +function waitForHighcharts(e, delay, maxCount, count = 0) { count++; return waitFor(delay).then(() => { if (count < maxCount) { if (e.innerHTML) { return Promise.resolve(true); - } else { + } else { return waitForHighcharts(e, delay, maxCount, count); } } else { return Promise.resolve(false); } }); -}; +} diff --git a/assets/js/shortcodes/intro.js b/assets/js/shortcodes/intro.js index 457b9a62..c27337b8 100644 --- a/assets/js/shortcodes/intro.js +++ b/assets/js/shortcodes/intro.js @@ -2,8 +2,8 @@ import { atou, addFunctionToResizeEvent, getTriggers, - disableSmoothScroll -} from '../theme/modules/helpers.min.js' + disableSmoothScroll, +} from '../theme/modules/helpers.min.js'; // VARS // const INTRO_STEPS = 'steps'; @@ -11,82 +11,97 @@ const INTRO_EXIT_BOOL = 'isExiting'; const INTRO_TRIGGER_ONLY = 'triggeronly'; const INTRO_TRIGGER_EXCEPT = 'triggerexcept'; const INTRO_THEME_FUNCTIONS = { - oncomplete: { + oncomplete: { applyOnStep: false, - callBack: "" + callBack: '', }, - onexit: { + onexit: { applyOnStep: false, - callBack: "enableSmoothScroll();" + callBack: 'enableSmoothScroll();', }, - onbeforeexit: { + onbeforeexit: { applyOnStep: false, - callBack: "" + callBack: '', }, - onchange: { + onchange: { applyOnStep: true, - callBack: "" + callBack: '', }, onbeforechange: { applyOnStep: true, - callBack: "" + callBack: '', }, - onafterchange: { + onafterchange: { applyOnStep: true, - callBack: "" - } -} + callBack: '', + }, +}; const themeCommonOptions = { - nextLabel: introNextLabel, - prevLabel: introPrevLabel, - skipLabel: introSkipLabel, - doneLabel: introDoneLabel, - hidePrev: false, - hideNext: false, - nextToDone: true, - exitOnEsc: true, + nextLabel: introNextLabel, + prevLabel: introPrevLabel, + skipLabel: introSkipLabel, + doneLabel: introDoneLabel, + hidePrev: false, + hideNext: false, + nextToDone: true, + exitOnEsc: true, exitOnOverlayClick: true, - showStepNumbers: false, + showStepNumbers: false, keyboardNavigation: true, - showButtons: true, - showBullets: true, - showProgress: true, - scrollToElement: true, - scrollTo: "element", - scrollPadding: 30, - overlayOpacity: 0.8, - disableInteraction: true + showButtons: true, + showBullets: true, + showProgress: true, + scrollToElement: true, + scrollTo: 'element', + scrollPadding: 30, + overlayOpacity: 0.8, + disableInteraction: true, }; -const introErrorTitle = atou(document.getElementById('intro-error-title').getAttribute('data')); -const introError = atou(document.getElementById('intro-error').getAttribute('data')); -const introEmpty = atou(document.getElementById('intro-empty').getAttribute('data')); +const introErrorTitle = atou( + document.getElementById('intro-error-title').getAttribute('data') +); +const introError = atou( + document.getElementById('intro-error').getAttribute('data') +); +const introEmpty = atou( + document.getElementById('intro-empty').getAttribute('data') +); const introErrorStep = { showBullets: false, - steps: [{ - title: introErrorTitle, - intro: introError - }] + steps: [ + { + title: introErrorTitle, + intro: introError, + }, + ], }; const introEmptyStep = { showBullets: false, - steps: [{ - title: introErrorTitle, - intro: introEmpty - }] + steps: [ + { + title: introErrorTitle, + intro: introEmpty, + }, + ], }; // MAIN // const divi = document.getElementsByClassName('sc-intro'); for (let i = 0; i < divi.length; i++) { - divi[i].addEventListener('click', function() { + divi[i].addEventListener('click', function () { disableSmoothScroll(); - let introOptions = parseIntroOptions(atou(divi[i].getAttribute('intro-data'))); - introOptions.steps = manageTriggeredSteps(introOptions.steps, getTriggers()); + let introOptions = parseIntroOptions( + atou(divi[i].getAttribute('intro-data')) + ); + introOptions.steps = manageTriggeredSteps( + introOptions.steps, + getTriggers() + ); let intro = introJs(); intro.setOptions(themeCommonOptions); intro.setOptions(manageEmptySteps(introOptions)); for (const key in INTRO_THEME_FUNCTIONS) { if (typeof intro[key] === 'function') { - intro[key](function() { + intro[key](function () { if (INTRO_THEME_FUNCTIONS[key].applyOnStep) { Function(INTRO_THEME_FUNCTIONS[key].callBack)(); if (this._introItems[this.currentStep()].hasOwnProperty(key)) { @@ -101,35 +116,38 @@ for (let i = 0; i < divi.length; i++) { }); } } - const exitIntro = function() { + const exitIntro = function () { if (!intro[INTRO_EXIT_BOOL]) { intro.isExiting = true; intro.exit(true); } - } + }; addFunctionToResizeEvent(exitIntro); intro.start(); }); -}; +} function parseIntroOptions(input) { try { let output = JSON.parse(input); return manageElements(manageEmptySteps(output)); } catch (error) { - introErrorStep.steps[0].intro = introError + introErrorStep.steps[0].intro = introError; return introErrorStep; } -}; +} function manageElements(input) { - for (let i = 0; i < input.steps.length ; i++) { + for (let i = 0; i < input.steps.length; i++) { if (input.steps[i].element) { try { input.steps[i].element = document.querySelector(input.steps[i].element); } catch { try { - input.steps[i].element = Function('return ' + input.steps[i].element)(); + input.steps[i].element = Function( + 'return ' + input.steps[i].element + )(); } catch { - introErrorStep.steps[0].intro = introError + `
(Step${i}:${input.steps[i].element})` + introErrorStep.steps[0].intro = + introError + `
(Step${i}:${input.steps[i].element})`; return introErrorStep; } } @@ -146,17 +164,17 @@ function manageEmptySteps(input) { } function manageTriggeredSteps(steps, triggers) { let outputSteps = []; - for (let i = 0; i < steps.length ; i++) { - if (keepSteps(steps[i],triggers)) { + for (let i = 0; i < steps.length; i++) { + if (keepSteps(steps[i], triggers)) { outputSteps[outputSteps.length] = steps[i]; } } return outputSteps; -}; +} function keepSteps(step, triggers) { let isTriggered = true; if (step.hasOwnProperty(INTRO_TRIGGER_ONLY)) { - isTriggered = false + isTriggered = false; for (const trigger of step[INTRO_TRIGGER_ONLY]) { if (triggers.includes(trigger)) { isTriggered = true; diff --git a/assets/js/shortcodes/openapi.js b/assets/js/shortcodes/openapi.js index 308007b7..75fd9803 100644 --- a/assets/js/shortcodes/openapi.js +++ b/assets/js/shortcodes/openapi.js @@ -1,11 +1,11 @@ import { addFunctionToResizeEvent, - getFirstAncestorByClass -} from '../theme/modules/helpers.min.js' + getFirstAncestorByClass, +} from '../theme/modules/helpers.min.js'; // VARS // // MAIN // -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { renderAllOpenAPI(); }); function renderAllOpenAPI() { @@ -14,12 +14,12 @@ function renderAllOpenAPI() { renderOpenAPI(divo[i]); } if (divo.length) { - const resizeOpenAPI = function() { + const resizeOpenAPI = function () { let divi = document.getElementsByClassName('sc-openapi-iframe'); for (let i = 0; i < divi.length; i++) { setOpenAPIHeight(divi[i]); } - } + }; addFunctionToResizeEvent(resizeOpenAPI); } } @@ -34,7 +34,7 @@ function renderOpenAPI(oc) { const cssRef = '/css/external/swagger-ui/swagger-ui.min.css'; const cssRel = 'stylesheet'; const cssType = 'text/css'; - const oiCss = 'html,body { overflow: hidden; }' + const oiCss = 'html,body { overflow: hidden; }'; oi.classList.toggle('sc-openapi-iframe', true); oi.srcdoc = ` @@ -56,18 +56,18 @@ function renderOpenAPI(oc) { SwaggerUIBundle({ url: oc.getAttribute('openapi-url'), domNode: oi.contentWindow.document.getElementById(openapiId), - presets: [ - SwaggerUIBundle.presets.apis, - SwaggerUIStandalonePreset - ] + presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset], }); }) .then(() => { - let observerCallback = function() { + let observerCallback = function () { setOpenAPIHeight(oi); - } + }; let observer = new MutationObserver(observerCallback); - observer.observe(oi.contentWindow.document.documentElement, { childList: true, subtree: true }); + observer.observe(oi.contentWindow.document.documentElement, { + childList: true, + subtree: true, + }); }) .then(() => { openapiWrapper.classList.toggle('is-loading', false); @@ -84,9 +84,11 @@ function renderOpenAPI(oc) { openapiWrapper.classList.toggle('is-loading', false); openapiWrapper.insertAdjacentElement('afterbegin', ed); }); - } + }; oc.appendChild(oi); } function setOpenAPIHeight(oi) { - oi.style.height = oi.contentWindow.document.documentElement.getBoundingClientRect().height + 'px'; + oi.style.height = + oi.contentWindow.document.documentElement.getBoundingClientRect().height + + 'px'; } diff --git a/assets/js/shortcodes/treeview.js b/assets/js/shortcodes/treeview.js index a3793c0f..8fbe3ad7 100644 --- a/assets/js/shortcodes/treeview.js +++ b/assets/js/shortcodes/treeview.js @@ -1,12 +1,10 @@ -import { - getFirstAncestorByClass -} from '../theme/modules/helpers.min.js' +import { getFirstAncestorByClass } from '../theme/modules/helpers.min.js'; // VARS // // MAIN // let sctv = document.getElementsByClassName('sc-treeview-coll-trigger'); for (let i = 0; i < sctv.length; i++) { - sctv[i].addEventListener('click', function() { + sctv[i].addEventListener('click', function () { let coll = getFirstAncestorByClass(this, 'sc-treeview-coll'); if (coll) { coll.classList.toggle('is-collapsed'); diff --git a/assets/js/theme/404_particles.js b/assets/js/theme/404_particles.js index 659d4666..d702001d 100644 --- a/assets/js/theme/404_particles.js +++ b/assets/js/theme/404_particles.js @@ -1,17 +1,14 @@ -import { - getCssVar, - getRandomInt -} from './modules/helpers.min.js' +import { getCssVar, getRandomInt } from './modules/helpers.min.js'; // VARS // // MAIN // let canvas = document.getElementById('scene'); -let ch = canvas.height = canvas.getBoundingClientRect().height; -let cw = canvas.width = canvas.getBoundingClientRect().width; +let ch = (canvas.height = canvas.getBoundingClientRect().height); +let cw = (canvas.width = canvas.getBoundingClientRect().width); let sceneBackground = getCssVar('--scene-background'); let context = canvas.getContext('2d'); -let previousMouseCoord = {x:0, y:0}; -let mouseCoord = {x:0, y:0}; +let previousMouseCoord = { x: 0, y: 0 }; +let mouseCoord = { x: 0, y: 0 }; let sceneResize = false; let particlesCount = 0; let particles = []; @@ -20,24 +17,24 @@ let colors = [ getCssVar('--particle-color-2'), getCssVar('--particle-color-3'), getCssVar('--particle-color-4'), - getCssVar('--particle-color-5') + getCssVar('--particle-color-5'), ]; const dpi = 200; -let Particle = function(x, y) { - this.x = getRandomInt(cw); - this.y = getRandomInt(ch); - this.coord = {x:x, y:y}; - this.r = Math.min((getRandomInt((cw / dpi)) + 1), 6); +let Particle = function (x, y) { + this.x = getRandomInt(cw); + this.y = getRandomInt(ch); + this.coord = { x: x, y: y }; + this.r = Math.min(getRandomInt(cw / dpi) + 1, 6); this.vx = (Math.random() - 0.5) * 100; this.vy = (Math.random() - 0.5) * 100; this.accX = 0; this.accY = 0; - this.friction = Math.random() * 0.05 + 0.90; + this.friction = Math.random() * 0.05 + 0.9; this.color = colors[Math.floor(Math.random() * 6)]; -} +}; -Particle.prototype.render = function(isDisableMouse) { +Particle.prototype.render = function (isDisableMouse) { this.accX = (this.coord.x - this.x) / 100; this.accY = (this.coord.y - this.y) / 100; this.vx += this.accX; @@ -45,12 +42,12 @@ Particle.prototype.render = function(isDisableMouse) { this.vx *= this.friction; this.vy *= this.friction; this.x += this.vx; - this.y += this.vy; + this.y += this.vy; if (!isDisableMouse) { let a = this.x - mouseCoord.x; let b = this.y - mouseCoord.y; var distance = Math.sqrt(a * a + b * b); - if(distance < (cw / 15)) { + if (distance < cw / 15) { this.accX = (this.x - mouseCoord.x) / 100; this.accY = (this.y - mouseCoord.y) / 100; this.vx += this.accX; @@ -61,7 +58,7 @@ Particle.prototype.render = function(isDisableMouse) { context.beginPath(); context.arc(this.x, this.y, this.r, 0, Math.PI * 2, false); context.fill(); -} +}; function onmouseCoordMove(e) { mouseCoord.x = e.clientX; @@ -69,7 +66,7 @@ function onmouseCoordMove(e) { } function onTouchMove(e) { - if(e.touches.length > 0 ) { + if (e.touches.length > 0) { mouseCoord.x = e.touches[0].clientX; mouseCoord.y = e.touches[0].clientY; } @@ -84,7 +81,7 @@ function initScene() { ch = canvas.height = canvas.getBoundingClientRect().height; cw = canvas.width = canvas.getBoundingClientRect().width; context.clearRect(0, 0, canvas.width, canvas.height); - context.font = 'bold ' + (cw / 5) + 'px sans-serif'; + context.font = 'bold ' + cw / 5 + 'px sans-serif'; context.fillStyle = sceneBackground; context.textAlign = 'center'; context.fillText(text404, cw / 2, ch / 2); @@ -92,9 +89,9 @@ function initScene() { context.clearRect(0, 0, canvas.width, canvas.height); context.globalCompositeOperation = 'screen'; particles = []; - for(let y = 0; y < ch; y += Math.round(cw / dpi)) { - for(let x = 0; x < cw; x += Math.round(cw / dpi)) { - if(imageData[((x + y * cw) * 4) + 3] > 128){ + for (let y = 0; y < ch; y += Math.round(cw / dpi)) { + for (let x = 0; x < cw; x += Math.round(cw / dpi)) { + if (imageData[(x + y * cw) * 4 + 3] > 128) { particles.push(new Particle(x, y)); } } @@ -105,7 +102,10 @@ function initScene() { function renderScene() { context.clearRect(0, 0, canvas.width, canvas.height); let isDisableMouse = false; - if ((previousMouseCoord.x === mouseCoord.x) && (previousMouseCoord.x === mouseCoord.x)) { + if ( + previousMouseCoord.x === mouseCoord.x && + previousMouseCoord.x === mouseCoord.x + ) { isDisableMouse = true; } else { previousMouseCoord.x = mouseCoord.x; @@ -116,17 +116,17 @@ function renderScene() { particles[i].render(isDisableMouse); } requestAnimationFrame(renderScene); -}; +} -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { initScene(); requestAnimationFrame(renderScene); window.addEventListener('mousemove', onmouseCoordMove); window.addEventListener('touchmove', onTouchMove); window.addEventListener('touchend', onTouchEnd); - window.addEventListener('resize', function() { + window.addEventListener('resize', function () { if (!sceneResize) { - requestAnimationFrame(function() { + requestAnimationFrame(function () { initScene(); sceneResize = false; }); diff --git a/assets/js/theme/browserCompatibility.js b/assets/js/theme/browserCompatibility.js index b3dede1b..e2ee78f4 100644 --- a/assets/js/theme/browserCompatibility.js +++ b/assets/js/theme/browserCompatibility.js @@ -5,7 +5,8 @@ function browserCompatibility() { var msie = ua.indexOf('MSIE '); var trident = ua.indexOf('Trident/'); console.log(ua); - var unsupportedBrowserHtml = "\ + var unsupportedBrowserHtml = + "\
\
\
\ @@ -14,13 +15,19 @@ function browserCompatibility() {

$BROWSER_VERSION

\
\
\ -
" + "; if (msie > 0) { // IE 10 or older, return version number - document.body.innerHTML = unsupportedBrowserHtml.replace('$BROWSER_VERSION','IE ' + parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10)); + document.body.innerHTML = unsupportedBrowserHtml.replace( + '$BROWSER_VERSION', + 'IE ' + parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10) + ); } else if (trident > 0) { // IE 11, return version number var rv = ua.indexOf('rv:'); - document.body.innerHTML = unsupportedBrowserHtml.replace('$BROWSER_VERSION','IE ' + parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10)); - }; -}; + document.body.innerHTML = unsupportedBrowserHtml.replace( + '$BROWSER_VERSION', + 'IE ' + parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10) + ); + } +} diff --git a/assets/js/theme/init.js b/assets/js/theme/init.js index d5369b11..40e01172 100644 --- a/assets/js/theme/init.js +++ b/assets/js/theme/init.js @@ -4,15 +4,12 @@ import { displayModal, getFirstAncestorByClass, isPreCopyToEnable, -} from './modules/helpers.min.js' -import { - resizeFunctionsList, - shortcutsKeys -} from './modules/const.min.js' +} from './modules/helpers.min.js'; +import { resizeFunctionsList, shortcutsKeys } from './modules/const.min.js'; // VARS // // MAIN // -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { // Manage shortcuts let keyBuffer = []; document.addEventListener('keyup', function (e) { @@ -28,8 +25,18 @@ document.addEventListener('DOMContentLoaded', function() { } for (const shortcut in shortcutsKeys) { if (shortcutsKeys[shortcut].keys) { - if (shortcutsKeys[shortcut].keys.every((k, i) => new Intl.Collator([], {usage: "search", sensitivity: "base"}).compare(k, keyBuffer[i]) === 0)) { - if (typeof window[shortcutsKeys[shortcut].function] === 'function') { + if ( + shortcutsKeys[shortcut].keys.every( + (k, i) => + new Intl.Collator([], { + usage: 'search', + sensitivity: 'base', + }).compare(k, keyBuffer[i]) === 0 + ) + ) { + if ( + typeof window[shortcutsKeys[shortcut].function] === 'function' + ) { e.preventDefault(); window[shortcutsKeys[shortcut].function](); } @@ -39,7 +46,7 @@ document.addEventListener('DOMContentLoaded', function() { } }); // Manage modals closing - document.addEventListener('click', function(e) { + document.addEventListener('click', function (e) { if (e.target.classList.contains('modal-container')) { closeModals(e.target); } @@ -52,7 +59,10 @@ document.addEventListener('DOMContentLoaded', function() { let ti = document.createElement('i'); tdiv.setAttribute('class', 'copy-code is-action-button'); ti.setAttribute('class', 'fa-solid fa-copy'); - if ((typeof codeCopyBefore !== 'undefined') && (typeof codeCopyAfter !== 'undefined')) { + if ( + typeof codeCopyBefore !== 'undefined' && + typeof codeCopyAfter !== 'undefined' + ) { tdiv.setAttribute('title', codeCopyBefore); tdiv.setAttribute('title-after', codeCopyAfter); } @@ -65,54 +75,54 @@ document.addEventListener('DOMContentLoaded', function() { } p[i].appendChild(tdiv); tdiv.appendChild(ti); - tdiv.addEventListener('click', function(e) { + tdiv.addEventListener('click', function (e) { const parentWidth = this.parentElement.getBoundingClientRect().width; const elementWidth = this.getBoundingClientRect().width; - this.style.maxWidth = (parentWidth - elementWidth) + 'px'; + this.style.maxWidth = parentWidth - elementWidth + 'px'; navigator.clipboard.writeText(this.previousElementSibling.textContent); }); } - }; + } // Manage modals for images let img = document.querySelectorAll('#content img'); for (let i = 0; i < img.length; i++) { if (img[i].parentNode.tagName !== 'A') { img[i].classList.toggle('is-modal', true); - img[i].addEventListener('click', function(e) { + img[i].addEventListener('click', function (e) { let el = document.createElement('img'); el.src = this.src; addElementToModal(el); displayModal(); }); - }; - }; + } + } // Manage tabs in content let tt = document.getElementsByClassName('tabs-trigger'); for (let i = 0; i < tt.length; i++) { - tt[i].addEventListener('click', function(e) { + tt[i].addEventListener('click', function (e) { for (let j = 0; j < tt.length; j++) { if (this === tt[j]) { tt[j].classList.toggle('is-active', true); } else { tt[j].classList.toggle('is-active', false); } - }; + } let tr = document.getElementsByClassName('tabs-results-list'); for (let j = 0; j < tr.length; j++) { - if ((this.id + '-results') === tr[j].id) { + if (this.id + '-results' === tr[j].id) { tr[j].classList.toggle('is-active', true); } else { tr[j].classList.toggle('is-active', false); } - }; + } }); - }; + } }); // Function to hide search lists on resize let scrollResize = false; -window.addEventListener('resize', function() { +window.addEventListener('resize', function () { if (!scrollResize) { - window.requestAnimationFrame(function() { + window.requestAnimationFrame(function () { for (let i = 0; i < resizeFunctionsList.length; i++) { resizeFunctionsList[i](); } diff --git a/assets/js/theme/modules/helpers.js b/assets/js/theme/modules/helpers.js index e31bf422..29ee6832 100644 --- a/assets/js/theme/modules/helpers.js +++ b/assets/js/theme/modules/helpers.js @@ -8,8 +8,8 @@ import { sizeTriggerMobile, mediaTriggerHover, mediaTriggerNoHover, - resizeFunctionsList -} from './const.min.js' + resizeFunctionsList, +} from './const.min.js'; // VARS // let isManualCollapsedSidebar = false; @@ -23,14 +23,14 @@ export function closeModals(e) { } else { let modals = document.getElementsByClassName('modal-container'); for (const modal of modals) { - closeModal(modal) + closeModal(modal); } } } // Function that close a single modal function closeModal(modal) { if (modal.id === 'modalContainer') { - document.getElementById('modal').innerHTML = ""; + document.getElementById('modal').innerHTML = ''; } modal.classList.toggle('is-hidden', true); } @@ -55,10 +55,18 @@ export function addFunctionToResizeEvent(f) { // Get the actual size and return associated triggers export function getTriggers() { let triggers = []; - if (document.body.clientWidth >= widescreenSize) { triggers.push(sizeTriggerWidescreen); } - if (document.body.clientWidth >= desktopSize) { triggers.push(sizeTriggerDesktop); } - if (document.body.clientWidth >= tabletSize) { triggers.push(sizeTriggerTouch); } - if (document.body.clientWidth < tabletSize) { triggers.push(sizeTriggerMobile); } + if (document.body.clientWidth >= widescreenSize) { + triggers.push(sizeTriggerWidescreen); + } + if (document.body.clientWidth >= desktopSize) { + triggers.push(sizeTriggerDesktop); + } + if (document.body.clientWidth >= tabletSize) { + triggers.push(sizeTriggerTouch); + } + if (document.body.clientWidth < tabletSize) { + triggers.push(sizeTriggerMobile); + } if (window.matchMedia('(hover: hover)').matches) { triggers.push(mediaTriggerHover); } else { @@ -73,7 +81,9 @@ export function addElementToModal(el) { } // Display modal container export function displayModal() { - document.getElementById('modalContainer').classList.toggle('is-hidden', false); + document + .getElementById('modalContainer') + .classList.toggle('is-hidden', false); } // Check if an element is in the viewport export function isInViewport(e) { @@ -83,9 +93,9 @@ export function isInViewport(e) { e.getBoundingClientRect().top !== 0 && e.getBoundingClientRect().left !== 0 ); -}; +} // Check if an element is fully visible in a scroll container -export function isInScrollContainer(e,c) { +export function isInScrollContainer(e, c) { return ( e.getBoundingClientRect().top > c.getBoundingClientRect().top && e.getBoundingClientRect().bottom < c.getBoundingClientRect().bottom @@ -93,24 +103,32 @@ export function isInScrollContainer(e,c) { } // Get the first ancestor containing the input given class export function getFirstAncestorByClass(e, cls) { - while ((e = e.parentNode) && (e.classList) && !e.classList.contains(cls)); + while ((e = e.parentNode) && e.classList && !e.classList.contains(cls)); if (!e.classList) { return null; } else { return e; } -}; +} // Check if the element can hold the copy option export function isPreCopyToEnable(e) { - let firstCodeChild = e.querySelector(':scope > code:first-of-type') - if (e.tagName === 'PRE' && firstCodeChild && !firstCodeChild.classList.contains('language-mermaid')) { + let firstCodeChild = e.querySelector(':scope > code:first-of-type'); + if ( + e.tagName === 'PRE' && + firstCodeChild && + !firstCodeChild.classList.contains('language-mermaid') + ) { let te = e; - while ((te = te.parentNode) && (te.classList) && !te.classList.contains('highlight')); + while ( + (te = te.parentNode) && + te.classList && + !te.classList.contains('highlight') + ); if (!te.classList) { return true; } else { let tp = te.querySelectorAll('pre'); - if (tp[tp.length-1] === e) { + if (tp[tp.length - 1] === e) { return true; } else { return false; @@ -119,79 +137,82 @@ export function isPreCopyToEnable(e) { } else { return false; } -}; +} // Get the scroll offset to make an item positioned at the edge of its scrollable container export function getScrollOffset(e, sc) { if (e.getBoundingClientRect().top < sc.getBoundingClientRect().top) { return e.getBoundingClientRect().top - sc.getBoundingClientRect().top; - } else if (e.getBoundingClientRect().bottom > sc.getBoundingClientRect().bottom) { - return e.getBoundingClientRect().bottom - sc.getBoundingClientRect().bottom; + } else if ( + e.getBoundingClientRect().bottom > sc.getBoundingClientRect().bottom + ) { + return e.getBoundingClientRect().bottom - sc.getBoundingClientRect().bottom; } else { return 0; - }; -}; + } +} // Get the scroll offset to make an item positioned in the middle of its scrollable container export function getScrollMiddleOffset(e, sc) { return ( - ((e.getBoundingClientRect().bottom + e.getBoundingClientRect().top) - - (sc.getBoundingClientRect().bottom + sc.getBoundingClientRect().top)) - / 2 + (e.getBoundingClientRect().bottom + + e.getBoundingClientRect().top - + (sc.getBoundingClientRect().bottom + sc.getBoundingClientRect().top)) / + 2 ); -}; +} // Sort results of json array based on input properties export function sortByProperties() { let properties = arguments; - return function(x, y) { - let tempX = x; - let tempY = y; - for (let i = 0; i < properties.length; i++) { - tempX = tempX[properties[i]]; - tempY = tempY[properties[i]]; - } - return ((tempX === tempY) ? 0 : ((tempX > tempY) ? 1 : -1)); + return function (x, y) { + let tempX = x; + let tempY = y; + for (let i = 0; i < properties.length; i++) { + tempX = tempX[properties[i]]; + tempY = tempY[properties[i]]; + } + return tempX === tempY ? 0 : tempX > tempY ? 1 : -1; }; -}; +} // Check if an element is focusable export function isFocusable(e) { - const x = e.getBoundingClientRect().left + (e.getBoundingClientRect().width / 2); - const y = e.getBoundingClientRect().top + (e.getBoundingClientRect().height / 2); - return ( - e === document.elementFromPoint(x,y) - ); -}; + const x = + e.getBoundingClientRect().left + e.getBoundingClientRect().width / 2; + const y = + e.getBoundingClientRect().top + e.getBoundingClientRect().height / 2; + return e === document.elementFromPoint(x, y); +} // Function to hide search list export function hideSearchList() { let searchList = document.getElementById('searchList'); searchList.classList.toggle('is-hidden', true); searchList.scrollTop = 0; removeActive(searchList.getElementsByTagName('li')); -}; +} // Function to show all the lists export function showSearchList() { let searchList = document.getElementById('searchList'); searchList.classList.toggle('is-hidden', false); searchList.scrollTop = 0; -}; +} // Function to check the state of the search list export function isSearchListHidden() { return document.getElementById('searchList').classList.contains('is-hidden'); -}; +} // Function to make a list item inactive for arrow keys management export function removeActive(items) { for (let i = 0; i < items.length; i++) { items[i].classList.toggle('is-selected', false); } -}; +} // Function to get a random int based on a max value export function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } -// Function to get a css variable set in root +// Function to get a css variable set in root export function getCssVar(v) { return getComputedStyle(document.documentElement).getPropertyValue(v); } // Function that wait for the scroll event to finish -export function waitForScroll(e, delay, maxCount, count=0) { +export function waitForScroll(e, delay, maxCount, count = 0) { let previousScrollTop = e.scrollTop; count++; return waitFor(delay).then(() => { @@ -199,75 +220,97 @@ export function waitForScroll(e, delay, maxCount, count=0) { return Promise.resolve(false); } else { if (previousScrollTop !== e.scrollTop) { - previousScrollTop = e.scrollTop; - return waitForScroll(e, delay, maxCount, count); + previousScrollTop = e.scrollTop; + return waitForScroll(e, delay, maxCount, count); } else { - return Promise.resolve(true); + return Promise.resolve(true); } } }); -}; +} // Function to set a timeout, returning a promise export function waitFor(d) { - return new Promise(function(resolve) { + return new Promise(function (resolve) { setTimeout(resolve, d); }); -}; +} // Function to toggle the sidebar at desired state // - force (true is uncollapsed, false is collapsed) // - noTransition (true to disable transition, false by default) export function toggleSidebar(force, noTransition) { if (typeof force === 'undefined') { - force = document.getElementById('sidebarContainer').classList.contains('is-sidebar-collapsed'); + force = document + .getElementById('sidebarContainer') + .classList.contains('is-sidebar-collapsed'); } if (typeof noTransition === 'undefined') { noTransition = false; } - document.getElementById('sidebar').classList.toggle('is-transition-disabled', noTransition); - document.getElementById('sidebarContainer').classList.toggle('is-transition-disabled', noTransition); - document.getElementById('sidebarCollapsible').classList.toggle('is-transition-disabled', noTransition); - document.getElementById('sidebarContainer').classList.toggle('is-sidebar-collapsed', !force); - document.getElementById('sidebarContainer').classList.toggle('is-sidebar-uncollapsed', force); + document + .getElementById('sidebar') + .classList.toggle('is-transition-disabled', noTransition); + document + .getElementById('sidebarContainer') + .classList.toggle('is-transition-disabled', noTransition); + document + .getElementById('sidebarCollapsible') + .classList.toggle('is-transition-disabled', noTransition); + document + .getElementById('sidebarContainer') + .classList.toggle('is-sidebar-collapsed', !force); + document + .getElementById('sidebarContainer') + .classList.toggle('is-sidebar-uncollapsed', force); let ie = document.getElementsByClassName('is-expandable'); for (let i = 0; i < ie.length; i++) { ie[i].classList.toggle('is-hovered', false); - }; + } } // Manage click on collapsible sidebar export function manageClickCollapsibleSidebar() { if (getTriggers().includes(sizeTriggerDesktop)) { - isManualCollapsedSidebar = !document.getElementById('sidebarContainer').classList.contains('is-sidebar-collapsed'); - }; + isManualCollapsedSidebar = !document + .getElementById('sidebarContainer') + .classList.contains('is-sidebar-collapsed'); + } toggleSidebar(); -}; +} // Manage collapsible sidebar depending on window size export function manageDefaultCollapsibleSidebar() { if (!getTriggers().includes(sizeTriggerDesktop) || isManualCollapsedSidebar) { toggleSidebar(false); } else { toggleSidebar(true); - }; -}; + } +} // Function to toggle the extend menu at desired state only if menu is displayed // - force (true is uncollapsed, false is collapsed) export function toggleExtendMenu(force) { if (typeof force === 'undefined') { - force = !document.getElementById('navbarExtend').classList.contains('is-hovered'); + force = !document + .getElementById('navbarExtend') + .classList.contains('is-hovered'); } - if (!document.getElementById('navbarExtend').classList.contains('is-hidden')) { - document.getElementById('navbarExtendWrapper').classList.toggle('is-hovered', force) - document.getElementById('navbarExtendItemsContainer').classList.toggle('is-transition-disabled', force) - }; -}; + if ( + !document.getElementById('navbarExtend').classList.contains('is-hidden') + ) { + document + .getElementById('navbarExtendWrapper') + .classList.toggle('is-hovered', force); + document + .getElementById('navbarExtendItemsContainer') + .classList.toggle('is-transition-disabled', force); + } +} // Function to get the first visible element from a CSS selector // - selector (css element selector) export function getFirstVisibleElement(selector) { for (const elem of document.querySelectorAll(selector)) { if (elem.offsetParent !== null) { return elem; - }; + } } -}; +} // Function to disable animation on scroll export function disableSmoothScroll() { let cc = document.getElementById('contentContainer'); @@ -289,26 +332,34 @@ export function toggleSidebarEntry(e, force) { entriesTitle.classList.toggle('is-entries-expanded', force); e.classList.toggle('is-icon-shrinked', !force); e.classList.toggle('is-icon-expanded', force); -}; +} // Function to toggle the sidebar entries at desired state // - force (true to expand all entries, false to shrink all entries) export function toggleSidebarEntries(force) { let iie = document.getElementsByClassName('is-icon-expandable'); for (let i = 0; i < iie.length; i++) { toggleSidebarEntry(iie[i], force); - }; -}; + } +} // Function that manage the navbar menu export function manageNavbarMenu() { const navbarExtendWidth = document.getElementById('navbarExtend').offsetWidth; - const navbarLogoWidth = document.getElementById('globalLogoContainer').offsetWidth; + const navbarLogoWidth = document.getElementById( + 'globalLogoContainer' + ).offsetWidth; const searchWidth = document.getElementById('searchContainer').offsetWidth; const maxLength = document.body.clientWidth - navbarLogoWidth - searchWidth; - const navbarItems = document.getElementById('navbarItemsEnd').children - const navbarExtendItems = document.getElementById('navbarExtendItemsWrapper').children + const navbarItems = document.getElementById('navbarItemsEnd').children; + const navbarExtendItems = document.getElementById( + 'navbarExtendItemsWrapper' + ).children; let tempLength = navbarExtendWidth; - for (let i = 0; i < (navbarItems.length -1); i++) { - tempLength = tempLength + ((navbarItems[i].offsetWidth) ? (navbarItems[i].offsetWidth) : navbarExtendItems[i].offsetWidth) + for (let i = 0; i < navbarItems.length - 1; i++) { + tempLength = + tempLength + + (navbarItems[i].offsetWidth + ? navbarItems[i].offsetWidth + : navbarExtendItems[i].offsetWidth); if (tempLength > maxLength) { navbarItems[i].classList.toggle('is-hidden', true); navbarExtendItems[i].classList.toggle('is-hidden', false); @@ -317,8 +368,12 @@ export function manageNavbarMenu() { navbarExtendItems[i].classList.toggle('is-hidden', true); } } - document.getElementById('navbarExtend').classList.toggle('is-hidden', (maxLength >= tempLength)); - document.getElementById('navbarItemsEnd').classList.toggle('is-invisible', false); + document + .getElementById('navbarExtend') + .classList.toggle('is-hidden', maxLength >= tempLength); + document + .getElementById('navbarItemsEnd') + .classList.toggle('is-invisible', false); } // Function returning a loading helper export function getLoadingHelper(wrapperClass, wrapperId) { @@ -330,7 +385,11 @@ export function getLoadingHelper(wrapperClass, wrapperId) { const dots = document.createElement('div'); const dot = document.createElement('div'); container.id = wrapperId; - container.classList.add('helper-loading-container', 'is-loading', wrapperClass); + container.classList.add( + 'helper-loading-container', + 'is-loading', + wrapperClass + ); loading.classList.add('helper-loading'); title.classList.add('helper-loading-title'); title.innerHTML = helperLoadingLabel; @@ -338,7 +397,7 @@ export function getLoadingHelper(wrapperClass, wrapperId) { dots.classList.add('helper-loading-dots'); dot.classList.add('helper-loading-dot'); fragment.appendChild(container); - container.appendChild(loading) + container.appendChild(loading); loading.appendChild(title); loading.appendChild(spinner); spinner.appendChild(dots); @@ -350,24 +409,32 @@ export function getLoadingHelper(wrapperClass, wrapperId) { // Manage click on TOC export function manageClickCollapsibleToc() { if (getTriggers().includes(sizeTriggerWidescreen)) { - isManualCollapsedToc = !document.getElementById('contentContainer').classList.contains('is-toc-collapsed'); - }; + isManualCollapsedToc = !document + .getElementById('contentContainer') + .classList.contains('is-toc-collapsed'); + } toggleToc(); -}; +} // Manage TOC depending on window size export function manageDefaultToc() { if (!getTriggers().includes(sizeTriggerWidescreen) || isManualCollapsedToc) { toggleToc(false); } else { toggleToc(true); - }; -}; + } +} // Function to toggle the TOC at desired state // - force (true is uncollapsed, false to collapsed) export function toggleToc(force) { if (typeof force === 'undefined') { - force = document.getElementById('contentContainer').classList.contains('is-toc-collapsed'); + force = document + .getElementById('contentContainer') + .classList.contains('is-toc-collapsed'); } - document.getElementById('contentContainer').classList.toggle('is-toc-collapsed', !force); - document.getElementById('contentContainer').classList.toggle('is-toc-uncollapsed', force); -}; \ No newline at end of file + document + .getElementById('contentContainer') + .classList.toggle('is-toc-collapsed', !force); + document + .getElementById('contentContainer') + .classList.toggle('is-toc-uncollapsed', force); +} diff --git a/assets/js/theme/modules/helpersGlobal.js b/assets/js/theme/modules/helpersGlobal.js index d34700bc..0146460c 100644 --- a/assets/js/theme/modules/helpersGlobal.js +++ b/assets/js/theme/modules/helpersGlobal.js @@ -9,8 +9,8 @@ import { toggleSidebar, toggleSidebarEntry, toggleSidebarEntries, - toggleToc -} from './helpers.min.js' + toggleToc, +} from './helpers.min.js'; // VARS // // MAIN // @@ -24,4 +24,4 @@ window.toggleExtendMenu = toggleExtendMenu; window.toggleSidebar = toggleSidebar; window.toggleSidebarEntry = toggleSidebarEntry; window.toggleSidebarEntries = toggleSidebarEntries; -window.toggleToc = toggleToc; \ No newline at end of file +window.toggleToc = toggleToc; diff --git a/assets/js/theme/navbar.js b/assets/js/theme/navbar.js index f4ad6f0d..578b48f3 100644 --- a/assets/js/theme/navbar.js +++ b/assets/js/theme/navbar.js @@ -1,21 +1,21 @@ import { addFunctionToResizeEvent, - manageNavbarMenu -} from './modules/helpers.min.js' + manageNavbarMenu, +} from './modules/helpers.min.js'; // VARS // // MAIN // -window.addEventListener('load', function() { +window.addEventListener('load', function () { manageNavbarMenu(); -}) -document.addEventListener('DOMContentLoaded', function() { +}); +document.addEventListener('DOMContentLoaded', function () { addFunctionToResizeEvent(manageNavbarMenu); // Manage modals from the navbar const triggers = document.querySelectorAll('#navbar .navbar-trigger'); for (const trigger of triggers) { - const triggeredId = trigger.getAttribute('trigger') - trigger.addEventListener('click', function() { + const triggeredId = trigger.getAttribute('trigger'); + trigger.addEventListener('click', function () { document.getElementById(triggeredId).classList.toggle('is-hidden', false); }); - }; -}); \ No newline at end of file + } +}); diff --git a/assets/js/theme/print.js b/assets/js/theme/print.js index 7334b2cf..fdb4b212 100644 --- a/assets/js/theme/print.js +++ b/assets/js/theme/print.js @@ -1,16 +1,16 @@ // VARS // // MAIN // //Manage print of page content -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { let pbs = document.querySelectorAll('[id^="printButton"]'); for (const pb of pbs) { - pb.setAttribute('title',printLabel); - pb.addEventListener('click', function(e) { + pb.setAttribute('title', printLabel); + pb.addEventListener('click', function (e) { try { window.print(); } catch (error) { console.error('Error printing page content:' + error); } }); - }; + } }); diff --git a/assets/js/theme/qrcode.js b/assets/js/theme/qrcode.js index a12256fe..1cec9916 100644 --- a/assets/js/theme/qrcode.js +++ b/assets/js/theme/qrcode.js @@ -1,32 +1,29 @@ -import { - addElementToModal, - displayModal -} from './modules/helpers.min.js' +import { addElementToModal, displayModal } from './modules/helpers.min.js'; // VARS // // MAIN // //Manage print of page content -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { let qrcs = document.querySelectorAll('[id^="qrCodeButton"]'); for (const qrc of qrcs) { - qrc.setAttribute('title',qrCodeLabel); - qrc.addEventListener('click', function(e) { + qrc.setAttribute('title', qrCodeLabel); + qrc.addEventListener('click', function (e) { let qrImg = document.createElement('img'); - qrImg.id = "currentPageQrCode"; + qrImg.id = 'currentPageQrCode'; const qrCode = new QRious({ - background: "white", + background: 'white', backgroundAlpha: 1, element: qrImg, - foreground: "black", + foreground: 'black', foregroundAlpha: 1, - level: "L", - mime: "image/png", + level: 'L', + mime: 'image/png', padding: null, size: 250, - value: window.location.href + value: window.location.href, }); addElementToModal(qrImg); displayModal(); }); - }; + } }); diff --git a/assets/js/theme/search.js b/assets/js/theme/search.js index 0a0d25b5..020aae0e 100644 --- a/assets/js/theme/search.js +++ b/assets/js/theme/search.js @@ -4,14 +4,14 @@ import { isSearchListHidden, showSearchList, removeActive, - sortByProperties -} from './modules/helpers.min.js' + sortByProperties, +} from './modules/helpers.min.js'; import { flexSearchThemeOptions, - flexSearchOptions -} from './modules/const.min.js' + flexSearchOptions, +} from './modules/const.min.js'; -(function() { +(function () { 'use strict'; // VARS // // Current focus state of the search input element @@ -23,23 +23,27 @@ import { // Function to retrieve the input json file search function buildIndex(url) { if (!url.endsWith('/')) { - url = url + '/' - }; + url = url + '/'; + } fetch(url + 'index.json') .then((response) => response.json()) - .then((data) => data.forEach(entry => flexSearch.add(entry))) + .then((data) => data.forEach((entry) => flexSearch.add(entry))) .catch(() => disableSearch()); } // Function to disable search in case the input json file search is not found function disableSearch() { - searchInput.setAttribute('disabled',''); - searchInput.setAttribute('title',naCommonLabel); + searchInput.setAttribute('disabled', ''); + searchInput.setAttribute('title', naCommonLabel); } // Function to init actions for search function initSearch() { - searchInput.addEventListener('input', (e) => {manageSearch(true)}); - searchInput.addEventListener('focus', (e) => {manageSearch(false)}); - searchInput.addEventListener('keydown', function(e) { + searchInput.addEventListener('input', (e) => { + manageSearch(true); + }); + searchInput.addEventListener('focus', (e) => { + manageSearch(false); + }); + searchInput.addEventListener('keydown', function (e) { if (searchList) { let listItems = searchList.getElementsByTagName('li'); if (e.key === 'ArrowDown') { @@ -61,7 +65,7 @@ import { } }); // Hide all result lists except the active input component if clicked - document.addEventListener('click', function(e) { + document.addEventListener('click', function (e) { if (e.target !== searchInput) { hideSearchList(); } else { @@ -69,7 +73,9 @@ import { } }); // Hide all result lists when current window becomes inactive - window.addEventListener('blur', function() {hideSearchList()}); + window.addEventListener('blur', function () { + hideSearchList(); + }); } // Function to search items based on input query function manageSearch(newSearch) { @@ -79,7 +85,7 @@ import { emptyList(); currentFocus = -1; const flexResults = flexSearch.search(query, { enrich: true }); - const results = manageSearchResults(flexResults) + const results = manageSearchResults(flexResults); showResults(results, query); } showSearchList(); @@ -89,20 +95,26 @@ import { } // Function to organize and extract results from flex results function manageSearchResults(flexResults) { - let flexResultsConcat = [] - let flexResultsFiltered = [] + let flexResultsConcat = []; + let flexResultsFiltered = []; flexResults.forEach((entry) => { flexResultsConcat = flexResultsConcat.concat(entry.result); - }) - flexResultsConcat.filter((entry, index) => { - return index === flexResultsConcat.findIndex(e => { - return e.id === entry.id; - }); - }).sort((a, b) => { - a.id - b.id; - }).forEach((entry) => { - flexResultsFiltered.push(entry.doc); }); + flexResultsConcat + .filter((entry, index) => { + return ( + index === + flexResultsConcat.findIndex((e) => { + return e.id === entry.id; + }) + ); + }) + .sort((a, b) => { + a.id - b.id; + }) + .forEach((entry) => { + flexResultsFiltered.push(entry.doc); + }); return flexResultsFiltered.sort(sortByProperties('rootTitleIndex')); } // Function to add results to the search list @@ -113,11 +125,19 @@ import { const highlightedTitle = highlightResult(item.title, query); const highlightedContent = highlightMultilineResult(item.content, query); if (highlightedTitle.highlighted || highlightedContent.highlighted) { - if ((tempRootTitleIndex == 0 && tempRootTitleIndex == item.rootTitleIndex) || (tempRootTitleIndex < item.rootTitleIndex)) { + if ( + (tempRootTitleIndex == 0 && + tempRootTitleIndex == item.rootTitleIndex) || + tempRootTitleIndex < item.rootTitleIndex + ) { tempRootTitleIndex = item.rootTitleIndex; addTitleToSearchList(item); - }; - addResultToSearchList(item, highlightedTitle.output, highlightedContent.output); + } + addResultToSearchList( + item, + highlightedTitle.output, + highlightedContent.output + ); isResults = true; } } @@ -194,7 +214,7 @@ import { if (!listItems || listItems.length === 0) return false; removeActive(listItems); if (currentFocus >= listItems.length) currentFocus = 0; - if (currentFocus < 0) currentFocus = (listItems.length - 1); + if (currentFocus < 0) currentFocus = listItems.length - 1; listItems[currentFocus].classList.add('is-selected'); } // Function to manage the scroll for arrow keys management @@ -228,16 +248,22 @@ import { let isHighlightedResult = false; return { highlighted: isHighlightedResult, - output: '' + input.replace(getDiacriticsRegex(query), function(match, offset, string) { - isHighlightedResult = true; - return '' + match + ''; - }) + '' + output: + '' + + input.replace( + getDiacriticsRegex(query), + function (match, offset, string) { + isHighlightedResult = true; + return '' + match + ''; + } + ) + + '', }; - }; + } // Function to highlight a search result based on the input query // without taking diacritics into account and setting delimiter between two distant matches function highlightMultilineResult(input, query) { - let output = ""; + let output = ''; let isHighlightedResult = false; let isLineWithoutHighlight = false; const lineDelimiter = flexSearchThemeOptions.lineDelimiter; @@ -252,22 +278,25 @@ import { if (indexes.length > 0) { isLineWithoutHighlight = false; output = output.concat(''); - if ((indexes[0][0] - maxCharOffset) > minIndex) { + if (indexes[0][0] - maxCharOffset > minIndex) { minIndex = indexes[0][0] - maxCharOffset; output = output.concat(lineDelimiter); } - if ((indexes[indexes.length - 1][1] + maxCharOffset) < maxIndex) { + if (indexes[indexes.length - 1][1] + maxCharOffset < maxIndex) { maxIndex = indexes[indexes.length - 1][1] + maxCharOffset; } let tIndex; let nIndex = indexes.shift(); let isIntermediate = false; - for (let i = minIndex; i < (maxIndex + 1); i++) { + for (let i = minIndex; i < maxIndex + 1; i++) { if ((tIndex && tIndex[0] === i) || (nIndex && nIndex[0] === i)) { output = output.concat(''); isHighlightedResult = true; } - if ((tIndex && i <= (tIndex[1] + maxCharOffset)) || (nIndex && i >= (nIndex[0] - maxCharOffset))) { + if ( + (tIndex && i <= tIndex[1] + maxCharOffset) || + (nIndex && i >= nIndex[0] - maxCharOffset) + ) { output = output.concat(line.charAt(i)); } else { if (!isIntermediate) { @@ -295,116 +324,290 @@ import { } return { highlighted: isHighlightedResult, - output: output + output: output, }; - }; + } // Function to build two-dimensions array containing indexes (begin and end) // of matches in a string based on a regex function buildMatchesIndexes(input, regex) { let match; let indexes = []; - while (match = regex.exec(input)) { - indexes.push([match.index, (regex.lastIndex-1)]); + while ((match = regex.exec(input))) { + indexes.push([match.index, regex.lastIndex - 1]); } return indexes; } // Function to set a regexp matching diacritics function getDiacriticsRegex(input) { let defaultDiacriticsRemovalMap = [ - {'base':'A', 'letters':'\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F'}, - {'base':'AA','letters':'\uA732'}, - {'base':'AE','letters':'\u00C6\u01FC\u01E2'}, - {'base':'AO','letters':'\uA734'}, - {'base':'AU','letters':'\uA736'}, - {'base':'AV','letters':'\uA738\uA73A'}, - {'base':'AY','letters':'\uA73C'}, - {'base':'B', 'letters':'\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181'}, - {'base':'C', 'letters':'\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E'}, - {'base':'D', 'letters':'\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779'}, - {'base':'DZ','letters':'\u01F1\u01C4'}, - {'base':'Dz','letters':'\u01F2\u01C5'}, - {'base':'E', 'letters':'\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E'}, - {'base':'F', 'letters':'\u0046\u24BB\uFF26\u1E1E\u0191\uA77B'}, - {'base':'G', 'letters':'\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E'}, - {'base':'H', 'letters':'\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D'}, - {'base':'I', 'letters':'\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197'}, - {'base':'J', 'letters':'\u004A\u24BF\uFF2A\u0134\u0248'}, - {'base':'K', 'letters':'\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2'}, - {'base':'L', 'letters':'\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780'}, - {'base':'LJ','letters':'\u01C7'}, - {'base':'Lj','letters':'\u01C8'}, - {'base':'M', 'letters':'\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C'}, - {'base':'N', 'letters':'\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4'}, - {'base':'NJ','letters':'\u01CA'}, - {'base':'Nj','letters':'\u01CB'}, - {'base':'O', 'letters':'\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C'}, - {'base':'OI','letters':'\u01A2'}, - {'base':'OO','letters':'\uA74E'}, - {'base':'OU','letters':'\u0222'}, - {'base':'P', 'letters':'\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754'}, - {'base':'Q', 'letters':'\u0051\u24C6\uFF31\uA756\uA758\u024A'}, - {'base':'R', 'letters':'\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782'}, - {'base':'S', 'letters':'\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784'}, - {'base':'T', 'letters':'\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786'}, - {'base':'TZ','letters':'\uA728'}, - {'base':'U', 'letters':'\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244'}, - {'base':'V', 'letters':'\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245'}, - {'base':'VY','letters':'\uA760'}, - {'base':'W', 'letters':'\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72'}, - {'base':'X', 'letters':'\u0058\u24CD\uFF38\u1E8A\u1E8C'}, - {'base':'Y', 'letters':'\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE'}, - {'base':'Z', 'letters':'\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762'}, - {'base':'a', 'letters':'\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250'}, - {'base':'aa','letters':'\uA733'}, - {'base':'ae','letters':'\u00E6\u01FD\u01E3'}, - {'base':'ao','letters':'\uA735'}, - {'base':'au','letters':'\uA737'}, - {'base':'av','letters':'\uA739\uA73B'}, - {'base':'ay','letters':'\uA73D'}, - {'base':'b', 'letters':'\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253'}, - {'base':'c', 'letters':'\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184'}, - {'base':'d', 'letters':'\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A'}, - {'base':'dz','letters':'\u01F3\u01C6'}, - {'base':'e', 'letters':'\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD'}, - {'base':'f', 'letters':'\u0066\u24D5\uFF46\u1E1F\u0192\uA77C'}, - {'base':'g', 'letters':'\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F'}, - {'base':'h', 'letters':'\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265'}, - {'base':'hv','letters':'\u0195'}, - {'base':'i', 'letters':'\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131'}, - {'base':'j', 'letters':'\u006A\u24D9\uFF4A\u0135\u01F0\u0249'}, - {'base':'k', 'letters':'\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3'}, - {'base':'l', 'letters':'\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747'}, - {'base':'lj','letters':'\u01C9'}, - {'base':'m', 'letters':'\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F'}, - {'base':'n', 'letters':'\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5'}, - {'base':'nj','letters':'\u01CC'}, - {'base':'o', 'letters':'\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275'}, - {'base':'oi','letters':'\u01A3'}, - {'base':'ou','letters':'\u0223'}, - {'base':'oo','letters':'\uA74F'}, - {'base':'p','letters':'\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755'}, - {'base':'q','letters':'\u0071\u24E0\uFF51\u024B\uA757\uA759'}, - {'base':'r','letters':'\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783'}, - {'base':'s','letters':'\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B'}, - {'base':'t','letters':'\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787'}, - {'base':'tz','letters':'\uA729'}, - {'base':'u','letters': '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289'}, - {'base':'v','letters':'\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C'}, - {'base':'vy','letters':'\uA761'}, - {'base':'w','letters':'\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73'}, - {'base':'x','letters':'\u0078\u24E7\uFF58\u1E8B\u1E8D'}, - {'base':'y','letters':'\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF'}, - {'base':'z','letters':'\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763'} + { + base: 'A', + letters: + '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F', + }, + { base: 'AA', letters: '\uA732' }, + { base: 'AE', letters: '\u00C6\u01FC\u01E2' }, + { base: 'AO', letters: '\uA734' }, + { base: 'AU', letters: '\uA736' }, + { base: 'AV', letters: '\uA738\uA73A' }, + { base: 'AY', letters: '\uA73C' }, + { + base: 'B', + letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181', + }, + { + base: 'C', + letters: + '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E', + }, + { + base: 'D', + letters: + '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779', + }, + { base: 'DZ', letters: '\u01F1\u01C4' }, + { base: 'Dz', letters: '\u01F2\u01C5' }, + { + base: 'E', + letters: + '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E', + }, + { base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' }, + { + base: 'G', + letters: + '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E', + }, + { + base: 'H', + letters: + '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D', + }, + { + base: 'I', + letters: + '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197', + }, + { base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' }, + { + base: 'K', + letters: + '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2', + }, + { + base: 'L', + letters: + '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780', + }, + { base: 'LJ', letters: '\u01C7' }, + { base: 'Lj', letters: '\u01C8' }, + { + base: 'M', + letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C', + }, + { + base: 'N', + letters: + '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4', + }, + { base: 'NJ', letters: '\u01CA' }, + { base: 'Nj', letters: '\u01CB' }, + { + base: 'O', + letters: + '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C', + }, + { base: 'OI', letters: '\u01A2' }, + { base: 'OO', letters: '\uA74E' }, + { base: 'OU', letters: '\u0222' }, + { + base: 'P', + letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754', + }, + { base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' }, + { + base: 'R', + letters: + '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782', + }, + { + base: 'S', + letters: + '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784', + }, + { + base: 'T', + letters: + '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786', + }, + { base: 'TZ', letters: '\uA728' }, + { + base: 'U', + letters: + '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244', + }, + { + base: 'V', + letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245', + }, + { base: 'VY', letters: '\uA760' }, + { + base: 'W', + letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72', + }, + { base: 'X', letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' }, + { + base: 'Y', + letters: + '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE', + }, + { + base: 'Z', + letters: + '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762', + }, + { + base: 'a', + letters: + '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250', + }, + { base: 'aa', letters: '\uA733' }, + { base: 'ae', letters: '\u00E6\u01FD\u01E3' }, + { base: 'ao', letters: '\uA735' }, + { base: 'au', letters: '\uA737' }, + { base: 'av', letters: '\uA739\uA73B' }, + { base: 'ay', letters: '\uA73D' }, + { + base: 'b', + letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253', + }, + { + base: 'c', + letters: + '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184', + }, + { + base: 'd', + letters: + '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A', + }, + { base: 'dz', letters: '\u01F3\u01C6' }, + { + base: 'e', + letters: + '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD', + }, + { base: 'f', letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' }, + { + base: 'g', + letters: + '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F', + }, + { + base: 'h', + letters: + '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265', + }, + { base: 'hv', letters: '\u0195' }, + { + base: 'i', + letters: + '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131', + }, + { base: 'j', letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' }, + { + base: 'k', + letters: + '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3', + }, + { + base: 'l', + letters: + '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747', + }, + { base: 'lj', letters: '\u01C9' }, + { + base: 'm', + letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F', + }, + { + base: 'n', + letters: + '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5', + }, + { base: 'nj', letters: '\u01CC' }, + { + base: 'o', + letters: + '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275', + }, + { base: 'oi', letters: '\u01A3' }, + { base: 'ou', letters: '\u0223' }, + { base: 'oo', letters: '\uA74F' }, + { + base: 'p', + letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755', + }, + { base: 'q', letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' }, + { + base: 'r', + letters: + '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783', + }, + { + base: 's', + letters: + '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B', + }, + { + base: 't', + letters: + '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787', + }, + { base: 'tz', letters: '\uA729' }, + { + base: 'u', + letters: + '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289', + }, + { + base: 'v', + letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C', + }, + { base: 'vy', letters: '\uA761' }, + { + base: 'w', + letters: + '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73', + }, + { base: 'x', letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' }, + { + base: 'y', + letters: + '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF', + }, + { + base: 'z', + letters: + '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763', + }, ]; // build a map to feed to the function let stringRegExp = ''; for (const inputChar of input) { let isLetterFound = false; - diacriticsLoop: - for (let j = 0; j < defaultDiacriticsRemovalMap.length ; j++) { + diacriticsLoop: for ( + let j = 0; + j < defaultDiacriticsRemovalMap.length; + j++ + ) { for (const letter of defaultDiacriticsRemovalMap[j].letters) { if (inputChar === letter) { - stringRegExp = stringRegExp.concat('[', defaultDiacriticsRemovalMap[j].letters, ']'); + stringRegExp = stringRegExp.concat( + '[', + defaultDiacriticsRemovalMap[j].letters, + ']' + ); isLetterFound = true; break diacriticsLoop; } @@ -415,14 +618,14 @@ import { } } return new RegExp(stringRegExp, 'gi'); - }; + } // MAIN // - const hideSearch = function() { + const hideSearch = function () { if (!isSearchListHidden()) { hideSearchList(); } - } + }; addFunctionToResizeEvent(hideSearch); buildIndex(baseUrl); initSearch(); -})(); \ No newline at end of file +})(); diff --git a/assets/js/theme/shortcuts.js b/assets/js/theme/shortcuts.js index 7572eaed..fae088fa 100644 --- a/assets/js/theme/shortcuts.js +++ b/assets/js/theme/shortcuts.js @@ -1,7 +1,4 @@ -import { - closeModals, - isFocusable -} from './modules/helpers.min.js' +import { closeModals, isFocusable } from './modules/helpers.min.js'; // VARS // // MAIN // @@ -16,7 +13,9 @@ function scShowInfo() { window.scShowShortcuts = scShowShortcuts; function scShowShortcuts() { closeModals(); - document.getElementById('navbarShortcuts').classList.toggle('is-hidden', false); + document + .getElementById('navbarShortcuts') + .classList.toggle('is-hidden', false); document.getElementById('search').blur(); } // Function to go to homepage diff --git a/assets/js/theme/sidebar.js b/assets/js/theme/sidebar.js index 75b3d94f..da2d9ca3 100644 --- a/assets/js/theme/sidebar.js +++ b/assets/js/theme/sidebar.js @@ -7,107 +7,147 @@ import { getScrollOffset, manageClickCollapsibleSidebar, manageDefaultCollapsibleSidebar, - toggleSidebarEntry -} from './modules/helpers.min.js' -import { - overlayOptions -} from './modules/const.min.js' + toggleSidebarEntry, +} from './modules/helpers.min.js'; +import { overlayOptions } from './modules/const.min.js'; // VARS // // MAIN // //Manage sidebar actions -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { manageDefaultCollapsibleSidebar(); //Create perfect scrollbar instances new OverlayScrollbars(document.getElementById('sidebar'), overlayOptions); //Manage expand function for sidebar entries let iie = document.getElementsByClassName('is-icon-expandable'); for (let i = 0; i < iie.length; i++) { - iie[i].addEventListener('click', function(e) { + iie[i].addEventListener('click', function (e) { toggleSidebarEntry(this); }); - }; + } //Manage hover function for sidebar entries when collapsed let ifei = document.getElementsByClassName('is-fs-expandable-icon'); for (let i = 0; i < ifei.length; i++) { - ifei[i].addEventListener('mouseenter', function(e) { + ifei[i].addEventListener('mouseenter', function (e) { let entriesContainer = this.nextElementSibling; if (e.relatedTarget !== entriesContainer) { let sidebarContainer = document.getElementById('sidebarContainer'); - let sidebarCurrentWidth = parseFloat(getComputedStyle(sidebarContainer).getPropertyValue('width')); - let sidebarMinimumWidth = parseFloat(getComputedStyle(document.getElementById('sidebarMobileWrapper')).getPropertyValue('max-width')) - if (sidebarContainer.classList.contains('is-sidebar-collapsed') && entriesContainer && (sidebarCurrentWidth <= sidebarMinimumWidth)) { + let sidebarCurrentWidth = parseFloat( + getComputedStyle(sidebarContainer).getPropertyValue('width') + ); + let sidebarMinimumWidth = parseFloat( + getComputedStyle( + document.getElementById('sidebarMobileWrapper') + ).getPropertyValue('max-width') + ); + if ( + sidebarContainer.classList.contains('is-sidebar-collapsed') && + entriesContainer && + sidebarCurrentWidth <= sidebarMinimumWidth + ) { entriesContainer.classList.toggle('is-hovered', true); entriesContainer.classList.toggle('is-invisible', true); let sidebar = document.getElementById('sidebar'); - let entriesWrapper = entriesContainer.getElementsByClassName('is-sidebar-list-wrapper')[0]; + let entriesWrapper = entriesContainer.getElementsByClassName( + 'is-sidebar-list-wrapper' + )[0]; // Scroll the sidebar to make the element fully visible if (!isInScrollContainer(this, sidebar)) { let scrollContainer = getFirstAncestorByClass(this, 'os-viewport'); if (scrollContainer) { - scrollContainer.scrollTop = scrollContainer.scrollTop + getScrollOffset(this, scrollContainer); - }; - }; - const sidebarPadding = parseFloat(getComputedStyle(sidebar).getPropertyValue('padding-top')); - const sidebarBorder = parseFloat(getComputedStyle(sidebar).getPropertyValue('border-right-width')); - const logoBorder = parseFloat(getComputedStyle(document.getElementById('globalLogo')).getPropertyValue('margin-bottom')); - const sidebarTop = sidebarContainer.getBoundingClientRect().top - logoBorder; - const sidebarIconTop = this.getBoundingClientRect().top - sidebarPadding - sidebarBorder; + scrollContainer.scrollTop = + scrollContainer.scrollTop + + getScrollOffset(this, scrollContainer); + } + } + const sidebarPadding = parseFloat( + getComputedStyle(sidebar).getPropertyValue('padding-top') + ); + const sidebarBorder = parseFloat( + getComputedStyle(sidebar).getPropertyValue('border-right-width') + ); + const logoBorder = parseFloat( + getComputedStyle( + document.getElementById('globalLogo') + ).getPropertyValue('margin-bottom') + ); + const sidebarTop = + sidebarContainer.getBoundingClientRect().top - logoBorder; + const sidebarIconTop = + this.getBoundingClientRect().top - sidebarPadding - sidebarBorder; const sidebarMinTop = Math.max(sidebarIconTop, sidebarTop); const entriesHeight = entriesWrapper.getBoundingClientRect().height; const offsetBot = window.innerHeight - sidebarMinTop - entriesHeight; - let entriesTop = ""; - let entriesMaxHeight = ""; + let entriesTop = ''; + let entriesMaxHeight = ''; if (offsetBot > 0) { entriesTop = sidebarMinTop; - entriesMaxHeight = (window.innerHeight - sidebarMinTop); + entriesMaxHeight = window.innerHeight - sidebarMinTop; } else { entriesTop = sidebarMinTop; - entriesMaxHeight = (window.innerHeight - sidebarMinTop); - }; - entriesContainer.style.top = entriesTop + "px"; - entriesContainer.style.left = this.getBoundingClientRect().right + "px"; - entriesWrapper.style.maxHeight = entriesMaxHeight + "px"; + entriesMaxHeight = window.innerHeight - sidebarMinTop; + } + entriesContainer.style.top = entriesTop + 'px'; + entriesContainer.style.left = + this.getBoundingClientRect().right + 'px'; + entriesWrapper.style.maxHeight = entriesMaxHeight + 'px'; new OverlayScrollbars(entriesWrapper, overlayOptions); - manageActiveEntryScroll(document.getElementById('sidebarActiveEntry')); + manageActiveEntryScroll( + document.getElementById('sidebarActiveEntry') + ); entriesContainer.classList.toggle('is-invisible', false); - }; - }; + } + } }); - ifei[i].addEventListener('mouseleave', function(e) { + ifei[i].addEventListener('mouseleave', function (e) { let sidebarContainer = document.getElementById('sidebarContainer'); let entriesContainer = this.nextElementSibling; - let entriesWrapper = entriesContainer.getElementsByClassName('is-sidebar-list-wrapper')[0]; - if (sidebarContainer.classList.contains('is-sidebar-collapsed') && entriesContainer) { + let entriesWrapper = entriesContainer.getElementsByClassName( + 'is-sidebar-list-wrapper' + )[0]; + if ( + sidebarContainer.classList.contains('is-sidebar-collapsed') && + entriesContainer + ) { if (e.relatedTarget !== entriesContainer) { entriesContainer.classList.toggle('is-hovered', false); - entriesContainer.style.top = ""; - entriesContainer.style.bottom = ""; - entriesContainer.style.left = ""; - entriesWrapper.style.maxHeight = ""; - }; - }; + entriesContainer.style.top = ''; + entriesContainer.style.bottom = ''; + entriesContainer.style.left = ''; + entriesWrapper.style.maxHeight = ''; + } + } }); - }; + } let ie = document.getElementsByClassName('is-expandable'); for (let i = 0; i < ie.length; i++) { - ie[i].addEventListener('mouseleave', function(e) { - if (e.relatedTarget && getFirstAncestorByClass(e.relatedTarget, 'is-fs-expandable-icon') !== this.previousElementSibling) { + ie[i].addEventListener('mouseleave', function (e) { + if ( + e.relatedTarget && + getFirstAncestorByClass(e.relatedTarget, 'is-fs-expandable-icon') !== + this.previousElementSibling + ) { let sidebarContainer = document.getElementById('sidebarContainer'); if (sidebarContainer.classList.contains('is-sidebar-collapsed')) { this.classList.toggle('is-hovered', false); - this.style.top = ""; - this.style.bottom = ""; - this.style.left = ""; - this.getElementsByClassName('is-sidebar-list-wrapper')[0].style.maxHeight = ""; - }; - }; + this.style.top = ''; + this.style.bottom = ''; + this.style.left = ''; + this.getElementsByClassName( + 'is-sidebar-list-wrapper' + )[0].style.maxHeight = ''; + } + } }); - }; + } manageActiveEntryScroll(document.getElementById('sidebarActiveEntry')); // Manage click on collapsible sidebar - document.getElementById('sidebarUncollapse').addEventListener('click', () => {manageClickCollapsibleSidebar()}); - document.getElementById('sidebarCollapse').addEventListener('click', () => {manageClickCollapsibleSidebar()}); + document.getElementById('sidebarUncollapse').addEventListener('click', () => { + manageClickCollapsibleSidebar(); + }); + document.getElementById('sidebarCollapse').addEventListener('click', () => { + manageClickCollapsibleSidebar(); + }); // Manage collapsible sidebar during resize of window addFunctionToResizeEvent(manageDefaultCollapsibleSidebar); }); @@ -116,7 +156,8 @@ function manageActiveEntryScroll(e) { if (e && isInViewport(e)) { let scrollContainer = getFirstAncestorByClass(e, 'os-viewport'); if (scrollContainer) { - scrollContainer.scrollTop = scrollContainer.scrollTop + getScrollMiddleOffset(e, scrollContainer); - }; - }; -}; \ No newline at end of file + scrollContainer.scrollTop = + scrollContainer.scrollTop + getScrollMiddleOffset(e, scrollContainer); + } + } +} diff --git a/assets/js/theme/toc.js b/assets/js/theme/toc.js index 8b3690f0..4157b9f5 100644 --- a/assets/js/theme/toc.js +++ b/assets/js/theme/toc.js @@ -2,13 +2,13 @@ import { addFunctionToResizeEvent, manageClickCollapsibleToc, manageDefaultToc, - waitForScroll -} from './modules/helpers.min.js' + waitForScroll, +} from './modules/helpers.min.js'; // VARS // // MAIN // //Manage Toc actions -document.addEventListener('DOMContentLoaded', function() { +document.addEventListener('DOMContentLoaded', function () { manageDefaultToc(); // Manage toc during scroll function manageTocScroll() { @@ -22,13 +22,15 @@ document.addEventListener('DOMContentLoaded', function() { } else { tocEntryNext(te[i]); } - }; - }; + } + } // Return the index of the current entry of the Toc let getCurrentTocEntryIndex = function (containerTop) { let currentTocEntry = -1; for (let i = 0; i < te.length; i++) { - const titleTop = document.getElementById(te[i].getAttribute('href').substring(1)).getBoundingClientRect().top; + const titleTop = document + .getElementById(te[i].getAttribute('href').substring(1)) + .getBoundingClientRect().top; if (Math.floor(titleTop - containerTop) <= 0) { currentTocEntry = i; } @@ -39,38 +41,40 @@ document.addEventListener('DOMContentLoaded', function() { function tocEntryPast(e) { e.classList.toggle('is-past', true); e.classList.toggle('is-current', false); - }; + } // Change style for current entry function tocEntryCurrent(e) { e.classList.toggle('is-past', false); e.classList.toggle('is-current', true); - }; + } // Change style for next entries function tocEntryNext(e) { e.classList.toggle('is-past', false); e.classList.toggle('is-current', false); - }; + } // Manage toc global behavior let scrollTicking = false; let isTocClicked = false; let cc = document.getElementById('contentContainer'); let te = document.querySelectorAll('#TableOfContents a'); for (let i = 0; i < te.length; i++) { - te[i].addEventListener('click', function(e) { + te[i].addEventListener('click', function (e) { isTocClicked = true; - waitForScroll(cc, 100, 100).then(result => { - if (result) { - manageTocScroll(); - isTocClicked = false; - } else { - return Promise.reject("Cannot reach end of scroll"); - } - }).catch(err => { - console.error("Error managing click event for " + this + ": " + err); + waitForScroll(cc, 100, 100) + .then((result) => { + if (result) { + manageTocScroll(); + isTocClicked = false; + } else { + return Promise.reject('Cannot reach end of scroll'); + } + }) + .catch((err) => { + console.error('Error managing click event for ' + this + ': ' + err); isTocClicked = false; - }); + }); }); - }; + } // Function to manage the back to top button function manageBackToTop() { if (cc.scrollTop > 0) { @@ -78,28 +82,30 @@ document.addEventListener('DOMContentLoaded', function() { } else { btt.classList.toggle('is-active', false); } - }; + } let btt = document.getElementById('tocBackToTop'); if (btt) { - btt.addEventListener('click', function(e) { + btt.addEventListener('click', function (e) { cc.scrollTop = 0; isTocClicked = true; - waitForScroll(cc, 100, 100).then(result => { - if (result) { - manageTocScroll(); - isTocClicked = false; - } else { - return Promise.reject("Cannot reach end of scroll"); - } - }).catch(err => { - console.error("Error managing click event for " + this + ": " + err); + waitForScroll(cc, 100, 100) + .then((result) => { + if (result) { + manageTocScroll(); + isTocClicked = false; + } else { + return Promise.reject('Cannot reach end of scroll'); + } + }) + .catch((err) => { + console.error('Error managing click event for ' + this + ': ' + err); isTocClicked = false; - }); + }); }); - }; - cc.addEventListener('scroll', function() { + } + cc.addEventListener('scroll', function () { if (!scrollTicking) { - window.requestAnimationFrame(function() { + window.requestAnimationFrame(function () { if (!isTocClicked) { manageTocScroll(); } @@ -112,8 +118,10 @@ document.addEventListener('DOMContentLoaded', function() { // Manage click on collapsible toc let tc = document.getElementById('tocCollapsible'); if (tc) { - tc.addEventListener('click', () => {manageClickCollapsibleToc()}); - }; + tc.addEventListener('click', () => { + manageClickCollapsibleToc(); + }); + } // Manage collapsible sidebar during resize of window addFunctionToResizeEvent(manageDefaultToc); -}); \ No newline at end of file +}); diff --git a/cypress.config.js b/cypress.config.js index a33126e2..fb8997f8 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,49 +1,52 @@ -const { defineConfig } = require('cypress') +const { defineConfig } = require('cypress'); module.exports = defineConfig({ e2e: { - baseUrl: "http://localhost:1313/" + baseUrl: 'http://localhost:1313/', }, viewportWidth: 1920, viewportHeight: 1080, screenshotOnRunFailure: false, video: false, env: { - "404_PATH" : "404.html", - "SITEMAP_XML_PATH" : "sitemap.xml", - "FRENCH_URL_PREFIX" : "/fr", - "FUNC_TOC_PATH" : "functionalities/toc/", - "FUNC_TOC_DISABLED_PATH" : "functionalities/toc/toc_disabled/", - "FUNC_BANNER_PATHS" : ["functionalities/banner/global/","functionalities/banner/single/"], - "FUNC_MERMAID_PATH" : "functionalities/mermaid/", - "HOMEPAGE_URL" : "http://localhost:1313/", - "NULL_STRING" : "bnVsbFN0cmluZw==", - "SEARCH_TEST_INPUT" : "theme", - "SC_PATH" : "shortcodes/", - "SC_ALERT_PATH" : "alert/", - "SC_ASYNCAPI_PATH" : "asyncapi/", - "SC_BLOCKQUOTE_PATH" : "blockquote/", - "SC_COLLAPSIBLE_PATH" : "collapsible/", - "SC_HIGHCHARTS_PATH" : "highcharts/", - "SC_INTRO_PATH" : "intro/", - "SC_OPENAPI_PATH" : "openapi/", - "SC_PAGEBREAK_PATH" : "pagebreak/", - "SC_PARAMETER_PATH" : "parameter/", - "SC_SNIPPET_PATH" : "snippet/", - "SC_TREEVIEW_PATH" : "treeview/", - "SITEMAP_PATH" : "sitemap/", - "TAXONOMY_PATH" : "categories/", - "TERM_PATH" : "categories/markdown/", - "THEME_PATH" : "theme/", - "VIEWPORT_COMMON_HEIGHT" : 1080, - "VIEWPORT_WIDESCREEN_MAXWIDTH" : 1407, - "VIEWPORT_WIDESCREEN_MINWIDTH" : 1216, - "VIEWPORT_DESKTOP_MAXWIDTH" : 1215, - "VIEWPORT_DESKTOP_MINWIDTH" : 1024, - "VIEWPORT_TOUCH_MAXWIDTH" : 1023, - "VIEWPORT_TOUCH_MINWIDTH" : 769, - "VIEWPORT_MOBILE_MAXWIDTH" : 768, - "VIEWPORT_MOBILE_MINWIDTH" : 300, - "WAIT_FOR_ANIMATION" : 500 - } -}) + '404_PATH': '404.html', + SITEMAP_XML_PATH: 'sitemap.xml', + FRENCH_URL_PREFIX: '/fr', + FUNC_TOC_PATH: 'functionalities/toc/', + FUNC_TOC_DISABLED_PATH: 'functionalities/toc/toc_disabled/', + FUNC_BANNER_PATHS: [ + 'functionalities/banner/global/', + 'functionalities/banner/single/', + ], + FUNC_MERMAID_PATH: 'functionalities/mermaid/', + HOMEPAGE_URL: 'http://localhost:1313/', + NULL_STRING: 'bnVsbFN0cmluZw==', + SEARCH_TEST_INPUT: 'theme', + SC_PATH: 'shortcodes/', + SC_ALERT_PATH: 'alert/', + SC_ASYNCAPI_PATH: 'asyncapi/', + SC_BLOCKQUOTE_PATH: 'blockquote/', + SC_COLLAPSIBLE_PATH: 'collapsible/', + SC_HIGHCHARTS_PATH: 'highcharts/', + SC_INTRO_PATH: 'intro/', + SC_OPENAPI_PATH: 'openapi/', + SC_PAGEBREAK_PATH: 'pagebreak/', + SC_PARAMETER_PATH: 'parameter/', + SC_SNIPPET_PATH: 'snippet/', + SC_TREEVIEW_PATH: 'treeview/', + SITEMAP_PATH: 'sitemap/', + TAXONOMY_PATH: 'categories/', + TERM_PATH: 'categories/markdown/', + THEME_PATH: 'theme/', + VIEWPORT_COMMON_HEIGHT: 1080, + VIEWPORT_WIDESCREEN_MAXWIDTH: 1407, + VIEWPORT_WIDESCREEN_MINWIDTH: 1216, + VIEWPORT_DESKTOP_MAXWIDTH: 1215, + VIEWPORT_DESKTOP_MINWIDTH: 1024, + VIEWPORT_TOUCH_MAXWIDTH: 1023, + VIEWPORT_TOUCH_MINWIDTH: 769, + VIEWPORT_MOBILE_MAXWIDTH: 768, + VIEWPORT_MOBILE_MINWIDTH: 300, + WAIT_FOR_ANIMATION: 500, + }, +}); diff --git a/cypress/e2e/global/404Tests.cy.js b/cypress/e2e/global/404Tests.cy.js index 58981b62..50cf7753 100644 --- a/cypress/e2e/global/404Tests.cy.js +++ b/cypress/e2e/global/404Tests.cy.js @@ -1,17 +1,14 @@ describe('for: 404 page', () => { beforeEach(() => { - cy.visit(Cypress.env('404_PATH')) - }) + cy.visit(Cypress.env('404_PATH')); + }); it('link back to homepage should be displayed', () => { - cy.get('#footer404') - .should('be.visible') - }) + cy.get('#footer404').should('be.visible'); + }); it('link back to homepage should redirect to homepage', () => { - cy.get('#footer404') - .click() - cy.location() - .should((loc) => { - expect(loc.toString()).to.eq(Cypress.env('HOMEPAGE_URL')) - }) - }) -}) \ No newline at end of file + cy.get('#footer404').click(); + cy.location().should((loc) => { + expect(loc.toString()).to.eq(Cypress.env('HOMEPAGE_URL')); + }); + }); +}); diff --git a/cypress/e2e/global/bannerTests.cy.js b/cypress/e2e/global/bannerTests.cy.js index dc7eb986..97de084c 100644 --- a/cypress/e2e/global/bannerTests.cy.js +++ b/cypress/e2e/global/bannerTests.cy.js @@ -1,15 +1,13 @@ for (const bannerUrl of Cypress.env('FUNC_BANNER_PATHS')) { describe('for: table of content of ' + bannerUrl, () => { beforeEach(() => { - cy.visit(bannerUrl) - }) + cy.visit(bannerUrl); + }); it('at least one banner should be displayed', () => { - cy.get('#content .banner') - .should('have.length.at.least', 1) - }) + cy.get('#content .banner').should('have.length.at.least', 1); + }); it('banner should be displayed', () => { - cy.get('#content .banner') - .should('be.visible') - }) - }) -} \ No newline at end of file + cy.get('#content .banner').should('be.visible'); + }); + }); +} diff --git a/cypress/e2e/global/contentTests.cy.js b/cypress/e2e/global/contentTests.cy.js index ca8115a2..cf537660 100644 --- a/cypress/e2e/global/contentTests.cy.js +++ b/cypress/e2e/global/contentTests.cy.js @@ -1,16 +1,16 @@ describe('for: content', () => { beforeEach(() => { - cy.visit(Cypress.env('FUNC_TOC_PATH')) - }) + cy.visit(Cypress.env('FUNC_TOC_PATH')); + }); it('all titles should have anchors', () => { cy.get('#content') .children('h1,h2,h3,h4,h5,h6') .each(($title) => { cy.get($title[0]) .children('a[href="#' + encodeURI($title[0].id).toLowerCase() + '"]') - .should('have.class', 'anchor') - }) - }) + .should('have.class', 'anchor'); + }); + }); it('all anchors should redirect to appropriate URL', () => { cy.get('#content') .children('h1,h2,h3,h4,h5,h6') @@ -18,9 +18,14 @@ describe('for: content', () => { cy.get($title[0]) .children('a[href="#' + encodeURI($title[0].id).toLowerCase() + '"]') .should('have.class', 'anchor') - .click({ force: true }) - cy.location('href') - .should('eq', Cypress.env('HOMEPAGE_URL') + Cypress.env('FUNC_TOC_PATH') + '#' + encodeURI($title[0].id).toLowerCase()) - }) - }) -}) \ No newline at end of file + .click({ force: true }); + cy.location('href').should( + 'eq', + Cypress.env('HOMEPAGE_URL') + + Cypress.env('FUNC_TOC_PATH') + + '#' + + encodeURI($title[0].id).toLowerCase() + ); + }); + }); +}); diff --git a/cypress/e2e/global/logoTests.cy.js b/cypress/e2e/global/logoTests.cy.js index 9a7942a0..ce621bec 100644 --- a/cypress/e2e/global/logoTests.cy.js +++ b/cypress/e2e/global/logoTests.cy.js @@ -1,15 +1,12 @@ describe('for: logo', () => { beforeEach(() => { - cy.visit(Cypress.env('SITEMAP_PATH')) - }) + cy.visit(Cypress.env('SITEMAP_PATH')); + }); it('logo should be displayed', () => { - cy.get('#globalLogo') - .should('be.visible') - }) + cy.get('#globalLogo').should('be.visible'); + }); it('logo should redirect to homepage', () => { - cy.get('#globalLogo') - .click() - cy.location('href') - .should('eq', Cypress.env('HOMEPAGE_URL')) - }) -}) \ No newline at end of file + cy.get('#globalLogo').click(); + cy.location('href').should('eq', Cypress.env('HOMEPAGE_URL')); + }); +}); diff --git a/cypress/e2e/global/mermaidTests.cy.js b/cypress/e2e/global/mermaidTests.cy.js index b6f85224..b96c15dd 100644 --- a/cypress/e2e/global/mermaidTests.cy.js +++ b/cypress/e2e/global/mermaidTests.cy.js @@ -1,67 +1,71 @@ describe('for: mermaid', () => { beforeEach(() => { - cy.visit(Cypress.env('FUNC_MERMAID_PATH')) - }) + cy.visit(Cypress.env('FUNC_MERMAID_PATH')); + }); it('one mermaid should be displayed', () => { - cy.get('#content .sc-mermaid-wrapper > .sc-mermaid-container') - .should('have.length', 1) - }) + cy.get('#content .sc-mermaid-wrapper > .sc-mermaid-container').should( + 'have.length', + 1 + ); + }); it('mermaid should be visible', () => { - cy.get('#content .sc-mermaid-wrapper > .sc-mermaid-container') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('be.visible') - }) - }) + cy.get('#content .sc-mermaid-wrapper > .sc-mermaid-container').each( + ($elem) => { + cy.get($elem).scrollIntoView().should('be.visible'); + } + ); + }); it('mermaid should not have a loading helper once loaded', () => { - cy.get('#content .sc-mermaid-wrapper.helper-loading-container') - .should('not.have.class', 'is-loading') - }) + cy.get('#content .sc-mermaid-wrapper.helper-loading-container').should( + 'not.have.class', + 'is-loading' + ); + }); it('mermaid should contain one svg with corresponding id', () => { - cy.get('#content .sc-mermaid-wrapper.helper-loading-container') - .each(($elem) => { + cy.get('#content .sc-mermaid-wrapper.helper-loading-container').each( + ($elem) => { let elId = $elem[0].id; - cy.get('#' + elId + '-svg') - .should('have.length', 1) - }) - }) + cy.get('#' + elId + '-svg').should('have.length', 1); + } + ); + }); it('mermaid should contain one export button', () => { - cy.get('#content .sc-mermaid-wrapper.helper-loading-container') - .each(($elem) => { + cy.get('#content .sc-mermaid-wrapper.helper-loading-container').each( + ($elem) => { let elId = $elem[0].id; - cy.get('#' + elId + '-export-svg') - .should('have.length', 1) - }) - }) + cy.get('#' + elId + '-export-svg').should('have.length', 1); + } + ); + }); it('mermaid should open modal containing svg when clicked', () => { - cy.get('#content .sc-mermaid-wrapper.helper-loading-container') - .each(($elem) => { + cy.get('#content .sc-mermaid-wrapper.helper-loading-container').each( + ($elem) => { let elId = $elem[0].id; cy.get('#' + elId + '-svg') .scrollIntoView() - .click({ force: true }) - cy.get('#modalContainer #modal #' + elId + '-svg') - .should('be.visible') - }) - }) + .click({ force: true }); + cy.get('#modalContainer #modal #' + elId + '-svg').should('be.visible'); + } + ); + }); // For now local download is not fully supported in firefox browser. // Cypress doesn't seems to accept browser preferences in headless mode. // https://github.com/cypress-io/cypress/issues/8814 it('export button should export mermaid', { browser: '!firefox' }, () => { const path = require('path'); - cy.get('#content .sc-mermaid-wrapper.helper-loading-container') - .each(($elem) => { + cy.get('#content .sc-mermaid-wrapper.helper-loading-container').each( + ($elem) => { let elId = $elem[0].id; - cy.get('#' + elId + '-svg') - .then(($svg) => { - $svg[0].removeAttribute('class'); - cy.get('#' + elId + '-export-svg') - .scrollIntoView() - .click({ force: true }) - cy.readFile(path.join(Cypress.config('downloadsFolder'), elId + '.svg')) - .should('be.equal', $svg[0].outerHTML) - }) - }) - }) -}) \ No newline at end of file + cy.get('#' + elId + '-svg').then(($svg) => { + $svg[0].removeAttribute('class'); + cy.get('#' + elId + '-export-svg') + .scrollIntoView() + .click({ force: true }); + cy.readFile( + path.join(Cypress.config('downloadsFolder'), elId + '.svg') + ).should('be.equal', $svg[0].outerHTML); + }); + } + ); + }); +}); diff --git a/cypress/e2e/global/multilingualTests.cy.js b/cypress/e2e/global/multilingualTests.cy.js index f2a7af15..d104f082 100644 --- a/cypress/e2e/global/multilingualTests.cy.js +++ b/cypress/e2e/global/multilingualTests.cy.js @@ -1,40 +1,62 @@ describe('for: multilingual', () => { beforeEach(() => { - cy.visit(Cypress.env('HOMEPAGE_URL')) - }) + cy.visit(Cypress.env('HOMEPAGE_URL')); + }); it('sitemap.xml should have 2 entries', () => { cy.request(Cypress.env('SITEMAP_XML_PATH')) .its('body') .then((sitemapindex) => { const parser = new DOMParser(); - const xmlSitemapindex = parser.parseFromString(sitemapindex, "text/xml"); - expect(xmlSitemapindex.getElementsByTagName('sitemap')).to.have.length(2) - }) - }) + const xmlSitemapindex = parser.parseFromString( + sitemapindex, + 'text/xml' + ); + expect(xmlSitemapindex.getElementsByTagName('sitemap')).to.have.length( + 2 + ); + }); + }); it('languages sitemap.xml should have the same number of url', () => { cy.request(Cypress.env('SITEMAP_XML_PATH')) .its('body') .then((sitemapindex) => { const parser = new DOMParser(); - const sitemaps = parser.parseFromString(sitemapindex, "text/xml").getElementsByTagName('sitemap'); - cy.request(sitemaps[0].getElementsByTagName('loc')[0].childNodes[0].nodeValue) + const sitemaps = parser + .parseFromString(sitemapindex, 'text/xml') + .getElementsByTagName('sitemap'); + cy.request( + sitemaps[0].getElementsByTagName('loc')[0].childNodes[0].nodeValue + ) .its('body') - .then((urlset) => parser.parseFromString(urlset, "text/xml").getElementsByTagName('url').length) + .then( + (urlset) => + parser + .parseFromString(urlset, 'text/xml') + .getElementsByTagName('url').length + ) .then((urlCount) => { for (let sitemap of sitemaps) { - cy.request(sitemap.getElementsByTagName('loc')[0].childNodes[0].nodeValue) + cy.request( + sitemap.getElementsByTagName('loc')[0].childNodes[0].nodeValue + ) .its('body') - .then((urlset) => parser.parseFromString(urlset, "text/xml").getElementsByTagName('url')) + .then((urlset) => + parser + .parseFromString(urlset, 'text/xml') + .getElementsByTagName('url') + ) .should((urlset) => { - expect(urlset.length).to.equal(urlCount) + expect(urlset.length).to.equal(urlCount); }) .then((urlset) => { for (let url of urlset) { - cy.request(url.getElementsByTagName('loc')[0].childNodes[0].nodeValue) + cy.request( + url.getElementsByTagName('loc')[0].childNodes[0].nodeValue + ); } - }) + }); } - }) - }) - }) -}) \ No newline at end of file + }); + }); + }); +}); diff --git a/cypress/e2e/global/navbarTests.cy.js b/cypress/e2e/global/navbarTests.cy.js index 66193278..d3152bc3 100644 --- a/cypress/e2e/global/navbarTests.cy.js +++ b/cypress/e2e/global/navbarTests.cy.js @@ -1,100 +1,92 @@ -const testCases = ['default', 'mobile'] +const testCases = ['default', 'mobile']; for (const testCase of testCases) { describe('for: navbar' + ' on ' + testCase, () => { - const extendId = (testCase == 'mobile') ? 'Extend' : ''; + const extendId = testCase == 'mobile' ? 'Extend' : ''; beforeEach(() => { - cy[testCase + 'NavbarBeforeEach']() - }) + cy[testCase + 'NavbarBeforeEach'](); + }); describe('when multilingual dropdown', () => { it('hover should display languages', () => { - cy.get(`#langsSelectorContainer${extendId}`) - .then(($elem) => { - $elem.get(0).classList.toggle('is-hovered', true) - }) - cy.get(`#dropdown-menu-langs${extendId}`) - .should('be.visible') - }) + cy.get(`#langsSelectorContainer${extendId}`).then(($elem) => { + $elem.get(0).classList.toggle('is-hovered', true); + }); + cy.get(`#dropdown-menu-langs${extendId}`).should('be.visible'); + }); it('should have 2 languages', () => { - cy.get(`#dropdown-menu-langs${extendId} .dropdown-item`) - .should('have.length', 2) - }) - }) + cy.get(`#dropdown-menu-langs${extendId} .dropdown-item`).should( + 'have.length', + 2 + ); + }); + }); describe('when tag dropdown', () => { it('hover should display taxonomies', () => { - cy.get(`#taxonomiesSelectorContainer${extendId}`) - .then(($elem) => { - $elem.get(0).classList.toggle('is-hovered', true) - }) - cy.get(`#dropdown-menu-taxonomies${extendId}`) - .should('be.visible') - }) + cy.get(`#taxonomiesSelectorContainer${extendId}`).then(($elem) => { + $elem.get(0).classList.toggle('is-hovered', true); + }); + cy.get(`#dropdown-menu-taxonomies${extendId}`).should('be.visible'); + }); it('should have 2 tag', () => { - cy.get(`#dropdown-menu-taxonomies${extendId} .dropdown-item`) - .should('have.length', 2) - }) - }) + cy.get(`#dropdown-menu-taxonomies${extendId} .dropdown-item`).should( + 'have.length', + 2 + ); + }); + }); describe('when print icon', () => { it('print icon should be displayed', () => { - cy.get(`#printButton${extendId}`) - .should('be.visible') - }) + cy.get(`#printButton${extendId}`).should('be.visible'); + }); it('print icon should open print preview when clicked', () => { - cy.window().its('scPrint') - cy.scPrintStub() - cy.get(`#printButton${extendId}`) - .click() - cy.scPrintResults() - }) - }) + cy.window().its('scPrint'); + cy.scPrintStub(); + cy.get(`#printButton${extendId}`).click(); + cy.scPrintResults(); + }); + }); describe('when QR code icon', () => { it('QR code icon should be displayed', () => { - cy.get(`#qrCodeButton${extendId}`) - .should('be.visible') - }) + cy.get(`#qrCodeButton${extendId}`).should('be.visible'); + }); it('QR code icon should open QR code panel when clicked', () => { - cy.window().its('scQrCode') - cy.get(`#qrCodeButton${extendId}`) - .click() - cy.scQrCodeResults() - }) - }) + cy.window().its('scQrCode'); + cy.get(`#qrCodeButton${extendId}`).click(); + cy.scQrCodeResults(); + }); + }); describe('when shortcuts icon', () => { it('shortcuts icon should be displayed', () => { - cy.get(`#shortcutsInfo${extendId}`) - .should('be.visible') - }) + cy.get(`#shortcutsInfo${extendId}`).should('be.visible'); + }); it('shortcuts icon should open shortcuts panel when clicked', () => { - cy.window().its('scShowShortcuts') - cy.get(`#shortcutsInfo${extendId}`) - .click() - cy.scShowShortcutsResults() - }) - }) + cy.window().its('scShowShortcuts'); + cy.get(`#shortcutsInfo${extendId}`).click(); + cy.scShowShortcutsResults(); + }); + }); describe('when information icon', () => { it('information icon should be displayed', () => { - cy.get(`#siteInfo${extendId}`) - .should('be.visible') - }) + cy.get(`#siteInfo${extendId}`).should('be.visible'); + }); it('information icon should open website information panel when clicked', () => { - cy.window().its('scShowInfo') - cy.get(`#siteInfo${extendId}`) - .click() - cy.scShowInfoResults() - }) - }) + cy.window().its('scShowInfo'); + cy.get(`#siteInfo${extendId}`).click(); + cy.scShowInfoResults(); + }); + }); describe('when versionning dropdown', () => { it('hover should display versions', () => { - cy.get(`#versionsSelectorContainer${extendId}`) - .then(($elem) => { - $elem.get(0).classList.toggle('is-hovered', true) - }) - cy.get(`#dropdown-menu-versions${extendId}`) - .should('be.visible') - }) + cy.get(`#versionsSelectorContainer${extendId}`).then(($elem) => { + $elem.get(0).classList.toggle('is-hovered', true); + }); + cy.get(`#dropdown-menu-versions${extendId}`).should('be.visible'); + }); it('should have 2 versions', () => { - cy.get(`#dropdown-menu-versions${extendId} .dropdown-item`) - .should('have.length', 2) - }) - }) - }) -} \ No newline at end of file + cy.get(`#dropdown-menu-versions${extendId} .dropdown-item`).should( + 'have.length', + 2 + ); + }); + }); + }); +} diff --git a/cypress/e2e/global/qrcodeTests.cy.js b/cypress/e2e/global/qrcodeTests.cy.js index ffbe5dc2..50703f8f 100644 --- a/cypress/e2e/global/qrcodeTests.cy.js +++ b/cypress/e2e/global/qrcodeTests.cy.js @@ -1,18 +1,18 @@ describe('for: QR code', () => { beforeEach(() => { - cy.visit(Cypress.env('HOMEPAGE_URL')) - }) + cy.visit(Cypress.env('HOMEPAGE_URL')); + }); it('QR code should display the correct QR code', () => { - let homeQrCode = 'homeQrCode.png' + let homeQrCode = 'homeQrCode.png'; if (Cypress.browser.name === 'firefox') { - homeQrCode = 'homeQrCode_firefox.png' + homeQrCode = 'homeQrCode_firefox.png'; } - cy.get('#qrCodeButton') - .click() - cy.get('#currentPageQrCode') - .then(($img) => { - cy.fixture('qrcode/' + homeQrCode, 'base64') - .should('be.equal', $img[0].src.replace(/^data:image.+;base64,/, '')) - }) - }) -}) \ No newline at end of file + cy.get('#qrCodeButton').click(); + cy.get('#currentPageQrCode').then(($img) => { + cy.fixture('qrcode/' + homeQrCode, 'base64').should( + 'be.equal', + $img[0].src.replace(/^data:image.+;base64,/, '') + ); + }); + }); +}); diff --git a/cypress/e2e/global/searchTests.cy.js b/cypress/e2e/global/searchTests.cy.js index b47deab9..0a2b281c 100644 --- a/cypress/e2e/global/searchTests.cy.js +++ b/cypress/e2e/global/searchTests.cy.js @@ -1,79 +1,56 @@ describe('for: search', () => { beforeEach(() => { - cy.visit(Cypress.env('HOMEPAGE_URL')) - }) + cy.visit(Cypress.env('HOMEPAGE_URL')); + }); it('search should not be disabled', () => { - cy.get('#search') - .should('not.be.disabled') - }) + cy.get('#search').should('not.be.disabled'); + }); it('search should be empty by default', () => { - cy.get('#search') - .should('have.value', '') - }) + cy.get('#search').should('have.value', ''); + }); it('search should not modify user input', () => { cy.get('#search') .type(Cypress.env('SEARCH_TEST_INPUT'), { delay: 0 }) - .should('have.value', Cypress.env('SEARCH_TEST_INPUT')) - }) + .should('have.value', Cypress.env('SEARCH_TEST_INPUT')); + }); it('search should display elements', () => { - cy.get('#search') - .type(Cypress.env('SEARCH_TEST_INPUT'), { delay: 0 }) + cy.get('#search').type(Cypress.env('SEARCH_TEST_INPUT'), { delay: 0 }); cy.get('#searchList') .children() .should('be.visible') - .should('have.length.greaterThan', 0) - }) + .should('have.length.greaterThan', 0); + }); it('search should display elements when focused', () => { - cy.get('#search') - .type(Cypress.env('SEARCH_TEST_INPUT'), { delay: 0 }) - cy.window() - .trigger('blur') - cy.get('#search') - .focus() - cy.get('#searchList') - .children() - .should('be.visible') - }) + cy.get('#search').type(Cypress.env('SEARCH_TEST_INPUT'), { delay: 0 }); + cy.window().trigger('blur'); + cy.get('#search').focus(); + cy.get('#searchList').children().should('be.visible'); + }); it('search should empty', () => { cy.get('#search') .type('xxx', { delay: 0 }) .clear() - .should('have.value', '') - }) + .should('have.value', ''); + }); it('search should display one element when no results', () => { - cy.get('#search') - .type(Cypress.env('NULL_STRING'), { delay: 0 }) - cy.get('#searchList') - .children() - .should('have.length', 1) - }) + cy.get('#search').type(Cypress.env('NULL_STRING'), { delay: 0 }); + cy.get('#searchList').children().should('have.length', 1); + }); it('search should not display elements when search for 1 char', () => { - cy.get('#search') - .type('x', { delay: 0 }) - cy.get('#searchList') - .children() - .should('have.length', 0) - }) + cy.get('#search').type('x', { delay: 0 }); + cy.get('#searchList').children().should('have.length', 0); + }); it('search should display elements when search for 2 char', () => { - cy.get('#search') - .type('xx', { delay: 0 }) - cy.get('#searchList') - .children() - .should('have.length.greaterThan', 0) - }) + cy.get('#search').type('xx', { delay: 0 }); + cy.get('#searchList').children().should('have.length.greaterThan', 0); + }); it('search should not display elements after resize', () => { - cy.get('#search') - .type(Cypress.env('SEARCH_TEST_INPUT'), { delay: 0 }) - cy.viewportMobile() - cy.get('#searchList') - .children() - .should('not.be.visible') - }) + cy.get('#search').type(Cypress.env('SEARCH_TEST_INPUT'), { delay: 0 }); + cy.viewportMobile(); + cy.get('#searchList').children().should('not.be.visible'); + }); it('empty search should not display elements', () => { - cy.get('#search') - .clear() - cy.get('#searchList') - .children() - .should('have.length', 0) - }) -}) \ No newline at end of file + cy.get('#search').clear(); + cy.get('#searchList').children().should('have.length', 0); + }); +}); diff --git a/cypress/e2e/global/shortcutsTests.cy.js b/cypress/e2e/global/shortcutsTests.cy.js index 49ab5796..15d845d2 100644 --- a/cypress/e2e/global/shortcutsTests.cy.js +++ b/cypress/e2e/global/shortcutsTests.cy.js @@ -1,120 +1,90 @@ describe('for: shortcuts', () => { beforeEach(() => { - cy.visit(Cypress.env('SITEMAP_PATH')) - }) + cy.visit(Cypress.env('SITEMAP_PATH')); + }); it('[shift+i] should open website information panel', () => { - cy.window().its('scShowInfo') - cy.get('body') - .type('{shift+i}', { delay: 0 }) - cy.scShowInfoResults() - }) + cy.window().its('scShowInfo'); + cy.get('body').type('{shift+i}', { delay: 0 }); + cy.scShowInfoResults(); + }); it('[shift+k] should open shortcuts panel', () => { - cy.window().its('scShowShortcuts') - cy.get('body') - .type('{shift+k}', { delay: 0 }) - cy.scShowShortcutsResults() - }) + cy.window().its('scShowShortcuts'); + cy.get('body').type('{shift+k}', { delay: 0 }); + cy.scShowShortcutsResults(); + }); it('[shift+h] should redirect to homepage', () => { - cy.window().its('scGoHome') - cy.get('body') - .type('{shift+h}', { delay: 0 }) - cy.location() - .should((loc) => { - expect(loc.toString()).to.eq(Cypress.env('HOMEPAGE_URL')) - }) - }) + cy.window().its('scGoHome'); + cy.get('body').type('{shift+h}', { delay: 0 }); + cy.location().should((loc) => { + expect(loc.toString()).to.eq(Cypress.env('HOMEPAGE_URL')); + }); + }); it('[shift+f] should focus on search', () => { - cy.window().its('scGoSearch') - cy.get('body') - .type('{shift+f}', { delay: 0 }) - cy.get('#search') - .should('be.focused') - }) + cy.window().its('scGoSearch'); + cy.get('body').type('{shift+f}', { delay: 0 }); + cy.get('#search').should('be.focused'); + }); it('[shift+m] should collapse sidebar when uncollapsed', () => { - cy.window().its('scToggleSidebar') - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.toggleSidebar(true, true) - cy.get('body') - .type('{shift+m}', { delay: 0 }) - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-collapsed') - }) + cy.window().its('scToggleSidebar').wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.toggleSidebar(true, true); + cy.get('body').type('{shift+m}', { delay: 0 }); + cy.get('#sidebarContainer').should('have.class', 'is-sidebar-collapsed'); + }); it('[shift+m] should uncollapse sidebar when collapsed', () => { - cy.window().its('scToggleSidebar') - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.toggleSidebar(false, true) - cy.get('body') - .type('{shift+m}', { delay: 0 }) - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-uncollapsed') - }) + cy.window().its('scToggleSidebar').wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.toggleSidebar(false, true); + cy.get('body').type('{shift+m}', { delay: 0 }); + cy.get('#sidebarContainer').should('have.class', 'is-sidebar-uncollapsed'); + }); it('[shift+t] should collapse toc when uncollapsed', () => { - cy.window().its('scToggleToc') - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.toggleToc(true) - cy.get('body') - .type('{shift+t}', { delay: 0 }) - cy.get('#contentContainer') - .should('have.class', 'is-toc-collapsed') - }) + cy.window().its('scToggleToc').wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.toggleToc(true); + cy.get('body').type('{shift+t}', { delay: 0 }); + cy.get('#contentContainer').should('have.class', 'is-toc-collapsed'); + }); it('[shift+t] should uncollapse toc when collapsed', () => { - cy.window().its('scToggleToc') - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.toggleToc(false) - cy.get('body') - .type('{shift+t}', { delay: 0 }) - cy.get('#contentContainer') - .should('have.class', 'is-toc-uncollapsed') - }) + cy.window().its('scToggleToc').wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.toggleToc(false); + cy.get('body').type('{shift+t}', { delay: 0 }); + cy.get('#contentContainer').should('have.class', 'is-toc-uncollapsed'); + }); it('[shift+↑] should go to the top of the page', () => { - cy.window().its('scBackToTop') - cy.disableSmoothScroll() - cy.get('#contentContainer') - .scrollTo('bottom') - cy.get('body') - .type('{shift+uparrow}', { delay: 0 }) - cy.get('#contentContainer') - .should('have.prop', 'scrollTop', 0) - }) + cy.window().its('scBackToTop'); + cy.disableSmoothScroll(); + cy.get('#contentContainer').scrollTo('bottom'); + cy.get('body').type('{shift+uparrow}', { delay: 0 }); + cy.get('#contentContainer').should('have.prop', 'scrollTop', 0); + }); it('[shift+↓] should go to the bottom of the page', () => { - cy.window().its('scGoToBottom') - cy.disableSmoothScroll() - cy.get('#contentContainer') - .scrollTo('top') - cy.get('body') - .type('{shift+downarrow}', { delay: 0 }) + cy.window().its('scGoToBottom'); + cy.disableSmoothScroll(); + cy.get('#contentContainer').scrollTo('top'); + cy.get('body').type('{shift+downarrow}', { delay: 0 }); cy.get('#contentContainer').then(($elem) => { let calcScrollHeight = $elem[0].clientHeight + $elem[0].scrollTop; let elScrollHeight = $elem[0].scrollHeight; expect(elScrollHeight).to.equal(calcScrollHeight); - }) - }) + }); + }); it('[shift+p] should open print preview', () => { - cy.window().its('scPrint') - cy.scPrintStub() - cy.get('body') - .type('{shift+p}', { delay: 0 }) - cy.scPrintResults() - }) + cy.window().its('scPrint'); + cy.scPrintStub(); + cy.get('body').type('{shift+p}', { delay: 0 }); + cy.scPrintResults(); + }); it('[escape] should close modal', () => { - cy.window().its('scCloseModals') - cy.get('body') - .type('{shift+1}') - .type('{esc}') - cy.get('#modalContainer') - .should('be.not.visible') - }) + cy.window().its('scCloseModals'); + cy.get('body').type('{shift+1}').type('{esc}'); + cy.get('#modalContainer').should('be.not.visible'); + }); it('[shift+q] should open QR code panel', () => { - cy.window().its('scQrCode') - cy.get('body') - .type('{shift+q}', { delay: 0 }) - cy.scQrCodeResults() - }) + cy.window().its('scQrCode'); + cy.get('body').type('{shift+q}', { delay: 0 }); + cy.scQrCodeResults(); + }); it('[shift+1] should open the example panel', () => { - cy.window().its('scExample') - cy.get('body') - .type('{shift+1}') - cy.get('#modalContainer') - .should('be.visible') - }) -}) \ No newline at end of file + cy.window().its('scExample'); + cy.get('body').type('{shift+1}'); + cy.get('#modalContainer').should('be.visible'); + }); +}); diff --git a/cypress/e2e/global/sidebarTests.cy.js b/cypress/e2e/global/sidebarTests.cy.js index 7188b872..3e3479ee 100644 --- a/cypress/e2e/global/sidebarTests.cy.js +++ b/cypress/e2e/global/sidebarTests.cy.js @@ -1,106 +1,94 @@ describe('for: sidebar', () => { beforeEach(() => { - cy.visit(Cypress.env('HOMEPAGE_URL')) - }) + cy.visit(Cypress.env('HOMEPAGE_URL')); + }); describe('when onload', () => { it('sidebar should be uncollapsed by default on desktop', () => { - cy.viewportDesktop('min') - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-uncollapsed') - }) + cy.viewportDesktop('min'); + cy.get('#sidebarContainer').should( + 'have.class', + 'is-sidebar-uncollapsed' + ); + }); it('sidebar should be collapsed by default on touch', () => { - cy.viewportTouch() - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-collapsed') - }) + cy.viewportTouch(); + cy.get('#sidebarContainer').should('have.class', 'is-sidebar-collapsed'); + }); it('sidebar should be collapsed by default on mobile', () => { - cy.viewportMobile() - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-collapsed') - }) + cy.viewportMobile(); + cy.get('#sidebarContainer').should('have.class', 'is-sidebar-collapsed'); + }); it('sidebar entries should be shrinked by default', () => { - cy.viewportDesktop('min') - cy.get('.is-icon-expandable') - .should('have.class', 'is-icon-shrinked') - }) + cy.viewportDesktop('min'); + cy.get('.is-icon-expandable').should('have.class', 'is-icon-shrinked'); + }); it('sidebar entries should be uncollapsed when current page is a section', () => { - cy.visit(Cypress.env('THEME_PATH')) - cy.viewportDesktop('min') - cy.get('#sidebarActiveEntry').as('sidebarActiveEntry') + cy.visit(Cypress.env('THEME_PATH')); + cy.viewportDesktop('min'); + cy.get('#sidebarActiveEntry').as('sidebarActiveEntry'); cy.get('@sidebarActiveEntry') .parent() - .should('have.class', 'is-entries-expanded') - cy.get('@sidebarActiveEntry') - .next('ul') - .should('be.visible') - }) - }) + .should('have.class', 'is-entries-expanded'); + cy.get('@sidebarActiveEntry').next('ul').should('be.visible'); + }); + }); describe('when sidebar uncollapsed', () => { beforeEach(() => { - cy.toggleSidebar(true, true) - }) + cy.toggleSidebar(true, true); + }); it('sidebar should collapse', () => { - cy.get('#sidebarCollapse') - .click() - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-collapsed') - }) + cy.get('#sidebarCollapse').click(); + cy.get('#sidebarContainer').should('have.class', 'is-sidebar-collapsed'); + }); it('expandable entries should expand', () => { - cy.toggleSidebarEntries(false) - cy.get('.is-icon-expandable') - .each(($elem) => { - cy.scrollAndClickElem($elem) - .should('have.class', 'is-icon-expanded') - }) - }) + cy.toggleSidebarEntries(false); + cy.get('.is-icon-expandable').each(($elem) => { + cy.scrollAndClickElem($elem).should('have.class', 'is-icon-expanded'); + }); + }); it('expandable entries should shrink', () => { - cy.toggleSidebarEntries(true) - cy.get('.is-icon-expandable') - .each(($elem) => { - cy.scrollAndClickElem($elem) - .should('have.class', 'is-icon-shrinked') - }) - }) + cy.toggleSidebarEntries(true); + cy.get('.is-icon-expandable').each(($elem) => { + cy.scrollAndClickElem($elem).should('have.class', 'is-icon-shrinked'); + }); + }); it('sidebar should collapse when resized from desktop to touch', () => { - cy.viewportDesktop('min') - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.viewportTouch() - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-collapsed') - }) + cy.viewportDesktop('min').wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.viewportTouch(); + cy.get('#sidebarContainer').should('have.class', 'is-sidebar-collapsed'); + }); it('sidebar should collapse when resized from touch (with sidebar uncollapsed) to mobile', () => { - cy.viewportTouch('min') - cy.toggleSidebar(true, true) - cy.viewportMobile() - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-collapsed') - }) - }) + cy.viewportTouch('min'); + cy.toggleSidebar(true, true); + cy.viewportMobile(); + cy.get('#sidebarContainer').should('have.class', 'is-sidebar-collapsed'); + }); + }); describe('when sidebar collapsed', () => { beforeEach(() => { - cy.toggleSidebar(false, true) - }) + cy.toggleSidebar(false, true); + }); it('sidebar should uncollapse', () => { - cy.get('#sidebarUncollapse') - .click() - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-uncollapsed') - }) + cy.get('#sidebarUncollapse').click(); + cy.get('#sidebarContainer').should( + 'have.class', + 'is-sidebar-uncollapsed' + ); + }); it('menu item should appear on hover', () => { - cy.get('.is-fs-expandable-icon') - .first() - .trigger('mouseenter') + cy.get('.is-fs-expandable-icon').first().trigger('mouseenter'); cy.get('.is-fs-expandable-icon') .siblings('.is-expandable') .first() - .should('have.class', 'is-hovered') - }) + .should('have.class', 'is-hovered'); + }); it('sidebar should uncollapse when resized from touch to desktop', () => { - cy.viewportTouch() - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.viewportDesktop('min') - cy.get('#sidebarContainer') - .should('have.class', 'is-sidebar-uncollapsed') - }) - }) -}) \ No newline at end of file + cy.viewportTouch().wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.viewportDesktop('min'); + cy.get('#sidebarContainer').should( + 'have.class', + 'is-sidebar-uncollapsed' + ); + }); + }); +}); diff --git a/cypress/e2e/global/tocTests.cy.js b/cypress/e2e/global/tocTests.cy.js index 194f65b6..bc185cb7 100644 --- a/cypress/e2e/global/tocTests.cy.js +++ b/cypress/e2e/global/tocTests.cy.js @@ -1,114 +1,90 @@ describe('for: table of contents', () => { beforeEach(() => { - cy.visit(Cypress.env('FUNC_TOC_PATH')) - }) + cy.visit(Cypress.env('FUNC_TOC_PATH')); + }); it('toc should be uncollapsed by default on widescreen', () => { - cy.viewportWidescreen('min') - cy.get('#contentContainer') - .should('have.class', 'is-toc-uncollapsed') - cy.get('#tocContainer') - .should('be.visible') - }) + cy.viewportWidescreen('min'); + cy.get('#contentContainer').should('have.class', 'is-toc-uncollapsed'); + cy.get('#tocContainer').should('be.visible'); + }); it('toc should be collapsed by default on desktop', () => { - cy.viewportDesktop() - cy.get('#contentContainer') - .should('have.class', 'is-toc-collapsed') - cy.get('#tocContainer') - .should('not.be.visible') - }) + cy.viewportDesktop(); + cy.get('#contentContainer').should('have.class', 'is-toc-collapsed'); + cy.get('#tocContainer').should('not.be.visible'); + }); it('toc should be collapsed by default on touch', () => { - cy.viewportTouch() - cy.get('#contentContainer') - .should('have.class', 'is-toc-collapsed') - cy.get('#tocContainer') - .should('not.be.visible') - }) + cy.viewportTouch(); + cy.get('#contentContainer').should('have.class', 'is-toc-collapsed'); + cy.get('#tocContainer').should('not.be.visible'); + }); it('toc should be collapsed by default on mobile', () => { - cy.viewportMobile() - cy.get('#contentContainer') - .should('have.class', 'is-toc-collapsed') - cy.get('#tocContainer') - .should('not.be.visible') - }) + cy.viewportMobile(); + cy.get('#contentContainer').should('have.class', 'is-toc-collapsed'); + cy.get('#tocContainer').should('not.be.visible'); + }); it('toc should not be displayed on homepage', () => { - cy.visit(Cypress.env('HOMEPAGE_URL')) - cy.get('#tocWrapper') - .should('not.exist') - }) + cy.visit(Cypress.env('HOMEPAGE_URL')); + cy.get('#tocWrapper').should('not.exist'); + }); it('toc should not be displayed on term pages', () => { - cy.visit(Cypress.env('TERM_PATH')) - cy.get('#tocWrapper') - .should('not.exist') - }) + cy.visit(Cypress.env('TERM_PATH')); + cy.get('#tocWrapper').should('not.exist'); + }); it('toc should not be displayed on taxonomy pages', () => { - cy.visit(Cypress.env('TAXONOMY_PATH')) - cy.get('#tocWrapper') - .should('not.exist') - }) + cy.visit(Cypress.env('TAXONOMY_PATH')); + cy.get('#tocWrapper').should('not.exist'); + }); it('toc should contain all titles types and they should be visible', () => { cy.get('#content') .children('h1,h2,h3,h4,h5,h6') .each(($title) => { - cy.get('#tocWrapper #tocContainer a[href="#' + $title[0].id + '"]') - .should('be.visible') - }) - }) + cy.get( + '#tocWrapper #tocContainer a[href="#' + $title[0].id + '"]' + ).should('be.visible'); + }); + }); it('toc should contain taxonomies', () => { cy.get('#tocWrapper #tocContainer #taxonomies .taxonomy') .should('have.length.at.least', 1) - .should('be.visible') - }) + .should('be.visible'); + }); describe('when toc uncollapsed', () => { beforeEach(() => { - cy.toggleToc(true) - }) + cy.toggleToc(true); + }); it('toc should collapse', () => { - cy.get('#tocCollapsible') - .click() - cy.get('#contentContainer') - .should('have.class', 'is-toc-collapsed') - cy.get('#tocContainer') - .should('not.be.visible') - }) + cy.get('#tocCollapsible').click(); + cy.get('#contentContainer').should('have.class', 'is-toc-collapsed'); + cy.get('#tocContainer').should('not.be.visible'); + }); it('toc should collapse when resized from widescreen to desktop', () => { - cy.viewportWidescreen('min') - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.viewportDesktop() - cy.get('#contentContainer') - .should('have.class', 'is-toc-collapsed') - cy.get('#tocContainer') - .should('not.be.visible') - }) + cy.viewportWidescreen('min').wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.viewportDesktop(); + cy.get('#contentContainer').should('have.class', 'is-toc-collapsed'); + cy.get('#tocContainer').should('not.be.visible'); + }); it('toc should collapse when resized from desktop (with toc uncollapsed) to touch', () => { - cy.viewportDesktop('min') - cy.toggleToc(true) - cy.viewportTouch() - cy.get('#contentContainer') - .should('have.class', 'is-toc-collapsed') - cy.get('#tocContainer') - .should('not.be.visible') - }) - }) + cy.viewportDesktop('min'); + cy.toggleToc(true); + cy.viewportTouch(); + cy.get('#contentContainer').should('have.class', 'is-toc-collapsed'); + cy.get('#tocContainer').should('not.be.visible'); + }); + }); describe('when toc collapsed', () => { beforeEach(() => { - cy.toggleToc(false) - }) + cy.toggleToc(false); + }); it('toc should uncollapse', () => { - cy.get('#tocCollapsible') - .click() - cy.get('#contentContainer') - .should('have.class', 'is-toc-uncollapsed') - cy.get('#tocContainer') - .should('be.visible') - }) + cy.get('#tocCollapsible').click(); + cy.get('#contentContainer').should('have.class', 'is-toc-uncollapsed'); + cy.get('#tocContainer').should('be.visible'); + }); it('toc should uncollapse when resized from desktop to widescreen', () => { - cy.viewportDesktop() - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - cy.viewportWidescreen('min') - cy.get('#contentContainer') - .should('have.class', 'is-toc-uncollapsed') - cy.get('#tocContainer') - .should('be.visible') - }) - }) -}) \ No newline at end of file + cy.viewportDesktop().wait(Cypress.env('WAIT_FOR_ANIMATION')); + cy.viewportWidescreen('min'); + cy.get('#contentContainer').should('have.class', 'is-toc-uncollapsed'); + cy.get('#tocContainer').should('be.visible'); + }); + }); +}); diff --git a/cypress/e2e/pages/homeTests.cy.js b/cypress/e2e/pages/homeTests.cy.js index 4228a04e..f967135e 100644 --- a/cypress/e2e/pages/homeTests.cy.js +++ b/cypress/e2e/pages/homeTests.cy.js @@ -1,37 +1,36 @@ describe('for: homepage', () => { beforeEach(() => { - cy.visit(Cypress.env('HOMEPAGE_URL')) - }) + cy.visit(Cypress.env('HOMEPAGE_URL')); + }); it('home intro should be displayed', () => { - cy.get('#contentHome #introHome') - .should('have.length', 1) - }) + cy.get('#contentHome #introHome').should('have.length', 1); + }); it('home intro should be visible', () => { - cy.get('#contentHome #introHome') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('be.visible') - }) - }) + cy.get('#contentHome #introHome').each(($elem) => { + cy.get($elem).scrollIntoView().should('be.visible'); + }); + }); it('home intro should display and follow all steps', () => { - cy.get('#contentHome #introHome') - .each(($elem) => { - cy.scrollAndClickElem($elem) - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip ul[role=tablist] li[role=presentation]') - .then(($bullets) => { - for (let i = 1; i < $bullets.length; i++) { - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') - .should('exist') - .should('be.visible') - cy.get('.introjs-tooltipReferenceLayer .introjs-button.introjs-nextbutton') - .scrollAndClick() - } - }) - cy.get('.introjs-tooltipReferenceLayer .introjs-button.introjs-donebutton') - .scrollAndClick() - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') - .should('not.exist') - }) - }) -}) \ No newline at end of file + cy.get('#contentHome #introHome').each(($elem) => { + cy.scrollAndClickElem($elem); + cy.get( + '.introjs-tooltipReferenceLayer .introjs-tooltip ul[role=tablist] li[role=presentation]' + ).then(($bullets) => { + for (let i = 1; i < $bullets.length; i++) { + cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') + .should('exist') + .should('be.visible'); + cy.get( + '.introjs-tooltipReferenceLayer .introjs-button.introjs-nextbutton' + ).scrollAndClick(); + } + }); + cy.get( + '.introjs-tooltipReferenceLayer .introjs-button.introjs-donebutton' + ).scrollAndClick(); + cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip').should( + 'not.exist' + ); + }); + }); +}); diff --git a/cypress/e2e/shortcodes/alertTests.cy.js b/cypress/e2e/shortcodes/alertTests.cy.js index 09ad2996..64aec992 100644 --- a/cypress/e2e/shortcodes/alertTests.cy.js +++ b/cypress/e2e/shortcodes/alertTests.cy.js @@ -1,29 +1,22 @@ describe('for: alert shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_ALERT_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_ALERT_PATH')); + }); it('two info alerts should be displayed', () => { - cy.get('#content .sc-alert.sc-alert-info') - .should('have.length', 2) - }) + cy.get('#content .sc-alert.sc-alert-info').should('have.length', 2); + }); it('one success alert should be displayed', () => { - cy.get('#content .sc-alert.sc-alert-success') - .should('have.length', 1) - }) + cy.get('#content .sc-alert.sc-alert-success').should('have.length', 1); + }); it('one warning alert should be displayed', () => { - cy.get('#content .sc-alert.sc-alert-warning') - .should('have.length', 1) - }) + cy.get('#content .sc-alert.sc-alert-warning').should('have.length', 1); + }); it('one error alert should be displayed', () => { - cy.get('#content .sc-alert.sc-alert-error') - .should('have.length', 1) - }) + cy.get('#content .sc-alert.sc-alert-error').should('have.length', 1); + }); it('alerts should be visible', () => { - cy.get('#content .sc-alert') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('be.visible') - }) - }) -}) \ No newline at end of file + cy.get('#content .sc-alert').each(($elem) => { + cy.get($elem).scrollIntoView().should('be.visible'); + }); + }); +}); diff --git a/cypress/e2e/shortcodes/asyncapiTests.cy.js b/cypress/e2e/shortcodes/asyncapiTests.cy.js index 34f1442a..4a6c45e6 100644 --- a/cypress/e2e/shortcodes/asyncapiTests.cy.js +++ b/cypress/e2e/shortcodes/asyncapiTests.cy.js @@ -1,17 +1,24 @@ describe('for: asyncapi shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_ASYNCAPI_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_ASYNCAPI_PATH')); + }); it('two asyncapi should be displayed', () => { - cy.get('#content asyncapi-component') - .should('have.length', 2) - }) + cy.get('#content asyncapi-component').should('have.length', 2); + }); it('asyncapi should have a loading helper', () => { - cy.get('#content .sc-asyncapi-wrapper') - .should('have.class', 'helper-loading-container') - }) - it('asyncapi should not have a loading helper once loaded', { defaultCommandTimeout: 10000 }, () => { - cy.get('#content .sc-asyncapi-wrapper.helper-loading-container') - .should('not.have.class', 'is-loading') - }) -}) \ No newline at end of file + cy.get('#content .sc-asyncapi-wrapper').should( + 'have.class', + 'helper-loading-container' + ); + }); + it( + 'asyncapi should not have a loading helper once loaded', + { defaultCommandTimeout: 10000 }, + () => { + cy.get('#content .sc-asyncapi-wrapper.helper-loading-container').should( + 'not.have.class', + 'is-loading' + ); + } + ); +}); diff --git a/cypress/e2e/shortcodes/blockquoteTests.cy.js b/cypress/e2e/shortcodes/blockquoteTests.cy.js index bcac25f7..600cb175 100644 --- a/cypress/e2e/shortcodes/blockquoteTests.cy.js +++ b/cypress/e2e/shortcodes/blockquoteTests.cy.js @@ -1,13 +1,14 @@ describe('for: blockquote shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_BLOCKQUOTE_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_BLOCKQUOTE_PATH')); + }); it('two blockquotes should be displayed', () => { - cy.get('#content .sc-blockquote') - .should('have.length', 2) - }) + cy.get('#content .sc-blockquote').should('have.length', 2); + }); it('one blockquote should have a source', () => { - cy.get('#content .sc-blockquote .sc-blockquote-source') - .should('have.length', 1) - }) -}) \ No newline at end of file + cy.get('#content .sc-blockquote .sc-blockquote-source').should( + 'have.length', + 1 + ); + }); +}); diff --git a/cypress/e2e/shortcodes/collapsibleTests.cy.js b/cypress/e2e/shortcodes/collapsibleTests.cy.js index 60d76ec2..9a389ffe 100644 --- a/cypress/e2e/shortcodes/collapsibleTests.cy.js +++ b/cypress/e2e/shortcodes/collapsibleTests.cy.js @@ -1,42 +1,34 @@ describe('for: collapsible shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_COLLAPSIBLE_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_COLLAPSIBLE_PATH')); + }); it('two collapsibles should be displayed', () => { - cy.get('#content .sc-collapsible-container') - .should('have.length', 2) - }) + cy.get('#content .sc-collapsible-container').should('have.length', 2); + }); it('collapsibles should have a header and a content', () => { - cy.get('#content .sc-collapsible-container') - .each(($elem) => { - cy.get($elem) - .children('.sc-collapsible-header') - .should('have.length', 1) - cy.get($elem) - .children('.sc-collapsible-content') - .should('have.length', 1) - }) - }) + cy.get('#content .sc-collapsible-container').each(($elem) => { + cy.get($elem).children('.sc-collapsible-header').should('have.length', 1); + cy.get($elem) + .children('.sc-collapsible-content') + .should('have.length', 1); + }); + }); it('collapsibles should be uncollapsed by default', () => { - cy.get('#content .sc-collapsible-container') - .each(($elem) => { - cy.get($elem) - .children('.sc-collapsible-header') - .should('not.have.class', 'sc-uncollapsed') - }) - }) + cy.get('#content .sc-collapsible-container').each(($elem) => { + cy.get($elem) + .children('.sc-collapsible-header') + .should('not.have.class', 'sc-uncollapsed'); + }); + }); it('collapsibles should uncollapse when clicked', () => { - cy.get('#content .sc-collapsible-container') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .children('.sc-collapsible-header') - .wait(Cypress.env('WAIT_FOR_ANIMATION')) - .click({ force: true }) - .should('have.class', 'sc-uncollapsed') - cy.get($elem) - .children('.sc-collapsible-content') - .should('be.visible') - }) - }) -}) \ No newline at end of file + cy.get('#content .sc-collapsible-container').each(($elem) => { + cy.get($elem) + .scrollIntoView() + .children('.sc-collapsible-header') + .wait(Cypress.env('WAIT_FOR_ANIMATION')) + .click({ force: true }) + .should('have.class', 'sc-uncollapsed'); + cy.get($elem).children('.sc-collapsible-content').should('be.visible'); + }); + }); +}); diff --git a/cypress/e2e/shortcodes/highchartsTests.cy.js b/cypress/e2e/shortcodes/highchartsTests.cy.js index c92dec47..a25eaab7 100644 --- a/cypress/e2e/shortcodes/highchartsTests.cy.js +++ b/cypress/e2e/shortcodes/highchartsTests.cy.js @@ -1,29 +1,36 @@ describe('for: highcharts shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_HIGHCHARTS_PATH')) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_HIGHCHARTS_PATH')); cy.on('uncaught:exception', (err, runnable) => { - return false - }) - }) + return false; + }); + }); it('four highcharts should be displayed', () => { - cy.get('#content .sc-highcharts-wrapper > .sc-highcharts-container') - .should('have.length', 4) - }) - it('highcharts should have a loading helper', { defaultCommandTimeout: 60000 }, () => { - cy.get('#content .sc-highcharts-wrapper') - .each(($elem) => { + cy.get('#content .sc-highcharts-wrapper > .sc-highcharts-container').should( + 'have.length', + 4 + ); + }); + it( + 'highcharts should have a loading helper', + { defaultCommandTimeout: 60000 }, + () => { + cy.get('#content .sc-highcharts-wrapper').each(($elem) => { cy.get($elem) .scrollIntoView() - .should('have.class', 'helper-loading-container') - }) - - }) - it('highcharts should not have a loading helper once loaded', { defaultCommandTimeout: 60000 }, () => { - cy.get('#content .sc-highcharts-wrapper.helper-loading-container') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('not.have.class', 'is-loading') - }) - }) -}) \ No newline at end of file + .should('have.class', 'helper-loading-container'); + }); + } + ); + it( + 'highcharts should not have a loading helper once loaded', + { defaultCommandTimeout: 60000 }, + () => { + cy.get('#content .sc-highcharts-wrapper.helper-loading-container').each( + ($elem) => { + cy.get($elem).scrollIntoView().should('not.have.class', 'is-loading'); + } + ); + } + ); +}); diff --git a/cypress/e2e/shortcodes/introTests.cy.js b/cypress/e2e/shortcodes/introTests.cy.js index eda452ad..c3cc3e84 100644 --- a/cypress/e2e/shortcodes/introTests.cy.js +++ b/cypress/e2e/shortcodes/introTests.cy.js @@ -1,66 +1,60 @@ describe('for: intro shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_INTRO_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_INTRO_PATH')); + }); it('one intro should be displayed', () => { - cy.get('#content #introTest') - .should('have.length', 1) - }) + cy.get('#content #introTest').should('have.length', 1); + }); it('intro should be visible', () => { - cy.get('#content #introTest') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('be.visible') - }) - }) + cy.get('#content #introTest').each(($elem) => { + cy.get($elem).scrollIntoView().should('be.visible'); + }); + }); it('intro should open intro modal when clicked', () => { - cy.get('#content #introTest') - .each(($elem) => { - cy.scrollAndClickElem($elem) - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') - .should('exist') - .should('be.visible') - }) - }) + cy.get('#content #introTest').each(($elem) => { + cy.scrollAndClickElem($elem); + cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') + .should('exist') + .should('be.visible'); + }); + }); it('intro should exit when escape key is pressed', () => { - cy.get('#content #introTest') - .each(($elem) => { - cy.scrollAndClickElem($elem) - cy.get('body') - .type('{esc}') - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') - .should('not.exist') - }) - }) + cy.get('#content #introTest').each(($elem) => { + cy.scrollAndClickElem($elem); + cy.get('body').type('{esc}'); + cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip').should( + 'not.exist' + ); + }); + }); it('intro should exit when clicked outside of tooltip', () => { - cy.get('#content #introTest') - .each(($elem) => { - cy.scrollAndClickElem($elem) - cy.get('.introjs-overlay') - .click({ force: true }) - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') - .should('not.exist') - }) - }) + cy.get('#content #introTest').each(($elem) => { + cy.scrollAndClickElem($elem); + cy.get('.introjs-overlay').click({ force: true }); + cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip').should( + 'not.exist' + ); + }); + }); it('intro should exit when skipbutton clicked', () => { - cy.get('#content #introTest') - .each(($elem) => { - cy.scrollAndClickElem($elem) - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip .introjs-skipbutton') - .click({ force: true }) - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') - .should('not.exist') - }) - }) + cy.get('#content #introTest').each(($elem) => { + cy.scrollAndClickElem($elem); + cy.get( + '.introjs-tooltipReferenceLayer .introjs-tooltip .introjs-skipbutton' + ).click({ force: true }); + cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip').should( + 'not.exist' + ); + }); + }); it('intro should exit when window resized', () => { - cy.viewportDesktop() - cy.get('#content #introTest') - .each(($elem) => { - cy.scrollAndClickElem($elem) - cy.viewportTouch() - cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip') - .should('not.exist') - }) - }) -}) \ No newline at end of file + cy.viewportDesktop(); + cy.get('#content #introTest').each(($elem) => { + cy.scrollAndClickElem($elem); + cy.viewportTouch(); + cy.get('.introjs-tooltipReferenceLayer .introjs-tooltip').should( + 'not.exist' + ); + }); + }); +}); diff --git a/cypress/e2e/shortcodes/openapiTests.cy.js b/cypress/e2e/shortcodes/openapiTests.cy.js index 58e21883..0b6ca44d 100644 --- a/cypress/e2e/shortcodes/openapiTests.cy.js +++ b/cypress/e2e/shortcodes/openapiTests.cy.js @@ -1,34 +1,57 @@ describe('for: openapi shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_OPENAPI_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_OPENAPI_PATH')); + }); it('two openapi should be displayed', () => { - cy.get('#content .sc-openapi-wrapper > .sc-openapi-container') - .should('have.length', 2) - }) + cy.get('#content .sc-openapi-wrapper > .sc-openapi-container').should( + 'have.length', + 2 + ); + }); it('openapi should have a loading helper', () => { - cy.get('#content .sc-openapi-wrapper') - .should('have.class', 'helper-loading-container') - }) - it('openapi should not have a loading helper once loaded', { defaultCommandTimeout: 10000 }, () => { - cy.get('#content .sc-openapi-wrapper.helper-loading-container') - .should('not.have.class', 'is-loading') - }) + cy.get('#content .sc-openapi-wrapper').should( + 'have.class', + 'helper-loading-container' + ); + }); + it( + 'openapi should not have a loading helper once loaded', + { defaultCommandTimeout: 10000 }, + () => { + cy.get('#content .sc-openapi-wrapper.helper-loading-container').should( + 'not.have.class', + 'is-loading' + ); + } + ); // For now local download is not fully supported in firefox browser. // Cypress doesn't seems to accept browser preferences in headless mode. // https://github.com/cypress-io/cypress/issues/8814 - it('export link should export openapi', { browser: '!firefox', defaultCommandTimeout: 10000 }, () => { - const path = require('path'); - cy.get('.sc-openapi-iframe').first() - .its('0.contentDocument') - .its('body') - .find('.information-container .link').first() - .click({ force: true }) - .then(($openapiLink) => { - const fileName = $openapiLink[0].href.substring($openapiLink[0].href.lastIndexOf('/') + 1) - cy.readFile(path.join(Cypress.config('downloadsFolder'), fileName)).then((fileContent) => { - cy.fixture('openapi/example.yaml', 'utf8').should('be.equal', fileContent) - }) - }) - }) -}) \ No newline at end of file + it( + 'export link should export openapi', + { browser: '!firefox', defaultCommandTimeout: 10000 }, + () => { + const path = require('path'); + cy.get('.sc-openapi-iframe') + .first() + .its('0.contentDocument') + .its('body') + .find('.information-container .link') + .first() + .click({ force: true }) + .then(($openapiLink) => { + const fileName = $openapiLink[0].href.substring( + $openapiLink[0].href.lastIndexOf('/') + 1 + ); + cy.readFile( + path.join(Cypress.config('downloadsFolder'), fileName) + ).then((fileContent) => { + cy.fixture('openapi/example.yaml', 'utf8').should( + 'be.equal', + fileContent + ); + }); + }); + } + ); +}); diff --git a/cypress/e2e/shortcodes/pagebreakTests.cy.js b/cypress/e2e/shortcodes/pagebreakTests.cy.js index a688d9f0..c8db1392 100644 --- a/cypress/e2e/shortcodes/pagebreakTests.cy.js +++ b/cypress/e2e/shortcodes/pagebreakTests.cy.js @@ -1,13 +1,11 @@ describe('for: pagebreak shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_PAGEBREAK_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_PAGEBREAK_PATH')); + }); it('one pagebreak should be set in the page', () => { - cy.get('#content .sc-pagebreak') - .should('have.length', 1) - }) + cy.get('#content .sc-pagebreak').should('have.length', 1); + }); it('pagebreak should not be visible', () => { - cy.get('#content .sc-pagebreak') - .should('not.be.visible') - }) -}) \ No newline at end of file + cy.get('#content .sc-pagebreak').should('not.be.visible'); + }); +}); diff --git a/cypress/e2e/shortcodes/parameterTests.cy.js b/cypress/e2e/shortcodes/parameterTests.cy.js index b2ba4b08..54ff065a 100644 --- a/cypress/e2e/shortcodes/parameterTests.cy.js +++ b/cypress/e2e/shortcodes/parameterTests.cy.js @@ -1,17 +1,13 @@ describe('for: parameter shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_PARAMETER_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_PARAMETER_PATH')); + }); it('seven parameters should be displayed', () => { - cy.get('#content .sc-parameter') - .should('have.length', 7) - }) + cy.get('#content .sc-parameter').should('have.length', 7); + }); it('parameters should be visible', () => { - cy.get('#content .sc-parameter') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('be.visible') - }) - }) -}) \ No newline at end of file + cy.get('#content .sc-parameter').each(($elem) => { + cy.get($elem).scrollIntoView().should('be.visible'); + }); + }); +}); diff --git a/cypress/e2e/shortcodes/snippetTests.cy.js b/cypress/e2e/shortcodes/snippetTests.cy.js index 38a655b2..2c5e25f3 100644 --- a/cypress/e2e/shortcodes/snippetTests.cy.js +++ b/cypress/e2e/shortcodes/snippetTests.cy.js @@ -1,47 +1,46 @@ describe('for: snippet shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_SNIPPET_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_SNIPPET_PATH')); + }); it('ten snippets wrapper should be displayed', () => { - cy.get('#content .sc-snippet-wrapper') - .should('have.length', 10) - }) + cy.get('#content .sc-snippet-wrapper').should('have.length', 10); + }); it('snippets wrapper should be visible', () => { - cy.get('#content .sc-snippet-wrapper') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('be.visible') - }) - }) + cy.get('#content .sc-snippet-wrapper').each(($elem) => { + cy.get($elem).scrollIntoView().should('be.visible'); + }); + }); it('at least one snippet with caption should be displayed', () => { - cy.get('#content .sc-snippet-wrapper .sc-snippet-caption') - .should('have.length.at.least', 1) - }) + cy.get('#content .sc-snippet-wrapper .sc-snippet-caption').should( + 'have.length.at.least', + 1 + ); + }); it('at least one md snippet should be displayed', () => { - cy.get('#content .sc-snippet-wrapper .sc-snippet-md') - .should('have.length.at.least', 1) - }) + cy.get('#content .sc-snippet-wrapper .sc-snippet-md').should( + 'have.length.at.least', + 1 + ); + }); it('at least one plaintext snippet should be displayed', () => { - cy.get('#content .sc-snippet-wrapper .sc-snippet-plaintext') - .should('have.length.at.least', 1) - }) + cy.get('#content .sc-snippet-wrapper .sc-snippet-plaintext').should( + 'have.length.at.least', + 1 + ); + }); it('2 snippets wrapper with 3 tabs should be displayed', () => { cy.get('#content .sc-snippet-wrapper.sc-snippet-tabs') .should('have.length', 2) .each(($elem) => { - cy.get($elem) - .children('.sc-snippet-label') - .should('have.length', 3) - }) - }) + cy.get($elem).children('.sc-snippet-label').should('have.length', 3); + }); + }); it('tabs should be visible when clicked', () => { - cy.get('#content .sc-snippet-wrapper .sc-snippet-label') - .each(($elem) => { - let tabContentId = $elem[0].getAttribute('for'); - cy.scrollAndClickElem($elem) - .get(`#${tabContentId}-content`) - .should('be.visible') - }) - }) -}) \ No newline at end of file + cy.get('#content .sc-snippet-wrapper .sc-snippet-label').each(($elem) => { + let tabContentId = $elem[0].getAttribute('for'); + cy.scrollAndClickElem($elem) + .get(`#${tabContentId}-content`) + .should('be.visible'); + }); + }); +}); diff --git a/cypress/e2e/shortcodes/treeviewTests.cy.js b/cypress/e2e/shortcodes/treeviewTests.cy.js index 74f63718..5926a20e 100644 --- a/cypress/e2e/shortcodes/treeviewTests.cy.js +++ b/cypress/e2e/shortcodes/treeviewTests.cy.js @@ -1,49 +1,54 @@ describe('for: treeview shortcode', () => { beforeEach(() => { - cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_TREEVIEW_PATH')) - }) + cy.visit(Cypress.env('SC_PATH') + Cypress.env('SC_TREEVIEW_PATH')); + }); it('six treeviews should be displayed', () => { - cy.get('#content .sc-treeview') - .should('have.length', 6) - }) + cy.get('#content .sc-treeview').should('have.length', 6); + }); it('treeviews should be visible', () => { - cy.get('#content .sc-treeview') - .each(($elem) => { - cy.get($elem) - .scrollIntoView() - .should('be.visible') - }) - }) + cy.get('#content .sc-treeview').each(($elem) => { + cy.get($elem).scrollIntoView().should('be.visible'); + }); + }); it('one treeview with warning alert should be displayed', () => { - cy.get('#content .sc-treeview .sc-alert.sc-alert-warning') - .should('have.length', 1) - }) + cy.get('#content .sc-treeview .sc-alert.sc-alert-warning').should( + 'have.length', + 1 + ); + }); it('one graph treeview should be displayed', () => { - cy.get('#content .sc-treeview > .sc-treeview-graph') - .should('have.length', 1) - }) + cy.get('#content .sc-treeview > .sc-treeview-graph').should( + 'have.length', + 1 + ); + }); it('three tree treeviews should be displayed', () => { - cy.get('#content .sc-treeview > .sc-treeview-tree') - .should('have.length', 3) - }) + cy.get('#content .sc-treeview > .sc-treeview-tree').should( + 'have.length', + 3 + ); + }); it('one treeview should be fully collapsed by default', () => { - cy.get('#content .sc-treeview > .sc-treeview-tree > .sc-treeview-coll.is-collapsed') - .should('have.length', 1) - }) + cy.get( + '#content .sc-treeview > .sc-treeview-tree > .sc-treeview-coll.is-collapsed' + ).should('have.length', 1); + }); it('uncollapsed treeview colls should collapse', () => { - cy.get('#content .sc-treeview > .sc-treeview-tree > .sc-treeview-coll:not(.is-collapsed) .sc-treeview-coll-trigger') - .each(($elem) => { - cy.scrollAndClickElem($elem) - .closest('.sc-treeview-coll') - .should('have.class', 'is-collapsed') - }) - }) + cy.get( + '#content .sc-treeview > .sc-treeview-tree > .sc-treeview-coll:not(.is-collapsed) .sc-treeview-coll-trigger' + ).each(($elem) => { + cy.scrollAndClickElem($elem) + .closest('.sc-treeview-coll') + .should('have.class', 'is-collapsed'); + }); + }); it('collapsed treeview colls should uncollapse', () => { - cy.get('#content .sc-treeview > .sc-treeview-tree > .sc-treeview-coll.is-collapsed .sc-treeview-coll-trigger') - .each(($elem) => { - cy.scrollAndClickElem($elem) - .closest('.sc-treeview-coll') - .should('not.have.class', 'is-collapsed') - }) - }) -}) \ No newline at end of file + cy.get( + '#content .sc-treeview > .sc-treeview-tree > .sc-treeview-coll.is-collapsed .sc-treeview-coll-trigger' + ).each(($elem) => { + cy.scrollAndClickElem($elem) + .closest('.sc-treeview-coll') + .should('not.have.class', 'is-collapsed'); + }); + }); +}); diff --git a/cypress/fixtures/openapi/example.yaml b/cypress/fixtures/openapi/example.yaml index 86713d72..6ab845c0 100644 --- a/cypress/fixtures/openapi/example.yaml +++ b/cypress/fixtures/openapi/example.yaml @@ -9,7 +9,7 @@ paths: summary: Returns a list of users. description: Optional extended description in CommonMark or HTML. responses: - '200': # status code + '200': # status code description: A JSON array of user names content: application/json: @@ -29,4 +29,4 @@ components: type: string required: - id - - name \ No newline at end of file + - name diff --git a/cypress/support/e2e.js b/cypress/support/e2e.js index 4b9e49e9..f0c29c08 100644 --- a/cypress/support/e2e.js +++ b/cypress/support/e2e.js @@ -4,4 +4,7 @@ import './global/navbarCommands'; import './globalCommands'; // See: https://github.com/cypress-io/cypress/issues/20341 -Cypress.on("uncaught:exception", err => !err.message.includes("ResizeObserver")); +Cypress.on( + 'uncaught:exception', + (err) => !err.message.includes('ResizeObserver') +); diff --git a/cypress/support/global/navbarCommands.js b/cypress/support/global/navbarCommands.js index d2b0cbbb..5389f74e 100644 --- a/cypress/support/global/navbarCommands.js +++ b/cypress/support/global/navbarCommands.js @@ -1,37 +1,30 @@ Cypress.Commands.add('defaultNavbarBeforeEach', () => { - cy.visit(Cypress.env('HOMEPAGE_URL')) -}) + cy.visit(Cypress.env('HOMEPAGE_URL')); +}); Cypress.Commands.add('mobileNavbarBeforeEach', () => { - cy.visit(Cypress.env('HOMEPAGE_URL')) - cy.viewportMobile('min') - cy.get('#navbarExtendWrapper') - .then(($elem) => { - $elem.get(0).classList.toggle('is-hovered', true) - }) -}) + cy.visit(Cypress.env('HOMEPAGE_URL')); + cy.viewportMobile('min'); + cy.get('#navbarExtendWrapper').then(($elem) => { + $elem.get(0).classList.toggle('is-hovered', true); + }); +}); Cypress.Commands.add('scShowInfoResults', () => { - cy.get('#navbarInfo') - .should('be.visible') -}) + cy.get('#navbarInfo').should('be.visible'); +}); Cypress.Commands.add('scShowShortcutsResults', () => { - cy.get('#navbarShortcuts') - .should('be.visible') -}) + cy.get('#navbarShortcuts').should('be.visible'); +}); Cypress.Commands.add('scPrintStub', () => { - cy.window() - .then((win) => { - cy.stub(win, 'print') - }) -}) + cy.window().then((win) => { + cy.stub(win, 'print'); + }); +}); Cypress.Commands.add('scPrintResults', () => { - cy.window() - .then((win) => { - expect(win.print).to.be.calledOnce - }) -}) + cy.window().then((win) => { + expect(win.print).to.be.calledOnce; + }); +}); Cypress.Commands.add('scQrCodeResults', () => { - cy.get('#modalContainer') - .should('be.visible') - cy.get('#currentPageQrCode') - .should('be.visible') -}) \ No newline at end of file + cy.get('#modalContainer').should('be.visible'); + cy.get('#currentPageQrCode').should('be.visible'); +}); diff --git a/cypress/support/globalCommands.js b/cypress/support/globalCommands.js index 39fd8254..a926408f 100644 --- a/cypress/support/globalCommands.js +++ b/cypress/support/globalCommands.js @@ -3,51 +3,75 @@ // *********************************************** Cypress.Commands.add('viewportWidescreen', ($size) => { if ($size === 'min') - cy.viewport(Cypress.env('VIEWPORT_WIDESCREEN_MINWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) + cy.viewport( + Cypress.env('VIEWPORT_WIDESCREEN_MINWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); else - cy.viewport(Cypress.env('VIEWPORT_WIDESCREEN_MAXWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) -}) + cy.viewport( + Cypress.env('VIEWPORT_WIDESCREEN_MAXWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); +}); Cypress.Commands.add('viewportDesktop', ($size) => { if ($size === 'min') - cy.viewport(Cypress.env('VIEWPORT_DESKTOP_MINWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) + cy.viewport( + Cypress.env('VIEWPORT_DESKTOP_MINWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); else - cy.viewport(Cypress.env('VIEWPORT_DESKTOP_MAXWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) -}) + cy.viewport( + Cypress.env('VIEWPORT_DESKTOP_MAXWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); +}); Cypress.Commands.add('viewportTouch', ($size) => { if ($size === 'min') - cy.viewport(Cypress.env('VIEWPORT_TOUCH_MINWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) + cy.viewport( + Cypress.env('VIEWPORT_TOUCH_MINWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); else - cy.viewport(Cypress.env('VIEWPORT_TOUCH_MAXWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) -}) + cy.viewport( + Cypress.env('VIEWPORT_TOUCH_MAXWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); +}); Cypress.Commands.add('viewportMobile', ($size) => { if ($size === 'min') - cy.viewport(Cypress.env('VIEWPORT_MOBILE_MINWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) + cy.viewport( + Cypress.env('VIEWPORT_MOBILE_MINWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); else - cy.viewport(Cypress.env('VIEWPORT_MOBILE_MAXWIDTH'), Cypress.env('VIEWPORT_COMMON_HEIGHT'), true) -}) + cy.viewport( + Cypress.env('VIEWPORT_MOBILE_MAXWIDTH'), + Cypress.env('VIEWPORT_COMMON_HEIGHT'), + true + ); +}); Cypress.Commands.add('toggleSidebar', ($force, $noTransition) => { - cy.window() - .then((window) => window.toggleSidebar($force, $noTransition)) -}) + cy.window().then((window) => window.toggleSidebar($force, $noTransition)); +}); Cypress.Commands.add('toggleSidebarEntries', ($force) => { - cy.window() - .then((window) => window.toggleSidebarEntries($force)) -}) + cy.window().then((window) => window.toggleSidebarEntries($force)); +}); Cypress.Commands.add('toggleToc', ($force) => { - cy.window() - .then((window) => window.toggleToc($force)) -}) + cy.window().then((window) => window.toggleToc($force)); +}); Cypress.Commands.add('disableSmoothScroll', () => { - cy.window() - .then((window) => window.disableSmoothScroll()) -}) + cy.window().then((window) => window.disableSmoothScroll()); +}); Cypress.Commands.add('scrollAndClickElem', ($elem) => { - cy.get($elem) - .scrollIntoView() - .click({ force: true }) -}) + cy.get($elem).scrollIntoView().click({ force: true }); +}); Cypress.Commands.add('scrollAndClick', { prevSubject: true }, ($elem) => { - cy.wrap($elem) - .scrollIntoView() - .click({ force: true }) -}) \ No newline at end of file + cy.wrap($elem).scrollIntoView().click({ force: true }); +}); diff --git a/exampleSite/assets/css/shortcuts.css b/exampleSite/assets/css/shortcuts.css index 83e6fc98..9b095c35 100644 --- a/exampleSite/assets/css/shortcuts.css +++ b/exampleSite/assets/css/shortcuts.css @@ -10,4 +10,4 @@ font-weight: bold; font-size: 3rem; float: left; -} \ No newline at end of file +} diff --git a/exampleSite/assets/js/shortcuts.js b/exampleSite/assets/js/shortcuts.js index 2f624e15..fbbed362 100644 --- a/exampleSite/assets/js/shortcuts.js +++ b/exampleSite/assets/js/shortcuts.js @@ -1,7 +1,7 @@ import { addElementToModal, - displayModal -} from './theme/modules/helpers.min.js' + displayModal, +} from './theme/modules/helpers.min.js'; // VARS // // MAIN // @@ -13,4 +13,4 @@ function scExample() { el.innerHTML = '{{i18n "shortcut_example"}}'; addElementToModal(el); displayModal(); -} \ No newline at end of file +} diff --git a/exampleSite/asyncapi/example.yaml b/exampleSite/asyncapi/example.yaml index 914691e7..cb852949 100644 --- a/exampleSite/asyncapi/example.yaml +++ b/exampleSite/asyncapi/example.yaml @@ -20,4 +20,4 @@ components: email: type: string format: email - description: Email of the user \ No newline at end of file + description: Email of the user diff --git a/exampleSite/data/dir/exampleTemplate.json b/exampleSite/data/dir/exampleTemplate.json index b1815866..3cea8f69 100644 --- a/exampleSite/data/dir/exampleTemplate.json +++ b/exampleSite/data/dir/exampleTemplate.json @@ -1,6 +1,6 @@ { "exampleMap": { - "exampleArray": ["VAR1","VAR2","VAR3"], + "exampleArray": ["VAR1", "VAR2", "VAR3"], "exampleString": "STRING" } -} \ No newline at end of file +} diff --git a/exampleSite/i18n/en.yaml b/exampleSite/i18n/en.yaml index 9544d584..75071fc0 100644 --- a/exampleSite/i18n/en.yaml +++ b/exampleSite/i18n/en.yaml @@ -1,17 +1,17 @@ -- id: navbarinfo_content - translation: | - Website built with [Hugo](https://gohugo.io/) -- id: navbarinfo_github_main - translation: GitHub repository -- id: navbarinfo_github_download - translation: Download -- id: navbarinfo_github_issue - translation: Report an issue -- id: navbarinfo_github_fork - translation: Fork -- id: example_keys_wording - translation: "Shift,1" -- id: example_wording - translation: "Display a shortcut example" -- id: shortcut_example - translation: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue." +- id: navbarinfo_content + translation: | + Website built with [Hugo](https://gohugo.io/) +- id: navbarinfo_github_main + translation: GitHub repository +- id: navbarinfo_github_download + translation: Download +- id: navbarinfo_github_issue + translation: Report an issue +- id: navbarinfo_github_fork + translation: Fork +- id: example_keys_wording + translation: 'Shift,1' +- id: example_wording + translation: 'Display a shortcut example' +- id: shortcut_example + translation: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue.' diff --git a/exampleSite/i18n/fr.yaml b/exampleSite/i18n/fr.yaml index 385123d6..475111e9 100644 --- a/exampleSite/i18n/fr.yaml +++ b/exampleSite/i18n/fr.yaml @@ -1,17 +1,17 @@ -- id: navbarinfo_content - translation: | - Site généré avec [Hugo](https://gohugo.io/) -- id: navbarinfo_github_main - translation: Projet GitHub -- id: navbarinfo_github_download - translation: Télécharger -- id: navbarinfo_github_issue - translation: Signaler une anomalie -- id: navbarinfo_github_fork - translation: Fork -- id: example_keys_wording - translation: "Maj,1" -- id: example_wording - translation: "Afficher un exemple de raccourci" -- id: shortcut_example - translation: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue." +- id: navbarinfo_content + translation: | + Site généré avec [Hugo](https://gohugo.io/) +- id: navbarinfo_github_main + translation: Projet GitHub +- id: navbarinfo_github_download + translation: Télécharger +- id: navbarinfo_github_issue + translation: Signaler une anomalie +- id: navbarinfo_github_fork + translation: Fork +- id: example_keys_wording + translation: 'Maj,1' +- id: example_wording + translation: 'Afficher un exemple de raccourci' +- id: shortcut_example + translation: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue.' diff --git a/exampleSite/layouts/partials/custom/custom-info.html b/exampleSite/layouts/partials/custom/custom-info.html index a66f5b3c..b6d7ae4b 100644 --- a/exampleSite/layouts/partials/custom/custom-info.html +++ b/exampleSite/layouts/partials/custom/custom-info.html @@ -1,37 +1,57 @@ -{{$optMd := dict "markup" "goldmark"}} - -

{{i18n "navbarinfo_content" | .RenderString $optMd}} ({{hugo.Version}})

-

{{.Site.Copyright}} ({{with .GitInfo}}{{.AbbreviatedHash}}{{end}})

+{{ $optMd := dict "markup" "goldmark" }} + +

+ {{ i18n "navbarinfo_content" | .RenderString $optMd }} ({{ hugo.Version }}) +

+

+ {{ .Site.Copyright }} ({{ with .GitInfo }}{{ .AbbreviatedHash }}{{ end }}) +

diff --git a/exampleSite/openapi/example.yaml b/exampleSite/openapi/example.yaml index 86713d72..6ab845c0 100644 --- a/exampleSite/openapi/example.yaml +++ b/exampleSite/openapi/example.yaml @@ -9,7 +9,7 @@ paths: summary: Returns a list of users. description: Optional extended description in CommonMark or HTML. responses: - '200': # status code + '200': # status code description: A JSON array of user names content: application/json: @@ -29,4 +29,4 @@ components: type: string required: - id - - name \ No newline at end of file + - name diff --git a/exampleSite/templates/configuration/i18n.en.yaml b/exampleSite/templates/configuration/i18n.en.yaml index 92a3e430..3e731310 100644 --- a/exampleSite/templates/configuration/i18n.en.yaml +++ b/exampleSite/templates/configuration/i18n.en.yaml @@ -1,19 +1,19 @@ -- id: navbarinfo_content - translation: | - Website built with [Hugo](https://gohugo.io/) -- id: navbarinfo_github_main - translation: GitHub repository -- id: navbarinfo_github_download - translation: Download -- id: navbarinfo_github_issue - translation: Report an issue -- id: navbarinfo_github_fork - translation: Fork -# Comma-separated labels associated with the keyboard keys of the shortcut -- id: example_keys_wording - translation: "Shift,1" -# Shortcut description -- id: example_wording - translation: "Display a shortcut example" -- id: shortcut_example - translation: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue." +- id: navbarinfo_content + translation: | + Website built with [Hugo](https://gohugo.io/) +- id: navbarinfo_github_main + translation: GitHub repository +- id: navbarinfo_github_download + translation: Download +- id: navbarinfo_github_issue + translation: Report an issue +- id: navbarinfo_github_fork + translation: Fork +# Comma-separated labels associated with the keyboard keys of the shortcut +- id: example_keys_wording + translation: 'Shift,1' +# Shortcut description +- id: example_wording + translation: 'Display a shortcut example' +- id: shortcut_example + translation: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue.' diff --git a/exampleSite/templates/configuration/i18n.fr.yaml b/exampleSite/templates/configuration/i18n.fr.yaml index c9096b97..3247d19a 100644 --- a/exampleSite/templates/configuration/i18n.fr.yaml +++ b/exampleSite/templates/configuration/i18n.fr.yaml @@ -11,9 +11,9 @@ translation: Fork # Libellés (séparés par des virgules) associés au touches de clavier du raccourci - id: example_keys_wording - translation: "Maj,1" + translation: 'Maj,1' # Description du raccourci - id: example_wording - translation: "Afficher un exemple de raccourci" + translation: 'Afficher un exemple de raccourci' - id: shortcut_example - translation: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue." + translation: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut aliquam metus. Nam massa lectus, consequat nec est eget, faucibus suscipit nunc. Donec dapibus tortor eget libero laoreet, quis commodo orci mattis. Pellentesque in arcu et odio viverra varius vitae sit amet dolor. Mauris venenatis malesuada leo, et egestas lectus feugiat vel. Morbi pretium id turpis ac varius. Integer ut ipsum augue.' diff --git a/exampleSite/templates/configuration/shortcuts.js b/exampleSite/templates/configuration/shortcuts.js index b14c534b..e8ee98db 100644 --- a/exampleSite/templates/configuration/shortcuts.js +++ b/exampleSite/templates/configuration/shortcuts.js @@ -1,7 +1,7 @@ import { addElementToModal, - displayModal -} from '/js/theme/modules/helpers.min.js' + displayModal, +} from '/js/theme/modules/helpers.min.js'; window.scExample = scExample; @@ -11,4 +11,4 @@ function scExample() { el.innerHTML = '{{i18n "shortcut_example"}}'; addElementToModal(el); displayModal(); -} \ No newline at end of file +} diff --git a/i18n/en.yaml b/i18n/en.yaml index 1ba0e611..1940113d 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -1,118 +1,118 @@ -- id: homepage_title - translation: "Homepage" -- id: search_placeholder - translation: "Search" -- id: search_no_results - translation: "No result found" -- id: sidebar_collapse - translation: "Collapse sidebar" -- id: banner_default_content - translation: | - You are viewing the version ***{{.Site.Params.currentversion}}*** of this website. - For an up-to-date documentation, please check the [latest version]({{.Site.Params.latestversionurl}}). -- id: toc_title - translation: "On this page:" -- id: toc_backtotop - translation: "Back to top" -- id: navbar_label_print - translation: "Print" -- id: navbar_label_qrcode - translation: "QR code" -- id: navbar_label_shortcuts - translation: "Shortcuts" -- id: navbar_label_taxonomies - translation: "Taxonomies" -- id: navbar_label_versions - translation: "Versions" -- id: navbar_label_info - translation: "About" -- id: navbarinfo_title - translation: "About" -- id: navbarshortcuts_title - translation: "Keyboard shortcuts" -- id: 1_info_keys_wording - translation: "Shift,i" -- id: 1_info_wording - translation: "Show website information" -- id: 2_shortcuts_keys_wording - translation: "Shift,k" -- id: 2_shortcuts_wording - translation: "Show shortcuts" -- id: 3_home_keys_wording - translation: "Shift,h" -- id: 3_home_wording - translation: "Go to homepage" -- id: 4_search_keys_wording - translation: "Shift,f" -- id: 4_search_wording - translation: "Find on website" -- id: 5_togglesidebar_keys_wording - translation: "Shift,m" -- id: 5_togglesidebar_wording - translation: "Collapse/Uncollapse sidebar" -- id: 6_toggletoc_keys_wording - translation: "Shift,t" -- id: 6_toggletoc_wording - translation: "Collapse/Uncollapse toc" -- id: 7_backtotop_keys_wording - translation: "Shift,↑" -- id: 7_backtotop_wording - translation: "Go to the top of the page" -- id: 8_gotobottom_keys_wording - translation: "Shift,↓" -- id: 8_gotobottom_wording - translation: "Go to the bottom of the page" -- id: 9_print_keys_wording - translation: "Shift,p" -- id: 9_print_wording - translation: "Print current page" -- id: 10_qrcode_keys_wording - translation: "Shift,q" -- id: 10_qrcode_wording - translation: "Get current page QR code" -- id: 11_closemodals_keys_wording - translation: "Escape" -- id: 11_closemodals_wording - translation: "Close modals" -- id: shortcode_collapsible - translation: "Expand/Collapse" -- id: no_data - translation: "No data available" -- id: empty_description - translation: "No description available" -- id: read_more - translation: "Read more" -- id: helper_loading - translation: "Loading" -- id: code_copy_before - translation: "Copy to clipboard" -- id: code_copy_after - translation: "Copied to clipboard" -- id: download_as_svg - translation: "Download as SVG" -- id: 404_title - translation: "Oops, we can't find the page you're looking for." -- id: 404_footer - translation: "Back to homepage" -- id: intro_error_title - translation: "Error !!" -- id: intro_error - translation: "Invalid JSON. Please check the Intro shortcode definition." -- id: intro_empty - translation: "Attribute steps not found. Please check the Intro shortcode definition" -- id: intro_prevlabel - translation: "Previous" -- id: intro_nextlabel - translation: "Next" -- id: intro_skiplabel - translation: "✗" -- id: intro_donelabel - translation: "Done" -- id: na_common - translation: "Not available" -- id: sidebar_collapsible_title - translation: "Collapse/Uncollapse sidebar" -- id: toc_collapsible_title - translation: "Collapse/Uncollapse table of contents" -- id: highcharts_error - translation: "Highcharts rendering unavailable" \ No newline at end of file +- id: homepage_title + translation: 'Homepage' +- id: search_placeholder + translation: 'Search' +- id: search_no_results + translation: 'No result found' +- id: sidebar_collapse + translation: 'Collapse sidebar' +- id: banner_default_content + translation: | + You are viewing the version ***{{.Site.Params.currentversion}}*** of this website. + For an up-to-date documentation, please check the [latest version]({{.Site.Params.latestversionurl}}). +- id: toc_title + translation: 'On this page:' +- id: toc_backtotop + translation: 'Back to top' +- id: navbar_label_print + translation: 'Print' +- id: navbar_label_qrcode + translation: 'QR code' +- id: navbar_label_shortcuts + translation: 'Shortcuts' +- id: navbar_label_taxonomies + translation: 'Taxonomies' +- id: navbar_label_versions + translation: 'Versions' +- id: navbar_label_info + translation: 'About' +- id: navbarinfo_title + translation: 'About' +- id: navbarshortcuts_title + translation: 'Keyboard shortcuts' +- id: 1_info_keys_wording + translation: 'Shift,i' +- id: 1_info_wording + translation: 'Show website information' +- id: 2_shortcuts_keys_wording + translation: 'Shift,k' +- id: 2_shortcuts_wording + translation: 'Show shortcuts' +- id: 3_home_keys_wording + translation: 'Shift,h' +- id: 3_home_wording + translation: 'Go to homepage' +- id: 4_search_keys_wording + translation: 'Shift,f' +- id: 4_search_wording + translation: 'Find on website' +- id: 5_togglesidebar_keys_wording + translation: 'Shift,m' +- id: 5_togglesidebar_wording + translation: 'Collapse/Uncollapse sidebar' +- id: 6_toggletoc_keys_wording + translation: 'Shift,t' +- id: 6_toggletoc_wording + translation: 'Collapse/Uncollapse toc' +- id: 7_backtotop_keys_wording + translation: 'Shift,↑' +- id: 7_backtotop_wording + translation: 'Go to the top of the page' +- id: 8_gotobottom_keys_wording + translation: 'Shift,↓' +- id: 8_gotobottom_wording + translation: 'Go to the bottom of the page' +- id: 9_print_keys_wording + translation: 'Shift,p' +- id: 9_print_wording + translation: 'Print current page' +- id: 10_qrcode_keys_wording + translation: 'Shift,q' +- id: 10_qrcode_wording + translation: 'Get current page QR code' +- id: 11_closemodals_keys_wording + translation: 'Escape' +- id: 11_closemodals_wording + translation: 'Close modals' +- id: shortcode_collapsible + translation: 'Expand/Collapse' +- id: no_data + translation: 'No data available' +- id: empty_description + translation: 'No description available' +- id: read_more + translation: 'Read more' +- id: helper_loading + translation: 'Loading' +- id: code_copy_before + translation: 'Copy to clipboard' +- id: code_copy_after + translation: 'Copied to clipboard' +- id: download_as_svg + translation: 'Download as SVG' +- id: 404_title + translation: "Oops, we can't find the page you're looking for." +- id: 404_footer + translation: 'Back to homepage' +- id: intro_error_title + translation: 'Error !!' +- id: intro_error + translation: 'Invalid JSON. Please check the Intro shortcode definition.' +- id: intro_empty + translation: 'Attribute steps not found. Please check the Intro shortcode definition' +- id: intro_prevlabel + translation: 'Previous' +- id: intro_nextlabel + translation: 'Next' +- id: intro_skiplabel + translation: '✗' +- id: intro_donelabel + translation: 'Done' +- id: na_common + translation: 'Not available' +- id: sidebar_collapsible_title + translation: 'Collapse/Uncollapse sidebar' +- id: toc_collapsible_title + translation: 'Collapse/Uncollapse table of contents' +- id: highcharts_error + translation: 'Highcharts rendering unavailable' diff --git a/i18n/fr.yaml b/i18n/fr.yaml index 919b5a4b..104f2c1d 100644 --- a/i18n/fr.yaml +++ b/i18n/fr.yaml @@ -1,118 +1,118 @@ - id: homepage_title translation: "Page d'accueil" - id: search_placeholder - translation: "Rechercher" + translation: 'Rechercher' - id: search_no_results - translation: "Aucun résultat trouvé" + translation: 'Aucun résultat trouvé' - id: sidebar_collapse - translation: "Réduire le menu latéral" + translation: 'Réduire le menu latéral' - id: banner_default_content translation: | Vous consultez la version ***{{.Site.Params.currentversion}}*** de ce site. Pour une version à jour de la documentation, merci de se référer à la [dernière version]({{.Site.Params.latestversionurl}}). - id: toc_title - translation: "Sur cette page:" + translation: 'Sur cette page:' - id: toc_backtotop - translation: "Retour en haut" + translation: 'Retour en haut' - id: navbar_label_print - translation: "Imprimer" + translation: 'Imprimer' - id: navbar_label_qrcode - translation: "QR code" + translation: 'QR code' - id: navbar_label_shortcuts - translation: "Raccourcis" + translation: 'Raccourcis' - id: navbar_label_taxonomies - translation: "Taxonomies" + translation: 'Taxonomies' - id: navbar_label_versions - translation: "Versions" + translation: 'Versions' - id: navbar_label_info - translation: "À propos" + translation: 'À propos' - id: navbarinfo_title - translation: "À propos" + translation: 'À propos' - id: navbarshortcuts_title - translation: "Raccourcis clavier" + translation: 'Raccourcis clavier' - id: 1_info_keys_wording - translation: "Maj,i" + translation: 'Maj,i' - id: 1_info_wording - translation: "Afficher les informations du site" + translation: 'Afficher les informations du site' - id: 2_shortcuts_keys_wording - translation: "Maj,k" + translation: 'Maj,k' - id: 2_shortcuts_wording - translation: "Afficher les raccourcis" + translation: 'Afficher les raccourcis' - id: 3_home_keys_wording - translation: "Maj,h" + translation: 'Maj,h' - id: 3_home_wording translation: "Aller à la page d'accueil" - id: 4_search_keys_wording - translation: "Maj,f" + translation: 'Maj,f' - id: 4_search_wording - translation: "Rechercher sur le site" + translation: 'Rechercher sur le site' - id: 5_togglesidebar_keys_wording - translation: "Maj,m" + translation: 'Maj,m' - id: 5_togglesidebar_wording - translation: "Réduire/Développer la table des matières" + translation: 'Réduire/Développer la table des matières' - id: 6_toggletoc_keys_wording - translation: "Maj,m" + translation: 'Maj,m' - id: 6_toggletoc_wording - translation: "Réduire/Développer la table des matières" + translation: 'Réduire/Développer la table des matières' - id: 7_backtotop_keys_wording - translation: "Maj,↑" + translation: 'Maj,↑' - id: 7_backtotop_wording - translation: "Aller en haut de la page" + translation: 'Aller en haut de la page' - id: 8_gotobottom_keys_wording - translation: "Maj,↓" + translation: 'Maj,↓' - id: 8_gotobottom_wording - translation: "Aller en bas de la page" + translation: 'Aller en bas de la page' - id: 9_print_keys_wording - translation: "Maj,p" + translation: 'Maj,p' - id: 9_print_wording - translation: "Imprimer la page courante" + translation: 'Imprimer la page courante' - id: 10_qrcode_keys_wording - translation: "Maj,q" + translation: 'Maj,q' - id: 10_qrcode_wording - translation: "Obtenir le QR code de la page courante" + translation: 'Obtenir le QR code de la page courante' - id: 11_closemodals_keys_wording - translation: "Echap" + translation: 'Echap' - id: 11_closemodals_wording - translation: "Fermer les fenêtres modales" + translation: 'Fermer les fenêtres modales' - id: shortcode_collapsible - translation: "Développer/Réduire" + translation: 'Développer/Réduire' - id: no_data - translation: "Aucune donnée disponible" + translation: 'Aucune donnée disponible' - id: empty_description - translation: "Aucune description disponible" + translation: 'Aucune description disponible' - id: read_more - translation: "Lire plus" + translation: 'Lire plus' - id: helper_loading - translation: "Chargement" + translation: 'Chargement' - id: code_copy_before - translation: "Copier dans le presse-papiers" + translation: 'Copier dans le presse-papiers' - id: code_copy_after - translation: "Copié dans le presse-papiers" + translation: 'Copié dans le presse-papiers' - id: download_as_svg - translation: "Télécharger en tant que SVG" + translation: 'Télécharger en tant que SVG' - id: 404_title translation: "Oups, nous n'arrivons pas à trouver la page que vous cherchez." - id: 404_footer translation: "Retour à la page d'accueil" - id: intro_error_title - translation: "Erreur !!" + translation: 'Erreur !!' - id: intro_error - translation: "JSON invalide. Veuillez vérifier la définition du shortcode Intro." + translation: 'JSON invalide. Veuillez vérifier la définition du shortcode Intro.' - id: intro_empty - translation: "Attribut steps introuvable. Veuillez vérifier la définition du shortcode Intro." + translation: 'Attribut steps introuvable. Veuillez vérifier la définition du shortcode Intro.' - id: intro_prevlabel - translation: "Précédent" + translation: 'Précédent' - id: intro_nextlabel - translation: "Suivant" + translation: 'Suivant' - id: intro_skiplabel - translation: "✗" + translation: '✗' - id: intro_donelabel - translation: "Terminer" + translation: 'Terminer' - id: na_common - translation: "Non disponible" + translation: 'Non disponible' - id: sidebar_collapsible_title - translation: "Développer/Réduire menu latéral" + translation: 'Développer/Réduire menu latéral' - id: toc_collapsible_title - translation: "Développer/Réduire table des matières" + translation: 'Développer/Réduire table des matières' - id: highcharts_error - translation: "Rendu du Highcharts non disponible" \ No newline at end of file + translation: 'Rendu du Highcharts non disponible' diff --git a/layouts/404.html b/layouts/404.html index 9bfaa693..85ff2510 100644 --- a/layouts/404.html +++ b/layouts/404.html @@ -2,26 +2,32 @@ - {{partial "theme/meta.html" .}} - {{$404sass := resources.Get "sass/404.sass"}} - {{$options := (dict "outputStyle" "compressed" "includePaths" (slice "assets/bulma" "assets/sass"))}} - {{$main := $404sass | resources.ExecuteAsTemplate "css/404.sass" . | resources.ToCSS $options}} - + {{ partial "theme/meta.html" . }} + {{ $404sass := resources.Get "sass/404.sass" }} + {{ $options := (dict "outputStyle" "compressed" "includePaths" (slice "assets/bulma" "assets/sass")) }} + {{ $main := $404sass | resources.ExecuteAsTemplate "css/404.sass" . | resources.ToCSS $options }} +
-
+ - - - - diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 73c187f3..06c6dcf9 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1 +1,6 @@ -{{.Text}} \ No newline at end of file +{{ .Text }} diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index 84567d62..b78f526e 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,5 +1,11 @@ -{{$simpleLink := true}} -{{with (findRE "" .Text)}} - {{$simpleLink = false}} -{{end}} -{{.Text | safeHTML}} \ No newline at end of file +{{ $simpleLink := true }} +{{ with (findRE "" .Text) }} + {{ $simpleLink = false }} +{{ end }} +{{ .Text | safeHTML }} diff --git a/layouts/_default/index.html b/layouts/_default/index.html index 6ebfeea3..8c4de7a8 100644 --- a/layouts/_default/index.html +++ b/layouts/_default/index.html @@ -1 +1 @@ -{{partial "main.html" (dict "root" . "contentTemplate" "theme/content.html")}} \ No newline at end of file +{{ partial "main.html" (dict "root" . "contentTemplate" "theme/content.html") }} diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 6ebfeea3..8c4de7a8 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1 +1 @@ -{{partial "main.html" (dict "root" . "contentTemplate" "theme/content.html")}} \ No newline at end of file +{{ partial "main.html" (dict "root" . "contentTemplate" "theme/content.html") }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 6ebfeea3..8c4de7a8 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1 +1 @@ -{{partial "main.html" (dict "root" . "contentTemplate" "theme/content.html")}} \ No newline at end of file +{{ partial "main.html" (dict "root" . "contentTemplate" "theme/content.html") }} diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html index 1cd33355..eb467d3c 100644 --- a/layouts/_default/taxonomy.html +++ b/layouts/_default/taxonomy.html @@ -1 +1 @@ -{{partial "main.html" (dict "root" . "contentTemplate" "theme/taxonomy-content.html")}} \ No newline at end of file +{{ partial "main.html" (dict "root" . "contentTemplate" "theme/taxonomy-content.html") }} diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html index e6407bed..e3ebdad1 100644 --- a/layouts/_default/terms.html +++ b/layouts/_default/terms.html @@ -1 +1 @@ -{{partial "main.html" (dict "root" . "contentTemplate" "theme/terms-content.html")}} \ No newline at end of file +{{ partial "main.html" (dict "root" . "contentTemplate" "theme/terms-content.html") }} diff --git a/layouts/partials/custom/custom-footer.html b/layouts/partials/custom/custom-footer.html index 8f6466da..e40311dd 100644 --- a/layouts/partials/custom/custom-footer.html +++ b/layouts/partials/custom/custom-footer.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/layouts/partials/custom/custom-head.html b/layouts/partials/custom/custom-head.html index a9b17753..a2041871 100644 --- a/layouts/partials/custom/custom-head.html +++ b/layouts/partials/custom/custom-head.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/layouts/partials/custom/custom-info.html b/layouts/partials/custom/custom-info.html index a774bcdf..6f723b5a 100644 --- a/layouts/partials/custom/custom-info.html +++ b/layouts/partials/custom/custom-info.html @@ -1 +1 @@ - \ No newline at end of file + diff --git a/layouts/partials/main.html b/layouts/partials/main.html index f39e3ba5..a702fe8d 100644 --- a/layouts/partials/main.html +++ b/layouts/partials/main.html @@ -1,19 +1,22 @@ - {{partial "theme/meta.html" .root}} - {{partial "theme/includes-head.html" .root}} - {{partial "custom/custom-head.html" .root}} + {{ partial "theme/meta.html" .root }} + {{ partial "theme/includes-head.html" .root }} + {{ partial "custom/custom-head.html" .root }} - +
- {{partial "theme/header.html" .root}} -
- {{partial "theme/sidebar.html" .root}} - {{partial .contentTemplate .root}} + {{ partial "theme/header.html" .root }} +
+ {{ partial "theme/sidebar.html" .root }} + {{ partial .contentTemplate .root }}
- {{partial "theme/includes-end.html" .root}} - {{partial "custom/custom-footer.html" .root}} + {{ partial "theme/includes-end.html" .root }} + {{ partial "custom/custom-footer.html" .root }} - \ No newline at end of file + diff --git a/layouts/partials/theme/banner.html b/layouts/partials/theme/banner.html index 106ae403..432ea517 100644 --- a/layouts/partials/theme/banner.html +++ b/layouts/partials/theme/banner.html @@ -1,5 +1,5 @@ -{{with .text}} -