mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-28 10:24:19 +01:00
Add AnchorJS for docs anchors.
This commit is contained in:
parent
d5a2b27e16
commit
3f512c927b
@ -191,7 +191,7 @@ module.exports = function (grunt) {
|
||||
src: 'dist/css/<%= pkg.name %>-theme.css'
|
||||
},
|
||||
docs: {
|
||||
src: 'docs/assets/css/src/docs.css'
|
||||
src: ['docs/assets/css/anchor.css', 'docs/assets/css/src/docs.css']
|
||||
},
|
||||
examples: {
|
||||
expand: true,
|
||||
@ -237,8 +237,10 @@ module.exports = function (grunt) {
|
||||
},
|
||||
docs: {
|
||||
src: [
|
||||
'docs/assets/css/src/docs.css',
|
||||
'docs/assets/css/src/pygments-manni.css'
|
||||
'docs/assets/css/src/pygments-manni.css',
|
||||
'docs/assets/css/src/anchor.css',
|
||||
'docs/assets/css/src/docs.css'
|
||||
|
||||
],
|
||||
dest: 'docs/assets/css/docs.min.css'
|
||||
}
|
||||
|
@ -32,8 +32,9 @@
|
||||
{% if site.github %}
|
||||
<link href="../assets/css/docs.min.css" rel="stylesheet">
|
||||
{% else %}
|
||||
<link href="../assets/css/src/docs.css" rel="stylesheet">
|
||||
<link href="../assets/css/src/pygments-manni.css" rel="stylesheet">
|
||||
<link href="../assets/css/src/anchor.css" rel="stylesheet">
|
||||
<link href="../assets/css/src/docs.css" rel="stylesheet">
|
||||
{% endif %}
|
||||
<!--[if lt IE 9]><script src="../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
|
||||
<script src="../assets/js/ie-emulation-modes-warning.js"></script>
|
||||
|
4
docs/assets/css/docs.min.css
vendored
4
docs/assets/css/docs.min.css
vendored
File diff suppressed because one or more lines are too long
65
docs/assets/css/src/anchor.css
Normal file
65
docs/assets/css/src/anchor.css
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Store the link icon as a base64 embedded icon font.
|
||||
*/
|
||||
@font-face {
|
||||
font-family: 'anchorjs-icons';
|
||||
src: url(data:application/x-font-ttf;charset=utf-8;base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kAYwBvAE0AbwBvAG4AAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format('woff');
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
}
|
||||
.anchorjs-icon {
|
||||
font-family: 'anchorjs-icons';
|
||||
font-style: normal;
|
||||
font-variant: normal;
|
||||
font-weight: normal;
|
||||
line-height: 1;
|
||||
speak: none;
|
||||
text-transform: none;
|
||||
|
||||
/* Better Icon Rendering */
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Link placement and hover behavior.
|
||||
*/
|
||||
.anchorjs-link {
|
||||
opacity: 0;
|
||||
text-decoration: none;
|
||||
}
|
||||
*:hover > .anchorjs-link,
|
||||
.anchorjs-link:focus {
|
||||
/* To fade links as they appear, change transition-property from 'color' to 'all' */
|
||||
opacity: 1;
|
||||
-webkit-transition: color .16s linear;
|
||||
-moz-transition: color .16s linear;
|
||||
-o-transition: color .16s linear;
|
||||
transition: color .16s linear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reasonable default styles.
|
||||
* Feel free to override or replace these with your own.
|
||||
*/
|
||||
.anchorjs-link:link { color: #DFD487; }
|
||||
.anchorjs-link:visited { color: #DFD487; }
|
||||
.anchorjs-link:hover { color: #EC7963; }
|
||||
.anchorjs-link:active { color: #EC7963; }
|
||||
|
||||
.anchorjs-icon {
|
||||
font-size: 90%;
|
||||
padding-left: 6px;
|
||||
}
|
||||
|
||||
.anchorjs-icon:before {
|
||||
content: '\e600';
|
||||
/* alternative icons -- uncomment to use */
|
||||
/*
|
||||
content: '#';
|
||||
content: '¶';
|
||||
content: '❡';
|
||||
content: '§';
|
||||
*/
|
||||
}
|
@ -1578,3 +1578,12 @@ h1[id] {
|
||||
-webkit-box-shadow: 0 0 8px rgba(82,168,236,.6);
|
||||
box-shadow: 0 0 8px rgba(82,168,236,.6);
|
||||
}
|
||||
|
||||
/* AnchorJS overrides */
|
||||
.anchorjs-link:link,
|
||||
.anchorjs-link:visited,
|
||||
.anchorjs-link:hover,
|
||||
.anchorjs-link:active {
|
||||
color: #563d7c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
9
docs/assets/js/docs.min.js
vendored
9
docs/assets/js/docs.min.js
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@
|
||||
* details, see http://creativecommons.org/licenses/by/3.0/.
|
||||
*/
|
||||
|
||||
/* global ZeroClipboard */
|
||||
/* global ZeroClipboard, addAnchors */
|
||||
|
||||
!function ($) {
|
||||
'use strict';
|
||||
@ -174,3 +174,8 @@
|
||||
})
|
||||
|
||||
}(jQuery)
|
||||
|
||||
;(function () {
|
||||
'use strict';
|
||||
addAnchors('.bs-docs-container h1, .bs-docs-container h2, .bs-docs-container h3, .bs-docs-container h4, .bs-docs-container h5');
|
||||
})();
|
||||
|
48
docs/assets/js/vendor/anchor.js
vendored
Normal file
48
docs/assets/js/vendor/anchor.js
vendored
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
"docsJs": [
|
||||
"../assets/js/vendor/holder.js",
|
||||
"../assets/js/vendor/ZeroClipboard.min.js",
|
||||
"../assets/js/vendor/anchor.js",
|
||||
"../assets/js/src/application.js"
|
||||
]
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user