1// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT 2// IT'S ALL JUST JUNK FOR OUR DOCS! 3// ++++++++++++++++++++++++++++++++++++++++++ 4 5!function ($) { 6 7 $(function(){ 8 9 10 // tooltips 11 $('a[rel=tooltip]').tooltip() 12 13 // popovers 14 $("a[rel=popover]").popover() 15 16 // make code pretty 17 window.prettyPrint && prettyPrint() 18 19 // add-ons 20 $('.add-on :checkbox').on('click', function () { 21 var $this = $(this) 22 , method = $this.attr('checked') ? 'addClass' : 'removeClass' 23 $(this).parents('.add-on')[method]('active') 24 }) 25 26 // position static twipsies for components page 27 if ($(".twipsies a").length) { 28 $(window).on('load resize', function () { 29 $(".twipsies a").each(function () { 30 $(this) 31 .tooltip({ 32 placement: $(this).attr('title') 33 , trigger: 'manual' 34 }) 35 .tooltip('show') 36 }) 37 }) 38 } 39 40 // add tipsies to grid for scaffolding 41 if ($('#grid-system').length) { 42 $('#grid-system').tooltip({ 43 selector: '.show-grid > div' 44 , title: function () { return $(this).width() + 'px' } 45 }) 46 } 47 48 // fix sub nav on scroll 49 var $win = $(window) 50 , $nav = $('.subnav') 51 , navTop = $('.subnav').length && $('.subnav').offset().top - 40 52 , isFixed = 0 53 54 processScroll() 55 56 // hack sad times - holdover until rewrite for 2.1 57 $nav.on('click', function () { 58 if (!isFixed) setTimeout(function () { $win.scrollTop($win.scrollTop() - 47) }, 10) 59 }) 60 61 $win.on('scroll', processScroll) 62 63 function processScroll() { 64 var i, scrollTop = $win.scrollTop() 65 if (scrollTop >= navTop && !isFixed) { 66 isFixed = 1 67 $nav.addClass('subnav-fixed') 68 } else if (scrollTop <= navTop && isFixed) { 69 isFixed = 0 70 $nav.removeClass('subnav-fixed') 71 } 72 } 73 74 75 // button state demo 76 $('#fat-btn') 77 .click(function () { 78 var btn = $(this) 79 btn.button('loading') 80 setTimeout(function () { 81 btn.button('reset') 82 }, 3000) 83 }) 84 85 // carousel demo 86 $('#myCarousel').carousel() 87 88 // javascript build logic 89 var inputsComponent = $("#components.download input") 90 , inputsPlugin = $("#plugins.download input") 91 , inputsVariables = $("#variables.download input") 92 93 // toggle all plugin checkboxes 94 $('#components.download .toggle-all').on('click', function (e) { 95 e.preventDefault() 96 inputsComponent.attr('checked', !inputsComponent.is(':checked')) 97 }) 98 99 $('#plugins.download .toggle-all').on('click', function (e) { 100 e.preventDefault() 101 inputsPlugin.attr('checked', !inputsPlugin.is(':checked')) 102 }) 103 104 $('#variables.download .toggle-all').on('click', function (e) { 105 e.preventDefault() 106 inputsVariables.val('') 107 }) 108 109 // request built javascript 110 $('.download-btn').on('click', function () { 111 112 var css = $("#components.download input:checked") 113 .map(function () { return this.value }) 114 .toArray() 115 , js = $("#plugins.download input:checked") 116 .map(function () { return this.value }) 117 .toArray() 118 , vars = {} 119 , img = ['glyphicons-halflings.png', 'glyphicons-halflings-white.png'] 120 121 $("#variables.download input") 122 .each(function () { 123 $(this).val() && (vars[ $(this).prev().text() ] = $(this).val()) 124 }) 125 126 $.ajax({
127 type: 'POST' 128 , url: /\?dev/.test(window.location) ? 'http://localhost:3000' : 'http://bootstrap.herokuapp.com' 129 , dataType: 'jsonpi' 130 , params: { 131 js: js 132 , css: css 133 , vars: vars 134 , img: img 135 } 136 }) 137 }) 138 }) 139 140// Modified from the original jsonpi https://github.com/benvinegar/jquery-jsonpi 141$.ajaxTransport('jsonpi', function(opts, originalOptions, jqXHR) { 142 var url = opts.url; 143 144 return { 145 send: function(_, completeCallback) { 146 var name = 'jQuery_iframe_' + jQuery.now() 147 , iframe, form 148 149 iframe = $('<iframe>') 150 .attr('name', name) 151 .appendTo('head') 152 153 form = $('<form>') 154 .attr('method', opts.type) // GET or POST 155 .attr('action', url) 156 .attr('target', name) 157 158 $.each(opts.params, function(k, v) { 159 160 $('<input>') 161 .attr('type', 'hidden') 162 .attr('name', k) 163 .attr('value', typeof v == 'string' ? v : JSON.stringify(v)) 164 .appendTo(form) 165 }) 166 167 form.appendTo('body').submit() 168 } 169 } 170}) 171 172}(window.jQuery)
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.