From e40e2f36f9ccde3c1365883d8e6c07c4750e5bf2 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 4 Jan 2021 17:50:39 -0800 Subject: [PATCH] Format shipped css/js (#278) --- .prettierignore | 2 - css/elements.css | 557 +++++++++++++++++++++++--------------- docs/ecmarkup.js | 345 +++++++++++++---------- docs/elements.css | 557 +++++++++++++++++++++++--------------- js/ecmarkup.js | 1 - js/findLocalReferences.js | 6 +- js/menu.js | 339 +++++++++++++---------- 7 files changed, 1098 insertions(+), 709 deletions(-) diff --git a/.prettierignore b/.prettierignore index 5a2f553e..17b298b4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,7 +2,5 @@ *.md *.json *.yml -*.css -js/ lib/ docs/ diff --git a/css/elements.css b/css/elements.css index b4b106d3..036f9f96 100644 --- a/css/elements.css +++ b/css/elements.css @@ -21,8 +21,8 @@ body.oldtoc { } a { - text-decoration: none; - color: #206ca7; + text-decoration: none; + color: #206ca7; } a:visited { @@ -30,15 +30,14 @@ a:visited { } a:hover { - text-decoration: underline; - color: #239dee; + text-decoration: underline; + color: #239dee; } - code { - font-weight: bold; - font-family: Consolas, Monaco, monospace; - white-space: pre; + font-weight: bold; + font-family: Consolas, Monaco, monospace; + white-space: pre; } pre code { @@ -52,13 +51,13 @@ pre code.hljs { } ol.toc { - list-style: none; - padding-left: 0; + list-style: none; + padding-left: 0; } ol.toc ol.toc { - padding-left: 2ex; - list-style: none; + padding-left: 2ex; + list-style: none; } var { @@ -132,23 +131,23 @@ emu-eqn div:first-child { } emu-note { - margin: 1em 0; - color: #666; - border-left: 5px solid #ccc; - display: flex; - flex-direction: row; + margin: 1em 0; + color: #666; + border-left: 5px solid #ccc; + display: flex; + flex-direction: row; } emu-note > span.note { - flex-basis: 100px; - min-width: 100px; - flex-grow: 0; - flex-shrink: 1; - text-transform: uppercase; - padding-left: 5px; + flex-basis: 100px; + min-width: 100px; + flex-grow: 0; + flex-shrink: 1; + text-transform: uppercase; + padding-left: 5px; } -emu-note[type=editor] { +emu-note[type='editor'] { border-left-color: #faa; } @@ -167,7 +166,7 @@ emu-note > div.note-contents > p:last-of-type { emu-table td code { white-space: normal; -} +} emu-figure { display: block; @@ -192,114 +191,120 @@ emu-table figure { } emu-production { - display: block; + display: block; } -emu-grammar[type="example"] emu-production, -emu-grammar[type="definition"] emu-production { - margin-top: 1em; - margin-bottom: 1em; - margin-left: 5ex; +emu-grammar[type='example'] emu-production, +emu-grammar[type='definition'] emu-production { + margin-top: 1em; + margin-bottom: 1em; + margin-left: 5ex; } -emu-grammar.inline, emu-production.inline, -emu-grammar.inline emu-production emu-rhs, emu-production.inline emu-rhs, +emu-grammar.inline, +emu-production.inline, +emu-grammar.inline emu-production emu-rhs, +emu-production.inline emu-rhs, emu-grammar[collapsed] emu-production emu-rhs { - display: inline; - padding-left: 1ex; - margin-left: 0; + display: inline; + padding-left: 1ex; + margin-left: 0; } emu-production[collapsed] emu-rhs { - display: inline; - padding-left: .5ex; - margin-left: 0; + display: inline; + padding-left: 0.5ex; + margin-left: 0; } -emu-grammar[collapsed] emu-production, emu-production[collapsed] { - margin: 0; +emu-grammar[collapsed] emu-production, +emu-production[collapsed] { + margin: 0; } emu-constraints { - font-size: .75em; - margin-right: .5ex; + font-size: 0.75em; + margin-right: 0.5ex; } emu-gann { - margin-right: .5ex; + margin-right: 0.5ex; } emu-gann emu-t:last-child, emu-gann emu-gprose:last-child, emu-gann emu-nt:last-child { - margin-right: 0; + margin-right: 0; } emu-geq { - margin-left: .5ex; - font-weight: bold; + margin-left: 0.5ex; + font-weight: bold; } emu-oneof { - font-weight: bold; - margin-left: .5ex; + font-weight: bold; + margin-left: 0.5ex; } emu-nt { - display: inline-block; - font-style: italic; - white-space: nowrap; - text-indent: 0; + display: inline-block; + font-style: italic; + white-space: nowrap; + text-indent: 0; } -emu-nt a, emu-nt a:visited { +emu-nt a, +emu-nt a:visited { color: #333; } emu-rhs emu-nt { - margin-right: .5ex; + margin-right: 0.5ex; } emu-t { - display: inline-block; - font-family: monospace; - font-weight: bold; - white-space: nowrap; - text-indent: 0; + display: inline-block; + font-family: monospace; + font-weight: bold; + white-space: nowrap; + text-indent: 0; } emu-production emu-t { - margin-right: .5ex; + margin-right: 0.5ex; } emu-rhs { - display: block; - padding-left: 75px; - text-indent: -25px; + display: block; + padding-left: 75px; + text-indent: -25px; } emu-production:not([collapsed]) emu-rhs { - border: 0.2ex dashed transparent; + border: 0.2ex dashed transparent; } emu-production:not([collapsed]) emu-rhs:hover { - border-color: #888; - background-color: #F0F0F0; + border-color: #888; + background-color: #f0f0f0; } emu-mods { - font-size: .85em; - vertical-align: sub; - font-style: normal; - font-weight: normal; + font-size: 0.85em; + vertical-align: sub; + font-style: normal; + font-weight: normal; } -emu-params, emu-opt { +emu-params, +emu-opt { margin-right: 1ex; font-family: monospace; } -emu-params, emu-constraints { +emu-params, +emu-constraints { color: #2aa198; } @@ -308,12 +313,12 @@ emu-opt { } emu-gprose { - font-size: 0.9em; - font-family: Helvetica, Arial, sans-serif; + font-size: 0.9em; + font-family: Helvetica, Arial, sans-serif; } emu-production emu-gprose { - margin-right: 1ex; + margin-right: 1ex; } h1.shortname { @@ -337,8 +342,13 @@ h1.first { margin-top: 0; } -h1, h2, h3, h4, h5, h6 { - position: relative; +h1, +h2, +h3, +h4, +h5, +h6 { + position: relative; } h1 .secnum { @@ -350,13 +360,27 @@ h1 span.title { order: 2; } - -h1 { font-size: 2.67em; margin-top: 2em; margin-bottom: 0; line-height: 1em;} -h2 { font-size: 2em; } -h3 { font-size: 1.56em; } -h4 { font-size: 1.25em; } -h5 { font-size: 1.11em; } -h6 { font-size: 1em; } +h1 { + font-size: 2.67em; + margin-top: 2em; + margin-bottom: 0; + line-height: 1em; +} +h2 { + font-size: 2em; +} +h3 { + font-size: 1.56em; +} +h4 { + font-size: 1.25em; +} +h5 { + font-size: 1.11em; +} +h6 { + font-size: 1em; +} h1:hover span.utils { display: block; @@ -374,9 +398,9 @@ span.utils { } span.utils:before { - content: "⤷"; - display: inline-block; - padding: 0 5px; + content: '⤷'; + display: inline-block; + padding: 0 5px; } span.utils > * { @@ -403,89 +427,194 @@ h6 span.utils span.anchor a:hover { color: #333; } -emu-intro h1, emu-clause h1, emu-annex h1 { font-size: 2em; } -emu-intro h2, emu-clause h2, emu-annex h2 { font-size: 1.56em; } -emu-intro h3, emu-clause h3, emu-annex h3 { font-size: 1.25em; } -emu-intro h4, emu-clause h4, emu-annex h4 { font-size: 1.11em; } -emu-intro h5, emu-clause h5, emu-annex h5 { font-size: 1em; } -emu-intro h6, emu-clause h6, emu-annex h6 { font-size: 0.9em; } -emu-intro emu-intro h1, emu-clause emu-clause h1, emu-annex emu-annex h1 { font-size: 1.56em; } -emu-intro emu-intro h2, emu-clause emu-clause h2, emu-annex emu-annex h2 { font-size: 1.25em; } -emu-intro emu-intro h3, emu-clause emu-clause h3, emu-annex emu-annex h3 { font-size: 1.11em; } -emu-intro emu-intro h4, emu-clause emu-clause h4, emu-annex emu-annex h4 { font-size: 1em; } -emu-intro emu-intro h5, emu-clause emu-clause h5, emu-annex emu-annex h5 { font-size: 0.9em; } -emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex h1 { font-size: 1.25em; } -emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex h2 { font-size: 1.11em; } -emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex h3 { font-size: 1em; } -emu-intro emu-intro emu-intro h4, emu-clause emu-clause emu-clause h4, emu-annex emu-annex emu-annex h4 { font-size: 0.9em; } -emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1.11em; } -emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex h2 { font-size: 1em; } -emu-intro emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex emu-annex h3 { font-size: 0.9em; } -emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1em; } -emu-intro emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex emu-annex h2 { font-size: 0.9em; } -emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 0.9em } - -emu-clause, emu-intro, emu-annex { - display: block; +emu-intro h1, +emu-clause h1, +emu-annex h1 { + font-size: 2em; +} +emu-intro h2, +emu-clause h2, +emu-annex h2 { + font-size: 1.56em; +} +emu-intro h3, +emu-clause h3, +emu-annex h3 { + font-size: 1.25em; +} +emu-intro h4, +emu-clause h4, +emu-annex h4 { + font-size: 1.11em; +} +emu-intro h5, +emu-clause h5, +emu-annex h5 { + font-size: 1em; +} +emu-intro h6, +emu-clause h6, +emu-annex h6 { + font-size: 0.9em; +} +emu-intro emu-intro h1, +emu-clause emu-clause h1, +emu-annex emu-annex h1 { + font-size: 1.56em; +} +emu-intro emu-intro h2, +emu-clause emu-clause h2, +emu-annex emu-annex h2 { + font-size: 1.25em; +} +emu-intro emu-intro h3, +emu-clause emu-clause h3, +emu-annex emu-annex h3 { + font-size: 1.11em; +} +emu-intro emu-intro h4, +emu-clause emu-clause h4, +emu-annex emu-annex h4 { + font-size: 1em; +} +emu-intro emu-intro h5, +emu-clause emu-clause h5, +emu-annex emu-annex h5 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex h1 { + font-size: 1.25em; +} +emu-intro emu-intro emu-intro h2, +emu-clause emu-clause emu-clause h2, +emu-annex emu-annex emu-annex h2 { + font-size: 1.11em; +} +emu-intro emu-intro emu-intro h3, +emu-clause emu-clause emu-clause h3, +emu-annex emu-annex emu-annex h3 { + font-size: 1em; +} +emu-intro emu-intro emu-intro h4, +emu-clause emu-clause emu-clause h4, +emu-annex emu-annex emu-annex h4 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex emu-annex h1 { + font-size: 1.11em; +} +emu-intro emu-intro emu-intro emu-intro h2, +emu-clause emu-clause emu-clause emu-clause h2, +emu-annex emu-annex emu-annex emu-annex h2 { + font-size: 1em; +} +emu-intro emu-intro emu-intro emu-intro h3, +emu-clause emu-clause emu-clause emu-clause h3, +emu-annex emu-annex emu-annex emu-annex h3 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex emu-annex emu-annex h1 { + font-size: 1em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro h2, +emu-clause emu-clause emu-clause emu-clause emu-clause h2, +emu-annex emu-annex emu-annex emu-annex emu-annex h2 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { + font-size: 0.9em; +} + +emu-clause, +emu-intro, +emu-annex { + display: block; } /* Figures and tables */ -figure { display: block; margin: 1em 0 3em 0; } -figure object { display: block; margin: 0 auto; } -figure table.real-table { margin: 0 auto; } +figure { + display: block; + margin: 1em 0 3em 0; +} +figure object { + display: block; + margin: 0 auto; +} +figure table.real-table { + margin: 0 auto; +} figure figcaption { - display: block; - color: #555555; - font-weight: bold; - text-align: center; + display: block; + color: #555555; + font-weight: bold; + text-align: center; } emu-table table { margin: 0 auto; } -emu-table table, table.real-table { - border-collapse: collapse; +emu-table table, +table.real-table { + border-collapse: collapse; } -emu-table td, emu-table th, table.real-table td, table.real-table th { - border: 1px solid black; - padding: 0.4em; - vertical-align: baseline; +emu-table td, +emu-table th, +table.real-table td, +table.real-table th { + border: 1px solid black; + padding: 0.4em; + vertical-align: baseline; } -emu-table th, emu-table thead td, table.real-table th { - background-color: #eeeeee; +emu-table th, +emu-table thead td, +table.real-table th { + background-color: #eeeeee; } /* Note: the left content edges of table.lightweight-table >tbody >tr >td and div.display line up. */ table.lightweight-table { - border-collapse: collapse; - margin: 0 0 0 1.5em; + border-collapse: collapse; + margin: 0 0 0 1.5em; } -table.lightweight-table td, table.lightweight-table th { - border: none; - padding: 0 0.5em; - vertical-align: baseline; +table.lightweight-table td, +table.lightweight-table th { + border: none; + padding: 0 0.5em; + vertical-align: baseline; } /* diff styles */ ins { - background-color: #e0f8e0; - text-decoration: none; - border-bottom: 1px solid #396; + background-color: #e0f8e0; + text-decoration: none; + border-bottom: 1px solid #396; } del { - background-color: #fee; + background-color: #fee; } -ins.block, del.block, -emu-production > ins, emu-production > del, -emu-grammar > ins, emu-grammar > del { +ins.block, +del.block, +emu-production > ins, +emu-production > del, +emu-grammar > ins, +emu-grammar > del { display: block; } -emu-rhs > ins, emu-rhs > del { +emu-rhs > ins, +emu-rhs > del { display: inline; } @@ -522,7 +651,7 @@ tr.del > td { -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; - user-select: none;; + user-select: none; cursor: pointer; } @@ -530,7 +659,8 @@ tr.del > td { #menu { display: flex; flex-direction: column; - width: 33%; height: 100vh; + width: 33%; + height: 100vh; max-width: 500px; box-sizing: border-box; background-color: #ddd; @@ -538,7 +668,8 @@ tr.del > td { transition: opacity 0.1s linear; padding: 0 5px; position: fixed; - left: 0; top: 0; + left: 0; + top: 0; border-right: 2px solid #bbb; z-index: 2; @@ -599,7 +730,8 @@ tr.del > td { padding: 0; } -#menu-toc > ol , #menu-toc > ol ol { +#menu-toc > ol, +#menu-toc > ol ol { list-style-type: none; margin: 0; padding: 0; @@ -629,7 +761,7 @@ tr.del > td { -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; - user-select: none;; + user-select: none; cursor: pointer; } @@ -660,7 +792,7 @@ tr.del > td { */ } -#menu-toc li.revealed-leaf> a { +#menu-toc li.revealed-leaf > a { color: #206ca7; /* background-color: #222; @@ -714,10 +846,10 @@ tr.del > td { flex-grow: 0; flex-shrink: 0; width: 100%; - + display: flex; flex-direction: column; - + max-height: 300px; } @@ -742,43 +874,42 @@ tr.del > td { } li.menu-search-result-clause:before { - content: 'clause'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; + content: 'clause'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } li.menu-search-result-op:before { - content: 'op'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; + content: 'op'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } li.menu-search-result-prod:before { - content: 'prod'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75% + content: 'prod'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } - li.menu-search-result-term:before { - content: 'term'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75% + content: 'term'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } #menu-search-results ul { @@ -791,7 +922,6 @@ li.menu-search-result-term:before { text-overflow: ellipsis; } - #menu-trace-list { counter-reset: item; margin: 0 0 0 20px; @@ -803,19 +933,19 @@ li.menu-search-result-term:before { } #menu-trace-list li .secnum:after { - content: " "; + content: ' '; } #menu-trace-list li:before { - content: counter(item) " "; - background-color: #222; - counter-increment: item; - color: #999; - width: 20px; - height: 20px; - line-height: 20px; - display: inline-block; - text-align: center; - margin: 2px 4px 2px 0; + content: counter(item) ' '; + background-color: #222; + counter-increment: item; + color: #999; + width: 20px; + height: 20px; + line-height: 20px; + display: inline-block; + text-align: center; + margin: 2px 4px 2px 0; } @media (max-width: 1000px) { @@ -857,16 +987,16 @@ li.menu-search-result-term:before { } h1 .secnum:empty { - margin: 0; padding: 0; + margin: 0; + padding: 0; } } - /* Toolbox */ .toolbox { - position: absolute; - background: #ddd; - border: 1px solid #aaa; + position: absolute; + background: #ddd; + border: 1px solid #aaa; display: none; color: #eee; padding: 5px; @@ -886,28 +1016,29 @@ li.menu-search-result-term:before { text-decoration: underline; } -.toolbox:after, .toolbox:before { - top: 100%; - left: 15px; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; +.toolbox:after, +.toolbox:before { + top: 100%; + left: 15px; + border: solid transparent; + content: ' '; + height: 0; + width: 0; + position: absolute; + pointer-events: none; } .toolbox:after { - border-color: rgba(0, 0, 0, 0); - border-top-color: #ddd; - border-width: 10px; - margin-left: -10px; + border-color: rgba(0, 0, 0, 0); + border-top-color: #ddd; + border-width: 10px; + margin-left: -10px; } .toolbox:before { - border-color: rgba(204, 204, 204, 0); - border-top-color: #aaa; - border-width: 12px; - margin-left: -12px; + border-color: rgba(204, 204, 204, 0); + border-top-color: #aaa; + border-width: 12px; + margin-left: -12px; } #references-pane-container { @@ -955,6 +1086,6 @@ li.menu-search-result-term:before { @media print { #menu-toggle { - display: none; + display: none; } } diff --git a/docs/ecmarkup.js b/docs/ecmarkup.js index ef29b3f5..074059b6 100644 --- a/docs/ecmarkup.js +++ b/docs/ecmarkup.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; function Search(menu) { this.menu = menu; @@ -10,8 +10,14 @@ function Search(menu) { document.addEventListener('keydown', this.documentKeydown.bind(this)); - this.$searchBox.addEventListener('keydown', debounce(this.searchBoxKeydown.bind(this), { stopPropagation: true })); - this.$searchBox.addEventListener('keyup', debounce(this.searchBoxKeyup.bind(this), { stopPropagation: true })); + this.$searchBox.addEventListener( + 'keydown', + debounce(this.searchBoxKeydown.bind(this), { stopPropagation: true }) + ); + this.$searchBox.addEventListener( + 'keyup', + debounce(this.searchBoxKeyup.bind(this), { stopPropagation: true }) + ); // Perform an initial search if the box is not empty. if (this.$searchBox.value) { @@ -25,13 +31,15 @@ Search.prototype.loadBiblio = function () { this.biblio = []; } else { this.biblio = JSON.parse($biblio.textContent); - this.biblio.clauses = this.biblio.filter(function (e) { return e.type === 'clause' }); + this.biblio.clauses = this.biblio.filter(function (e) { + return e.type === 'clause'; + }); this.biblio.byId = this.biblio.reduce(function (map, entry) { map[entry.id] = entry; return map; }, {}); } -} +}; Search.prototype.documentKeydown = function (e) { if (e.keyCode === 191) { @@ -39,7 +47,7 @@ Search.prototype.documentKeydown = function (e) { e.stopPropagation(); this.triggerSearch(); } -} +}; Search.prototype.searchBoxKeydown = function (e) { e.stopPropagation(); @@ -50,7 +58,7 @@ Search.prototype.searchBoxKeydown = function (e) { e.preventDefault(); this.selectResult(); } -} +}; Search.prototype.searchBoxKeyup = function (e) { if (e.keyCode === 13 || e.keyCode === 9) { @@ -58,8 +66,7 @@ Search.prototype.searchBoxKeyup = function (e) { } this.search(e.target.value); -} - +}; Search.prototype.triggerSearch = function (e) { if (this.menu.isVisible()) { @@ -71,7 +78,7 @@ Search.prototype.triggerSearch = function (e) { this.$searchBox.focus(); this.$searchBox.select(); -} +}; // bit 12 - Set if the result starts with searchString // bits 8-11: 8 - number of chunks multiplied by 2 if cases match, otherwise 1. // bits 1-7: 127 - length of the entry @@ -87,7 +94,7 @@ function relevance(result, searchString) { } if (result.match.prefix) { - relevance += 2048 + relevance += 2048; } relevance += Math.max(0, 255 - result.entry.key.length); @@ -112,11 +119,13 @@ Search.prototype.search = function (searchString) { var results; if (/^[\d\.]*$/.test(searchString)) { - results = this.biblio.clauses.filter(function (clause) { - return clause.number.substring(0, searchString.length) === searchString; - }).map(function (clause) { - return { entry: clause }; - }); + results = this.biblio.clauses + .filter(function (clause) { + return clause.number.substring(0, searchString.length) === searchString; + }) + .map(function (clause) { + return { entry: clause }; + }); } else { results = []; @@ -137,8 +146,9 @@ Search.prototype.search = function (searchString) { result.relevance = relevance(result, searchString); }); - results = results.sort(function (a, b) { return b.relevance - a.relevance }); - + results = results.sort(function (a, b) { + return b.relevance - a.relevance; + }); } if (results.length > 50) { @@ -146,14 +156,14 @@ Search.prototype.search = function (searchString) { } this.displayResults(results); -} +}; Search.prototype.hideSearch = function () { this.$search.classList.remove('active'); -} +}; Search.prototype.showSearch = function () { this.$search.classList.add('active'); -} +}; Search.prototype.selectResult = function () { var $first = this.$searchResults.querySelector('li:first-child a'); @@ -170,7 +180,7 @@ Search.prototype.selectResult = function () { if (this._closeAfterSearch) { this.menu.hide(); } -} +}; Search.prototype.displayResults = function (results) { if (results.length > 0) { @@ -204,19 +214,25 @@ Search.prototype.displayResults = function (results) { } if (text) { - html += ''; + html += + ''; } }); - html += '' + html += ''; this.$searchResults.innerHTML = html; } else { this.$searchResults.innerHTML = ''; this.$searchResults.classList.add('no-results'); } -} - +}; function Menu() { this.$toggle = document.getElementById('menu-toggle'); @@ -228,7 +244,7 @@ function Menu() { this.$specContainer = document.getElementById('spec-container'); this.search = new Search(this); - this._pinnedIds = {}; + this._pinnedIds = {}; this.loadPinEntries(); // toggle menu @@ -241,20 +257,26 @@ function Menu() { var tocItems = this.$menu.querySelectorAll('#menu-toc li'); for (var i = 0; i < tocItems.length; i++) { var $item = tocItems[i]; - $item.addEventListener('click', function($item, event) { - $item.classList.toggle('active'); - event.stopPropagation(); - }.bind(null, $item)); + $item.addEventListener( + 'click', + function ($item, event) { + $item.classList.toggle('active'); + event.stopPropagation(); + }.bind(null, $item) + ); } // close toc on toc item selection var tocLinks = this.$menu.querySelectorAll('#menu-toc li > a'); for (var i = 0; i < tocLinks.length; i++) { var $link = tocLinks[i]; - $link.addEventListener('click', function(event) { - this.toggle(); - event.stopPropagation(); - }.bind(this)); + $link.addEventListener( + 'click', + function (event) { + this.toggle(); + event.stopPropagation(); + }.bind(this) + ); } // update active clause on scroll @@ -268,8 +290,7 @@ function Menu() { if (offTop) { e.preventDefault(); } - var offBottom = e.deltaY > 0 - && target.offsetHeight + target.scrollTop >= target.scrollHeight; + var offBottom = e.deltaY > 0 && target.offsetHeight + target.scrollTop >= target.scrollHeight; if (offBottom) { e.preventDefault(); @@ -284,16 +305,16 @@ Menu.prototype.documentKeydown = function (e) { } else if (e.keyCode > 48 && e.keyCode < 58) { this.selectPin(e.keyCode - 49); } -} +}; Menu.prototype.updateActiveClause = function () { - this.setActiveClause(findActiveClause(this.$specContainer)) -} + this.setActiveClause(findActiveClause(this.$specContainer)); +}; Menu.prototype.setActiveClause = function (clause) { this.$activeClause = clause; this.revealInToc(this.$activeClause); -} +}; Menu.prototype.revealInToc = function (path) { var current = this.$toc.querySelectorAll('li.revealed'); @@ -307,7 +328,7 @@ Menu.prototype.revealInToc = function (path) { while (index < path.length) { var children = current.children; for (var i = 0; i < children.length; i++) { - if ('#' + path[index].id === children[i].children[1].getAttribute('href') ) { + if ('#' + path[index].id === children[i].children[1].getAttribute('href')) { children[i].classList.add('revealed'); if (index === path.length - 1) { children[i].classList.add('revealed-leaf'); @@ -315,7 +336,8 @@ Menu.prototype.revealInToc = function (path) { // this.$toc.getBoundingClientRect().top; var tocRect = this.$toc.getBoundingClientRect(); if (rect.top + 10 > tocRect.bottom) { - this.$toc.scrollTop = this.$toc.scrollTop + (rect.top - tocRect.bottom) + (rect.bottom - rect.top); + this.$toc.scrollTop = + this.$toc.scrollTop + (rect.top - tocRect.bottom) + (rect.bottom - rect.top); } else if (rect.top < tocRect.top) { this.$toc.scrollTop = this.$toc.scrollTop - (tocRect.top - rect.top); } @@ -325,21 +347,20 @@ Menu.prototype.revealInToc = function (path) { break; } } - } -} +}; function findActiveClause(root, path) { var clauses = new ClauseWalker(root); var $clause; var path = path || []; - while ($clause = clauses.nextNode()) { + while (($clause = clauses.nextNode())) { var rect = $clause.getBoundingClientRect(); - var $header = $clause.querySelector("h1"); - var marginTop = parseInt(getComputedStyle($header)["margin-top"]); + var $header = $clause.querySelector('h1'); + var marginTop = parseInt(getComputedStyle($header)['margin-top']); - if ((rect.top - marginTop) <= 0 && rect.bottom > 0) { + if (rect.top - marginTop <= 0 && rect.bottom > 0) { return findActiveClause($clause, path.concat($clause)) || path; } } @@ -359,42 +380,46 @@ function ClauseWalker(root) { } else { previous = node; } - if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-INTRO' || node.nodeName === 'EMU-ANNEX') { + if ( + node.nodeName === 'EMU-CLAUSE' || + node.nodeName === 'EMU-INTRO' || + node.nodeName === 'EMU-ANNEX' + ) { return NodeFilter.FILTER_ACCEPT; } else { return NodeFilter.FILTER_SKIP; } - } + }, }, false - ); + ); return treeWalker; } Menu.prototype.toggle = function () { this.$menu.classList.toggle('active'); -} +}; Menu.prototype.show = function () { this.$menu.classList.add('active'); -} +}; Menu.prototype.hide = function () { this.$menu.classList.remove('active'); -} +}; -Menu.prototype.isVisible = function() { +Menu.prototype.isVisible = function () { return this.$menu.classList.contains('active'); -} +}; Menu.prototype.showPins = function () { this.$pins.classList.add('active'); -} +}; Menu.prototype.hidePins = function () { this.$pins.classList.remove('active'); -} +}; Menu.prototype.addPinEntry = function (id) { var entry = this.search.biblio.byId[id]; @@ -412,7 +437,8 @@ Menu.prototype.addPinEntry = function (id) { } else { prefix = ''; } - this.$pinList.innerHTML += '
  • ' + prefix + entry.titleHTML + '
  • '; + this.$pinList.innerHTML += + '
  • ' + prefix + entry.titleHTML + '
  • '; } else { this.$pinList.innerHTML += '
  • ' + entry.key + '
  • '; } @@ -422,7 +448,7 @@ Menu.prototype.addPinEntry = function (id) { } this._pinnedIds[id] = true; this.persistPinEntries(); -} +}; Menu.prototype.removePinEntry = function (id) { var item = this.$pinList.querySelector('a[href="#' + id + '"]').parentNode; @@ -433,7 +459,7 @@ Menu.prototype.removePinEntry = function (id) { } this.persistPinEntries(); -} +}; Menu.prototype.persistPinEntries = function () { try { @@ -443,7 +469,7 @@ Menu.prototype.persistPinEntries = function () { } localStorage.pinEntries = JSON.stringify(Object.keys(this._pinnedIds)); -} +}; Menu.prototype.loadPinEntries = function () { try { @@ -455,10 +481,10 @@ Menu.prototype.loadPinEntries = function () { var pinsString = window.localStorage.pinEntries; if (!pinsString) return; var pins = JSON.parse(pinsString); - for(var i = 0; i < pins.length; i++) { + for (var i = 0; i < pins.length; i++) { this.addPinEntry(pins[i]); } -} +}; Menu.prototype.togglePinEntry = function (id) { if (!id) { @@ -470,24 +496,30 @@ Menu.prototype.togglePinEntry = function (id) { } else { this.addPinEntry(id); } -} +}; Menu.prototype.selectPin = function (num) { document.location = this.$pinList.children[num].children[0].href; -} +}; var menu; function init() { menu = new Menu(); var $container = document.getElementById('spec-container'); - $container.addEventListener('mouseover', debounce(function (e) { - Toolbox.activateIfMouseOver(e); - })); - document.addEventListener('keydown', debounce(function (e) { - if (e.code === "Escape" && Toolbox.active) { - Toolbox.deactivate(); - } - })); + $container.addEventListener( + 'mouseover', + debounce(function (e) { + Toolbox.activateIfMouseOver(e); + }) + ); + document.addEventListener( + 'keydown', + debounce(function (e) { + if (e.code === 'Escape' && Toolbox.active) { + Toolbox.deactivate(); + } + }) + ); } document.addEventListener('DOMContentLoaded', init); @@ -495,7 +527,7 @@ document.addEventListener('DOMContentLoaded', init); function debounce(fn, opts) { opts = opts || {}; var timeout; - return function(e) { + return function (e) { if (opts.stopPropagation) { e.stopPropagation(); } @@ -503,15 +535,18 @@ function debounce(fn, opts) { if (timeout) { clearTimeout(timeout); } - timeout = setTimeout(function() { - timeout = null; - fn.apply(this, args); - }.bind(this), 150); - } + timeout = setTimeout( + function () { + timeout = null; + fn.apply(this, args); + }.bind(this), + 150 + ); + }; } var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX']; -function findLocalReferences ($elem) { +function findLocalReferences($elem) { var name = $elem.innerHTML; var references = []; @@ -520,7 +555,7 @@ function findLocalReferences ($elem) { parentClause = parentClause.parentNode; } - if(!parentClause) return; + if (!parentClause) return; var vars = parentClause.querySelectorAll('var'); @@ -548,7 +583,7 @@ function toggleFindLocalReferences($elem) { } } -function installFindLocalReferences () { +function installFindLocalReferences() { document.addEventListener('click', function (e) { if (e.target.nodeName === 'VAR') { toggleFindLocalReferences(e.target); @@ -558,9 +593,6 @@ function installFindLocalReferences () { document.addEventListener('DOMContentLoaded', installFindLocalReferences); - - - // The following license applies to the fuzzysearch function // The MIT License (MIT) // Copyright © 2015 Nicolas Bevacqua @@ -581,7 +613,7 @@ document.addEventListener('DOMContentLoaded', installFindLocalReferences); // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -function fuzzysearch (searchString, haystack, caseInsensitive) { +function fuzzysearch(searchString, haystack, caseInsensitive) { var tlen = haystack.length; var qlen = searchString.length; var chunks = 1; @@ -615,7 +647,9 @@ function fuzzysearch (searchString, haystack, caseInsensitive) { } } - if (caseInsensitive) { return false; } + if (caseInsensitive) { + return false; + } return fuzzysearch(searchString.toLowerCase(), haystack.toLowerCase(), true); } @@ -632,19 +666,25 @@ var Toolbox = { this.$pinLink = document.createElement('a'); this.$pinLink.textContent = 'Pin'; this.$pinLink.setAttribute('href', '#'); - this.$pinLink.addEventListener('click', function (e) { - e.preventDefault(); - e.stopPropagation(); - menu.togglePinEntry(this.entry.id); - }.bind(this)); + this.$pinLink.addEventListener( + 'click', + function (e) { + e.preventDefault(); + e.stopPropagation(); + menu.togglePinEntry(this.entry.id); + }.bind(this) + ); this.$refsLink = document.createElement('a'); this.$refsLink.setAttribute('href', '#'); - this.$refsLink.addEventListener('click', function (e) { - e.preventDefault(); - e.stopPropagation(); - referencePane.showReferencesFor(this.entry); - }.bind(this)); + this.$refsLink.addEventListener( + 'click', + function (e) { + e.preventDefault(); + e.stopPropagation(); + referencePane.showReferencesFor(this.entry); + }.bind(this) + ); this.$container.appendChild(this.$permalink); this.$container.appendChild(this.$pinLink); this.$container.appendChild(this.$refsLink); @@ -681,7 +721,10 @@ var Toolbox = { if (ref && (!this.active || e.pageY > this._activeEl.offsetTop)) { var entry = menu.search.biblio.byId[ref.id]; this.activate(ref.element, entry, e.target); - } else if (this.active && ((e.pageY < this.top) || e.pageY > (this._activeEl.offsetTop + this._activeEl.offsetHeight))) { + } else if ( + this.active && + (e.pageY < this.top || e.pageY > this._activeEl.offsetTop + this._activeEl.offsetHeight) + ) { this.deactivate(); } }, @@ -689,11 +732,22 @@ var Toolbox = { findReferenceUnder: function (el) { while (el) { var parent = el.parentNode; - if (el.nodeName === 'H1' && parent.nodeName.match(/EMU-CLAUSE|EMU-ANNEX|EMU-INTRO/) && parent.id) { + if ( + el.nodeName === 'H1' && + parent.nodeName.match(/EMU-CLAUSE|EMU-ANNEX|EMU-INTRO/) && + parent.id + ) { return { element: el, id: parent.id }; - } else if (el.nodeName.match(/EMU-(?!CLAUSE|XREF|ANNEX|INTRO)|DFN/) && - el.id && el.id[0] !== '_') { - if (el.nodeName === 'EMU-FIGURE' || el.nodeName === 'EMU-TABLE' || el.nodeName === 'EMU-EXAMPLE') { + } else if ( + el.nodeName.match(/EMU-(?!CLAUSE|XREF|ANNEX|INTRO)|DFN/) && + el.id && + el.id[0] !== '_' + ) { + if ( + el.nodeName === 'EMU-FIGURE' || + el.nodeName === 'EMU-TABLE' || + el.nodeName === 'EMU-EXAMPLE' + ) { // return the figcaption element return { element: el.children[0].children[0], id: el.id }; } else if (el.nodeName === 'EMU-PRODUCTION') { @@ -712,11 +766,11 @@ var Toolbox = { this._activeEl = null; this.activeElBounds = null; this.active = false; - } -} + }, +}; var referencePane = { - init: function() { + init: function () { this.$container = document.createElement('div'); this.$container.setAttribute('id', 'references-pane-container'); @@ -736,9 +790,12 @@ var referencePane = { this.$header.appendChild(this.$headerRefId); this.$closeButton = document.createElement('span'); this.$closeButton.setAttribute('id', 'references-pane-close'); - this.$closeButton.addEventListener('click', function (e) { - this.deactivate(); - }.bind(this)); + this.$closeButton.addEventListener( + 'click', + function (e) { + this.deactivate(); + }.bind(this) + ); this.$header.appendChild(this.$closeButton); this.$pane.appendChild(this.$header); @@ -772,35 +829,43 @@ var referencePane = { var dupCount = 0; this.$headerRefId.textContent = '#' + entry.id; this.$headerRefId.setAttribute('href', '#' + entry.id); - entry.referencingIds.map(function (id) { - var target = document.getElementById(id); - var cid = findParentClauseId(target); - var clause = menu.search.biblio.byId[cid]; - return { id: id, clause: clause } - }).sort(function (a, b) { - return sortByClauseNumber(a.clause, b.clause); - }).forEach(function (record, i) { - if (previousId === record.clause.id) { - previousCell.innerHTML += ' (' + (dupCount + 2) + ')'; - dupCount++; - } else { - var row = newBody.insertRow(); - var cell = row.insertCell(); - cell.innerHTML = record.clause.number; - cell = row.insertCell(); - cell.innerHTML = '' + record.clause.titleHTML + ''; - previousCell = cell; - previousId = record.clause.id; - dupCount = 0; - } - }, this); + entry.referencingIds + .map(function (id) { + var target = document.getElementById(id); + var cid = findParentClauseId(target); + var clause = menu.search.biblio.byId[cid]; + return { id: id, clause: clause }; + }) + .sort(function (a, b) { + return sortByClauseNumber(a.clause, b.clause); + }) + .forEach(function (record, i) { + if (previousId === record.clause.id) { + previousCell.innerHTML += ' (' + (dupCount + 2) + ')'; + dupCount++; + } else { + var row = newBody.insertRow(); + var cell = row.insertCell(); + cell.innerHTML = record.clause.number; + cell = row.insertCell(); + cell.innerHTML = '' + record.clause.titleHTML + ''; + previousCell = cell; + previousId = record.clause.id; + dupCount = 0; + } + }, this); this.$table.removeChild(this.$tableBody); this.$tableBody = newBody; this.$table.appendChild(this.$tableBody); - } -} + }, +}; function findParentClauseId(node) { - while (node && node.nodeName !== 'EMU-CLAUSE' && node.nodeName !== 'EMU-INTRO' && node.nodeName !== 'EMU-ANNEX') { + while ( + node && + node.nodeName !== 'EMU-CLAUSE' && + node.nodeName !== 'EMU-INTRO' && + node.nodeName !== 'EMU-ANNEX' + ) { node = node.parentNode; } if (!node) return null; @@ -831,7 +896,7 @@ function sortByClauseNumber(c1, c2) { return -1; } else if (Number.isNaN(c1cn) && !Number.isNaN(c2cn)) { return 1; - } else if(c1cn > c2cn) { + } else if (c1cn > c2cn) { return 1; } else if (c1cn < c2cn) { return -1; @@ -847,9 +912,9 @@ function sortByClauseNumber(c1, c2) { document.addEventListener('DOMContentLoaded', function () { Toolbox.init(); referencePane.init(); -}) +}); var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX']; -function findLocalReferences ($elem) { +function findLocalReferences($elem) { var name = $elem.innerHTML; var references = []; @@ -858,7 +923,7 @@ function findLocalReferences ($elem) { parentClause = parentClause.parentNode; } - if(!parentClause) return; + if (!parentClause) return; var vars = parentClause.querySelectorAll('var'); @@ -886,7 +951,7 @@ function toggleFindLocalReferences($elem) { } } -function installFindLocalReferences () { +function installFindLocalReferences() { document.addEventListener('click', function (e) { if (e.target.nodeName === 'VAR') { toggleFindLocalReferences(e.target); diff --git a/docs/elements.css b/docs/elements.css index b4b106d3..036f9f96 100644 --- a/docs/elements.css +++ b/docs/elements.css @@ -21,8 +21,8 @@ body.oldtoc { } a { - text-decoration: none; - color: #206ca7; + text-decoration: none; + color: #206ca7; } a:visited { @@ -30,15 +30,14 @@ a:visited { } a:hover { - text-decoration: underline; - color: #239dee; + text-decoration: underline; + color: #239dee; } - code { - font-weight: bold; - font-family: Consolas, Monaco, monospace; - white-space: pre; + font-weight: bold; + font-family: Consolas, Monaco, monospace; + white-space: pre; } pre code { @@ -52,13 +51,13 @@ pre code.hljs { } ol.toc { - list-style: none; - padding-left: 0; + list-style: none; + padding-left: 0; } ol.toc ol.toc { - padding-left: 2ex; - list-style: none; + padding-left: 2ex; + list-style: none; } var { @@ -132,23 +131,23 @@ emu-eqn div:first-child { } emu-note { - margin: 1em 0; - color: #666; - border-left: 5px solid #ccc; - display: flex; - flex-direction: row; + margin: 1em 0; + color: #666; + border-left: 5px solid #ccc; + display: flex; + flex-direction: row; } emu-note > span.note { - flex-basis: 100px; - min-width: 100px; - flex-grow: 0; - flex-shrink: 1; - text-transform: uppercase; - padding-left: 5px; + flex-basis: 100px; + min-width: 100px; + flex-grow: 0; + flex-shrink: 1; + text-transform: uppercase; + padding-left: 5px; } -emu-note[type=editor] { +emu-note[type='editor'] { border-left-color: #faa; } @@ -167,7 +166,7 @@ emu-note > div.note-contents > p:last-of-type { emu-table td code { white-space: normal; -} +} emu-figure { display: block; @@ -192,114 +191,120 @@ emu-table figure { } emu-production { - display: block; + display: block; } -emu-grammar[type="example"] emu-production, -emu-grammar[type="definition"] emu-production { - margin-top: 1em; - margin-bottom: 1em; - margin-left: 5ex; +emu-grammar[type='example'] emu-production, +emu-grammar[type='definition'] emu-production { + margin-top: 1em; + margin-bottom: 1em; + margin-left: 5ex; } -emu-grammar.inline, emu-production.inline, -emu-grammar.inline emu-production emu-rhs, emu-production.inline emu-rhs, +emu-grammar.inline, +emu-production.inline, +emu-grammar.inline emu-production emu-rhs, +emu-production.inline emu-rhs, emu-grammar[collapsed] emu-production emu-rhs { - display: inline; - padding-left: 1ex; - margin-left: 0; + display: inline; + padding-left: 1ex; + margin-left: 0; } emu-production[collapsed] emu-rhs { - display: inline; - padding-left: .5ex; - margin-left: 0; + display: inline; + padding-left: 0.5ex; + margin-left: 0; } -emu-grammar[collapsed] emu-production, emu-production[collapsed] { - margin: 0; +emu-grammar[collapsed] emu-production, +emu-production[collapsed] { + margin: 0; } emu-constraints { - font-size: .75em; - margin-right: .5ex; + font-size: 0.75em; + margin-right: 0.5ex; } emu-gann { - margin-right: .5ex; + margin-right: 0.5ex; } emu-gann emu-t:last-child, emu-gann emu-gprose:last-child, emu-gann emu-nt:last-child { - margin-right: 0; + margin-right: 0; } emu-geq { - margin-left: .5ex; - font-weight: bold; + margin-left: 0.5ex; + font-weight: bold; } emu-oneof { - font-weight: bold; - margin-left: .5ex; + font-weight: bold; + margin-left: 0.5ex; } emu-nt { - display: inline-block; - font-style: italic; - white-space: nowrap; - text-indent: 0; + display: inline-block; + font-style: italic; + white-space: nowrap; + text-indent: 0; } -emu-nt a, emu-nt a:visited { +emu-nt a, +emu-nt a:visited { color: #333; } emu-rhs emu-nt { - margin-right: .5ex; + margin-right: 0.5ex; } emu-t { - display: inline-block; - font-family: monospace; - font-weight: bold; - white-space: nowrap; - text-indent: 0; + display: inline-block; + font-family: monospace; + font-weight: bold; + white-space: nowrap; + text-indent: 0; } emu-production emu-t { - margin-right: .5ex; + margin-right: 0.5ex; } emu-rhs { - display: block; - padding-left: 75px; - text-indent: -25px; + display: block; + padding-left: 75px; + text-indent: -25px; } emu-production:not([collapsed]) emu-rhs { - border: 0.2ex dashed transparent; + border: 0.2ex dashed transparent; } emu-production:not([collapsed]) emu-rhs:hover { - border-color: #888; - background-color: #F0F0F0; + border-color: #888; + background-color: #f0f0f0; } emu-mods { - font-size: .85em; - vertical-align: sub; - font-style: normal; - font-weight: normal; + font-size: 0.85em; + vertical-align: sub; + font-style: normal; + font-weight: normal; } -emu-params, emu-opt { +emu-params, +emu-opt { margin-right: 1ex; font-family: monospace; } -emu-params, emu-constraints { +emu-params, +emu-constraints { color: #2aa198; } @@ -308,12 +313,12 @@ emu-opt { } emu-gprose { - font-size: 0.9em; - font-family: Helvetica, Arial, sans-serif; + font-size: 0.9em; + font-family: Helvetica, Arial, sans-serif; } emu-production emu-gprose { - margin-right: 1ex; + margin-right: 1ex; } h1.shortname { @@ -337,8 +342,13 @@ h1.first { margin-top: 0; } -h1, h2, h3, h4, h5, h6 { - position: relative; +h1, +h2, +h3, +h4, +h5, +h6 { + position: relative; } h1 .secnum { @@ -350,13 +360,27 @@ h1 span.title { order: 2; } - -h1 { font-size: 2.67em; margin-top: 2em; margin-bottom: 0; line-height: 1em;} -h2 { font-size: 2em; } -h3 { font-size: 1.56em; } -h4 { font-size: 1.25em; } -h5 { font-size: 1.11em; } -h6 { font-size: 1em; } +h1 { + font-size: 2.67em; + margin-top: 2em; + margin-bottom: 0; + line-height: 1em; +} +h2 { + font-size: 2em; +} +h3 { + font-size: 1.56em; +} +h4 { + font-size: 1.25em; +} +h5 { + font-size: 1.11em; +} +h6 { + font-size: 1em; +} h1:hover span.utils { display: block; @@ -374,9 +398,9 @@ span.utils { } span.utils:before { - content: "⤷"; - display: inline-block; - padding: 0 5px; + content: '⤷'; + display: inline-block; + padding: 0 5px; } span.utils > * { @@ -403,89 +427,194 @@ h6 span.utils span.anchor a:hover { color: #333; } -emu-intro h1, emu-clause h1, emu-annex h1 { font-size: 2em; } -emu-intro h2, emu-clause h2, emu-annex h2 { font-size: 1.56em; } -emu-intro h3, emu-clause h3, emu-annex h3 { font-size: 1.25em; } -emu-intro h4, emu-clause h4, emu-annex h4 { font-size: 1.11em; } -emu-intro h5, emu-clause h5, emu-annex h5 { font-size: 1em; } -emu-intro h6, emu-clause h6, emu-annex h6 { font-size: 0.9em; } -emu-intro emu-intro h1, emu-clause emu-clause h1, emu-annex emu-annex h1 { font-size: 1.56em; } -emu-intro emu-intro h2, emu-clause emu-clause h2, emu-annex emu-annex h2 { font-size: 1.25em; } -emu-intro emu-intro h3, emu-clause emu-clause h3, emu-annex emu-annex h3 { font-size: 1.11em; } -emu-intro emu-intro h4, emu-clause emu-clause h4, emu-annex emu-annex h4 { font-size: 1em; } -emu-intro emu-intro h5, emu-clause emu-clause h5, emu-annex emu-annex h5 { font-size: 0.9em; } -emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex h1 { font-size: 1.25em; } -emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex h2 { font-size: 1.11em; } -emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex h3 { font-size: 1em; } -emu-intro emu-intro emu-intro h4, emu-clause emu-clause emu-clause h4, emu-annex emu-annex emu-annex h4 { font-size: 0.9em; } -emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1.11em; } -emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex h2 { font-size: 1em; } -emu-intro emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex emu-annex h3 { font-size: 0.9em; } -emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1em; } -emu-intro emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex emu-annex h2 { font-size: 0.9em; } -emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 0.9em } - -emu-clause, emu-intro, emu-annex { - display: block; +emu-intro h1, +emu-clause h1, +emu-annex h1 { + font-size: 2em; +} +emu-intro h2, +emu-clause h2, +emu-annex h2 { + font-size: 1.56em; +} +emu-intro h3, +emu-clause h3, +emu-annex h3 { + font-size: 1.25em; +} +emu-intro h4, +emu-clause h4, +emu-annex h4 { + font-size: 1.11em; +} +emu-intro h5, +emu-clause h5, +emu-annex h5 { + font-size: 1em; +} +emu-intro h6, +emu-clause h6, +emu-annex h6 { + font-size: 0.9em; +} +emu-intro emu-intro h1, +emu-clause emu-clause h1, +emu-annex emu-annex h1 { + font-size: 1.56em; +} +emu-intro emu-intro h2, +emu-clause emu-clause h2, +emu-annex emu-annex h2 { + font-size: 1.25em; +} +emu-intro emu-intro h3, +emu-clause emu-clause h3, +emu-annex emu-annex h3 { + font-size: 1.11em; +} +emu-intro emu-intro h4, +emu-clause emu-clause h4, +emu-annex emu-annex h4 { + font-size: 1em; +} +emu-intro emu-intro h5, +emu-clause emu-clause h5, +emu-annex emu-annex h5 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex h1 { + font-size: 1.25em; +} +emu-intro emu-intro emu-intro h2, +emu-clause emu-clause emu-clause h2, +emu-annex emu-annex emu-annex h2 { + font-size: 1.11em; +} +emu-intro emu-intro emu-intro h3, +emu-clause emu-clause emu-clause h3, +emu-annex emu-annex emu-annex h3 { + font-size: 1em; +} +emu-intro emu-intro emu-intro h4, +emu-clause emu-clause emu-clause h4, +emu-annex emu-annex emu-annex h4 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex emu-annex h1 { + font-size: 1.11em; +} +emu-intro emu-intro emu-intro emu-intro h2, +emu-clause emu-clause emu-clause emu-clause h2, +emu-annex emu-annex emu-annex emu-annex h2 { + font-size: 1em; +} +emu-intro emu-intro emu-intro emu-intro h3, +emu-clause emu-clause emu-clause emu-clause h3, +emu-annex emu-annex emu-annex emu-annex h3 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex emu-annex emu-annex h1 { + font-size: 1em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro h2, +emu-clause emu-clause emu-clause emu-clause emu-clause h2, +emu-annex emu-annex emu-annex emu-annex emu-annex h2 { + font-size: 0.9em; +} +emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, +emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, +emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { + font-size: 0.9em; +} + +emu-clause, +emu-intro, +emu-annex { + display: block; } /* Figures and tables */ -figure { display: block; margin: 1em 0 3em 0; } -figure object { display: block; margin: 0 auto; } -figure table.real-table { margin: 0 auto; } +figure { + display: block; + margin: 1em 0 3em 0; +} +figure object { + display: block; + margin: 0 auto; +} +figure table.real-table { + margin: 0 auto; +} figure figcaption { - display: block; - color: #555555; - font-weight: bold; - text-align: center; + display: block; + color: #555555; + font-weight: bold; + text-align: center; } emu-table table { margin: 0 auto; } -emu-table table, table.real-table { - border-collapse: collapse; +emu-table table, +table.real-table { + border-collapse: collapse; } -emu-table td, emu-table th, table.real-table td, table.real-table th { - border: 1px solid black; - padding: 0.4em; - vertical-align: baseline; +emu-table td, +emu-table th, +table.real-table td, +table.real-table th { + border: 1px solid black; + padding: 0.4em; + vertical-align: baseline; } -emu-table th, emu-table thead td, table.real-table th { - background-color: #eeeeee; +emu-table th, +emu-table thead td, +table.real-table th { + background-color: #eeeeee; } /* Note: the left content edges of table.lightweight-table >tbody >tr >td and div.display line up. */ table.lightweight-table { - border-collapse: collapse; - margin: 0 0 0 1.5em; + border-collapse: collapse; + margin: 0 0 0 1.5em; } -table.lightweight-table td, table.lightweight-table th { - border: none; - padding: 0 0.5em; - vertical-align: baseline; +table.lightweight-table td, +table.lightweight-table th { + border: none; + padding: 0 0.5em; + vertical-align: baseline; } /* diff styles */ ins { - background-color: #e0f8e0; - text-decoration: none; - border-bottom: 1px solid #396; + background-color: #e0f8e0; + text-decoration: none; + border-bottom: 1px solid #396; } del { - background-color: #fee; + background-color: #fee; } -ins.block, del.block, -emu-production > ins, emu-production > del, -emu-grammar > ins, emu-grammar > del { +ins.block, +del.block, +emu-production > ins, +emu-production > del, +emu-grammar > ins, +emu-grammar > del { display: block; } -emu-rhs > ins, emu-rhs > del { +emu-rhs > ins, +emu-rhs > del { display: inline; } @@ -522,7 +651,7 @@ tr.del > td { -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; - user-select: none;; + user-select: none; cursor: pointer; } @@ -530,7 +659,8 @@ tr.del > td { #menu { display: flex; flex-direction: column; - width: 33%; height: 100vh; + width: 33%; + height: 100vh; max-width: 500px; box-sizing: border-box; background-color: #ddd; @@ -538,7 +668,8 @@ tr.del > td { transition: opacity 0.1s linear; padding: 0 5px; position: fixed; - left: 0; top: 0; + left: 0; + top: 0; border-right: 2px solid #bbb; z-index: 2; @@ -599,7 +730,8 @@ tr.del > td { padding: 0; } -#menu-toc > ol , #menu-toc > ol ol { +#menu-toc > ol, +#menu-toc > ol ol { list-style-type: none; margin: 0; padding: 0; @@ -629,7 +761,7 @@ tr.del > td { -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; - user-select: none;; + user-select: none; cursor: pointer; } @@ -660,7 +792,7 @@ tr.del > td { */ } -#menu-toc li.revealed-leaf> a { +#menu-toc li.revealed-leaf > a { color: #206ca7; /* background-color: #222; @@ -714,10 +846,10 @@ tr.del > td { flex-grow: 0; flex-shrink: 0; width: 100%; - + display: flex; flex-direction: column; - + max-height: 300px; } @@ -742,43 +874,42 @@ tr.del > td { } li.menu-search-result-clause:before { - content: 'clause'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; + content: 'clause'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } li.menu-search-result-op:before { - content: 'op'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; + content: 'op'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } li.menu-search-result-prod:before { - content: 'prod'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75% + content: 'prod'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } - li.menu-search-result-term:before { - content: 'term'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75% + content: 'term'; + width: 40px; + display: inline-block; + text-align: right; + padding-right: 1ex; + color: #666; + font-size: 75%; } #menu-search-results ul { @@ -791,7 +922,6 @@ li.menu-search-result-term:before { text-overflow: ellipsis; } - #menu-trace-list { counter-reset: item; margin: 0 0 0 20px; @@ -803,19 +933,19 @@ li.menu-search-result-term:before { } #menu-trace-list li .secnum:after { - content: " "; + content: ' '; } #menu-trace-list li:before { - content: counter(item) " "; - background-color: #222; - counter-increment: item; - color: #999; - width: 20px; - height: 20px; - line-height: 20px; - display: inline-block; - text-align: center; - margin: 2px 4px 2px 0; + content: counter(item) ' '; + background-color: #222; + counter-increment: item; + color: #999; + width: 20px; + height: 20px; + line-height: 20px; + display: inline-block; + text-align: center; + margin: 2px 4px 2px 0; } @media (max-width: 1000px) { @@ -857,16 +987,16 @@ li.menu-search-result-term:before { } h1 .secnum:empty { - margin: 0; padding: 0; + margin: 0; + padding: 0; } } - /* Toolbox */ .toolbox { - position: absolute; - background: #ddd; - border: 1px solid #aaa; + position: absolute; + background: #ddd; + border: 1px solid #aaa; display: none; color: #eee; padding: 5px; @@ -886,28 +1016,29 @@ li.menu-search-result-term:before { text-decoration: underline; } -.toolbox:after, .toolbox:before { - top: 100%; - left: 15px; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; +.toolbox:after, +.toolbox:before { + top: 100%; + left: 15px; + border: solid transparent; + content: ' '; + height: 0; + width: 0; + position: absolute; + pointer-events: none; } .toolbox:after { - border-color: rgba(0, 0, 0, 0); - border-top-color: #ddd; - border-width: 10px; - margin-left: -10px; + border-color: rgba(0, 0, 0, 0); + border-top-color: #ddd; + border-width: 10px; + margin-left: -10px; } .toolbox:before { - border-color: rgba(204, 204, 204, 0); - border-top-color: #aaa; - border-width: 12px; - margin-left: -12px; + border-color: rgba(204, 204, 204, 0); + border-top-color: #aaa; + border-width: 12px; + margin-left: -12px; } #references-pane-container { @@ -955,6 +1086,6 @@ li.menu-search-result-term:before { @media print { #menu-toggle { - display: none; + display: none; } } diff --git a/js/ecmarkup.js b/js/ecmarkup.js index 8b137891..e69de29b 100644 --- a/js/ecmarkup.js +++ b/js/ecmarkup.js @@ -1 +0,0 @@ - diff --git a/js/findLocalReferences.js b/js/findLocalReferences.js index b884c11b..a41f00d3 100644 --- a/js/findLocalReferences.js +++ b/js/findLocalReferences.js @@ -1,5 +1,5 @@ var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX']; -function findLocalReferences ($elem) { +function findLocalReferences($elem) { var name = $elem.innerHTML; var references = []; @@ -8,7 +8,7 @@ function findLocalReferences ($elem) { parentClause = parentClause.parentNode; } - if(!parentClause) return; + if (!parentClause) return; var vars = parentClause.querySelectorAll('var'); @@ -36,7 +36,7 @@ function toggleFindLocalReferences($elem) { } } -function installFindLocalReferences () { +function installFindLocalReferences() { document.addEventListener('click', function (e) { if (e.target.nodeName === 'VAR') { toggleFindLocalReferences(e.target); diff --git a/js/menu.js b/js/menu.js index 9b55c89d..d64b5a7a 100644 --- a/js/menu.js +++ b/js/menu.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; function Search(menu) { this.menu = menu; @@ -10,8 +10,14 @@ function Search(menu) { document.addEventListener('keydown', this.documentKeydown.bind(this)); - this.$searchBox.addEventListener('keydown', debounce(this.searchBoxKeydown.bind(this), { stopPropagation: true })); - this.$searchBox.addEventListener('keyup', debounce(this.searchBoxKeyup.bind(this), { stopPropagation: true })); + this.$searchBox.addEventListener( + 'keydown', + debounce(this.searchBoxKeydown.bind(this), { stopPropagation: true }) + ); + this.$searchBox.addEventListener( + 'keyup', + debounce(this.searchBoxKeyup.bind(this), { stopPropagation: true }) + ); // Perform an initial search if the box is not empty. if (this.$searchBox.value) { @@ -25,13 +31,15 @@ Search.prototype.loadBiblio = function () { this.biblio = []; } else { this.biblio = JSON.parse($biblio.textContent); - this.biblio.clauses = this.biblio.filter(function (e) { return e.type === 'clause' }); + this.biblio.clauses = this.biblio.filter(function (e) { + return e.type === 'clause'; + }); this.biblio.byId = this.biblio.reduce(function (map, entry) { map[entry.id] = entry; return map; }, {}); } -} +}; Search.prototype.documentKeydown = function (e) { if (e.keyCode === 191) { @@ -39,7 +47,7 @@ Search.prototype.documentKeydown = function (e) { e.stopPropagation(); this.triggerSearch(); } -} +}; Search.prototype.searchBoxKeydown = function (e) { e.stopPropagation(); @@ -50,7 +58,7 @@ Search.prototype.searchBoxKeydown = function (e) { e.preventDefault(); this.selectResult(); } -} +}; Search.prototype.searchBoxKeyup = function (e) { if (e.keyCode === 13 || e.keyCode === 9) { @@ -58,8 +66,7 @@ Search.prototype.searchBoxKeyup = function (e) { } this.search(e.target.value); -} - +}; Search.prototype.triggerSearch = function (e) { if (this.menu.isVisible()) { @@ -71,7 +78,7 @@ Search.prototype.triggerSearch = function (e) { this.$searchBox.focus(); this.$searchBox.select(); -} +}; // bit 12 - Set if the result starts with searchString // bits 8-11: 8 - number of chunks multiplied by 2 if cases match, otherwise 1. // bits 1-7: 127 - length of the entry @@ -87,7 +94,7 @@ function relevance(result, searchString) { } if (result.match.prefix) { - relevance += 2048 + relevance += 2048; } relevance += Math.max(0, 255 - result.entry.key.length); @@ -112,11 +119,13 @@ Search.prototype.search = function (searchString) { var results; if (/^[\d\.]*$/.test(searchString)) { - results = this.biblio.clauses.filter(function (clause) { - return clause.number.substring(0, searchString.length) === searchString; - }).map(function (clause) { - return { entry: clause }; - }); + results = this.biblio.clauses + .filter(function (clause) { + return clause.number.substring(0, searchString.length) === searchString; + }) + .map(function (clause) { + return { entry: clause }; + }); } else { results = []; @@ -137,8 +146,9 @@ Search.prototype.search = function (searchString) { result.relevance = relevance(result, searchString); }); - results = results.sort(function (a, b) { return b.relevance - a.relevance }); - + results = results.sort(function (a, b) { + return b.relevance - a.relevance; + }); } if (results.length > 50) { @@ -146,14 +156,14 @@ Search.prototype.search = function (searchString) { } this.displayResults(results); -} +}; Search.prototype.hideSearch = function () { this.$search.classList.remove('active'); -} +}; Search.prototype.showSearch = function () { this.$search.classList.add('active'); -} +}; Search.prototype.selectResult = function () { var $first = this.$searchResults.querySelector('li:first-child a'); @@ -170,7 +180,7 @@ Search.prototype.selectResult = function () { if (this._closeAfterSearch) { this.menu.hide(); } -} +}; Search.prototype.displayResults = function (results) { if (results.length > 0) { @@ -204,19 +214,25 @@ Search.prototype.displayResults = function (results) { } if (text) { - html += ''; + html += + ''; } }); - html += '' + html += ''; this.$searchResults.innerHTML = html; } else { this.$searchResults.innerHTML = ''; this.$searchResults.classList.add('no-results'); } -} - +}; function Menu() { this.$toggle = document.getElementById('menu-toggle'); @@ -228,7 +244,7 @@ function Menu() { this.$specContainer = document.getElementById('spec-container'); this.search = new Search(this); - this._pinnedIds = {}; + this._pinnedIds = {}; this.loadPinEntries(); // toggle menu @@ -241,20 +257,26 @@ function Menu() { var tocItems = this.$menu.querySelectorAll('#menu-toc li'); for (var i = 0; i < tocItems.length; i++) { var $item = tocItems[i]; - $item.addEventListener('click', function($item, event) { - $item.classList.toggle('active'); - event.stopPropagation(); - }.bind(null, $item)); + $item.addEventListener( + 'click', + function ($item, event) { + $item.classList.toggle('active'); + event.stopPropagation(); + }.bind(null, $item) + ); } // close toc on toc item selection var tocLinks = this.$menu.querySelectorAll('#menu-toc li > a'); for (var i = 0; i < tocLinks.length; i++) { var $link = tocLinks[i]; - $link.addEventListener('click', function(event) { - this.toggle(); - event.stopPropagation(); - }.bind(this)); + $link.addEventListener( + 'click', + function (event) { + this.toggle(); + event.stopPropagation(); + }.bind(this) + ); } // update active clause on scroll @@ -268,8 +290,7 @@ function Menu() { if (offTop) { e.preventDefault(); } - var offBottom = e.deltaY > 0 - && target.offsetHeight + target.scrollTop >= target.scrollHeight; + var offBottom = e.deltaY > 0 && target.offsetHeight + target.scrollTop >= target.scrollHeight; if (offBottom) { e.preventDefault(); @@ -284,16 +305,16 @@ Menu.prototype.documentKeydown = function (e) { } else if (e.keyCode > 48 && e.keyCode < 58) { this.selectPin(e.keyCode - 49); } -} +}; Menu.prototype.updateActiveClause = function () { - this.setActiveClause(findActiveClause(this.$specContainer)) -} + this.setActiveClause(findActiveClause(this.$specContainer)); +}; Menu.prototype.setActiveClause = function (clause) { this.$activeClause = clause; this.revealInToc(this.$activeClause); -} +}; Menu.prototype.revealInToc = function (path) { var current = this.$toc.querySelectorAll('li.revealed'); @@ -307,7 +328,7 @@ Menu.prototype.revealInToc = function (path) { while (index < path.length) { var children = current.children; for (var i = 0; i < children.length; i++) { - if ('#' + path[index].id === children[i].children[1].getAttribute('href') ) { + if ('#' + path[index].id === children[i].children[1].getAttribute('href')) { children[i].classList.add('revealed'); if (index === path.length - 1) { children[i].classList.add('revealed-leaf'); @@ -315,7 +336,8 @@ Menu.prototype.revealInToc = function (path) { // this.$toc.getBoundingClientRect().top; var tocRect = this.$toc.getBoundingClientRect(); if (rect.top + 10 > tocRect.bottom) { - this.$toc.scrollTop = this.$toc.scrollTop + (rect.top - tocRect.bottom) + (rect.bottom - rect.top); + this.$toc.scrollTop = + this.$toc.scrollTop + (rect.top - tocRect.bottom) + (rect.bottom - rect.top); } else if (rect.top < tocRect.top) { this.$toc.scrollTop = this.$toc.scrollTop - (tocRect.top - rect.top); } @@ -325,21 +347,20 @@ Menu.prototype.revealInToc = function (path) { break; } } - } -} +}; function findActiveClause(root, path) { var clauses = new ClauseWalker(root); var $clause; var path = path || []; - while ($clause = clauses.nextNode()) { + while (($clause = clauses.nextNode())) { var rect = $clause.getBoundingClientRect(); - var $header = $clause.querySelector("h1"); - var marginTop = parseInt(getComputedStyle($header)["margin-top"]); + var $header = $clause.querySelector('h1'); + var marginTop = parseInt(getComputedStyle($header)['margin-top']); - if ((rect.top - marginTop) <= 0 && rect.bottom > 0) { + if (rect.top - marginTop <= 0 && rect.bottom > 0) { return findActiveClause($clause, path.concat($clause)) || path; } } @@ -359,42 +380,46 @@ function ClauseWalker(root) { } else { previous = node; } - if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-INTRO' || node.nodeName === 'EMU-ANNEX') { + if ( + node.nodeName === 'EMU-CLAUSE' || + node.nodeName === 'EMU-INTRO' || + node.nodeName === 'EMU-ANNEX' + ) { return NodeFilter.FILTER_ACCEPT; } else { return NodeFilter.FILTER_SKIP; } - } + }, }, false - ); + ); return treeWalker; } Menu.prototype.toggle = function () { this.$menu.classList.toggle('active'); -} +}; Menu.prototype.show = function () { this.$menu.classList.add('active'); -} +}; Menu.prototype.hide = function () { this.$menu.classList.remove('active'); -} +}; -Menu.prototype.isVisible = function() { +Menu.prototype.isVisible = function () { return this.$menu.classList.contains('active'); -} +}; Menu.prototype.showPins = function () { this.$pins.classList.add('active'); -} +}; Menu.prototype.hidePins = function () { this.$pins.classList.remove('active'); -} +}; Menu.prototype.addPinEntry = function (id) { var entry = this.search.biblio.byId[id]; @@ -412,7 +437,8 @@ Menu.prototype.addPinEntry = function (id) { } else { prefix = ''; } - this.$pinList.innerHTML += '
  • ' + prefix + entry.titleHTML + '
  • '; + this.$pinList.innerHTML += + '
  • ' + prefix + entry.titleHTML + '
  • '; } else { this.$pinList.innerHTML += '
  • ' + entry.key + '
  • '; } @@ -422,7 +448,7 @@ Menu.prototype.addPinEntry = function (id) { } this._pinnedIds[id] = true; this.persistPinEntries(); -} +}; Menu.prototype.removePinEntry = function (id) { var item = this.$pinList.querySelector('a[href="#' + id + '"]').parentNode; @@ -433,7 +459,7 @@ Menu.prototype.removePinEntry = function (id) { } this.persistPinEntries(); -} +}; Menu.prototype.persistPinEntries = function () { try { @@ -443,7 +469,7 @@ Menu.prototype.persistPinEntries = function () { } localStorage.pinEntries = JSON.stringify(Object.keys(this._pinnedIds)); -} +}; Menu.prototype.loadPinEntries = function () { try { @@ -455,10 +481,10 @@ Menu.prototype.loadPinEntries = function () { var pinsString = window.localStorage.pinEntries; if (!pinsString) return; var pins = JSON.parse(pinsString); - for(var i = 0; i < pins.length; i++) { + for (var i = 0; i < pins.length; i++) { this.addPinEntry(pins[i]); } -} +}; Menu.prototype.togglePinEntry = function (id) { if (!id) { @@ -470,24 +496,30 @@ Menu.prototype.togglePinEntry = function (id) { } else { this.addPinEntry(id); } -} +}; Menu.prototype.selectPin = function (num) { document.location = this.$pinList.children[num].children[0].href; -} +}; var menu; function init() { menu = new Menu(); var $container = document.getElementById('spec-container'); - $container.addEventListener('mouseover', debounce(function (e) { - Toolbox.activateIfMouseOver(e); - })); - document.addEventListener('keydown', debounce(function (e) { - if (e.code === "Escape" && Toolbox.active) { - Toolbox.deactivate(); - } - })); + $container.addEventListener( + 'mouseover', + debounce(function (e) { + Toolbox.activateIfMouseOver(e); + }) + ); + document.addEventListener( + 'keydown', + debounce(function (e) { + if (e.code === 'Escape' && Toolbox.active) { + Toolbox.deactivate(); + } + }) + ); } document.addEventListener('DOMContentLoaded', init); @@ -495,7 +527,7 @@ document.addEventListener('DOMContentLoaded', init); function debounce(fn, opts) { opts = opts || {}; var timeout; - return function(e) { + return function (e) { if (opts.stopPropagation) { e.stopPropagation(); } @@ -503,15 +535,18 @@ function debounce(fn, opts) { if (timeout) { clearTimeout(timeout); } - timeout = setTimeout(function() { - timeout = null; - fn.apply(this, args); - }.bind(this), 150); - } + timeout = setTimeout( + function () { + timeout = null; + fn.apply(this, args); + }.bind(this), + 150 + ); + }; } var CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX']; -function findLocalReferences ($elem) { +function findLocalReferences($elem) { var name = $elem.innerHTML; var references = []; @@ -520,7 +555,7 @@ function findLocalReferences ($elem) { parentClause = parentClause.parentNode; } - if(!parentClause) return; + if (!parentClause) return; var vars = parentClause.querySelectorAll('var'); @@ -548,7 +583,7 @@ function toggleFindLocalReferences($elem) { } } -function installFindLocalReferences () { +function installFindLocalReferences() { document.addEventListener('click', function (e) { if (e.target.nodeName === 'VAR') { toggleFindLocalReferences(e.target); @@ -558,9 +593,6 @@ function installFindLocalReferences () { document.addEventListener('DOMContentLoaded', installFindLocalReferences); - - - // The following license applies to the fuzzysearch function // The MIT License (MIT) // Copyright © 2015 Nicolas Bevacqua @@ -581,7 +613,7 @@ document.addEventListener('DOMContentLoaded', installFindLocalReferences); // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -function fuzzysearch (searchString, haystack, caseInsensitive) { +function fuzzysearch(searchString, haystack, caseInsensitive) { var tlen = haystack.length; var qlen = searchString.length; var chunks = 1; @@ -615,7 +647,9 @@ function fuzzysearch (searchString, haystack, caseInsensitive) { } } - if (caseInsensitive) { return false; } + if (caseInsensitive) { + return false; + } return fuzzysearch(searchString.toLowerCase(), haystack.toLowerCase(), true); } @@ -632,19 +666,25 @@ var Toolbox = { this.$pinLink = document.createElement('a'); this.$pinLink.textContent = 'Pin'; this.$pinLink.setAttribute('href', '#'); - this.$pinLink.addEventListener('click', function (e) { - e.preventDefault(); - e.stopPropagation(); - menu.togglePinEntry(this.entry.id); - }.bind(this)); + this.$pinLink.addEventListener( + 'click', + function (e) { + e.preventDefault(); + e.stopPropagation(); + menu.togglePinEntry(this.entry.id); + }.bind(this) + ); this.$refsLink = document.createElement('a'); this.$refsLink.setAttribute('href', '#'); - this.$refsLink.addEventListener('click', function (e) { - e.preventDefault(); - e.stopPropagation(); - referencePane.showReferencesFor(this.entry); - }.bind(this)); + this.$refsLink.addEventListener( + 'click', + function (e) { + e.preventDefault(); + e.stopPropagation(); + referencePane.showReferencesFor(this.entry); + }.bind(this) + ); this.$container.appendChild(this.$permalink); this.$container.appendChild(this.$pinLink); this.$container.appendChild(this.$refsLink); @@ -681,7 +721,10 @@ var Toolbox = { if (ref && (!this.active || e.pageY > this._activeEl.offsetTop)) { var entry = menu.search.biblio.byId[ref.id]; this.activate(ref.element, entry, e.target); - } else if (this.active && ((e.pageY < this.top) || e.pageY > (this._activeEl.offsetTop + this._activeEl.offsetHeight))) { + } else if ( + this.active && + (e.pageY < this.top || e.pageY > this._activeEl.offsetTop + this._activeEl.offsetHeight) + ) { this.deactivate(); } }, @@ -689,11 +732,22 @@ var Toolbox = { findReferenceUnder: function (el) { while (el) { var parent = el.parentNode; - if (el.nodeName === 'H1' && parent.nodeName.match(/EMU-CLAUSE|EMU-ANNEX|EMU-INTRO/) && parent.id) { + if ( + el.nodeName === 'H1' && + parent.nodeName.match(/EMU-CLAUSE|EMU-ANNEX|EMU-INTRO/) && + parent.id + ) { return { element: el, id: parent.id }; - } else if (el.nodeName.match(/EMU-(?!CLAUSE|XREF|ANNEX|INTRO)|DFN/) && - el.id && el.id[0] !== '_') { - if (el.nodeName === 'EMU-FIGURE' || el.nodeName === 'EMU-TABLE' || el.nodeName === 'EMU-EXAMPLE') { + } else if ( + el.nodeName.match(/EMU-(?!CLAUSE|XREF|ANNEX|INTRO)|DFN/) && + el.id && + el.id[0] !== '_' + ) { + if ( + el.nodeName === 'EMU-FIGURE' || + el.nodeName === 'EMU-TABLE' || + el.nodeName === 'EMU-EXAMPLE' + ) { // return the figcaption element return { element: el.children[0].children[0], id: el.id }; } else if (el.nodeName === 'EMU-PRODUCTION') { @@ -712,11 +766,11 @@ var Toolbox = { this._activeEl = null; this.activeElBounds = null; this.active = false; - } -} + }, +}; var referencePane = { - init: function() { + init: function () { this.$container = document.createElement('div'); this.$container.setAttribute('id', 'references-pane-container'); @@ -736,9 +790,12 @@ var referencePane = { this.$header.appendChild(this.$headerRefId); this.$closeButton = document.createElement('span'); this.$closeButton.setAttribute('id', 'references-pane-close'); - this.$closeButton.addEventListener('click', function (e) { - this.deactivate(); - }.bind(this)); + this.$closeButton.addEventListener( + 'click', + function (e) { + this.deactivate(); + }.bind(this) + ); this.$header.appendChild(this.$closeButton); this.$pane.appendChild(this.$header); @@ -772,35 +829,43 @@ var referencePane = { var dupCount = 0; this.$headerRefId.textContent = '#' + entry.id; this.$headerRefId.setAttribute('href', '#' + entry.id); - entry.referencingIds.map(function (id) { - var target = document.getElementById(id); - var cid = findParentClauseId(target); - var clause = menu.search.biblio.byId[cid]; - return { id: id, clause: clause } - }).sort(function (a, b) { - return sortByClauseNumber(a.clause, b.clause); - }).forEach(function (record, i) { - if (previousId === record.clause.id) { - previousCell.innerHTML += ' (' + (dupCount + 2) + ')'; - dupCount++; - } else { - var row = newBody.insertRow(); - var cell = row.insertCell(); - cell.innerHTML = record.clause.number; - cell = row.insertCell(); - cell.innerHTML = '' + record.clause.titleHTML + ''; - previousCell = cell; - previousId = record.clause.id; - dupCount = 0; - } - }, this); + entry.referencingIds + .map(function (id) { + var target = document.getElementById(id); + var cid = findParentClauseId(target); + var clause = menu.search.biblio.byId[cid]; + return { id: id, clause: clause }; + }) + .sort(function (a, b) { + return sortByClauseNumber(a.clause, b.clause); + }) + .forEach(function (record, i) { + if (previousId === record.clause.id) { + previousCell.innerHTML += ' (' + (dupCount + 2) + ')'; + dupCount++; + } else { + var row = newBody.insertRow(); + var cell = row.insertCell(); + cell.innerHTML = record.clause.number; + cell = row.insertCell(); + cell.innerHTML = '' + record.clause.titleHTML + ''; + previousCell = cell; + previousId = record.clause.id; + dupCount = 0; + } + }, this); this.$table.removeChild(this.$tableBody); this.$tableBody = newBody; this.$table.appendChild(this.$tableBody); - } -} + }, +}; function findParentClauseId(node) { - while (node && node.nodeName !== 'EMU-CLAUSE' && node.nodeName !== 'EMU-INTRO' && node.nodeName !== 'EMU-ANNEX') { + while ( + node && + node.nodeName !== 'EMU-CLAUSE' && + node.nodeName !== 'EMU-INTRO' && + node.nodeName !== 'EMU-ANNEX' + ) { node = node.parentNode; } if (!node) return null; @@ -831,7 +896,7 @@ function sortByClauseNumber(c1, c2) { return -1; } else if (Number.isNaN(c1cn) && !Number.isNaN(c2cn)) { return 1; - } else if(c1cn > c2cn) { + } else if (c1cn > c2cn) { return 1; } else if (c1cn < c2cn) { return -1; @@ -847,4 +912,4 @@ function sortByClauseNumber(c1, c2) { document.addEventListener('DOMContentLoaded', function () { Toolbox.init(); referencePane.init(); -}) +});