Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
Manually rebuild application.js to run from jQuery 3.5.1
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ESKYoung committed Feb 8, 2021
1 parent dc6225c commit f78f0d7
Show file tree
Hide file tree
Showing 22 changed files with 3,002 additions and 8,339 deletions.
205 changes: 205 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -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
===============================================================================
Expand Down Expand Up @@ -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 <https://openjsf.org/>

Based on Underscore.js, copyright Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>

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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/structure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
58 changes: 58 additions & 0 deletions govuk_tech_docs_sphinx_theme/static/javascripts/_analytics.js
Original file line number Diff line number Diff line change
@@ -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)

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(function ($, root) {
'use strict'
root.GOVUK = root.GOVUK || {}
GOVUK.Modules = GOVUK.Modules || {}

GOVUK.modules = {
find: function (container) {
var modules
var moduleSelector = '[data-module]'
var component = container || $('body')

modules = component.find(moduleSelector)

// Container could be a module too
if (component.is(moduleSelector)) {
modules = modules.add(component)
}

return modules
},

start: function (container) {
var modules = this.find(container)

for (var i = 0, l = modules.length; i < l; i++) {
var module
var element = $(modules[i])
var type = camelCaseAndCapitalise(element.data('module'))
var started = element.data('module-started')

if (typeof GOVUK.Modules[type] === 'function' && !started) {
module = new GOVUK.Modules[type]()
module.start(element)
element.data('module-started', true)
}
}

// eg selectable-table to SelectableTable
function camelCaseAndCapitalise (string) {
return capitaliseFirstLetter(camelCase(string))
}

// http://stackoverflow.com/questions/6660977/convert-hyphens-to-camel-case-camelcase
function camelCase (string) {
return string.replace(/-([a-z])/g, function (g) {
return g[1].toUpperCase()
})
}

// http://stackoverflow.com/questions/1026069/capitalize-the-first-letter-of-string-in-javascript
function capitaliseFirstLetter (string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
}
}
})(jQuery, window)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(function ($, Modules) {
'use strict'

Modules.AnchoredHeadings = function () {
this.start = function ($element) {
var headings = $element.find('h1, h2, h3, h4, h5, h6')
headings.each(injectAnchor)
}

function injectAnchor () {
var $this = $(this)
$this.addClass('anchored-heading')
$this.prepend(
'<a href="#' + $this.attr('id') + '" class="anchored-heading__icon" aria-hidden="true" tabindex="-1"></a>'
)
}
}
})(jQuery, window.GOVUK.Modules)
Loading

0 comments on commit f78f0d7

Please sign in to comment.