Debian Codegraph @

docs/assets/js/templates.js

raw symbols SCIP
1 /***************************************************************************
2 * fheroes2: https://github.com/ihhub/fheroes2 *
3 * Copyright (C) 2025 *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 /**
22 * HTML templates for the heading-copy and code-copy functionality
23 */
24
25 // Create the fheroes2 namespace if it doesn't exist
26 globalThis.fheroes2 = globalThis.fheroes2 || {};
27
28 // Template for the live region
29 const liveRegionTemplate = `
30 <div aria-live="assertive" aria-atomic="true" style="position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;"></div>
31 `;
32
33 // Template for the heading anchor icon
34 const headingAnchorTemplate = `
35 <span class="heading-anchor" aria-label="Copy link to heading" role="button" tabindex="0">🔗</span>
36 `;
37
38 // Template for the code copy button
39 const codeCopyButtonTemplate = `
40 <button class="btn btn-primary copy-btn" aria-label="Copy code to clipboard" title="Copy code to clipboard" tabindex="0">Copy</button>
41 `;
42
43 // Export the templates to the fheroes2 namespace
44 globalThis.fheroes2.HeadingCopyTemplates = {
45 liveRegionTemplate,
46 headingAnchorTemplate
47 };
48
49 globalThis.fheroes2.CodeCopyTemplates = {
50 liveRegionTemplate,
51 codeCopyButtonTemplate
52 };