2012-01-28 00:36:37 -08:00
|
|
|
// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
|
|
|
|
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
|
|
|
// ++++++++++++++++++++++++++++++++++++++++++
|
2011-12-21 18:42:43 -08:00
|
|
|
|
2012-01-28 00:36:37 -08:00
|
|
|
!function ($) {
|
2011-12-21 18:42:43 -08:00
|
|
|
|
2012-01-28 00:36:37 -08:00
|
|
|
$(function(){
|
2012-01-24 17:13:02 -08:00
|
|
|
|
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-26 19:25:45 -07:00
|
|
|
var navHeight = $('.navbar').outerHeight(true) + 10
|
|
|
|
|
2013-07-28 22:23:20 -07:00
|
|
|
$body.scrollspy({
|
2013-07-26 19:25:45 -07:00
|
|
|
target: '.bs-sidebar',
|
|
|
|
offset: navHeight
|
|
|
|
})
|
|
|
|
|
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-07-28 22:23:20 -07:00
|
|
|
$body.on('click', '.bs-sidenav [href^=#]', function (e) {
|
2013-07-26 19:25:45 -07:00
|
|
|
var $target = $(this.getAttribute('href'))
|
|
|
|
|
2013-07-28 22:23:20 -07:00
|
|
|
e.preventDefault() // prevent browser scroll
|
2013-07-26 19:25:45 -07:00
|
|
|
|
2013-07-28 22:23:20 -07:00
|
|
|
$window.scrollTop($target.offset().top - navHeight + 5)
|
2013-07-26 19:25:45 -07:00
|
|
|
})
|
2013-07-25 23:30:13 -07:00
|
|
|
|
2013-03-30 18:41:26 -07:00
|
|
|
// back to top
|
2013-05-08 21:56:08 -07:00
|
|
|
setTimeout(function () {
|
2013-07-25 23:30:13 -07:00
|
|
|
var $sideBar = $('.bs-sidebar')
|
|
|
|
|
|
|
|
$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)
|
|
|
|
}
|
|
|
|
, bottom: function () {
|
|
|
|
return (this.bottom = $('.bs-footer').outerHeight(true))
|
|
|
|
}
|
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)
|
|
|
|
|
2012-01-28 00:46:04 -08:00
|
|
|
// tooltip demo
|
2012-06-05 18:25:46 -07:00
|
|
|
$('.tooltip-demo').tooltip({
|
2013-07-25 11:55:12 -07:00
|
|
|
selector: "[data-toggle=tooltip]"
|
2012-01-28 00:46:04 -08:00
|
|
|
})
|
2012-01-26 16:12:34 -08:00
|
|
|
|
2012-01-28 12:08:41 -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]",
|
|
|
|
container: ".bs-docs-navbar .nav"
|
|
|
|
})
|
|
|
|
|
2012-01-28 00:46:04 -08:00
|
|
|
// popover demo
|
2013-07-26 19:50:02 -07:00
|
|
|
$("[data-toggle=popover]")
|
2012-01-28 00:46:04 -08:00
|
|
|
.popover()
|
|
|
|
|
|
|
|
// button state demo
|
|
|
|
$('#fat-btn')
|
|
|
|
.click(function () {
|
|
|
|
var btn = $(this)
|
|
|
|
btn.button('loading')
|
|
|
|
setTimeout(function () {
|
|
|
|
btn.button('reset')
|
|
|
|
}, 3000)
|
|
|
|
})
|
|
|
|
|
|
|
|
// carousel demo
|
2013-02-16 02:47:15 -08:00
|
|
|
$('.bs-docs-carousel-example').carousel()
|
2012-01-28 00:46:04 -08:00
|
|
|
|
|
|
|
// javascript build logic
|
2013-05-23 21:34:32 -07:00
|
|
|
var inputsComponent = $("#less input")
|
2013-05-22 23:34:28 -07:00
|
|
|
, inputsPlugin = $("#plugins input")
|
2013-06-12 12:51:10 -06:00
|
|
|
, inputsVariables = $("#less-variables input")
|
2012-01-28 00:46:04 -08:00
|
|
|
|
|
|
|
// toggle all plugin checkboxes
|
2013-06-12 12:51:10 -06:00
|
|
|
$('#less .toggle').on('click', function (e) {
|
2012-01-28 00:46:04 -08:00
|
|
|
e.preventDefault()
|
2013-05-22 23:34:28 -07:00
|
|
|
inputsComponent.prop('checked', !inputsComponent.is(':checked'))
|
2012-01-28 00:46:04 -08:00
|
|
|
})
|
|
|
|
|
2013-05-22 23:34:28 -07:00
|
|
|
$('#plugins .toggle').on('click', function (e) {
|
2012-01-28 00:46:04 -08:00
|
|
|
e.preventDefault()
|
2013-05-22 23:34:28 -07:00
|
|
|
inputsPlugin.prop('checked', !inputsPlugin.is(':checked'))
|
2012-01-28 00:46:04 -08:00
|
|
|
})
|
|
|
|
|
2013-06-12 12:51:10 -06:00
|
|
|
$('#less-variables .toggle').on('click', function (e) {
|
2012-01-28 00:46:04 -08:00
|
|
|
e.preventDefault()
|
|
|
|
inputsVariables.val('')
|
|
|
|
})
|
|
|
|
|
|
|
|
// request built javascript
|
2013-06-12 13:40:37 -06:00
|
|
|
$('.bs-customize-download .btn').on('click', function (e) {
|
|
|
|
e.preventDefault()
|
2012-01-28 00:46:04 -08:00
|
|
|
|
2013-06-12 13:40:37 -06:00
|
|
|
var css = $("#less input:checked")
|
2012-01-28 00:46:04 -08:00
|
|
|
.map(function () { return this.value })
|
|
|
|
.toArray()
|
2013-05-22 23:34:28 -07:00
|
|
|
, js = $("#plugins input:checked")
|
2012-01-28 00:46:04 -08:00
|
|
|
.map(function () { return this.value })
|
|
|
|
.toArray()
|
|
|
|
, vars = {}
|
|
|
|
|
2013-06-12 13:40:37 -06:00
|
|
|
$("#less-variables input")
|
|
|
|
.each(function () {
|
|
|
|
$(this).val() && (vars[ $(this).prev().text() ] = $(this).val())
|
2012-01-28 00:46:04 -08:00
|
|
|
})
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST'
|
2013-06-12 13:40:37 -06:00
|
|
|
, url: /localhost/.test(window.location) ? 'http://localhost:9001' : 'http://bootstrap.herokuapp.com'
|
2012-01-28 00:46:04 -08:00
|
|
|
, dataType: 'jsonpi'
|
|
|
|
, params: {
|
2012-02-01 22:30:51 -08:00
|
|
|
js: js
|
2012-01-28 00:46:04 -08:00
|
|
|
, css: css
|
|
|
|
, vars: vars
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// Modified from the original jsonpi https://github.com/benvinegar/jquery-jsonpi
|
|
|
|
$.ajaxTransport('jsonpi', function(opts, originalOptions, jqXHR) {
|
|
|
|
var url = opts.url;
|
|
|
|
|
|
|
|
return {
|
|
|
|
send: function(_, completeCallback) {
|
|
|
|
var name = 'jQuery_iframe_' + jQuery.now()
|
|
|
|
, iframe, form
|
|
|
|
|
|
|
|
iframe = $('<iframe>')
|
|
|
|
.attr('name', name)
|
|
|
|
.appendTo('head')
|
|
|
|
|
|
|
|
form = $('<form>')
|
|
|
|
.attr('method', opts.type) // GET or POST
|
|
|
|
.attr('action', url)
|
|
|
|
.attr('target', name)
|
|
|
|
|
|
|
|
$.each(opts.params, function(k, v) {
|
|
|
|
|
|
|
|
$('<input>')
|
|
|
|
.attr('type', 'hidden')
|
|
|
|
.attr('name', k)
|
|
|
|
.attr('value', typeof v == 'string' ? v : JSON.stringify(v))
|
|
|
|
.appendTo(form)
|
|
|
|
})
|
|
|
|
|
|
|
|
form.appendTo('body').submit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2012-01-28 00:36:37 -08:00
|
|
|
|
2012-12-23 06:51:46 -05:00
|
|
|
}(window.jQuery)
|