diff options
author | ITSERVICES\rb7147 <rb7147@att.com> | 2017-04-25 11:46:00 -0400 |
---|---|---|
committer | ITSERVICES\rb7147 <rb7147@att.com> | 2017-05-03 09:58:17 -0400 |
commit | e0addf5b588a1244f9679becd90999dfcb4c3a94 (patch) | |
tree | 1212772d6366730266ff0e093c874b07aa716c29 /POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/anchor.js | |
parent | 39fb0f30472777e4b60d6a7ac8aa4eb9773961ff (diff) |
Policy 1707 commit to LF
Change-Id: Ibe6f01d92f9a434c040abb05d5386e89d675ae65
Signed-off-by: ITSERVICES\rb7147 <rb7147@att.com>
Diffstat (limited to 'POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/anchor.js')
-rw-r--r-- | POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/anchor.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/anchor.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/anchor.js new file mode 100644 index 000000000..e5ddfa725 --- /dev/null +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/CSS/bootstrap/docs/assets/js/vendor/anchor.js @@ -0,0 +1,48 @@ +/*! + * AnchorJS - v0.1.0 - 2014-08-17 + * https://github.com/bryanbraun/anchorjs + * Copyright (c) 2014 Bryan Braun; Licensed MIT + */ + +function addAnchors(selector) { + 'use strict'; + + // Sensible default selector, if none is provided. + if (!selector) { + selector = 'h1, h2, h3, h4, h5, h6'; + } else if (typeof selector !== 'string') { + throw new Error('AnchorJS accepts only strings; you used a ' + typeof selector); + } + + // Select any elements that match the provided selector. + var elements = document.querySelectorAll(selector); + + // Loop through the selected elements. + for (var i = 0; i < elements.length; i++) { + var elementID; + + if (elements[i].hasAttribute('id')) { + elementID = elements[i].getAttribute('id'); + } else { + // We need to create an ID on our element. First, we find which text selection method is available to the browser. + var textMethod = document.body.textContent ? 'textContent' : 'innerText'; + + // Get the text inside our element + var roughText = elements[i][textMethod]; + + // Refine it so it makes a good ID. Makes all lowercase and hyphen separated. + // Ex. Hello World > hello-world + var tidyText = roughText.replace(/\s+/g, '-').toLowerCase(); + + // Assign it to our element. + // Currently the setAttribute element is only supported in IE9 and above. + elements[i].setAttribute('id', tidyText); + + // Grab it for use in our anchor. + elementID = tidyText; + } + var anchor = '<a class="anchorjs-link" href="#' + elementID + '"><span class="anchorjs-icon"></span></a>'; + + elements[i].innerHTML += anchor; + } +} |