This repository has been archived by the owner on Apr 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
22 changed files
with
3,002 additions
and
8,339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
govuk_tech_docs_sphinx_theme/static/javascripts/_analytics.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
1 change: 1 addition & 0 deletions
1
govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/govuk-frontend-3.10.2.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
govuk_tech_docs_sphinx_theme/static/javascripts/_govuk/modules.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
18 changes: 18 additions & 0 deletions
18
govuk_tech_docs_sphinx_theme/static/javascripts/_modules/anchored-headings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.