From f78f0d74ba0d82e45a993b4bb40aa1e3d8d34643 Mon Sep 17 00:00:00 2001 From: ESKYoung Date: Mon, 1 Feb 2021 21:05:41 +0000 Subject: [PATCH] Manually rebuild `application.js` to run from jQuery 3.5.1 Folder structure within `static/javascripts` reflects the `alphagov/tech-docs-gem` project, version 2.1.0 `spec/javascripts` folder available at: https://github.com/alphagov/tech-docs-gem/ All files at the top-level of this `static/javascripts` folder, as well as the `_modules` sub-folder, and the `_govuk/modules.js` script are identical to the `alphagov/tech-docs-gem`, version 2.1.0 release. All files in the `_vendor` folder are to the latest available release: - jQuery v3.5.1 (`_vendor/jquery.js`) - modernizer 3.6.0 (`_vendor/modernizer.js`) - Fixed Sticky v0.1.7 (`_vendor/fixedsticky.js`) - Lodash 4.7.15 (`_vendor/lodash.js`) - lunr 2.3.9 (`_vendor/lunr.min.js`) - mark.js v8.11.1 (`_vendor/jquery.mark.js`) The `_govuk/govuk-frontend-3.10.2.min.js` file was obtained from the `alphagov/govuk-frontend` project, version 3.10.2 available at: https://github.com/alphagov/govuk-frontend The `_govuk/govuk-frontend-3.10.2.min.js` file can be found in the release source code. --- LICENSE | 205 + README.md | 4 +- docs/structure/README.md | 4 +- .../static/javascripts/_analytics.js | 58 + .../_govuk/govuk-frontend-3.10.2.min.js | 1 + .../static/javascripts/_govuk/modules.js | 56 + .../javascripts/_modules/anchored-headings.js | 18 + .../_modules/collapsible-navigation.js | 89 + .../_modules/in-page-navigation.js | 132 + .../static/javascripts/_modules/navigation.js | 34 + .../javascripts/_modules/page-expiry.js | 15 + .../static/javascripts/_modules/search.js | 362 + .../javascripts/_modules/table-of-contents.js | 103 + .../static/javascripts/_start_modules.js | 12 + .../static/javascripts/_vendor/fixedsticky.js | 194 + .../static/javascripts/_vendor/jquery.js | 2 + .../static/javascripts/_vendor/jquery.mark.js | 1081 +++ .../static/javascripts/_vendor/lodash.js | 615 ++ .../static/javascripts/_vendor/lunr.min.js | 6 + .../static/javascripts/_vendor/modernizer.js | 3 + .../static/javascripts/application.js | 8335 ----------------- .../static/javascripts/govuk_tech_docs.js | 12 + 22 files changed, 3002 insertions(+), 8339 deletions(-) create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_analytics.js create mode 100755 govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/govuk-frontend-3.10.2.min.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/modules.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_modules/anchored-headings.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_modules/collapsible-navigation.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_modules/in-page-navigation.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_modules/navigation.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_modules/page-expiry.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_modules/search.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_modules/table-of-contents.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_start_modules.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_vendor/fixedsticky.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_vendor/jquery.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_vendor/jquery.mark.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_vendor/lodash.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_vendor/lunr.min.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/_vendor/modernizer.js delete mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/application.js create mode 100644 govuk_tech_docs_sphinx_theme/static/javascripts/govuk_tech_docs.js diff --git a/LICENSE b/LICENSE index f0f6100..856dfbe 100644 --- a/LICENSE +++ b/LICENSE @@ -29,6 +29,13 @@ This project incorporates components from the projects listed below: 1. `alphagov/tech-docs-template` commit `1fb26fc` (https://github.com/alphagov/tech-docs-template) 2. `alphagov/tech-docs-gem` version 2.1.0 (https://github.com/alphagov/tech-docs-gem) +3. `jquery/jquery` version 3.5.1 (https://github.com/jquery/jquery) +4. `Modernizr/Modernizr` version 3.6.0 (https://github.com/Modernizr/Modernizr) +5. `filamentgroup/fixed-sticky` v0.1.7 (https://github.com/filamentgroup/fixed-sticky) +6. `lodash/lodash` v4.7.15 (https://github.com/lodash/lodash) +7. `olivernn/lunr.js` v2.3.9 (https://github.com/olivernn/lunr.js) +8. `julmot/mark.js` version 8.11.1 (https://github.com/julmot/mark.js) +9. `alphagov/govuk-frontend` v3.10.2 (https://github.com/alphagov/govuk-frontend) %% `alphagov/tech-docs-template` NOTICES AND INFORMATION BEGIN HERE =============================================================================== @@ -85,3 +92,201 @@ SOFTWARE. =============================================================================== END OF `alphagov/tech-docs-gem` NOTICES AND INFORMATION + +%% `jquery/jquery` NOTICES AND INFORMATION BEGIN HERE +=============================================================================== + +Copyright JS Foundation and other contributors, https://js.foundation/ + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 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. + +=============================================================================== +END OF `jquery/jquery` NOTICES AND INFORMATION + +%% `Modernizr/Modernizr` NOTICES AND INFORMATION BEGIN HERE +=============================================================================== + +/*! Modernizr 3.5.0 | MIT */ + +=============================================================================== +END OF `Modernizr/Modernizr` NOTICES AND INFORMATION + +%% `filamentgroup/fixed-sticky` NOTICES AND INFORMATION BEGIN HERE +=============================================================================== + +The MIT License (MIT) + +Copyright (c) 2013 Filament Group + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +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. + +=============================================================================== +END OF `filamentgroup/fixed-sticky` NOTICES AND INFORMATION + +%% `lodash/lodash` NOTICES AND INFORMATION BEGIN HERE +=============================================================================== + +Copyright OpenJS Foundation and other contributors + +Based on Underscore.js, copyright Jeremy Ashkenas, +DocumentCloud and Investigative Reporters & Editors + +This software consists of voluntary contributions made by many +individuals. For exact contribution history, see the revision history +available at https://github.com/lodash/lodash + +The following license applies to all parts of this software except as +documented below: + +==== + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 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. + +==== + +Copyright and related rights for sample code are waived via CC0. Sample +code is defined as all source code displayed within the prose of the +documentation. + +CC0: http://creativecommons.org/publicdomain/zero/1.0/ + +==== + +Files located in the node_modules and vendor directories are externally +maintained libraries used by this software which have their own +licenses; we recommend you read them, as their terms may differ from the +terms above. + +=============================================================================== +END OF `lodash/lodash` NOTICES AND INFORMATION + +%% `olivernn/lunr.js` NOTICES AND INFORMATION BEGIN HERE +=============================================================================== + +Copyright (C) 2013 by Oliver Nightingale + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR 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. + +=============================================================================== +END OF `olivernn/lunr.js` NOTICES AND INFORMATION + +%% `julmot/mark.js` NOTICES AND INFORMATION BEGIN HERE +=============================================================================== + +The MIT License (MIT) + +Copyright (c) 2014–2018 Julian Kühnel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR 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. + +=============================================================================== +END OF `julmot/mark.js` NOTICES AND INFORMATION + +%% `alphagov/govuk-frontend` NOTICES AND INFORMATION BEGIN HERE +=============================================================================== + +The MIT License (MIT) + +Copyright (C) 2017 Crown Copyright (Government Digital Service) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR 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. + +=============================================================================== +END OF `alphagov/govuk-frontend` NOTICES AND INFORMATION diff --git a/README.md b/README.md index 5c20d13..0853aa2 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ To be added. ## Licence Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample -code in the documentation. The documentation is © Crown copyright and available under the terms of the Open Government -3.0 licence. +code in the documentation. Additional third-party component licences are stated in the `LICENSE` file. The +documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence. ## Contributing diff --git a/docs/structure/README.md b/docs/structure/README.md index bef93b2..9ef2f95 100644 --- a/docs/structure/README.md +++ b/docs/structure/README.md @@ -81,8 +81,8 @@ The [contributing guidelines][contributing] for this project. ### `LICENSE` The licence for this project. Unless stated otherwise, the codebase is released under the MIT License. This covers both -the codebase and any sample code in the documentation. The documentation is © Crown copyright and available under the -terms of the Open Government 3.0 licence. +the codebase and any sample code in the documentation. Additional third-party component licences are stated in the +`LICENSE` file. The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence. ### `Makefile` diff --git a/govuk_tech_docs_sphinx_theme/static/javascripts/_analytics.js b/govuk_tech_docs_sphinx_theme/static/javascripts/_analytics.js new file mode 100644 index 0000000..184af31 --- /dev/null +++ b/govuk_tech_docs_sphinx_theme/static/javascripts/_analytics.js @@ -0,0 +1,58 @@ +(function ($) { + function trackLinkClick (action, $element) { + var linkText = $.trim($element.text()) + var linkURL = $element.attr('href') + var label = linkText + '|' + linkURL + + ga( + 'send', + 'event', + 'SM Technical Documentation', // Event Category + action, // Event Action + label // Event Label + ) + } + + function linkTrackingEventHandler (action) { + return function () { + trackLinkClick(action, $(this)) + } + } + + function catchBrokenFragmentLinks () { + var fragment = window.location.hash + var $target = $(fragment) + if (!$target.get(0)) { + ga( + 'send', + 'event', + 'Broken fragment ID', // Event Category + 'pageview', // Event Action + window.location.pathname + fragment // Event Label + ) + } + } + + $(document).on('ready', function () { + if (typeof ga === 'undefined') { + return + } + + $('.technical-documentation a').on('click', linkTrackingEventHandler('inTextClick')) + $('.header a').on('click', linkTrackingEventHandler('topNavigationClick')) + $('.toc a').on('click', linkTrackingEventHandler('tableOfContentsNavigationClick')) + catchBrokenFragmentLinks() + + // Borrowed from: + // https://github.com/alphagov/govuk_frontend_toolkit/blob/master/javascripts/govuk/analytics/analytics.js + window.stripPIIFromString = function (string) { + var EMAIL_PATTERN = /[^\s=/?&]+(?:@|%40)[^\s=/?&]+/g + var POSTCODE_PATTERN = /[A-PR-UWYZ][A-HJ-Z]?[0-9][0-9A-HJKMNPR-Y]?(?:[\s+]|%20)*[0-9][ABD-HJLNPQ-Z]{2}/gi + var DATE_PATTERN = /\d{4}(-?)\d{2}(-?)\d{2}/g + var stripped = string.replace(EMAIL_PATTERN, '[email]') + .replace(DATE_PATTERN, '[date]') + .replace(POSTCODE_PATTERN, '[postcode]') + return stripped + } + }) +})(jQuery) diff --git a/govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/govuk-frontend-3.10.2.min.js b/govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/govuk-frontend-3.10.2.min.js new file mode 100755 index 0000000..eaee832 --- /dev/null +++ b/govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/govuk-frontend-3.10.2.min.js @@ -0,0 +1 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("GOVUKFrontend",["exports"],e):e(t.GOVUKFrontend={})}(this,function(t){"use strict";function r(t,e){if(window.NodeList.prototype.forEach)return t.forEach(e);for(var n=0;n>>0,"object"==typeof i[r]?i[r].baseVal=a.join(" "):i[r]=a.join(" "),u())},s.remove=function(){d.apply(s,t=arguments);for(var t,e={},n=0,o=[];n>>0,"object"==typeof i[r]?i[r].baseVal=a.join(" "):i[r]=a.join(" "),u()},s.toggle=function(t,e){return d.apply(s,[t]),o!==e?e?(s.add(t),!0):(s.remove(t),!1):c[t]?(s.remove(t),!1):(s.add(t),!0)},s}}()),"classList"in(n=document.createElement("span"))&&(n.classList.toggle("x",!1),n.classList.contains("x")&&(n.classList.constructor.prototype.toggle=function(t){var e=arguments[1];if(e!==o)return this[(e=!!e)?"add":"remove"](t),e;var n=!this.contains(t);return this[n?"add":"remove"](t),n})),function(){var t=document.createElement("span");if("classList"in t&&(t.classList.add("a","b"),!t.classList.contains("b"))){var o=t.classList.constructor.prototype.add;t.classList.constructor.prototype.add=function(){for(var t=arguments,e=arguments.length,n=0;nsections',this.$openAllButton.setAttribute("class",this.openAllClass),this.$openAllButton.setAttribute("aria-expanded","false"),this.$openAllButton.setAttribute("type","button");var t=document.createElement("div");t.setAttribute("class",this.controlsClass),t.appendChild(this.$openAllButton),this.$module.insertBefore(t,this.$module.firstChild),this.$openAllButton.addEventListener("click",this.onOpenOrCloseAllToggle.bind(this))},n.prototype.initSectionHeaders=function(){r(this.$sections,function(t,e){var n=t.querySelector("."+this.sectionHeaderClass);this.initHeaderAttributes(n,e),this.setExpanded(this.isExpanded(t),t),n.addEventListener("click",this.onSectionToggle.bind(this,t)),this.setInitialState(t)}.bind(this))},n.prototype.initHeaderAttributes=function(e,t){var n=this,o=e.querySelector("."+this.sectionButtonClass),i=e.querySelector("."+this.sectionHeadingClass),r=e.querySelector("."+this.sectionSummaryClass),s=document.createElement("button");s.setAttribute("type","button"),s.setAttribute("id",this.moduleId+"-heading-"+(t+1)),s.setAttribute("aria-controls",this.moduleId+"-content-"+(t+1));for(var a=0;a