mirror of
https://github.com/twbs/bootstrap.git
synced 2025-01-29 21:52:22 +01:00
Update Anchor.js to v1.2.1.
[ci skip]
This commit is contained in:
parent
0269da3c50
commit
1029240b2d
196
docs/assets/js/vendor/anchor.js
vendored
196
docs/assets/js/vendor/anchor.js
vendored
@ -1,196 +0,0 @@
|
||||
/*!
|
||||
* AnchorJS - v1.0.1 - 2015-05-15
|
||||
* https://github.com/bryanbraun/anchorjs
|
||||
* Copyright (c) 2015 Bryan Braun; Licensed MIT
|
||||
*/
|
||||
|
||||
function AnchorJS(options) {
|
||||
'use strict';
|
||||
|
||||
this.options = options || {};
|
||||
|
||||
this._applyRemainingDefaultOptions = function(opts) {
|
||||
this.options.icon = this.options.hasOwnProperty('icon') ? opts.icon : ''; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'.
|
||||
this.options.visible = this.options.hasOwnProperty('visible') ? opts.visible : 'hover'; // Also accepts 'always'
|
||||
this.options.placement = this.options.hasOwnProperty('placement') ? opts.placement : 'right'; // Also accepts 'left'
|
||||
this.options.class = this.options.hasOwnProperty('class') ? opts.class : ''; // Accepts any class name.
|
||||
};
|
||||
|
||||
this._applyRemainingDefaultOptions(options);
|
||||
|
||||
this.add = function(selector) {
|
||||
var elements,
|
||||
elsWithIds,
|
||||
idList,
|
||||
elementID,
|
||||
i,
|
||||
roughText,
|
||||
tidyText,
|
||||
index,
|
||||
count,
|
||||
newTidyText,
|
||||
readableID,
|
||||
anchor,
|
||||
div,
|
||||
anchorNodes;
|
||||
|
||||
this._applyRemainingDefaultOptions(this.options);
|
||||
|
||||
// Provide a sensible default selector, if none is given.
|
||||
if (!selector) {
|
||||
selector = 'h1, h2, h3, h4, h5, h6';
|
||||
} else if (typeof selector !== 'string') {
|
||||
throw new Error('The selector provided to AnchorJS was invalid.');
|
||||
}
|
||||
|
||||
elements = document.querySelectorAll(selector);
|
||||
if (elements.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this._addBaselineStyles();
|
||||
|
||||
// We produce a list of existing IDs so we don't generate a duplicate.
|
||||
elsWithIds = document.querySelectorAll('[id]');
|
||||
idList = [].map.call(elsWithIds, function assign(el) {
|
||||
return el.id;
|
||||
});
|
||||
|
||||
for (i = 0; i < elements.length; i++) {
|
||||
|
||||
if (elements[i].hasAttribute('id')) {
|
||||
elementID = elements[i].getAttribute('id');
|
||||
} else {
|
||||
roughText = elements[i].textContent;
|
||||
|
||||
// Refine it so it makes a good ID. Strip out non-safe characters, replace
|
||||
// spaces with hyphens, truncate to 32 characters, and make toLowerCase.
|
||||
//
|
||||
// Example string: // '⚡⚡⚡ Unicode icons are cool--but don't belong in a URL.'
|
||||
tidyText = roughText.replace(/[^\w\s-]/gi, '') // ' Unicode icons are cool--but dont belong in a URL'
|
||||
.replace(/\s+/g, '-') // '-Unicode-icons-are-cool--but-dont-belong-in-a-URL'
|
||||
.replace(/-{2,}/g, '-') // '-Unicode-icons-are-cool-but-dont-belong-in-a-URL'
|
||||
.substring(0, 32) // '-Unicode-icons-are-cool-but-dont'
|
||||
.replace(/^-+|-+$/gm, '') // 'Unicode-icons-are-cool-but-dont'
|
||||
.toLowerCase(); // 'unicode-icons-are-cool-but-dont'
|
||||
|
||||
// Compare our generated ID to existing IDs (and increment it if needed)
|
||||
// before we add it to the page.
|
||||
newTidyText = tidyText;
|
||||
count = 0;
|
||||
do {
|
||||
if (index !== undefined) {
|
||||
newTidyText = tidyText + '-' + count;
|
||||
}
|
||||
// .indexOf is supported in IE9+.
|
||||
index = idList.indexOf(newTidyText);
|
||||
count += 1;
|
||||
} while (index !== -1);
|
||||
index = undefined;
|
||||
idList.push(newTidyText);
|
||||
|
||||
// Assign it to our element.
|
||||
// Currently the setAttribute element is only supported in IE9 and above.
|
||||
elements[i].setAttribute('id', newTidyText);
|
||||
|
||||
elementID = newTidyText;
|
||||
}
|
||||
|
||||
readableID = elementID.replace(/-/g, ' ');
|
||||
|
||||
anchor = '<a class="anchorjs-link ' + this.options.class + '" href="#' + elementID + '" aria-label="Anchor link for: ' + readableID + '" data-anchorjs-icon="' + this.options.icon + '"></a>';
|
||||
|
||||
div = document.createElement('div');
|
||||
div.innerHTML = anchor;
|
||||
anchorNodes = div.childNodes;
|
||||
|
||||
if (this.options.visible === 'always') {
|
||||
anchorNodes[0].style.opacity = '1';
|
||||
}
|
||||
|
||||
if (this.options.icon === '') {
|
||||
anchorNodes[0].style.fontFamily = 'anchorjs-icons';
|
||||
anchorNodes[0].style.fontStyle = 'normal';
|
||||
anchorNodes[0].style.fontVariant = 'normal';
|
||||
anchorNodes[0].style.fontWeight = 'normal';
|
||||
}
|
||||
|
||||
if (this.options.placement === 'left') {
|
||||
anchorNodes[0].style.position = 'absolute';
|
||||
anchorNodes[0].style.marginLeft = '-1em';
|
||||
anchorNodes[0].style.paddingRight = '0.5em';
|
||||
elements[i].insertBefore(anchorNodes[0], elements[i].firstChild);
|
||||
} else { // if the option provided is `right` (or anything else).
|
||||
anchorNodes[0].style.paddingLeft = '0.375em';
|
||||
elements[i].appendChild(anchorNodes[0]);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
this.remove = function(selector) {
|
||||
var domAnchor,
|
||||
elements = document.querySelectorAll(selector);
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
domAnchor = elements[i].querySelector('.anchorjs-link');
|
||||
if (domAnchor) {
|
||||
elements[i].removeChild(domAnchor);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
this._addBaselineStyles = function() {
|
||||
// We don't want to add global baseline styles if they've been added before.
|
||||
if (document.head.querySelector('style.anchorjs') !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var style = document.createElement('style'),
|
||||
linkRule =
|
||||
' .anchorjs-link {' +
|
||||
' opacity: 0;' +
|
||||
' text-decoration: none;' +
|
||||
' -webkit-font-smoothing: antialiased;' +
|
||||
' -moz-osx-font-smoothing: grayscale;' +
|
||||
' }',
|
||||
hoverRule =
|
||||
' *:hover > .anchorjs-link,' +
|
||||
' .anchorjs-link:focus {' +
|
||||
' opacity: 1;' +
|
||||
' }',
|
||||
anchorjsLinkFontFace =
|
||||
' @font-face {' +
|
||||
' font-family: "anchorjs-icons";' +
|
||||
' font-style: normal;' +
|
||||
' font-weight: normal;' + // Icon from icomoon; 10px wide & 10px tall; 2 empty below & 4 above
|
||||
' src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBTUAAAC8AAAAYGNtYXAWi9QdAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zgq29TcAAAF4AAABNGhlYWQEZM3pAAACrAAAADZoaGVhBhUDxgAAAuQAAAAkaG10eASAADEAAAMIAAAAFGxvY2EAKACuAAADHAAAAAxtYXhwAAgAVwAAAygAAAAgbmFtZQ5yJ3cAAANIAAAB2nBvc3QAAwAAAAAFJAAAACAAAwJAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADpywPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAOAAAAAoACAACAAIAAQAg6cv//f//AAAAAAAg6cv//f//AAH/4xY5AAMAAQAAAAAAAAAAAAAAAQAB//8ADwABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAACADEARAJTAsAAKwBUAAABIiYnJjQ/AT4BMzIWFxYUDwEGIicmND8BNjQnLgEjIgYPAQYUFxYUBw4BIwciJicmND8BNjIXFhQPAQYUFx4BMzI2PwE2NCcmNDc2MhcWFA8BDgEjARQGDAUtLXoWOR8fORYtLTgKGwoKCjgaGg0gEhIgDXoaGgkJBQwHdR85Fi0tOAobCgoKOBoaDSASEiANehoaCQkKGwotLXoWOR8BMwUFLYEuehYXFxYugC44CQkKGwo4GkoaDQ0NDXoaShoKGwoFBe8XFi6ALjgJCQobCjgaShoNDQ0NehpKGgobCgoKLYEuehYXAAEAAAABAACiToc1Xw889QALBAAAAAAA0XnFFgAAAADRecUWAAAAAAJTAsAAAAAIAAIAAAAAAAAAAQAAA8D/wAAABAAAAAAAAlMAAQAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAACAAAAAoAAMQAAAAAACgAUAB4AmgABAAAABQBVAAIAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEADgAAAAEAAAAAAAIABwCfAAEAAAAAAAMADgBLAAEAAAAAAAQADgC0AAEAAAAAAAUACwAqAAEAAAAAAAYADgB1AAEAAAAAAAoAGgDeAAMAAQQJAAEAHAAOAAMAAQQJAAIADgCmAAMAAQQJAAMAHABZAAMAAQQJAAQAHADCAAMAAQQJAAUAFgA1AAMAAQQJAAYAHACDAAMAAQQJAAoANAD4YW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzUmVndWxhcgBSAGUAZwB1AGwAYQByYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format("truetype");' +
|
||||
' }',
|
||||
pseudoElContent =
|
||||
' [data-anchorjs-icon]::after {' +
|
||||
' content: attr(data-anchorjs-icon);' +
|
||||
' }',
|
||||
firstStyleEl;
|
||||
|
||||
style.className = 'anchorjs';
|
||||
style.appendChild(document.createTextNode('')); // Necessary for Webkit.
|
||||
|
||||
// We place it in the head with the other style tags, if possible, so as to
|
||||
// not look out of place. We insert before the others so these styles can be
|
||||
// overridden if necessary.
|
||||
firstStyleEl = document.head.querySelector('[rel="stylesheet"], style');
|
||||
if (firstStyleEl === undefined) {
|
||||
document.head.appendChild(style);
|
||||
} else {
|
||||
document.head.insertBefore(style, firstStyleEl);
|
||||
}
|
||||
|
||||
style.sheet.insertRule(linkRule, style.sheet.cssRules.length);
|
||||
style.sheet.insertRule(hoverRule, style.sheet.cssRules.length);
|
||||
style.sheet.insertRule(pseudoElContent, style.sheet.cssRules.length);
|
||||
style.sheet.insertRule(anchorjsLinkFontFace, style.sheet.cssRules.length);
|
||||
};
|
||||
}
|
||||
|
||||
var anchors = new AnchorJS();
|
6
docs/assets/js/vendor/anchor.min.js
vendored
Normal file
6
docs/assets/js/vendor/anchor.min.js
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* AnchorJS - v1.2.1 - 2015-07-02
|
||||
* https://github.com/bryanbraun/anchorjs
|
||||
* Copyright (c) 2015 Bryan Braun; Licensed MIT
|
||||
*/
|
||||
function AnchorJS(A){"use strict";this.options=A||{},this._applyRemainingDefaultOptions=function(A){this.options.icon=this.options.hasOwnProperty("icon")?A.icon:"",this.options.visible=this.options.hasOwnProperty("visible")?A.visible:"hover",this.options.placement=this.options.hasOwnProperty("placement")?A.placement:"right",this.options.class=this.options.hasOwnProperty("class")?A.class:""},this._applyRemainingDefaultOptions(A),this.add=function(A){var e,t,o,n,i,s,a,l,r,h,c,g;if(this._applyRemainingDefaultOptions(this.options),A){if("string"!=typeof A)throw new Error("The selector provided to AnchorJS was invalid.")}else A="h1, h2, h3, h4, h5, h6";if(e=document.querySelectorAll(A),0===e.length)return!1;for(this._addBaselineStyles(),t=document.querySelectorAll("[id]"),o=[].map.call(t,function(A){return A.id}),i=0;i<e.length;i++){if(e[i].hasAttribute("id"))n=e[i].getAttribute("id");else{s=e[i].textContent,a=s.replace(/[^\w\s-]/gi,"").replace(/\s+/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase(),h=a,r=0;do void 0!==l&&(h=a+"-"+r),l=o.indexOf(h),r+=1;while(-1!==l);l=void 0,o.push(h),e[i].setAttribute("id",h),n=h}c=n.replace(/-/g," "),g=document.createElement("a"),g.className="anchorjs-link "+this.options.class,g.href="#"+n,g.setAttribute("aria-label","Anchor link for: "+c),g.setAttribute("data-anchorjs-icon",this.options.icon),"always"===this.options.visible&&(g.style.opacity="1"),""===this.options.icon&&(g.style.fontFamily="anchorjs-icons",g.style.fontStyle="normal",g.style.fontVariant="normal",g.style.fontWeight="normal",g.style.lineHeight=1),"left"===this.options.placement?(g.style.position="absolute",g.style.marginLeft="-1em",g.style.paddingRight="0.5em",e[i].insertBefore(g,e[i].firstChild)):(g.style.paddingLeft="0.375em",e[i].appendChild(g))}return this},this.remove=function(A){for(var e,t=document.querySelectorAll(A),o=0;o<t.length;o++)e=t[o].querySelector(".anchorjs-link"),e&&t[o].removeChild(e);return this},this._addBaselineStyles=function(){if(null===document.head.querySelector("style.anchorjs")){var A,e=document.createElement("style"),t=" .anchorjs-link { opacity: 0; text-decoration: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }",o=" *:hover > .anchorjs-link, .anchorjs-link:focus { opacity: 1; }",n=' @font-face { font-family: "anchorjs-icons"; font-style: normal; font-weight: normal; src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBTUAAAC8AAAAYGNtYXAWi9QdAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zgq29TcAAAF4AAABNGhlYWQEZM3pAAACrAAAADZoaGVhBhUDxgAAAuQAAAAkaG10eASAADEAAAMIAAAAFGxvY2EAKACuAAADHAAAAAxtYXhwAAgAVwAAAygAAAAgbmFtZQ5yJ3cAAANIAAAB2nBvc3QAAwAAAAAFJAAAACAAAwJAAZAABQAAApkCz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yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzVmVyc2lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzUmVndWxhcgBSAGUAZwB1AGwAYQByYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format("truetype"); }',i=" [data-anchorjs-icon]::after { content: attr(data-anchorjs-icon); }";e.className="anchorjs",e.appendChild(document.createTextNode("")),A=document.head.querySelector('[rel="stylesheet"], style'),void 0===A?document.head.appendChild(e):document.head.insertBefore(e,A),e.sheet.insertRule(t,e.sheet.cssRules.length),e.sheet.insertRule(o,e.sheet.cssRules.length),e.sheet.insertRule(i,e.sheet.cssRules.length),e.sheet.insertRule(n,e.sheet.cssRules.length)}}}var anchors=new AnchorJS;
|
@ -4,7 +4,7 @@
|
||||
"../assets/js/vendor/holder.min.js",
|
||||
"assets/js/vendor/jekyll-search.js",
|
||||
"../assets/js/vendor/ZeroClipboard.min.js",
|
||||
"../assets/js/vendor/anchor.js",
|
||||
"../assets/js/vendor/anchor.min.js",
|
||||
"../assets/js/vendor/tether.min.js",
|
||||
"../assets/js/src/application.js"
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user