@hmcts/annotation-ui-lib
Version:
PDF Viewer and ability to highlight text with and comment tracking
40 lines (35 loc) • 1.44 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define('GOVUKFrontend', ['exports'], factory) :
(factory((global.GOVUKFrontend = {})));
}(this, (function (exports) { 'use strict';
/**
* TODO: Ideally this would be a NodeList.prototype.forEach polyfill
* This seems to fail in IE8, requires more investigation.
* See: https://github.com/imagitama/nodelist-foreach-polyfill
*/
function nodeListForEach (nodes, callback) {
if (window.NodeList.prototype.forEach) {
return nodes.forEach(callback)
}
for (var i = 0; i < nodes.length; i++) {
callback.call(window, nodes[i], i, nodes);
}
}
// Used to generate a unique string, allows multiple instances of the component without
// Them conflicting with each other.
// https://stackoverflow.com/a/8809472
function generateUniqueID () {
var d = new Date().getTime();
if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
d += window.performance.now(); // use high-precision timer if available
}
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
})
}
exports.nodeListForEach = nodeListForEach;
exports.generateUniqueID = generateUniqueID;
})));