chulapa-jekyll 2.0.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +264 -35
  3. data/README.md +189 -180
  4. data/_data/version.yml +2 -2
  5. data/_includes/components/archive-documents.html +56 -0
  6. data/_includes/components/author.html +6 -1
  7. data/_includes/components/breadcrumbdatesocial.html +16 -12
  8. data/_includes/components/cactus.html +2 -1
  9. data/_includes/components/cloud-entry.html +26 -0
  10. data/_includes/components/cloud.html +66 -0
  11. data/_includes/components/collection-documents.html +17 -0
  12. data/_includes/components/footer-content.html +34 -0
  13. data/_includes/components/headers.html +22 -15
  14. data/_includes/components/indexcards.html +13 -10
  15. data/_includes/components/indexcategory-documents.html +11 -0
  16. data/_includes/components/navbar-classic.html +58 -0
  17. data/_includes/components/navbeforeafter.html +9 -6
  18. data/_includes/components/navigation-fallback.html +19 -0
  19. data/_includes/components/random.html +1 -0
  20. data/_includes/components/recommendations.html +97 -0
  21. data/_includes/components/related.html +1 -104
  22. data/_includes/components/scripts.html +9 -0
  23. data/_includes/components/sidetoc.html +5 -4
  24. data/_includes/components/simplelist.html +26 -0
  25. data/_includes/components/skin-attribution.html +169 -0
  26. data/_includes/components/theme-selector.html +14 -0
  27. data/_includes/footer.html +14 -165
  28. data/_includes/head.html +389 -242
  29. data/_includes/navbar.html +33 -77
  30. data/_includes/search/fusejs.html +20 -0
  31. data/_includes/search/google.html +3 -3
  32. data/_includes/search/lunr.html +19 -7
  33. data/_includes/search/simplesearch.html +46 -0
  34. data/_includes/snippets/article-images.html +25 -0
  35. data/_includes/snippets/bootstrapdemo.html +1472 -1303
  36. data/_includes/snippets/breadcrumb-names.html +5 -0
  37. data/_includes/snippets/canonical-url.html +17 -0
  38. data/_includes/snippets/carousel.html +16 -12
  39. data/_includes/snippets/dark-skin-enabled.html +14 -0
  40. data/_includes/snippets/datetranslate.html +7 -1
  41. data/_includes/snippets/jsonld-string.html +16 -0
  42. data/_includes/snippets/masonry.html +6 -4
  43. data/_includes/snippets/microformats-url.html +2 -0
  44. data/_includes/snippets/og-locale.html +19 -0
  45. data/_includes/snippets/page-language.html +4 -0
  46. data/_includes/snippets/publisher.html +22 -0
  47. data/_includes/snippets/video-metadata.html +15 -0
  48. data/_includes/snippets/video.html +21 -18
  49. data/_includes/snippets/youtube.html +17 -6
  50. data/_includes/theme-styles.html +201 -0
  51. data/_includes/welcomments/comment_form.html +5 -4
  52. data/_includes/welcomments/comments.html +5 -5
  53. data/_includes/welcomments/template.html +1 -1
  54. data/_layouts/archive.html +2 -75
  55. data/_layouts/cloudcategory.html +2 -101
  56. data/_layouts/cloudtag.html +2 -103
  57. data/_layouts/compress.html +1 -1
  58. data/_layouts/default.html +20 -9
  59. data/_layouts/indexcategory.html +2 -30
  60. data/_layouts/landingpage.html +12 -7
  61. data/_layouts/minimal.html +19 -9
  62. data/_layouts/search.html +17 -17
  63. data/_sass/bootstrap/_variables.scss +1 -1
  64. data/_sass/bootstrap/mixins/_badge.scss +1 -1
  65. data/_sass/chulapa/_autothemer.scss +31 -0
  66. data/_sass/chulapa/_buttons.scss +101 -0
  67. data/_sass/chulapa/_classes.scss +197 -59
  68. data/_sass/chulapa/_mixins.scss +42 -1
  69. data/_sass/chulapa/_reboot.scss +31 -0
  70. data/_sass/chulapa/_theme-selector.scss +1 -0
  71. data/_sass/chulapa/_variables.scss +8 -1
  72. data/_sass/chulapa/skins/_deeply.scss +229 -0
  73. data/_sass/chulapa/skins/_electro.scss +30 -0
  74. data/_sass/chulapa/skins/_graymor.scss +39 -0
  75. data/_sass/chulapa/skins/_hootstrap.scss +34 -0
  76. data/_sass/chulapa/skins/_lymcha.scss +27 -0
  77. data/_sass/chulapa/skins/_mickie.scss +38 -0
  78. data/_sass/chulapa/skins/_minco.scss +45 -0
  79. data/_sass/chulapa/skins/_monotone.scss +15 -0
  80. data/_sass/chulapa/skins/_preptor.scss +30 -0
  81. data/_sass/chulapa/skins/_skeeblu.scss +34 -0
  82. data/_sass/chulapa/skins/_sunset.scss +33 -0
  83. data/_sass/chulapa/skins/_wandoo.scss +22 -0
  84. data/_sass/chulapa/skins/bootswatch/_cyborg.scss +543 -0
  85. data/_sass/chulapa/skins/bootswatch/_darkly.scss +452 -0
  86. data/_sass/chulapa/skins/bootswatch/_flatly.scss +415 -0
  87. data/_sass/chulapa/skins/bootswatch/_journal.scss +163 -0
  88. data/_sass/chulapa/skins/bootswatch/_lux.scss +342 -0
  89. data/_sass/chulapa/skins/bootswatch/_materia.scss +914 -0
  90. data/_sass/chulapa/skins/bootswatch/_minty.scss +342 -0
  91. data/_sass/chulapa/skins/bootswatch/_sketchy.scss +757 -0
  92. data/_sass/chulapa/skins/bootswatch/_slate.scss +746 -0
  93. data/_sass/chulapa/skins/bootswatch/_solar.scss +454 -0
  94. data/_sass/chulapa/skins/bootswatch/_united.scss +85 -0
  95. data/_sass/chulapa/skins/bootswatch/_yeti.scss +699 -0
  96. data/_sass/chulapa/skins/bootswatch/cyborg.patch +301 -0
  97. data/_sass/chulapa/skins/bootswatch/darkly.patch +493 -0
  98. data/_sass/chulapa/skins/bootswatch/flatly.patch +325 -0
  99. data/_sass/chulapa/skins/bootswatch/journal.patch +71 -0
  100. data/_sass/chulapa/skins/bootswatch/lux.patch +97 -0
  101. data/_sass/chulapa/skins/bootswatch/materia.patch +250 -0
  102. data/_sass/chulapa/skins/bootswatch/minty.patch +400 -0
  103. data/_sass/chulapa/skins/bootswatch/sketchy.patch +863 -0
  104. data/_sass/chulapa/skins/bootswatch/slate.patch +537 -0
  105. data/_sass/chulapa/skins/bootswatch/solar.patch +307 -0
  106. data/_sass/chulapa/skins/bootswatch/united.patch +91 -0
  107. data/_sass/chulapa/skins/bootswatch/yeti.patch +552 -0
  108. data/_sass/chulapa-master.scss +10 -0
  109. data/_sass/highlight/README.md +176 -14
  110. data/_sass/highlight/abap.scss +62 -0
  111. data/_sass/highlight/algol.scss +46 -0
  112. data/_sass/highlight/algol_nu.scss +46 -0
  113. data/_sass/highlight/arduino.scss +63 -0
  114. data/_sass/highlight/autumn.scss +69 -58
  115. data/_sass/highlight/base16.scss +90 -0
  116. data/_sass/highlight/borland.scss +55 -46
  117. data/_sass/highlight/bw.scss +70 -34
  118. data/_sass/highlight/cobalt2.scss +197 -0
  119. data/_sass/highlight/coffee.scss +82 -0
  120. data/_sass/highlight/colorful.scss +178 -61
  121. data/_sass/highlight/cran.scss +185 -169
  122. data/_sass/highlight/default.scss +72 -61
  123. data/_sass/highlight/dracula.scss +93 -169
  124. data/_sass/highlight/emacs.scss +72 -61
  125. data/_sass/highlight/friendly.scss +72 -61
  126. data/_sass/highlight/friendly_grayscale.scss +72 -0
  127. data/_sass/highlight/fruity.scss +82 -70
  128. data/_sass/highlight/github.dark.scss +83 -0
  129. data/_sass/highlight/github.scss +116 -61
  130. data/_sass/highlight/gruvbox.dark.scss +83 -0
  131. data/_sass/highlight/gruvbox.light.scss +68 -84
  132. data/_sass/highlight/gruvbox.scss +97 -0
  133. data/_sass/highlight/igor.scss +36 -0
  134. data/_sass/highlight/igorpro.scss +45 -0
  135. data/_sass/highlight/inkpot.scss +78 -0
  136. data/_sass/highlight/lightbulb.scss +82 -0
  137. data/_sass/highlight/lilypond.scss +58 -0
  138. data/_sass/highlight/lovelace.scss +74 -0
  139. data/_sass/highlight/magritte.scss +175 -0
  140. data/_sass/highlight/manni.scss +72 -61
  141. data/_sass/highlight/material.scss +81 -0
  142. data/_sass/highlight/molokai.scss +211 -0
  143. data/_sass/highlight/monokai.scss +217 -65
  144. data/_sass/highlight/monokai.sublime.scss +203 -0
  145. data/_sass/highlight/murphy.scss +72 -61
  146. data/_sass/highlight/native.scss +82 -70
  147. data/_sass/highlight/night-owl.scss +201 -0
  148. data/_sass/highlight/nord.darker.scss +82 -0
  149. data/_sass/highlight/nord.scss +82 -0
  150. data/_sass/highlight/oksolar.dark.scss +175 -0
  151. data/_sass/highlight/oksolar.light.scss +175 -0
  152. data/_sass/highlight/one.dark.scss +82 -0
  153. data/_sass/highlight/panda.scss +195 -0
  154. data/_sass/highlight/paraiso.dark.scss +76 -0
  155. data/_sass/highlight/paraiso.light.scss +76 -0
  156. data/_sass/highlight/pastie.scss +154 -60
  157. data/_sass/highlight/perldoc.scss +69 -58
  158. data/_sass/highlight/rainbow_dash.scss +65 -0
  159. data/_sass/highlight/rrt.scss +82 -0
  160. data/_sass/highlight/sas.scss +63 -0
  161. data/_sass/highlight/selenized.black.scss +175 -0
  162. data/_sass/highlight/selenized.dark.scss +175 -0
  163. data/_sass/highlight/selenized.light.scss +175 -0
  164. data/_sass/highlight/selenized.white.scss +175 -0
  165. data/_sass/highlight/skeletor.scss +190 -140
  166. data/_sass/highlight/solarized.dark.scss +82 -0
  167. data/_sass/highlight/solarized.light.scss +82 -0
  168. data/_sass/highlight/stackoverflow.dark.scss +175 -0
  169. data/_sass/highlight/stackoverflow.light.scss +175 -0
  170. data/_sass/highlight/staroffice.scss +82 -0
  171. data/_sass/highlight/stata.dark.scss +82 -0
  172. data/_sass/highlight/stata.light.scss +49 -0
  173. data/_sass/highlight/tango.scss +81 -69
  174. data/_sass/highlight/template.scss +290 -0
  175. data/_sass/highlight/thankful_eyes.scss +180 -173
  176. data/_sass/highlight/trac.scss +70 -59
  177. data/_sass/highlight/tulip.scss +171 -0
  178. data/_sass/highlight/vim.scss +82 -70
  179. data/_sass/highlight/vs.scss +41 -33
  180. data/_sass/highlight/xcode.scss +65 -0
  181. data/_sass/highlight/zenburn.scss +82 -136
  182. data/_sass/reset-algolia.scss +27 -17
  183. data/_sass/skins/academia.scss +47 -10
  184. data/_sass/skins/auto.scss +25 -27
  185. data/_sass/skins/butterfly-dark.scss +73 -0
  186. data/_sass/skins/butterfly-dim.scss +81 -0
  187. data/_sass/skins/butterfly.scss +65 -0
  188. data/_sass/skins/cerulean.scss +120 -0
  189. data/_sass/skins/chulapa.scss +33 -6
  190. data/_sass/skins/cyborg.scss +3 -0
  191. data/_sass/skins/dark-bg.scss +83 -49
  192. data/_sass/skins/darkly.scss +3 -0
  193. data/_sass/skins/deeply.scss +17 -87
  194. data/_sass/skins/electro.scss +5 -19
  195. data/_sass/skins/flatly.scss +3 -0
  196. data/_sass/skins/focal.scss +56 -19
  197. data/_sass/skins/gitdev-dark.scss +28 -25
  198. data/_sass/skins/gitdev.scss +22 -19
  199. data/_sass/skins/graymor.scss +7 -22
  200. data/_sass/skins/hootstrap.scss +6 -13
  201. data/_sass/skins/journal.scss +3 -143
  202. data/_sass/skins/listen.scss +83 -0
  203. data/_sass/skins/litera.scss +281 -0
  204. data/_sass/skins/lux.scss +3 -376
  205. data/_sass/skins/lymcha.scss +4 -12
  206. data/_sass/skins/materia.scss +3 -0
  207. data/_sass/skins/media.scss +40 -12
  208. data/_sass/skins/mickie.scss +8 -11
  209. data/_sass/skins/minco.scss +11 -10
  210. data/_sass/skins/minty.scss +3 -168
  211. data/_sass/skins/monotone.scss +7 -11
  212. data/_sass/skins/navi.scss +54 -0
  213. data/_sass/skins/none.scss +24 -2
  214. data/_sass/skins/pear.scss +50 -6
  215. data/_sass/skins/preptor.scss +6 -15
  216. data/_sass/skins/pulse.scss +158 -0
  217. data/_sass/skins/skeeblu.scss +6 -17
  218. data/_sass/skins/sketchy.scss +3 -746
  219. data/_sass/skins/slate.scss +3 -0
  220. data/_sass/skins/solar.scss +3 -0
  221. data/_sass/skins/sunset.scss +6 -11
  222. data/_sass/skins/towards.scss +44 -5
  223. data/_sass/skins/twitter-dim.scss +60 -13
  224. data/_sass/skins/twitter-lights-out.scss +44 -11
  225. data/_sass/skins/twitter.scss +51 -10
  226. data/_sass/skins/united.scss +3 -0
  227. data/_sass/skins/universal.scss +46 -27
  228. data/_sass/skins/wandoo.scss +7 -12
  229. data/_sass/skins/yeti.scss +3 -0
  230. data/_sass/vendor/bootswatch/LICENSE +21 -0
  231. data/_sass/vendor/bootswatch/LICENSE-4.5.0 +21 -0
  232. data/_sass/vendor/bootswatch/README.md +57 -0
  233. data/_sass/vendor/bootswatch/cerulean/_bootswatch.scss +102 -0
  234. data/_sass/vendor/bootswatch/cerulean/_variables.scss +57 -0
  235. data/_sass/vendor/bootswatch/cyborg/_bootswatch.scss +330 -0
  236. data/_sass/vendor/bootswatch/cyborg/_variables.scss +169 -0
  237. data/_sass/vendor/bootswatch/darkly/_bootswatch.scss +247 -0
  238. data/_sass/vendor/bootswatch/darkly/_variables.scss +164 -0
  239. data/_sass/vendor/bootswatch/flatly/_bootswatch.scss +274 -0
  240. data/_sass/vendor/bootswatch/flatly/_variables.scss +106 -0
  241. data/_sass/vendor/bootswatch/journal/_bootswatch.scss +62 -0
  242. data/_sass/vendor/bootswatch/journal/_variables.scss +60 -0
  243. data/_sass/vendor/bootswatch/litera/_bootswatch.scss +268 -0
  244. data/_sass/vendor/bootswatch/litera/_variables.scss +96 -0
  245. data/_sass/vendor/bootswatch/lux/_bootswatch.scss +191 -0
  246. data/_sass/vendor/bootswatch/lux/_variables.scss +103 -0
  247. data/_sass/vendor/bootswatch/materia/_bootswatch.scss +747 -0
  248. data/_sass/vendor/bootswatch/materia/_variables.scss +129 -0
  249. data/_sass/vendor/bootswatch/minty/_bootswatch.scss +380 -0
  250. data/_sass/vendor/bootswatch/minty/_variables.scss +94 -0
  251. data/_sass/vendor/bootswatch/pulse/_bootswatch.scss +145 -0
  252. data/_sass/vendor/bootswatch/pulse/_variables.scss +96 -0
  253. data/_sass/vendor/bootswatch/sketchy/_bootswatch.scss +492 -0
  254. data/_sass/vendor/bootswatch/sketchy/_variables.scss +172 -0
  255. data/_sass/vendor/bootswatch/slate/_bootswatch.scss +531 -0
  256. data/_sass/vendor/bootswatch/slate/_variables.scss +163 -0
  257. data/_sass/vendor/bootswatch/solar/_bootswatch.scss +243 -0
  258. data/_sass/vendor/bootswatch/solar/_variables.scss +171 -0
  259. data/_sass/vendor/bootswatch/source.json +86 -0
  260. data/_sass/vendor/bootswatch/united/_bootswatch.scss +10 -0
  261. data/_sass/vendor/bootswatch/united/_variables.scss +54 -0
  262. data/_sass/vendor/bootswatch/yeti/_bootswatch.scss +586 -0
  263. data/_sass/vendor/bootswatch/yeti/_variables.scss +110 -0
  264. data/_sass/vendor/tophat/LICENSE +21 -0
  265. data/_sass/vendor/tophat/README.md +38 -0
  266. data/_sass/vendor/tophat/deeply/_styles.scss +6 -0
  267. data/_sass/vendor/tophat/deeply/_variables.scss +73 -0
  268. data/_sass/vendor/tophat/deeply/theme.scss +77 -0
  269. data/_sass/vendor/tophat/electro/_styles.scss +5 -0
  270. data/_sass/vendor/tophat/electro/_variables.scss +23 -0
  271. data/_sass/vendor/tophat/electro/theme.scss +28 -0
  272. data/_sass/vendor/tophat/graymor/_styles.scss +5 -0
  273. data/_sass/vendor/tophat/graymor/_variables.scss +18 -0
  274. data/_sass/vendor/tophat/graymor/theme.scss +24 -0
  275. data/_sass/vendor/tophat/hootstrap/_styles.scss +5 -0
  276. data/_sass/vendor/tophat/hootstrap/_variables.scss +14 -0
  277. data/_sass/vendor/tophat/hootstrap/theme.scss +18 -0
  278. data/_sass/vendor/tophat/lymcha/_styles.scss +5 -0
  279. data/_sass/vendor/tophat/lymcha/_variables.scss +13 -0
  280. data/_sass/vendor/tophat/lymcha/theme.scss +16 -0
  281. data/_sass/vendor/tophat/mickie/_styles.scss +5 -0
  282. data/_sass/vendor/tophat/mickie/_variables.scss +13 -0
  283. data/_sass/vendor/tophat/mickie/theme.scss +17 -0
  284. data/_sass/vendor/tophat/minco/_styles.scss +5 -0
  285. data/_sass/vendor/tophat/minco/_variables.scss +14 -0
  286. data/_sass/vendor/tophat/minco/theme.scss +18 -0
  287. data/_sass/vendor/tophat/monotone/_styles.scss +5 -0
  288. data/_sass/vendor/tophat/monotone/_variables.scss +14 -0
  289. data/_sass/vendor/tophat/monotone/theme.scss +18 -0
  290. data/_sass/vendor/tophat/preptor/_styles.scss +5 -0
  291. data/_sass/vendor/tophat/preptor/_variables.scss +14 -0
  292. data/_sass/vendor/tophat/preptor/theme.scss +18 -0
  293. data/_sass/vendor/tophat/skeeblu/_styles.scss +5 -0
  294. data/_sass/vendor/tophat/skeeblu/_variables.scss +17 -0
  295. data/_sass/vendor/tophat/skeeblu/theme.scss +22 -0
  296. data/_sass/vendor/tophat/source.json +57 -0
  297. data/_sass/vendor/tophat/sunset/_styles.scss +5 -0
  298. data/_sass/vendor/tophat/sunset/_variables.scss +13 -0
  299. data/_sass/vendor/tophat/sunset/theme.scss +16 -0
  300. data/_sass/vendor/tophat/wandoo/_styles.scss +5 -0
  301. data/_sass/vendor/tophat/wandoo/_variables.scss +18 -0
  302. data/_sass/vendor/tophat/wandoo/theme.scss +24 -0
  303. data/assets/atom.xml +10 -6
  304. data/assets/css/dark/highlighter.scss +10 -0
  305. data/assets/css/dark/main.scss +43 -0
  306. data/assets/css/highlighter.scss +6 -1
  307. data/assets/css/main.scss +12 -3
  308. data/assets/css/search-fusejs.css +14 -0
  309. data/assets/css/search-lunr.css +7 -0
  310. data/assets/js/better404/better404.js +68 -0
  311. data/assets/js/ch_ytdefer/ch_ytdefer.js +27 -83
  312. data/assets/js/chulapa_carousel.js +115 -0
  313. data/assets/js/chulapa_mermaid.js +31 -0
  314. data/assets/js/chulapa_navigation.js +71 -0
  315. data/assets/js/chulapa_photoswipe.js +106 -0
  316. data/assets/js/chulapa_script.js +199 -77
  317. data/assets/js/chulapa_search.js +89 -0
  318. data/assets/js/clipboard/chulapa_clipboard.js +17 -108
  319. data/assets/js/cusdis/chulapa_cusdis.js +1 -1
  320. data/assets/js/fusejs/fusejs-search.js +62 -0
  321. data/assets/js/fusejs/fusejs-search.min.js +4 -0
  322. data/assets/js/fusejs/fusejs-store.js +43 -0
  323. data/assets/js/lunr/lunr-search.js +127 -115
  324. data/assets/js/lunr/lunr-search.min.js +4 -0
  325. data/assets/js/lunr/lunr-store.js +31 -23
  326. data/assets/js/simplesearch/simplesearch-store.json +45 -0
  327. data/assets/rss.xml +4 -3
  328. metadata +220 -8
  329. data/_sass/highlight/UNLICENSE.txt +0 -24
@@ -0,0 +1,115 @@
1
+ // Bootstrap supplies slide transitions; this controller owns automatic motion.
2
+ (function () {
3
+ function setup() {
4
+ if (!window.jQuery || typeof window.jQuery.fn.carousel !== 'function') return;
5
+ const reduced = window.matchMedia('(prefers-reduced-motion: reduce)');
6
+ const hoverEnabled = window.matchMedia('(hover: hover)').matches;
7
+ document.querySelectorAll('[data-chulapa-carousel="true"]').forEach(carousel => {
8
+ if (carousel.dataset.chulapaCarouselReady) return;
9
+ carousel.dataset.chulapaCarouselReady = 'true';
10
+ const slides = Array.from(carousel.querySelectorAll('.carousel-item'));
11
+ const indicators = Array.from(carousel.querySelectorAll('.carousel-indicators button'));
12
+ const controls = Array.from(carousel.querySelectorAll('[data-slide], [data-slide-to]'));
13
+ const toggle = carousel.querySelector('.chulapa-carousel-toggle');
14
+ const inner = carousel.querySelector('.carousel-inner');
15
+ const symbol = toggle.querySelector('.chulapa-carousel-symbol');
16
+ const icon = symbol && symbol.querySelector('i');
17
+ const fallback = symbol && symbol.querySelector('.chulapa-carousel-fallback');
18
+ function checkIconFont() {
19
+ if (!icon || !document.fonts) return;
20
+ const style = getComputedStyle(icon, '::before');
21
+ const available = /Awesome/i.test(style.fontFamily) && style.content !== 'none' && style.content !== 'normal' &&
22
+ Array.from(document.fonts).some(font => font.status === 'loaded' && /Awesome/i.test(font.family) &&
23
+ style.fontFamily.includes(font.family.replace(/["']/g, ''))) &&
24
+ document.fonts.check(style.fontWeight + ' ' + style.fontSize + ' ' + style.fontFamily);
25
+ symbol.classList.toggle('has-icon-font', available);
26
+ }
27
+ if (document.fonts && icon) {
28
+ document.fonts.ready.then(() => {
29
+ const style = getComputedStyle(icon, '::before');
30
+ if (/Awesome/i.test(style.fontFamily)) {
31
+ document.fonts.load(style.fontWeight + ' ' + style.fontSize + ' ' + style.fontFamily, '\uf04b\uf04c')
32
+ .then(checkIconFont, () => {});
33
+ }
34
+ checkIconFont();
35
+ });
36
+ document.fonts.addEventListener('loadingdone', checkIconFont);
37
+ }
38
+ const interval = Number(carousel.getAttribute('data-interval'));
39
+ const automatic = slides.length > 1 && Number.isFinite(interval) && interval > 0;
40
+ const widget = window.jQuery(carousel);
41
+ let paused = reduced.matches;
42
+ let hovered = hoverEnabled && carousel.matches(':hover');
43
+ // Cached includes can repeat an ID; route each control to its own instance.
44
+ const originalId = carousel.id;
45
+ let suffix = 2;
46
+ while (document.getElementById(carousel.id) !== carousel) carousel.id = originalId + '-' + suffix++;
47
+ controls.forEach(control => control.setAttribute('data-target', '#' + carousel.id));
48
+ widget.carousel({ interval: automatic ? interval : false, ride: false, pause: false });
49
+ function updateSlides() {
50
+ slides.forEach((slide, index) => {
51
+ const active = slide.classList.contains('active');
52
+ if (indicators[index]) {
53
+ if (active) indicators[index].setAttribute('aria-current', 'true');
54
+ else indicators[index].removeAttribute('aria-current');
55
+ }
56
+ });
57
+ }
58
+ function updateMotion() {
59
+ const running = automatic && !paused && !hovered;
60
+ widget.carousel(running ? 'cycle' : 'pause');
61
+ inner.setAttribute('aria-live', running ? 'off' : 'polite');
62
+ toggle.setAttribute('aria-label', paused ? 'Start slideshow' : 'Pause slideshow');
63
+ if (symbol) {
64
+ const visibleIcon = symbol.querySelector('i, svg');
65
+ if (visibleIcon) {
66
+ if (visibleIcon.tagName.toLowerCase() === 'svg' && visibleIcon.getAttribute('data-icon') !== (paused ? 'play' : 'pause')) {
67
+ const replacement = document.createElement('i');
68
+ replacement.className = 'fa fas ' + (paused ? 'fa-play' : 'fa-pause');
69
+ visibleIcon.replaceWith(replacement);
70
+ } else {
71
+ visibleIcon.classList.toggle('fa-play', paused);
72
+ visibleIcon.classList.toggle('fa-pause', !paused);
73
+ }
74
+ }
75
+ fallback.textContent = paused ? '▶' : 'Ⅱ';
76
+ } else {
77
+ toggle.textContent = paused ? 'Start slideshow' : 'Pause slideshow';
78
+ }
79
+ }
80
+ toggle.hidden = !automatic;
81
+ toggle.addEventListener('click', () => { paused = !paused; updateMotion(); });
82
+ controls.forEach(control => {
83
+ control.addEventListener('click', event => {
84
+ event.preventDefault();
85
+ event.stopPropagation();
86
+ const index = control.getAttribute('data-slide-to');
87
+ widget.carousel(index === null ? control.getAttribute('data-slide') : Number(index));
88
+ // Bootstrap's to(currentIndex) otherwise restarts a paused carousel.
89
+ updateMotion();
90
+ });
91
+ });
92
+ carousel.addEventListener('focusin', event => {
93
+ if (!toggle.contains(event.target)) { paused = true; updateMotion(); }
94
+ });
95
+ carousel.addEventListener('pointerdown', event => {
96
+ if (!toggle.contains(event.target)) { paused = true; updateMotion(); }
97
+ });
98
+ carousel.addEventListener('keydown', event => {
99
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') { paused = true; updateMotion(); }
100
+ }, true);
101
+ carousel.addEventListener('mouseenter', () => { if (hoverEnabled) { hovered = true; updateMotion(); } });
102
+ carousel.addEventListener('mouseleave', () => { if (hoverEnabled) { hovered = false; updateMotion(); } });
103
+ function preferenceChanged(event) {
104
+ if (event.matches) { paused = true; updateMotion(); }
105
+ }
106
+ if (typeof reduced.addEventListener === 'function') reduced.addEventListener('change', preferenceChanged);
107
+ else if (typeof reduced.addListener === 'function') reduced.addListener(preferenceChanged);
108
+ widget.on('slid.bs.carousel', updateSlides);
109
+ updateSlides();
110
+ updateMotion();
111
+ });
112
+ }
113
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', setup, { once: true });
114
+ else setup();
115
+ })();
@@ -0,0 +1,31 @@
1
+ export async function renderDiagrams(root = document, load = () =>
2
+ import("https://cdn.jsdelivr.net/npm/mermaid@12.1.0/dist/mermaid.esm.min.mjs")) {
3
+ const blocks = Array.from(root.querySelectorAll("pre")).filter(pre =>
4
+ pre.classList.contains("mermaid") || pre.closest(".language-mermaid") ||
5
+ pre.querySelector("code.language-mermaid"));
6
+ if (!blocks.length) return;
7
+ try {
8
+ const { default: mermaid } = await load();
9
+ if (root.fonts) await root.fonts.ready;
10
+ mermaid.initialize({ startOnLoad: false, securityLevel: "strict" });
11
+ for (const [index, pre] of blocks.entries()) {
12
+ const code = pre.querySelector("code");
13
+ try {
14
+ await mermaid.parse((code || pre).textContent);
15
+ const { svg } = await mermaid.render("chulapa-mermaid-" + index,
16
+ (code || pre).textContent);
17
+ const diagram = root.createElement("div");
18
+ diagram.className = "chulapa-mermaid my-3";
19
+ diagram.style.overflowX = "auto";
20
+ diagram.innerHTML = svg;
21
+ pre.replaceWith(diagram);
22
+ } catch (error) {
23
+ console.warn("Unable to render Mermaid diagram", error);
24
+ }
25
+ }
26
+ } catch (error) {
27
+ console.warn("Unable to load Mermaid; diagram source is preserved", error);
28
+ }
29
+ }
30
+
31
+ if (typeof document !== "undefined") renderDiagrams();
@@ -0,0 +1,71 @@
1
+ (function () {
2
+ // Floating navigation uses a keyboard-operable button; the lateral TOC is independent.
3
+ var navigationButton = document.getElementById("navi-toggle");
4
+ var navigationMenu = document.getElementById("navi-menu");
5
+ if (navigationButton && navigationMenu) {
6
+ var pendingFocus;
7
+ function cancelInitialFocus() {
8
+ if (pendingFocus) navigationMenu.removeEventListener("transitionend", pendingFocus);
9
+ pendingFocus = null;
10
+ }
11
+ function setFloatingNavigation(open, returnFocus) {
12
+ cancelInitialFocus();
13
+ navigationButton.setAttribute("aria-expanded", String(open));
14
+ navigationMenu.setAttribute("aria-hidden", String(!open));
15
+ navigationMenu.inert = !open;
16
+ if (open) {
17
+ var firstLink = navigationMenu.querySelector("a, button");
18
+ if (firstLink) {
19
+ var previousFocus = document.activeElement;
20
+ firstLink.focus();
21
+ // Animated visibility may still be hidden during the initiating click.
22
+ if (document.activeElement !== firstLink) {
23
+ pendingFocus = function (event) {
24
+ if (event.target !== navigationMenu) return;
25
+ cancelInitialFocus();
26
+ if (navigationButton.getAttribute("aria-expanded") === "true" && document.activeElement === previousFocus) firstLink.focus();
27
+ };
28
+ navigationMenu.addEventListener("transitionend", pendingFocus);
29
+ }
30
+ }
31
+ } else if (returnFocus) {
32
+ navigationButton.focus();
33
+ }
34
+ }
35
+ navigationButton.addEventListener("click", function () {
36
+ setFloatingNavigation(navigationButton.getAttribute("aria-expanded") !== "true", true);
37
+ });
38
+ navigationMenu.addEventListener("keydown", function (event) {
39
+ if (event.key === "Escape") {
40
+ event.preventDefault();
41
+ event.stopPropagation();
42
+ setFloatingNavigation(false, true);
43
+ }
44
+ });
45
+ navigationButton.addEventListener("keydown", function (event) {
46
+ if (event.key === "Escape") {
47
+ setFloatingNavigation(false, true);
48
+ }
49
+ });
50
+ navigationMenu.addEventListener("click", function (event) {
51
+ var link = event.target.closest("a");
52
+ if (link && !link.hasAttribute("data-toggle")) {
53
+ setFloatingNavigation(false, true);
54
+ }
55
+ });
56
+ navigationMenu.addEventListener("focusout", function () {
57
+ setTimeout(function () {
58
+ if (!navigationMenu.contains(document.activeElement) &&
59
+ document.activeElement !== navigationButton) {
60
+ setFloatingNavigation(false, false);
61
+ }
62
+ }, 0);
63
+ });
64
+ window.addEventListener("resize", function () {
65
+ if (navigationButton.getClientRects().length === 0) {
66
+ setFloatingNavigation(false, false);
67
+ }
68
+ });
69
+ }
70
+
71
+ })();
@@ -0,0 +1,106 @@
1
+ const version = "5.4.4";
2
+ const cdn = `https://cdn.jsdelivr.net/npm/photoswipe@${version}/dist/`;
3
+
4
+ function loadStyles(root) {
5
+ return new Promise((resolve, reject) => {
6
+ const link = root.createElement("link");
7
+ link.rel = "stylesheet";
8
+ link.href = cdn + "photoswipe.css";
9
+ const timer = setTimeout(() => { link.remove(); reject(new Error("PhotoSwipe stylesheet timed out")); }, 15000);
10
+ link.onload = () => { clearTimeout(timer); resolve(); };
11
+ link.onerror = () => { clearTimeout(timer); link.remove(); reject(new Error("PhotoSwipe stylesheet unavailable")); };
12
+ root.head.append(link);
13
+ });
14
+ }
15
+
16
+ async function measure(image, view) {
17
+ if (image.naturalWidth && image.naturalHeight) return {width: image.naturalWidth, height: image.naturalHeight};
18
+ return new Promise((resolve, reject) => {
19
+ const probe = new view.Image();
20
+ const timer = setTimeout(() => reject(new Error("Image dimensions timed out")), 15000);
21
+ probe.onload = () => {
22
+ clearTimeout(timer);
23
+ if (!probe.naturalWidth || !probe.naturalHeight) reject(new Error("Image has no dimensions"));
24
+ else resolve({width: probe.naturalWidth, height: probe.naturalHeight});
25
+ };
26
+ probe.onerror = () => { clearTimeout(timer); reject(new Error("Image unavailable")); };
27
+ probe.src = image.currentSrc || image.src;
28
+ });
29
+ }
30
+
31
+ // A page may contain multiple galleries, each with its own image sequence.
32
+ export function initializePhotoSwipe(root = document, load, navigate) {
33
+ const view = root.defaultView;
34
+ navigate = navigate || (url => view.location.assign(url));
35
+ let assets;
36
+ let styles;
37
+ let busy = false;
38
+ const loadAssets = load || (() => {
39
+ if (!assets) {
40
+ styles = styles || loadStyles(root).catch(error => { styles = null; throw error; });
41
+ assets = Promise.all([import(cdn + "photoswipe.esm.min.js"), styles])
42
+ .then(([module]) => module.default).catch(error => { assets = null; throw error; });
43
+ }
44
+ return assets;
45
+ });
46
+ for (const gallery of root.querySelectorAll("[data-photoswipe-gallery]")) {
47
+ const links = Array.from(gallery.querySelectorAll("a.chulapa-photoswipe-item"));
48
+ if (!links.length) continue;
49
+ gallery.addEventListener("click", async event => {
50
+ const trigger = event.target.closest("a.chulapa-photoswipe-item");
51
+ const index = links.indexOf(trigger);
52
+ if (index < 0 || event.button !== 0 || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
53
+ event.preventDefault();
54
+ if (busy) return;
55
+ busy = true;
56
+ // Keep the triggering carousel slide visible while its modal is open.
57
+ const carousel = gallery.dataset.photoswipeGallery === "carousel" && view.jQuery ? view.jQuery(gallery) : null;
58
+ const stopSlide = event => event.preventDefault();
59
+ if (carousel) carousel.on("slide.bs.carousel", stopSlide);
60
+ const release = () => { busy = false; if (carousel) carousel.off("slide.bs.carousel", stopSlide); };
61
+ try {
62
+ const image = trigger.querySelector("img");
63
+ const [PhotoSwipe, dimensions] = await Promise.all([loadAssets(), measure(image, view)]);
64
+ // An already-running Bootstrap transition cannot be cancelled by slide events.
65
+ if (carousel && typeof carousel.carousel === "function" && gallery.querySelector?.(".carousel-item-next, .carousel-item-prev")) {
66
+ await new Promise(resolve => carousel.one("slid.bs.carousel", resolve));
67
+ }
68
+ const dataSource = links.map(link => {
69
+ const img = link.querySelector("img");
70
+ return {src: link.href, msrc: img.currentSrc || img.src, alt: img.alt, element: link,
71
+ width: img.naturalWidth || dimensions.width, height: img.naturalHeight || dimensions.height,
72
+ pendingDimensions: !img.naturalWidth || !img.naturalHeight};
73
+ });
74
+ Object.assign(dataSource[index], dimensions, {pendingDimensions: false});
75
+ const reduced = view.matchMedia && view.matchMedia("(prefers-reduced-motion: reduce)").matches;
76
+ const viewer = new PhotoSwipe({dataSource, index, returnFocus: false,
77
+ showHideAnimationType: reduced ? "none" : "zoom", zoomAnimationDuration: reduced ? 0 : 333});
78
+ // Offscreen lazy images are measured as PhotoSwipe loads them, not all at once.
79
+ viewer.on("loadComplete", ({content}) => {
80
+ const item = dataSource[content.index];
81
+ if (!item?.pendingDimensions || !content.element?.naturalWidth) return;
82
+ Object.assign(item, {width: content.element.naturalWidth, height: content.element.naturalHeight, pendingDimensions: false});
83
+ view.requestAnimationFrame(() => { if (!viewer.isDestroying) viewer.refreshSlideContent(content.index); });
84
+ });
85
+ viewer.on("destroy", () => {
86
+ release();
87
+ const restore = () => view.requestAnimationFrame(() => trigger.focus({preventScroll: true}));
88
+ const slide = trigger.closest?.(".carousel-item");
89
+ if (carousel && typeof carousel.carousel === "function" && slide && !slide.classList.contains("active")) {
90
+ carousel.one("slid.bs.carousel", restore);
91
+ carousel.carousel(index);
92
+ } else restore();
93
+ });
94
+ viewer.init();
95
+ viewer.element.setAttribute("aria-modal", "true");
96
+ viewer.element.setAttribute("aria-label", "Image gallery");
97
+ } catch (error) {
98
+ release();
99
+ console.warn("Unable to open PhotoSwipe; opening the original image", error);
100
+ navigate(trigger.href);
101
+ }
102
+ });
103
+ }
104
+ }
105
+
106
+ if (typeof document !== "undefined") initializePhotoSwipe();
@@ -1,9 +1,11 @@
1
+ // The legacy entry point loads only clipboard behavior from this maintained asset.
2
+ var clipboardOnly = document.currentScript && document.currentScript.getAttribute("data-clipboard-only") === "true";
3
+ if (!clipboardOnly) {
1
4
  var sT = document.getElementById("sidetoc");
2
- var btn = document.getElementById("demo");
5
+ var btn = document.getElementById("chulapa-sidetoc-toggle");
3
6
  var body = document.getElementById("body");
4
7
  var main = document.getElementById("maincontent");
5
- var heads = main.querySelectorAll("h1, h2, h3, h4, h5 , h6");
6
- var els = main.querySelectorAll("pre");
8
+ var heads = main ? main.querySelectorAll("h1, h2, h3, h4, h5 , h6") : [];
7
9
 
8
10
  // First load sidebar
9
11
  // Create hidden overlay
@@ -15,6 +17,15 @@ if (sT) {
15
17
  iDiv.setAttribute("id", "sideBarOverlay");
16
18
  iDiv.setAttribute("onclick", "closeSideBar()");
17
19
  body.prepend(iDiv);
20
+ function closeSidebarOnEscape(event) {
21
+ if (event.key === "Escape" && btn.getAttribute("aria-expanded") === "true") {
22
+ event.preventDefault();
23
+ event.stopPropagation();
24
+ closeSideBar();
25
+ }
26
+ }
27
+ btn.addEventListener("keydown", closeSidebarOnEscape);
28
+ document.getElementById("sideBar").addEventListener("keydown", closeSidebarOnEscape);
18
29
  } else if (btn) {
19
30
  // ToC was requested but no toc produced
20
31
  // Clean up DOM
@@ -24,6 +35,9 @@ if (sT) {
24
35
  }
25
36
 
26
37
  function openSideBar() {
38
+ var sidebar = document.getElementById("sideBar");
39
+ sidebar.inert = false;
40
+ sidebar.setAttribute("aria-hidden", "false");
27
41
  btn.removeAttribute("style");
28
42
  btn.setAttribute("aria-expanded", "true");
29
43
  document.getElementById("sideBarOverlay")
@@ -33,6 +47,11 @@ function openSideBar() {
33
47
  }
34
48
 
35
49
  function closeSideBar() {
50
+ var sidebar = document.getElementById("sideBar");
51
+ // Return focus before hiding its previous target from assistive technology.
52
+ btn.focus();
53
+ sidebar.inert = true;
54
+ sidebar.setAttribute("aria-hidden", "true");
36
55
  document.getElementById("sideBar")
37
56
  .removeAttribute("style");
38
57
  document.getElementById("sideBarOverlay")
@@ -43,12 +62,12 @@ function closeSideBar() {
43
62
 
44
63
  // Put anchors on headings
45
64
  heads.forEach(function (currentValue) {
46
- thish = currentValue;
47
- id = thish.id;
65
+ var thish = currentValue;
66
+ var id = thish.id;
48
67
  if (id) {
49
- anchor = document.createElement("a");
50
- sp = document.createElement("span");
51
- ic = document.createElement("i");
68
+ var anchor = document.createElement("a");
69
+ var sp = document.createElement("span");
70
+ var ic = document.createElement("i");
52
71
  anchor.classList.add("chulapa-header-link", "ml-2",
53
72
  "chulapaDateSocial");
54
73
  anchor.href = "#" + id;
@@ -64,57 +83,176 @@ heads.forEach(function (currentValue) {
64
83
  }
65
84
  });
66
85
 
86
+ // Track the reading position without changing focus or anchor navigation.
87
+ (function () {
88
+ if (!main) return;
89
+ var headingOrder = Array.from(heads);
90
+ var groups = ["toc", "sidetoc", "markdown-toc"].map(function (id) {
91
+ var toc = document.getElementById(id);
92
+ return toc ? Array.from(toc.querySelectorAll('li > a:first-child[href^="#"]')).map(function (link) {
93
+ var heading;
94
+ var fragment = link.getAttribute("href").slice(1);
95
+ try {
96
+ heading = document.getElementById(decodeURIComponent(fragment));
97
+ } catch (error) {
98
+ // Authored IDs can contain a literal percent sign, not a URI escape.
99
+ }
100
+ heading = heading || document.getElementById(fragment);
101
+ return heading && headingOrder.includes(heading) ? { link: link, heading: heading } : null;
102
+ }).filter(Boolean).sort(function (a, b) {
103
+ return headingOrder.indexOf(a.heading) - headingOrder.indexOf(b.heading);
104
+ }) : [];
105
+ }).filter(function (links) { return links.length; });
106
+ if (!groups.length) return;
107
+ var pending = false;
108
+ var current = new Map();
109
+ function isRendered(heading) {
110
+ if (!heading.getClientRects().length) return false;
111
+ if (heading.checkVisibility) return heading.checkVisibility({ visibilityProperty: true });
112
+ // Closed details can still report rectangles in some browsers.
113
+ var closed = heading.closest("details:not([open])");
114
+ if (closed) {
115
+ var summary = closed.querySelector("summary");
116
+ if (!summary || !summary.contains(heading)) return false;
117
+ }
118
+ var visibility = window.getComputedStyle(heading).visibility;
119
+ return visibility !== "hidden" && visibility !== "collapse";
120
+ }
121
+ function update() {
122
+ pending = false;
123
+ var readingLine = Math.min(120, window.innerHeight / 4);
124
+ var atBottom = window.scrollY > 0 &&
125
+ window.scrollY + window.innerHeight >= document.documentElement.scrollHeight - 2;
126
+ var positions = new Map();
127
+ groups.forEach(function (links) {
128
+ links.forEach(function (entry) {
129
+ if (!positions.has(entry.heading)) {
130
+ positions.set(entry.heading, isRendered(entry.heading) ? entry.heading.getBoundingClientRect().top : null);
131
+ }
132
+ });
133
+ });
134
+ groups.forEach(function (links) {
135
+ // Heading order comes from the document, including differently nested TOCs.
136
+ var active = null;
137
+ links.forEach(function (entry) {
138
+ var top = positions.get(entry.heading);
139
+ if (top !== null && (top <= readingLine || atBottom)) {
140
+ active = entry.heading;
141
+ }
142
+ });
143
+ if (current.get(links) === active) return;
144
+ current.set(links, active);
145
+ links.forEach(function (entry) {
146
+ if (entry.heading === active) {
147
+ entry.link.classList.add("chulapa-toc-active");
148
+ entry.link.setAttribute("aria-current", "location");
149
+ } else {
150
+ entry.link.classList.remove("chulapa-toc-active");
151
+ entry.link.removeAttribute("aria-current");
152
+ }
153
+ });
154
+ });
155
+ }
156
+ function schedule() {
157
+ if (!pending) {
158
+ pending = true;
159
+ window.requestAnimationFrame(update);
160
+ }
161
+ }
162
+ window.addEventListener("scroll", schedule, { passive: true });
163
+ window.addEventListener("resize", schedule);
164
+ window.addEventListener("hashchange", schedule);
165
+ window.addEventListener("load", schedule);
166
+ // Images, diagrams and web fonts can move headings after the initial render.
167
+ if (window.ResizeObserver) new window.ResizeObserver(schedule).observe(main);
168
+ if (window.MutationObserver) {
169
+ new window.MutationObserver(function (records) {
170
+ // Ignore TOC link styling and unrelated controls to avoid observer loops.
171
+ if (records.some(function (record) {
172
+ return headingOrder.some(function (heading) { return record.target.contains(heading); });
173
+ })) schedule();
174
+ }).observe(document.documentElement, {
175
+ subtree: true,
176
+ attributes: true
177
+ });
178
+ }
179
+ update();
180
+ })();
181
+
182
+ }
183
+
67
184
  // Copy Clipboard
68
185
  // Insert buttons
69
186
 
70
- els.forEach(function (currentValue, currentIndex) {
71
- preBlock = currentValue;
72
- i = currentIndex;
73
- // Select first child
74
- codeBlock = preBlock.firstChild;
75
- // If first child is code
76
- if (codeBlock.tagName.toLowerCase() == "code") {
77
- // Add br is no native
78
- hashigh = preBlock.classList.contains("highlight");
79
- if (hashigh === false){
80
- preBlock.classList.add("highlight");
81
- brk = document.createElement("br");
82
- codeBlock.prepend(brk);
187
+ function ch_clipboard_setup(root) {
188
+ if (!root) return;
189
+ var clipboardBody = document.getElementById("body");
190
+ root.querySelectorAll("pre").forEach(function (currentValue, currentIndex) {
191
+ var preBlock = currentValue;
192
+ var existingCopy = preBlock.querySelector(".btn-chulapa-copy-code");
193
+ if (existingCopy && existingCopy.classList.contains("btn-chulapa-copy-code")) return;
194
+ var i = currentIndex;
195
+ while (document.getElementById("clipboard_btn" + i)) i++;
196
+ // Select first child
197
+ var codeBlock = preBlock.querySelector("code");
198
+ if (clipboardBody && clipboardBody.getAttribute("data-mermaid") === "true" &&
199
+ (preBlock.classList.contains("mermaid") || preBlock.closest(".language-mermaid") ||
200
+ (codeBlock && codeBlock.classList.contains("language-mermaid")))) {
201
+ return;
202
+ }
203
+ // If first child is code
204
+ if (codeBlock) {
205
+ // Add br is no native
206
+ var hashigh = preBlock.classList.contains("highlight");
207
+ if (hashigh === false){
208
+ preBlock.classList.add("highlight");
209
+ var brk = document.createElement("br");
210
+ codeBlock.prepend(brk);
211
+ }
212
+ // Add id to code block
213
+ codeBlock.setAttribute("id", "clipboard_code" + i);
214
+ // Create button
215
+ var copybtn = document.createElement("button");
216
+ copybtn.classList.add("btn", "text-muted", "btn-sm",
217
+ "btn-chulapa-copy-code");
218
+ copybtn.innerHTML = "<i class='far fa-copy'></i>";
219
+ copybtn.id = "clipboard_btn" + i;
220
+ copybtn.type = "button";
221
+ copybtn.setAttribute("data-toggle", "tooltip");
222
+ copybtn.setAttribute("data-placement", "left");
223
+ copybtn.setAttribute("aria-label", "Copy code to clipboard");
224
+ //Function to copy to clipboard
225
+ copybtn.onclick = ch_copy_cliboard(i);
226
+ preBlock.prepend(copybtn);
227
+ } else {
228
+ console.log("No code block for\n" + preBlock.innerHTML);
83
229
  }
84
- // Add id to code block
85
- codeBlock.setAttribute("id", "clipboard_code" + i);
86
- // Create button
87
- copybtn = document.createElement("button");
88
- copybtn.classList.add("btn", "text-muted", "btn-sm",
89
- "btn-chulapa-copy-code");
90
- copybtn.innerHTML = "<i class='far fa-copy'></i>";
91
- copybtn.id = "clipboard_btn" + i;
92
- copybtn.type = "button";
93
- copybtn.setAttribute("data-toggle", "tooltip");
94
- copybtn.setAttribute("data-placement", "left");
95
- copybtn.setAttribute("aria-label", "Copy code to clipboard");
96
- //Function to copy to clipboard
97
- copybtn.onclick = ch_copy_cliboard(i);
98
- preBlock.prepend(copybtn);
99
- } else {
100
- console.log("No code block for\n" + preBlock.innerHTML);
101
- }
102
230
 
103
- });
231
+ });
232
+
233
+ }
234
+ ch_clipboard_setup(main);
104
235
 
105
- // Initialize Bootstrap tooltip
106
- $(function () {
107
- $("[data-toggle='tooltip']")
108
- .tooltip();
109
- })
236
+ // Copying remains available if the optional tooltip dependencies fail to load.
237
+ function tooltipTrigger(button) {
238
+ if (typeof $ !== "function") return null;
239
+ var trigger = $(button);
240
+ return trigger && typeof trigger.tooltip === "function" ? trigger : null;
241
+ }
242
+ if (typeof $ === "function") $(function () {
243
+ var trigger = tooltipTrigger("[data-toggle='tooltip']");
244
+ if (trigger) trigger.tooltip();
245
+ });
110
246
 
111
247
  function showTooltip(thisbtn, message) {
248
+ if (!thisbtn) return;
112
249
  thisbtn.tooltip("hide")
113
250
  .attr("data-original-title", message)
114
251
  .tooltip("show");
115
252
  }
116
253
 
117
254
  function hideTooltip(thisbtn) {
255
+ if (!thisbtn) return;
118
256
  setTimeout(function () {
119
257
  thisbtn.tooltip("hide");
120
258
  }, 1000);
@@ -136,40 +274,24 @@ async function setTooltip(thisbtn, tooltip, style) {
136
274
  }
137
275
 
138
276
  function ch_copy_cliboard(i) {
139
- return function () {
140
- // Select code content and strip HTML
141
- let thisCodeBlock = document.getElementById("clipboard_code" + i)
142
- .innerHTML;
143
- codeBlockStripped = stripHtml(thisCodeBlock);
144
-
145
- // Reset clipboard
146
- navigator.clipboard.writeText("");
147
-
148
- thiscopybtn = document.getElementById("clipboard_btn" + i);
149
- btnTrigger = $(thiscopybtn);
150
-
151
- // Set initial values
152
-
153
- style = "text-success";
154
- msg = "Copied on the clipboard:\n" + codeBlockStripped;
155
- tooltip = "Copied!";
277
+ return async function () {
278
+ const code = document.getElementById("clipboard_code" + i).textContent;
279
+ const button = document.getElementById("clipboard_btn" + i);
280
+ if (!button || button.disabled) return;
281
+ const trigger = tooltipTrigger(button);
282
+ let style = "text-success";
283
+ let tooltip = "Copied!";
284
+ button.disabled = true;
156
285
  try {
157
- navigator.clipboard.writeText(codeBlockStripped);
286
+ await navigator.clipboard.writeText(code);
158
287
  } catch {
159
- // Modify on error
160
288
  style = "text-danger";
161
- tooltip = "Error!";
162
- msg = "Error when copying the code";
289
+ tooltip = "Unable to copy code";
290
+ } finally {
291
+ button.disabled = false;
163
292
  }
164
- setTooltip(thiscopybtn, tooltip, style);
165
- showTooltip(btnTrigger, tooltip);
166
- hideTooltip(btnTrigger);
167
- console.log(msg);
168
- }
169
- }
170
- // stripHtml safely
171
- function stripHtml(html) {
172
- let tmp = document.createElement("DIV");
173
- tmp.innerHTML = html;
174
- return tmp.textContent || tmp.innerText || "";
293
+ setTooltip(button, tooltip, style);
294
+ showTooltip(trigger, tooltip);
295
+ hideTooltip(trigger);
296
+ };
175
297
  }