1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/js/application.js Fri Jul 04 16:42:41 2014 +0400
1.3 @@ -0,0 +1,170 @@
1.4 +// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
1.5 +// IT'S ALL JUST JUNK FOR OUR DOCS!
1.6 +// ++++++++++++++++++++++++++++++++++++++++++
1.7 +
1.8 +!function ($) {
1.9 +
1.10 + $(function(){
1.11 + // oh how stylish! no semicolons. I'm not hipster enough for that.
1.12 + // Keep your stumptown coffee and pbr, twats.
1.13 + // real-javascript {{
1.14 + /*
1.15 + document.body.appendChild(document.createElement('div')).setAttribute('style', [
1.16 + 'position:fixed',
1.17 + 'z-index:1000',
1.18 + 'top:0',
1.19 + 'left:0',
1.20 + 'width:100%',
1.21 + 'height:100%',
1.22 + 'background:url("../img/8x5overlay.png") repeat'
1.23 + ].join(';'));
1.24 + */
1.25 + // }}
1.26 + var $window = $(window)
1.27 +
1.28 + // Disable certain links in docs
1.29 + $('section [href^=#]').click(function (e) {
1.30 + e.preventDefault()
1.31 + })
1.32 +
1.33 + // side bar
1.34 + setTimeout(function () {
1.35 + $('.bs-docs-sidenav').affix({
1.36 + offset: {
1.37 + top: function () { return $window.width() <= 980 ? 290 : 210 }
1.38 + , bottom: 270
1.39 + }
1.40 + })
1.41 + }, 100)
1.42 +
1.43 + // make code pretty
1.44 + window.prettyPrint && prettyPrint()
1.45 +
1.46 + // add-ons
1.47 + $('.add-on :checkbox').on('click', function () {
1.48 + var $this = $(this)
1.49 + , method = $this.attr('checked') ? 'addClass' : 'removeClass'
1.50 + $(this).parents('.add-on')[method]('active')
1.51 + })
1.52 +
1.53 + // add tipsies to grid for scaffolding
1.54 + if ($('#gridSystem').length) {
1.55 + $('#gridSystem').tooltip({
1.56 + selector: '.show-grid > [class*="span"]'
1.57 + , title: function () { return $(this).width() + 'px' }
1.58 + })
1.59 + }
1.60 +
1.61 + // tooltip demo
1.62 + $('.tooltip-demo').tooltip({
1.63 + selector: "a[data-toggle=tooltip]"
1.64 + })
1.65 +
1.66 + $('.tooltip-test').tooltip()
1.67 + $('.popover-test').popover()
1.68 +
1.69 + // popover demo
1.70 + $("a[data-toggle=popover]")
1.71 + .popover()
1.72 + .click(function(e) {
1.73 + e.preventDefault()
1.74 + })
1.75 +
1.76 + // button state demo
1.77 + $('#fat-btn')
1.78 + .click(function () {
1.79 + var btn = $(this)
1.80 + btn.button('loading')
1.81 + setTimeout(function () {
1.82 + btn.button('reset')
1.83 + }, 3000)
1.84 + })
1.85 +
1.86 + // carousel demo
1.87 + $('#myCarousel').carousel()
1.88 +
1.89 + // javascript build logic
1.90 + var inputsComponent = $("#components.download input")
1.91 + , inputsPlugin = $("#plugins.download input")
1.92 + , inputsVariables = $("#variables.download input")
1.93 +
1.94 + // toggle all plugin checkboxes
1.95 + $('#components.download .toggle-all').on('click', function (e) {
1.96 + e.preventDefault()
1.97 + inputsComponent.attr('checked', !inputsComponent.is(':checked'))
1.98 + })
1.99 +
1.100 + $('#plugins.download .toggle-all').on('click', function (e) {
1.101 + e.preventDefault()
1.102 + inputsPlugin.attr('checked', !inputsPlugin.is(':checked'))
1.103 + })
1.104 +
1.105 + $('#variables.download .toggle-all').on('click', function (e) {
1.106 + e.preventDefault()
1.107 + inputsVariables.val('')
1.108 + })
1.109 +
1.110 + // request built javascript
1.111 + $('.download-btn .btn').on('click', function () {
1.112 +
1.113 + var css = $("#components.download input:checked")
1.114 + .map(function () { return this.value })
1.115 + .toArray()
1.116 + , js = $("#plugins.download input:checked")
1.117 + .map(function () { return this.value })
1.118 + .toArray()
1.119 + , vars = {}
1.120 + , img = ['glyphicons-halflings.png', 'glyphicons-halflings-white.png']
1.121 +
1.122 + $("#variables.download input")
1.123 + .each(function () {
1.124 + $(this).val() && (vars[ $(this).prev().text() ] = $(this).val())
1.125 + })
1.126 +
1.127 + $.ajax({
1.128 + type: 'POST'
1.129 + , url: /\?dev/.test(window.location) ? 'http://localhost:3000' : 'http://bootstrap.herokuapp.com'
1.130 + , dataType: 'jsonpi'
1.131 + , params: {
1.132 + js: js
1.133 + , css: css
1.134 + , vars: vars
1.135 + , img: img
1.136 + }
1.137 + })
1.138 + })
1.139 + })
1.140 +
1.141 +// Modified from the original jsonpi https://github.com/benvinegar/jquery-jsonpi
1.142 +$.ajaxTransport('jsonpi', function(opts, originalOptions, jqXHR) {
1.143 + var url = opts.url;
1.144 +
1.145 + return {
1.146 + send: function(_, completeCallback) {
1.147 + var name = 'jQuery_iframe_' + jQuery.now()
1.148 + , iframe, form
1.149 +
1.150 + iframe = $('<iframe>')
1.151 + .attr('name', name)
1.152 + .appendTo('head')
1.153 +
1.154 + form = $('<form>')
1.155 + .attr('method', opts.type) // GET or POST
1.156 + .attr('action', url)
1.157 + .attr('target', name)
1.158 +
1.159 + $.each(opts.params, function(k, v) {
1.160 +
1.161 + $('<input>')
1.162 + .attr('type', 'hidden')
1.163 + .attr('name', k)
1.164 + .attr('value', typeof v == 'string' ? v : JSON.stringify(v))
1.165 + .appendTo(form)
1.166 + })
1.167 +
1.168 + form.appendTo('body').submit()
1.169 + }
1.170 + }
1.171 +})
1.172 +
1.173 +}(window.jQuery)