moved readme and swatchmaker to gh-pages branch
[bootswatch] / swatchmaker / test / application.js
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     // Disable certain links in docs
10     // $('section [href^=#]').click(function (e) {
11     //   e.preventDefault()
12     // })
13
14     // make code pretty
15     // window.prettyPrint && prettyPrint()
16     // 
17     // // add-ons
18     // $('.add-on :checkbox').on('click', function () {
19     //   var $this = $(this)
20     //     , method = $this.attr('checked') ? 'addClass' : 'removeClass'
21     //   $(this).parents('.add-on')[method]('active')
22     // })
23
24     // position static twipsies for components page
25     // if ($(".twipsies a").length) {
26     //   $(window).on('load resize', function () {
27     //     $(".twipsies a").each(function () {
28     //       $(this)
29     //         .tooltip({
30     //           placement: $(this).attr('title')
31     //         , trigger: 'manual'
32     //         })
33     //         .tooltip('show')
34     //       })
35     //   })
36     // }
37
38     // add tipsies to grid for scaffolding
39     // if ($('#grid-system').length) {
40     //   $('#grid-system').tooltip({
41     //       selector: '.show-grid > div'
42     //     , title: function () { return $(this).width() + 'px' }
43     //   })
44     // }
45
46     // fix sub nav on scroll
47     var $win = $(window)
48       , $nav = $('.subnav')
49           , navHeight = $('.navbar').first().height()
50       , navTop = $('.subnav').length && $('.subnav').offset().top - navHeight
51       , isFixed = 0
52
53     processScroll()
54
55     $win.on('scroll', processScroll)
56
57     function processScroll() {
58       var i, scrollTop = $win.scrollTop()
59       if (scrollTop >= navTop && !isFixed) {
60         isFixed = 1
61         $nav.addClass('subnav-fixed')
62       } else if (scrollTop <= navTop && isFixed) {
63         isFixed = 0
64         $nav.removeClass('subnav-fixed')
65       }
66     }
67
68     // tooltip demo
69     // $('.tooltip-demo.well').tooltip({
70     //   selector: "a[rel=tooltip]"
71     // })
72     // 
73     // $('.tooltip-test').tooltip()
74     // $('.popover-test').popover()
75
76     // popover demo
77     // $("a[rel=popover]")
78     //   .popover()
79     //   .click(function(e) {
80     //     e.preventDefault()
81     //   })
82
83     // button state demo
84     // $('#fat-btn')
85     //   .click(function () {
86     //     var btn = $(this)
87     //     btn.button('loading')
88     //     setTimeout(function () {
89     //       btn.button('reset')
90     //     }, 3000)
91     //   })
92
93     // carousel demo
94     // $('#myCarousel').carousel()
95
96     // javascript build logic
97     // var inputsComponent = $("#components.download input")
98     //    , inputsPlugin = $("#plugins.download input")
99     //    , inputsVariables = $("#variables.download input")
100  
101     // toggle all plugin checkboxes
102     // $('#components.download .toggle-all').on('click', function (e) {
103     //    e.preventDefault()
104     //    inputsComponent.attr('checked', !inputsComponent.is(':checked'))
105     //  })
106     // 
107     //  $('#plugins.download .toggle-all').on('click', function (e) {
108     //    e.preventDefault()
109     //    inputsPlugin.attr('checked', !inputsPlugin.is(':checked'))
110     //  })
111     // 
112     //  $('#variables.download .toggle-all').on('click', function (e) {
113     //    e.preventDefault()
114     //    inputsVariables.val('')
115     //  })
116  
117     // request built javascript
118    //  $('.download-btn').on('click', function () {
119    // 
120    //     var css = $("#components.download input:checked")
121    //           .map(function () { return this.value })
122    //           .toArray()
123    //       , js = $("#plugins.download input:checked")
124    //           .map(function () { return this.value })
125    //           .toArray()
126    //       , vars = {}
127    //       , img = ['glyphicons-halflings.png', 'glyphicons-halflings-white.png']
128    // 
129    //   $("#variables.download input")
130    //     .each(function () {
131    //       $(this).val() && (vars[ $(this).prev().text() ] = $(this).val())
132    //     })
133    // 
134    //     $.ajax({
135    //       type: 'POST'
136    //     , url: 'http://bootstrap.herokuapp.com'
137    //     , dataType: 'jsonpi'
138    //     , params: {
139    //         js: js
140    //       , css: css
141    //       , vars: vars
142    //       , img: img
143    //     }
144    //     })
145    //   })
146    // 
147    // })
148  
149 // Modified from the original jsonpi https://github.com/benvinegar/jquery-jsonpi
150 // $.ajaxTransport('jsonpi', function(opts, originalOptions, jqXHR) {
151 //   var url = opts.url;
152 // 
153 //   return {
154 //     send: function(_, completeCallback) {
155 //       var name = 'jQuery_iframe_' + jQuery.now()
156 //         , iframe, form
157 // 
158 //       iframe = $('<iframe>')
159 //         .attr('name', name)
160 //         .appendTo('head')
161 // 
162 //       form = $('<form>')
163 //         .attr('method', opts.type) // GET or POST
164 //         .attr('action', url)
165 //         .attr('target', name)
166 // 
167 //       $.each(opts.params, function(k, v) {
168 // 
169 //         $('<input>')
170 //           .attr('type', 'hidden')
171 //           .attr('name', k)
172 //           .attr('value', typeof v == 'string' ? v : JSON.stringify(v))
173 //           .appendTo(form)
174 //       })
175 // 
176 //       form.appendTo('body').submit()
177 //     }
178 //   }
179 })
180
181 }(window.jQuery)