0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

Merge branch 'docs-anchors'

This commit is contained in:
Mark Otto 2015-01-21 19:20:21 -08:00
commit af9c7151b3
11 changed files with 134 additions and 12 deletions

View File

@ -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'
}

View File

@ -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>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,60 @@
/**
* Store the link icon as a base64 embedded icon font.
*/
@font-face {
font-family: 'anchorjs-link';
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg6v8yoAAAC8AAAAYGNtYXDL8RqdAAABHAAAADxnYXNwAAAAEAAAAVgAAAAIZ2x5Zkm2oNUAAAFgAAABWGhlYWQAHd4cAAACuAAAADZoaGVhB3sECwAAAvAAAAAkaG10eAYAAEcAAAMUAAAADGxvY2EACgCsAAADIAAAAAhtYXhwAAYAcAAAAygAAAAgbmFtZUQXtNYAAANIAAABOXBvc3QAAwAAAAAEhAAAACAAAwQAA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wQTExMTYwcJBgOYJCMjJP6+AwYGBgRQBAcGBwMEExMTE9sTMDIxEwQTExMTYwcJBgOYJCMjJAQjWV1aI9ojJCQjBAN1BCQjIyTaI1ldWiMEAwYFBQNQAgUFBQMEFDAyMRPaExMTEwQTMTIwE2MQISEiEZkjWl1ZI/7GAwYFBQNQAgUFBQMEFDAyMRPaExMTEwQTMTIwE2MQISEiEZkjWl1ZIwQkIyMk2iNZXVojBAABAAAAAQAAUf+MUF8PPPUACwQAAAAAAM6jTNMAAAAAzqNM0wAAAAADuQN5AAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAARwO5AAEAAAAAAAAAAAAAAAAAAAADAAAAAAIAAAAEAABHAAAAAAAKAKwAAQAAAAMAbgACAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAA4AAAABAAAAAAACAA4ARwABAAAAAAADAA4AJAABAAAAAAAEAA4AVQABAAAAAAAFABYADgABAAAAAAAGAAcAMgABAAAAAAAKACgAYwADAAEECQABAA4AAAADAAEECQACAA4ARwADAAEECQADAA4AJAADAAEECQAEAA4AVQADAAEECQAFABYADgADAAEECQAGAA4AOQADAAEECQAKACgAYwBpAGMAbwBtAG8AbwBuAFYAZQByAHMAaQBvAG4AIAAwAC4AMABpAGMAbwBtAG8AbwBuaWNvbW9vbgBpAGMAbwBtAG8AbwBuAFIAZQBnAHUAbABhAHIAaQBjAG8AbQBvAG8AbgBHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4AAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format('woff');
font-weight: normal;
font-style: normal;
}
.anchorjs-icon {
font-family: 'anchorjs-link';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Icon Rendering */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/**
* Link placement and hover behavior.
*/
.anchorjs-link {
float: left;
width: 1em;
height: 1em;
margin-left: -1.2em;
opacity: 0;
color: inherit;
text-align: center;
}
@media (max-width: 480px) {
.anchorjs-link {
display: none;
}
}
*:hover > .anchorjs-link,
.anchorjs-link:focus {
opacity: .75;
transition: color .16s linear;
}
*:hover > .anchorjs-link:hover {
opacity: 1;
text-decoration: none;
}
.anchorjs-icon {
font-size: 60%;
vertical-align: .2em;
}
.anchorjs-icon:before {
content: "\e600";
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -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
View 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;
}
}

File diff suppressed because one or more lines are too long

View File

@ -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"
]
},