2012-01-28 00:36:37 -08:00
|
|
|
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
|
|
|
|
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++
|
2013-10-17 14:11:40 -07:00
|
|
|
|
2013-10-17 11:33:04 -07:00
|
|
|
/*!
|
2014-01-13 21:58:27 -08:00
|
|
|
* JavaScript for Bootstrap's docs (http://getbootstrap.com)
|
2014-01-07 01:05:24 +01:00
|
|
|
* Copyright 2011-2014 Twitter, Inc.
|
2013-10-17 14:11:40 -07:00
|
|
|
* Licensed under the Creative Commons Attribution 3.0 Unported License. For
|
|
|
|
* details, see http://creativecommons.org/licenses/by/3.0/.
|
2013-10-17 11:33:04 -07:00
|
|
|
*/
|
|
|
|
|
2014-03-17 07:42:05 +02:00
|
|
|
/* global ZeroClipboard */
|
2011-12-21 18:42:43 -08:00
|
|
|
|
2012-01-28 00:36:37 -08:00
|
|
|
!function ($) {
|
2014-03-17 09:12:55 +02:00
|
|
|
'use strict';
|
2011-12-21 18:42:43 -08:00
|
|
|
|
2013-09-18 21:37:55 +03:00
|
|
|
$(function () {
|
2012-01-24 17:13:02 -08:00
|
|
|
|
2014-02-11 00:04:53 -08:00
|
|
|
// Scrollspy
|
2012-08-14 21:06:08 -07:00
|
|
|
var $window = $(window)
|
2013-07-28 22:23:20 -07:00
|
|
|
var $body = $(document.body)
|
2012-08-14 21:06:08 -07:00
|
|
|
|
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')
|
|
|
|
})
|
|
|
|
|
2014-02-11 00:04:53 -08:00
|
|
|
// Kill links
|
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()
|
|
|
|
})
|
|
|
|
|
2014-02-11 00:04:53 -08:00
|
|
|
// Sidenav affixing
|
2013-05-08 21:56:08 -07:00
|
|
|
setTimeout(function () {
|
2014-02-12 11:02:37 -08:00
|
|
|
var $sideBar = $('.bs-docs-sidebar')
|
2013-07-25 23:30:13 -07:00
|
|
|
|
|
|
|
$sideBar.affix({
|
2013-05-08 21:56:08 -07:00
|
|
|
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)
|
2013-12-21 22:59:40 +02:00
|
|
|
},
|
|
|
|
bottom: function () {
|
2014-02-12 11:02:37 -08:00
|
|
|
return (this.bottom = $('.bs-docs-footer').outerHeight(true))
|
2013-07-25 23:30:13 -07:00
|
|
|
}
|
2013-05-08 21:56:08 -07:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}, 100)
|
2012-08-14 21:06:08 -07:00
|
|
|
|
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)
|
|
|
|
|
2014-04-29 15:54:05 -07:00
|
|
|
// theme toggler
|
|
|
|
;(function () {
|
|
|
|
var stylesheetLink = $('#bs-theme-stylesheet')
|
2014-05-22 18:38:43 -07:00
|
|
|
var themeBtn = $('.bs-docs-theme-toggle')
|
2014-06-27 02:08:58 +02:00
|
|
|
|
|
|
|
var activateTheme = function () {
|
|
|
|
stylesheetLink.attr('href', stylesheetLink.attr('data-href'))
|
|
|
|
themeBtn.text('Disable theme preview')
|
|
|
|
localStorage.setItem('previewTheme', true)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (localStorage.getItem('previewTheme')) {
|
|
|
|
activateTheme()
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:54:05 -07:00
|
|
|
themeBtn.click(function () {
|
2014-06-27 02:08:58 +02:00
|
|
|
var href = stylesheetLink.attr('href')
|
2014-04-29 15:56:18 -07:00
|
|
|
if (!href || href.indexOf('data') === 0) {
|
2014-06-27 02:08:58 +02:00
|
|
|
activateTheme()
|
|
|
|
} else {
|
2014-04-29 15:56:18 -07:00
|
|
|
stylesheetLink.attr('href', '')
|
2014-05-22 18:38:43 -07:00
|
|
|
themeBtn.text('Preview theme')
|
2014-06-27 02:08:58 +02:00
|
|
|
localStorage.removeItem('previewTheme')
|
2014-04-29 15:56:18 -07:00
|
|
|
}
|
2014-04-29 15:54:05 -07:00
|
|
|
})
|
|
|
|
})();
|
|
|
|
|
2014-02-11 00:04:53 -08:00
|
|
|
// Tooltip and popover demos
|
2012-06-05 18:25:46 -07:00
|
|
|
$('.tooltip-demo').tooltip({
|
2014-04-18 18:53:05 -07:00
|
|
|
selector: '[data-toggle="tooltip"]',
|
2013-09-18 19:50:02 +03:00
|
|
|
container: 'body'
|
2012-01-28 00:46:04 -08:00
|
|
|
})
|
2014-06-26 11:41:40 -07:00
|
|
|
$('.popover-demo').popover({
|
|
|
|
selector: '[data-toggle="popover"]',
|
|
|
|
container: 'body'
|
|
|
|
})
|
2012-01-26 16:12:34 -08:00
|
|
|
|
2014-06-26 10:52:12 -07:00
|
|
|
// Demos within modals
|
2012-01-28 12:08:41 -08:00
|
|
|
$('.tooltip-test').tooltip()
|
|
|
|
$('.popover-test').popover()
|
2012-01-28 00:46:04 -08:00
|
|
|
|
2014-06-26 11:41:40 -07:00
|
|
|
// Default & dismissible popover demos
|
2014-02-10 21:34:05 -08:00
|
|
|
$('.bs-docs-popover').popover()
|
2014-06-26 13:01:15 -07:00
|
|
|
$('.bs-docs-popover-dismiss').popover({ trigger: 'focus' })
|
2014-02-10 21:34:05 -08:00
|
|
|
|
2014-02-11 00:04:53 -08:00
|
|
|
// Button state demo
|
|
|
|
$('#loading-example-btn').click(function () {
|
|
|
|
var btn = $(this)
|
|
|
|
btn.button('loading')
|
|
|
|
setTimeout(function () {
|
|
|
|
btn.button('reset')
|
|
|
|
}, 3000)
|
2014-02-10 21:34:05 -08:00
|
|
|
})
|
2012-01-28 00:46:04 -08:00
|
|
|
|
2014-02-11 00:04:53 -08:00
|
|
|
|
|
|
|
// Config ZeroClipboard
|
|
|
|
ZeroClipboard.config({
|
2014-03-20 07:26:37 +02:00
|
|
|
moviePath: '/assets/flash/ZeroClipboard.swf',
|
2014-02-11 00:04:53 -08:00
|
|
|
hoverClass: 'btn-clipboard-hover'
|
|
|
|
})
|
|
|
|
|
|
|
|
// Insert copy to clipboard button before .highlight or .bs-example
|
2014-03-17 07:42:05 +02:00
|
|
|
$('.highlight').each(function () {
|
2014-02-11 00:04:53 -08:00
|
|
|
var highlight = $(this)
|
|
|
|
var previous = highlight.prev()
|
|
|
|
var btnHtml = '<div class="zero-clipboard"><span class="btn-clipboard">Copy</span></div>'
|
|
|
|
|
|
|
|
if (previous.hasClass('bs-example')) {
|
|
|
|
previous.before(btnHtml.replace(/btn-clipboard/, 'btn-clipboard with-example'))
|
|
|
|
} else {
|
|
|
|
highlight.before(btnHtml)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
var zeroClipboard = new ZeroClipboard($('.btn-clipboard'))
|
|
|
|
var htmlBridge = $('#global-zeroclipboard-html-bridge')
|
2014-01-08 17:32:35 +05:30
|
|
|
|
|
|
|
// Handlers for ZeroClipboard
|
2014-03-17 07:42:05 +02:00
|
|
|
zeroClipboard.on('load', function () {
|
2014-01-08 17:32:35 +05:30
|
|
|
htmlBridge
|
2014-02-11 00:04:53 -08:00
|
|
|
.data('placement', 'top')
|
|
|
|
.attr('title', 'Copy to clipboard')
|
2014-01-08 17:32:35 +05:30
|
|
|
.tooltip()
|
|
|
|
})
|
|
|
|
|
|
|
|
// Copy to clipboard
|
2014-03-17 07:42:05 +02:00
|
|
|
zeroClipboard.on('dataRequested', function (client) {
|
2014-01-08 17:32:35 +05:30
|
|
|
var highlight = $(this).parent().nextAll('.highlight').first()
|
|
|
|
client.setText(highlight.text())
|
|
|
|
})
|
|
|
|
|
|
|
|
// Notify copy success and reset tooltip title
|
2014-03-17 07:42:05 +02:00
|
|
|
zeroClipboard.on('complete', function () {
|
2014-01-08 17:32:35 +05:30
|
|
|
htmlBridge
|
2014-02-11 00:04:53 -08:00
|
|
|
.attr('title', 'Copied!')
|
2014-01-08 17:32:35 +05:30
|
|
|
.tooltip('fixTitle')
|
|
|
|
.tooltip('show')
|
2014-06-09 23:29:44 -07:00
|
|
|
.attr('title', 'Copy to clipboard')
|
2014-01-08 17:32:35 +05:30
|
|
|
.tooltip('fixTitle')
|
|
|
|
})
|
|
|
|
|
|
|
|
// Notify copy failure
|
2014-03-17 07:42:05 +02:00
|
|
|
zeroClipboard.on('noflash wrongflash', function () {
|
2014-01-08 17:32:35 +05:30
|
|
|
htmlBridge
|
2014-02-11 00:04:53 -08:00
|
|
|
.attr('title', 'Flash required')
|
2014-01-08 17:32:35 +05:30
|
|
|
.tooltip('fixTitle')
|
|
|
|
.tooltip('show')
|
|
|
|
})
|
|
|
|
|
2013-09-18 21:37:55 +03:00
|
|
|
})
|
2012-01-28 00:36:37 -08:00
|
|
|
|
2013-11-26 08:43:26 +01:00
|
|
|
}(jQuery)
|