0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-30 12:24:19 +01:00
Bootstrap/docs/assets/js/application.js

102 lines
2.5 KiB
JavaScript
Raw Normal View History

// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
// IT'S ALL JUST JUNK FOR OUR DOCS!
// ++++++++++++++++++++++++++++++++++++++++++
/*!
* JavaScript for Bootstrap's docs (http://getbootstrap.com)
* Copyright 2011-2014 Twitter, Inc.
* Licensed under the Creative Commons Attribution 3.0 Unported License. For
* details, see http://creativecommons.org/licenses/by/3.0/.
*/
!function ($) {
$(function () {
2012-01-25 02:13:02 +01:00
// IE10 viewport hack for Surface/desktop Windows 8 bug
//
// See Getting Started docs for more information
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement('style')
msViewportStyle.appendChild(
document.createTextNode(
2013-09-18 18:50:02 +02:00
'@-ms-viewport{width:auto!important}'
)
)
document.querySelector('head').appendChild(msViewportStyle)
}
var $window = $(window)
2013-07-29 07:23:20 +02:00
var $body = $(document.body)
2013-07-27 04:25:45 +02:00
var navHeight = $('.navbar').outerHeight(true) + 10
2013-07-29 07:23:20 +02:00
$body.scrollspy({
2013-07-27 04:25:45 +02:00
target: '.bs-sidebar',
2014-01-10 03:05:04 +01:00
// offset: navHeight
2013-07-27 04:25:45 +02:00
})
2013-08-12 00:03:48 +02:00
$window.on('load', function () {
$body.scrollspy('refresh')
})
2013-07-29 07:14:43 +02:00
$('.bs-docs-container [href=#]').click(function (e) {
2012-01-23 23:14:16 +01:00
e.preventDefault()
})
2013-03-31 03:41:26 +02:00
// back to top
setTimeout(function () {
2013-07-26 08:30:13 +02:00
var $sideBar = $('.bs-sidebar')
$sideBar.affix({
offset: {
2013-07-26 08:30:13 +02:00
top: function () {
var offsetTop = $sideBar.offset().top
var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10)
var navOuterHeight = $('.bs-docs-nav').height()
return (this.top = offsetTop - navOuterHeight - sideBarMargin)
},
bottom: function () {
2013-07-26 08:30:13 +02:00
return (this.bottom = $('.bs-footer').outerHeight(true))
}
}
})
}, 100)
2013-03-31 03:41:26 +02:00
setTimeout(function () {
2013-05-09 07:52:48 +02:00
$('.bs-top').affix()
2013-03-31 03:41:26 +02:00
}, 100)
2012-01-28 09:46:04 +01:00
// tooltip demo
$('.tooltip-demo').tooltip({
2013-09-18 18:50:02 +02:00
selector: '[data-toggle=tooltip]',
container: 'body'
2012-01-28 09:46:04 +01:00
})
$('.tooltip-test').tooltip()
$('.popover-test').popover()
2012-01-28 09:46:04 +01:00
2013-03-28 07:33:45 +01:00
$('.bs-docs-navbar').tooltip({
2013-09-18 18:50:02 +02:00
selector: 'a[data-toggle=tooltip]',
container: '.bs-docs-navbar .nav'
2013-03-28 07:33:45 +01:00
})
2012-01-28 09:46:04 +01:00
// popover demo
2013-12-13 03:10:58 +01:00
$('[data-toggle=popover]').popover()
2012-01-28 09:46:04 +01:00
// button state demo
$('#loading-example-btn')
2012-01-28 09:46:04 +01:00
.click(function () {
var btn = $(this)
btn.button('loading')
setTimeout(function () {
btn.button('reset')
}, 3000)
})
})
2013-11-26 08:43:26 +01:00
}(jQuery)