0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-24 16:52:19 +01:00
Bootstrap/docs/assets/js/_src/application.js

108 lines
2.6 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 ($) {
2014-03-17 09:12:55 +02:00
'use strict';
$(function () {
2012-01-24 17:13:02 -08:00
var $window = $(window)
2013-07-28 22:23:20 -07:00
var $body = $(document.body)
2013-07-28 22:23:20 -07:00
$body.scrollspy({
2014-03-01 18:19:50 +02:00
target: '.bs-docs-sidebar'
2013-07-26 19:25:45 -07:00
})
2013-08-11 15:03:48 -07:00
$window.on('load', function () {
$body.scrollspy('refresh')
})
2013-07-28 22:14:43 -07:00
$('.bs-docs-container [href=#]').click(function (e) {
2012-01-23 14:14:16 -08:00
e.preventDefault()
})
2013-03-30 18:41:26 -07:00
// back to top
setTimeout(function () {
var $sideBar = $('.bs-docs-sidebar')
2013-07-25 23:30:13 -07:00
$sideBar.affix({
offset: {
2013-07-25 23:30:13 -07: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 () {
return (this.bottom = $('.bs-docs-footer').outerHeight(true))
2013-07-25 23:30:13 -07:00
}
}
})
}, 100)
2013-03-30 18:41:26 -07:00
setTimeout(function () {
2013-05-08 22:52:48 -07:00
$('.bs-top').affix()
2013-03-30 18:41:26 -07:00
}, 100)
// theme toggler
;(function () {
var stylesheetLink = $('#bs-theme-stylesheet')
2014-05-22 18:38:43 -07:00
var themeBtn = $('.bs-docs-theme-toggle')
themeBtn.click(function () {
2014-04-29 15:56:18 -07:00
var href = stylesheetLink.attr('href');
if (!href || href.indexOf('data') === 0) {
stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
2014-05-22 18:38:43 -07:00
themeBtn.text('Disable theme preview')
}
2014-04-29 15:56:18 -07:00
else {
stylesheetLink.attr('href', '')
2014-05-22 18:38:43 -07:00
themeBtn.text('Preview theme')
2014-04-29 15:56:18 -07:00
}
})
})();
2012-01-28 00:46:04 -08:00
// tooltip demo
$('.tooltip-demo').tooltip({
selector: '[data-toggle="tooltip"]',
2013-09-18 19:50:02 +03:00
container: 'body'
2012-01-28 00:46:04 -08:00
})
$('.tooltip-test').tooltip()
$('.popover-test').popover()
2012-01-28 00:46:04 -08:00
2013-03-27 23:33:45 -07:00
$('.bs-docs-navbar').tooltip({
selector: 'a[data-toggle="tooltip"]',
2013-09-18 19:50:02 +03:00
container: '.bs-docs-navbar .nav'
2013-03-27 23:33:45 -07:00
})
2012-01-28 00:46:04 -08:00
// popover demo
2014-02-10 21:34:05 -08:00
$('.bs-docs-popover').popover()
// Popover dismiss on next click
$('.bs-docs-popover-dismiss').popover({
trigger: 'focus'
})
2012-01-28 00:46:04 -08:00
// button state demo
$('#loading-example-btn')
2012-01-28 00:46:04 -08:00
.click(function () {
var btn = $(this)
btn.button('loading')
setTimeout(function () {
btn.button('reset')
}, 3000)
})
})
2013-11-26 08:43:26 +01:00
}(jQuery)