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
+ , navTop = $ ( '.subnav' ) . length && $ ( '.subnav' ) . offset ( ) . top - 40
50
+ , isFixed = 0
51
+
52
+ processScroll ( )
53
+
54
+ $win . on ( 'scroll' , processScroll )
55
+
56
+ function processScroll ( ) {
57
+ var i , scrollTop = $win . scrollTop ( )
58
+ if ( scrollTop >= navTop && ! isFixed ) {
59
+ isFixed = 1
60
+ $nav . addClass ( 'subnav-fixed' )
61
+ } else if ( scrollTop <= navTop && isFixed ) {
62
+ isFixed = 0
63
+ $nav . removeClass ( 'subnav-fixed' )
64
+ }
65
+ }
66
+
67
+ // tooltip demo
68
+ $ ( '.tooltip-demo.well' ) . tooltip ( {
69
+ selector : "a[rel=tooltip]"
70
+ } )
71
+
72
+ $ ( '.tooltip-test' ) . tooltip ( )
73
+ $ ( '.popover-test' ) . popover ( )
74
+
75
+ // popover demo
76
+ $ ( "a[rel=popover]" )
77
+ . popover ( )
78
+ . click ( function ( e ) {
79
+ e . preventDefault ( )
80
+ } )
81
+
82
+ // button state demo
83
+ $ ( '#fat-btn' )
84
+ . click ( function ( ) {
85
+ var btn = $ ( this )
86
+ btn . button ( 'loading' )
87
+ setTimeout ( function ( ) {
88
+ btn . button ( 'reset' )
89
+ } , 3000 )
90
+ } )
91
+
92
+ // carousel demo
93
+ $ ( '#myCarousel' ) . carousel ( )
94
+
95
+ // javascript build logic
96
+ var inputsComponent = $ ( "#components.download input" )
97
+ , inputsPlugin = $ ( "#plugins.download input" )
98
+ , inputsVariables = $ ( "#variables.download input" )
99
+
100
+ // toggle all plugin checkboxes
101
+ $ ( '#components.download .toggle-all' ) . on ( 'click' , function ( e ) {
102
+ e . preventDefault ( )
103
+ inputsComponent . attr ( 'checked' , ! inputsComponent . is ( ':checked' ) )
104
+ } )
105
+
106
+ $ ( '#plugins.download .toggle-all' ) . on ( 'click' , function ( e ) {
107
+ e . preventDefault ( )
108
+ inputsPlugin . attr ( 'checked' , ! inputsPlugin . is ( ':checked' ) )
109
+ } )
110
+
111
+ $ ( '#variables.download .toggle-all' ) . on ( 'click' , function ( e ) {
112
+ e . preventDefault ( )
113
+ inputsVariables . val ( '' )
114
+ } )
115
+
116
+ // request built javascript
117
+ $ ( '.download-btn' ) . on ( 'click' , function ( ) {
118
+
119
+ var css = $ ( "#components.download input:checked" )
120
+ . map ( function ( ) { return this . value } )
121
+ . toArray ( )
122
+ , js = $ ( "#plugins.download input:checked" )
123
+ . map ( function ( ) { return this . value } )
124
+ . toArray ( )
125
+ , vars = { }
126
+ , img = [ 'glyphicons-halflings.png' , 'glyphicons-halflings-white.png' ]
127
+
128
+ $ ( "#variables.download input" )
129
+ . each ( function ( ) {
130
+ $ ( this ) . val ( ) && ( vars [ $ ( this ) . prev ( ) . text ( ) ] = $ ( this ) . val ( ) )
131
+ } )
132
+
133
+ $ . ajax ( {
134
+ type : 'POST'
135
+ , url : 'http://bootstrap.herokuapp.com'
136
+ , dataType : 'jsonpi'
137
+ , params : {
138
+ js : js
139
+ , css : css
140
+ , vars : vars
141
+ , img : img
142
+ }
143
+ } )
144
+ } )
145
+
146
+ } )
147
+
148
+ // Modified from the original jsonpi https://github.com/benvinegar/jquery-jsonpi
149
+ $ . ajaxTransport ( 'jsonpi' , function ( opts , originalOptions , jqXHR ) {
150
+ var url = opts . url ;
151
+
152
+ return {
153
+ send : function ( _ , completeCallback ) {
154
+ var name = 'jQuery_iframe_' + jQuery . now ( )
155
+ , iframe , form
156
+
157
+ iframe = $ ( '<iframe>' )
158
+ . attr ( 'name' , name )
159
+ . appendTo ( 'head' )
160
+
161
+ form = $ ( '<form>' )
162
+ . attr ( 'method' , opts . type ) // GET or POST
163
+ . attr ( 'action' , url )
164
+ . attr ( 'target' , name )
165
+
166
+ $ . each ( opts . params , function ( k , v ) {
167
+
168
+ $ ( '<input>' )
169
+ . attr ( 'type' , 'hidden' )
170
+ . attr ( 'name' , k )
171
+ . attr ( 'value' , typeof v == 'string' ? v : JSON . stringify ( v ) )
172
+ . appendTo ( form )
173
+ } )
174
+
175
+ form . appendTo ( 'body' ) . submit ( )
176
+ }
177
+ }
178
+ } )
179
+
180
+ } ( window . jQuery )
0 commit comments