bootstrap.js 55.5 KB
Newer Older
fat's avatar
fat committed
1
2
if (!jQuery) { throw new Error("Bootstrap requires jQuery") }

fat's avatar
fat committed
3

4
/* ========================================================================
fat's avatar
fat committed
5
 * Bootstrap: transition.js v3.0.0
Chris Rebert's avatar
Chris Rebert committed
6
 * http://twbs.github.com/bootstrap/javascript.html#transitions
7
 * ========================================================================
fat's avatar
fat committed
8
 * Copyright 2013 Twitter, Inc.
9
10
11
12
13
14
15
16
17
18
19
20
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
21
 * ======================================================================== */
22
23


24
+function ($) { "use strict";
25

fat's avatar
fat committed
26
27
  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  // ============================================================
28

fat's avatar
fat committed
29
  function transitionEnd() {
fat's avatar
fat committed
30
    var el = document.createElement('bootstrap')
31

fat's avatar
fat committed
32
    var transEndEventNames = {
fat's avatar
fat committed
33
34
35
36
37
      'WebkitTransition' : 'webkitTransitionEnd'
    , 'MozTransition'    : 'transitionend'
    , 'OTransition'      : 'oTransitionEnd otransitionend'
    , 'transition'       : 'transitionend'
    }
38

fat's avatar
fat committed
39
40
    for (var name in transEndEventNames) {
      if (el.style[name] !== undefined) {
fat's avatar
fat committed
41
        return { end: transEndEventNames[name] }
42
      }
fat's avatar
fat committed
43
44
    }
  }
45

46
47
48
49
50
51
52
53
  // http://blog.alexmaccaw.com/css-transitions
  $.fn.emulateTransitionEnd = function (duration) {
    var called = false, $el    = this
    $(this).one('webkitTransitionEnd', function () { called = true })
    var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') }
    setTimeout(callback, duration)
  }

fat's avatar
fat committed
54
  $(function () {
fat's avatar
fat committed
55
56
    $.support.transition = transitionEnd()
  })
57

Mark Otto's avatar
Mark Otto committed
58
}(window.jQuery);
59
/* ========================================================================
fat's avatar
fat committed
60
 * Bootstrap: alert.js v3.0.0
Chris Rebert's avatar
Chris Rebert committed
61
 * http://twbs.github.com/bootstrap/javascript.html#alerts
62
 * ========================================================================
fat's avatar
fat committed
63
 * Copyright 2013 Twitter, Inc.
64
65
66
67
68
69
70
71
72
73
74
75
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
76
 * ======================================================================== */
77
78


79
+function ($) { "use strict";
80

fat's avatar
fat committed
81
82
  // ALERT CLASS DEFINITION
  // ======================
83
84

  var dismiss = '[data-dismiss="alert"]'
fat's avatar
fat committed
85
86
87
  var Alert   = function (el) {
    $(el).on('click', dismiss, this.close)
  }
88
89

  Alert.prototype.close = function (e) {
fat's avatar
fat committed
90
91
    var $this    = $(this)
    var selector = $this.attr('data-target')
92
93
94

    if (!selector) {
      selector = $this.attr('href')
fat's avatar
fat committed
95
      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
96
97
    }

fat's avatar
fat committed
98
    var $parent = $(selector)
99

fat's avatar
fat committed
100
    if (e) e.preventDefault()
101

fat's avatar
fat committed
102
103
104
    if (!$parent.length) {
      $parent = $this.hasClass('alert') ? $this : $this.parent()
    }
105

Mark Otto's avatar
Mark Otto committed
106
    $parent.trigger(e = $.Event('close.bs.alert'))
107
108
109
110
111
112

    if (e.isDefaultPrevented()) return

    $parent.removeClass('in')

    function removeElement() {
Mark Otto's avatar
Mark Otto committed
113
      $parent.trigger('closed.bs.alert').remove()
114
115
116
    }

    $.support.transition && $parent.hasClass('fade') ?
117
118
119
      $parent
        .one($.support.transition.end, removeElement)
        .emulateTransitionEnd(150) :
120
121
122
123
      removeElement()
  }


fat's avatar
fat committed
124
125
  // ALERT PLUGIN DEFINITION
  // =======================
126

127
128
  var old = $.fn.alert

129
130
131
  $.fn.alert = function (option) {
    return this.each(function () {
      var $this = $(this)
Mark Otto's avatar
Mark Otto committed
132
      var data  = $this.data('bs.alert')
fat's avatar
fat committed
133

Mark Otto's avatar
Mark Otto committed
134
      if (!data) $this.data('bs.alert', (data = new Alert(this)))
135
136
137
138
139
140
141
      if (typeof option == 'string') data[option].call($this)
    })
  }

  $.fn.alert.Constructor = Alert


fat's avatar
fat committed
142
143
  // ALERT NO CONFLICT
  // =================
144
145
146
147
148
149
150

  $.fn.alert.noConflict = function () {
    $.fn.alert = old
    return this
  }


fat's avatar
fat committed
151
  // ALERT DATA-API
fat's avatar
fat committed
152
  // ==============
153

Mark Otto's avatar
Mark Otto committed
154
  $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
155

Mark Otto's avatar
Mark Otto committed
156
}(window.jQuery);
157
/* ========================================================================
fat's avatar
fat committed
158
 * Bootstrap: button.js v3.0.0
Chris Rebert's avatar
Chris Rebert committed
159
 * http://twbs.github.com/bootstrap/javascript.html#buttons
160
 * ========================================================================
fat's avatar
fat committed
161
 * Copyright 2013 Twitter, Inc.
162
163
164
165
166
167
168
169
170
171
172
173
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
174
 * ======================================================================== */
175
176


177
+function ($) { "use strict";
178

fat's avatar
fat committed
179
180
  // BUTTON PUBLIC CLASS DEFINITION
  // ==============================
181
182
183

  var Button = function (element, options) {
    this.$element = $(element)
fat's avatar
fat committed
184
185
186
187
188
    this.options  = $.extend({}, Button.DEFAULTS, options)
  }

  Button.DEFAULTS = {
    loadingText: 'loading...'
189
190
191
  }

  Button.prototype.setState = function (state) {
fat's avatar
fat committed
192
193
194
195
    var d    = 'disabled'
    var $el  = this.$element
    var val  = $el.is('input') ? 'val' : 'html'
    var data = $el.data()
196
197

    state = state + 'Text'
fat's avatar
fat committed
198
199

    if (!data.resetText) $el.data('resetText', $el[val]())
200
201
202
203
204
205
206

    $el[val](data[state] || this.options[state])

    // push to event loop to allow forms to submit
    setTimeout(function () {
      state == 'loadingText' ?
        $el.addClass(d).attr(d, d) :
fat's avatar
fat committed
207
        $el.removeClass(d).removeAttr(d);
208
209
210
211
    }, 0)
  }

  Button.prototype.toggle = function () {
212
    var $parent = this.$element.closest('[data-toggle="buttons"]')
213

214
215
216
    if ($parent.length) {
      var $input = this.$element.find('input').prop('checked', !this.$element.hasClass('active'))
      if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
fat's avatar
fat committed
217
    }
218
219
220
221
222

    this.$element.toggleClass('active')
  }


fat's avatar
fat committed
223
224
  // BUTTON PLUGIN DEFINITION
  // ========================
225

226
227
  var old = $.fn.button

228
229
  $.fn.button = function (option) {
    return this.each(function () {
fat's avatar
fat committed
230
231
232
233
      var $this   = $(this)
      var data    = $this.data('button')
      var options = typeof option == 'object' && option

Mark Otto's avatar
Mark Otto committed
234
      if (!data) $this.data('bs.button', (data = new Button(this, options)))
fat's avatar
fat committed
235

236
237
238
239
240
241
242
243
      if (option == 'toggle') data.toggle()
      else if (option) data.setState(option)
    })
  }

  $.fn.button.Constructor = Button


fat's avatar
fat committed
244
245
  // BUTTON NO CONFLICT
  // ==================
246
247
248
249
250
251
252

  $.fn.button.noConflict = function () {
    $.fn.button = old
    return this
  }


fat's avatar
fat committed
253
254
  // BUTTON DATA-API
  // ===============
255

Mark Otto's avatar
Mark Otto committed
256
  $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
257
258
259
    var $btn = $(e.target)
    if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
    $btn.button('toggle')
260
    e.preventDefault()
261
262
  })

Mark Otto's avatar
Mark Otto committed
263
}(window.jQuery);
264
/* ========================================================================
fat's avatar
fat committed
265
 * Bootstrap: carousel.js v3.0.0
Chris Rebert's avatar
Chris Rebert committed
266
 * http://twbs.github.com/bootstrap/javascript.html#carousel
267
 * ========================================================================
268
269
270
271
272
273
274
275
276
277
278
279
280
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
281
 * ======================================================================== */
282
283


284
+function ($) { "use strict";
285

fat's avatar
fat committed
286
287
  // CAROUSEL CLASS DEFINITION
  // =========================
288
289

  var Carousel = function (element, options) {
fat's avatar
fat committed
290
    this.$element    = $(element)
fat's avatar
fat committed
291
    this.$indicators = this.$element.find('.carousel-indicators')
fat's avatar
fat committed
292
293
294
295
296
297
298
    this.options     = options
    this.paused      =
    this.sliding     =
    this.interval    =
    this.$active     =
    this.$items      = null

299
300
301
302
303
    this.options.pause == 'hover' && this.$element
      .on('mouseenter', $.proxy(this.pause, this))
      .on('mouseleave', $.proxy(this.cycle, this))
  }

fat's avatar
fat committed
304
305
306
307
  Carousel.DEFAULTS = {
    interval: 5000
  , pause: 'hover'
  }
308

fat's avatar
fat committed
309
310
  Carousel.prototype.cycle =  function (e) {
    e || (this.paused = false)
311

fat's avatar
fat committed
312
    this.interval && clearInterval(this.interval)
fat's avatar
fat committed
313

fat's avatar
fat committed
314
315
316
    this.options.interval
      && !this.paused
      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
317

fat's avatar
fat committed
318
319
    return this
  }
320

fat's avatar
fat committed
321
322
323
  Carousel.prototype.getActiveIndex = function () {
    this.$active = this.$element.find('.item.active')
    this.$items  = this.$active.parent().children()
324

fat's avatar
fat committed
325
326
    return this.$items.index(this.$active)
  }
327

fat's avatar
fat committed
328
329
330
  Carousel.prototype.to = function (pos) {
    var that        = this
    var activeIndex = this.getActiveIndex()
331

fat's avatar
fat committed
332
    if (pos > (this.$items.length - 1) || pos < 0) return
333

fat's avatar
fat committed
334
335
336
337
338
    if (this.sliding)       return this.$element.one('slid', function () { that.to(pos) })
    if (activeIndex == pos) return this.pause().cycle()

    return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
  }
339

fat's avatar
fat committed
340
341
342
343
344
345
  Carousel.prototype.pause = function (e) {
    e || (this.paused = true)

    if (this.$element.find('.next, .prev').length && $.support.transition.end) {
      this.$element.trigger($.support.transition.end)
      this.cycle(true)
346
347
    }

fat's avatar
fat committed
348
    this.interval = clearInterval(this.interval)
349

fat's avatar
fat committed
350
351
    return this
  }
352

fat's avatar
fat committed
353
354
355
356
  Carousel.prototype.next = function () {
    if (this.sliding) return
    return this.slide('next')
  }
357

fat's avatar
fat committed
358
359
360
361
  Carousel.prototype.prev = function () {
    if (this.sliding) return
    return this.slide('prev')
  }
362

fat's avatar
fat committed
363
364
365
366
367
368
369
  Carousel.prototype.slide = function (type, next) {
    var $active   = this.$element.find('.item.active')
    var $next     = next || $active[type]()
    var isCycling = this.interval
    var direction = type == 'next' ? 'left' : 'right'
    var fallback  = type == 'next' ? 'first' : 'last'
    var that      = this
Jacob Thornton's avatar
Jacob Thornton committed
370

fat's avatar
fat committed
371
    this.sliding = true
372

fat's avatar
fat committed
373
    isCycling && this.pause()
fat's avatar
fat committed
374

fat's avatar
fat committed
375
    $next = $next.length ? $next : this.$element.find('.item')[fallback]()
376

Mark Otto's avatar
Mark Otto committed
377
    var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
378

fat's avatar
fat committed
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
    if ($next.hasClass('active')) return

    if (this.$indicators.length) {
      this.$indicators.find('.active').removeClass('active')
      this.$element.one('slid', function () {
        var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
        $nextIndicator && $nextIndicator.addClass('active')
      })
    }

    if ($.support.transition && this.$element.hasClass('slide')) {
      this.$element.trigger(e)
      if (e.isDefaultPrevented()) return
      $next.addClass(type)
      $next[0].offsetWidth // force reflow
      $active.addClass(direction)
      $next.addClass(direction)
Jacob Thornton's avatar
Jacob Thornton committed
396
      $active
397
398
399
400
401
402
403
        .one($.support.transition.end, function () {
          $next.removeClass([type, direction].join(' ')).addClass('active')
          $active.removeClass(['active', direction].join(' '))
          that.sliding = false
          setTimeout(function () { that.$element.trigger('slid') }, 0)
        })
        .emulateTransitionEnd(600)
fat's avatar
fat committed
404
405
406
407
408
409
410
    } else {
      this.$element.trigger(e)
      if (e.isDefaultPrevented()) return
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
      this.$element.trigger('slid')
411
412
    }

fat's avatar
fat committed
413
414
415
    isCycling && this.cycle()

    return this
416
417
418
  }


fat's avatar
fat committed
419
420
  // CAROUSEL PLUGIN DEFINITION
  // ==========================
421

422
423
  var old = $.fn.carousel

424
425
  $.fn.carousel = function (option) {
    return this.each(function () {
fat's avatar
fat committed
426
      var $this   = $(this)
Mark Otto's avatar
Mark Otto committed
427
      var data    = $this.data('bs.carousel')
Jacob Thornton's avatar
Jacob Thornton committed
428
      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
fat's avatar
fat committed
429
430
      var action  = typeof option == 'string' ? option : options.slide

Mark Otto's avatar
Mark Otto committed
431
      if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
432
      if (typeof option == 'number') data.to(option)
Jacob Thornton's avatar
Jacob Thornton committed
433
      else if (action) data[action]()
Mark Otto's avatar
Mark Otto committed
434
      else if (options.interval) data.pause().cycle()
435
436
437
438
439
440
    })
  }

  $.fn.carousel.Constructor = Carousel


fat's avatar
fat committed
441
442
  // CAROUSEL NO CONFLICT
  // ====================
443
444
445
446
447
448

  $.fn.carousel.noConflict = function () {
    $.fn.carousel = old
    return this
  }

fat's avatar
fat committed
449

fat's avatar
fat committed
450
451
  // CAROUSEL DATA-API
  // =================
452

453
  $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
fat's avatar
fat committed
454
    var $this   = $(this), href
fat's avatar
fat committed
455
456
    var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
    var options = $.extend({}, $target.data(), $this.data())
fat's avatar
fat committed
457
458
    var slideIndex = $this.attr('data-slide-to')
    if (slideIndex) options.interval = false
459

460
    $target.carousel(options)
461
462

    if (slideIndex = $this.attr('data-slide-to')) {
fat's avatar
fat committed
463
      $target.data('bs.carousel').to(slideIndex)
464
465
    }

466
    e.preventDefault()
467
468
  })

fat's avatar
fat committed
469
470
471
472
473
474
475
  $(window).on('load', function () {
    $('[data-ride="carousel"]').each(function () {
      var $carousel = $(this)
      $carousel.carousel($carousel.data())
    })
  })

Mark Otto's avatar
Mark Otto committed
476
}(window.jQuery);
477
/* ========================================================================
fat's avatar
fat committed
478
 * Bootstrap: collapse.js v3.0.0
Chris Rebert's avatar
Chris Rebert committed
479
 * http://twbs.github.com/bootstrap/javascript.html#collapse
480
 * ========================================================================
481
482
483
484
485
486
487
488
489
490
491
492
493
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
494
 * ======================================================================== */
495
496


497
+function ($) { "use strict";
498

499
500
  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================
501
502

  var Collapse = function (element, options) {
503
504
505
    this.$element      = $(element)
    this.options       = $.extend({}, Collapse.DEFAULTS, options)
    this.transitioning = null
506

507
508
509
510
511
512
513
    if (this.options.parent) this.$parent = $(this.options.parent)
    if (this.options.toggle) this.toggle()
  }

  Collapse.DEFAULTS = {
    toggle: true
  }
514

515
516
517
  Collapse.prototype.dimension = function () {
    var hasWidth = this.$element.hasClass('width')
    return hasWidth ? 'width' : 'height'
518
519
  }

520
521
  Collapse.prototype.show = function () {
    if (this.transitioning || this.$element.hasClass('in')) return
522

fat's avatar
fat committed
523
524
525
526
    var startEvent = $.Event('show.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

527
528
    var dimension = this.dimension()
    var scroll    = $.camelCase(['scroll', dimension].join('-'))
529
    var actives   = this.$parent && this.$parent.find('> .accordion-group > .in')
530

531
    if (actives && actives.length) {
fat's avatar
fat committed
532
      var hasData = actives.data('bs.collapse')
533
534
      if (hasData && hasData.transitioning) return
      actives.collapse('hide')
fat's avatar
fat committed
535
      hasData || actives.data('bs.collapse', null)
536
537
    }

538
    this.$element[dimension](0)
fat's avatar
fat committed
539
    this.transition('addClass', 'shown.bs.collapse')
540

541
542
    if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
  }
543

544
545
  Collapse.prototype.hide = function () {
    if (this.transitioning || !this.$element.hasClass('in')) return
fat's avatar
fat committed
546
547
548
549
550

    var startEvent = $.Event('hide.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

551
552
    var dimension = this.dimension()
    this.reset(this.$element[dimension]())
fat's avatar
fat committed
553
    this.transition('removeClass', 'hidden.bs.collapse')
554
555
    this.$element[dimension](0)
  }
556

557
558
  Collapse.prototype.reset = function (size) {
    var dimension = this.dimension()
559

560
561
562
563
    this.$element
      .removeClass('collapse')
      [dimension](size || 'auto')
      [0].offsetWidth
564

Mark Otto's avatar
Mark Otto committed
565
    this.$element[size != null ? 'addClass' : 'removeClass']('collapse')
566

567
568
    return this
  }
569

fat's avatar
fat committed
570
  Collapse.prototype.transition = function (method, completeEvent) {
571
572
    var that     = this
    var complete = function () {
fat's avatar
fat committed
573
      if (completeEvent == 'shown.bs.collapse') that.reset()
574
575
      that.transitioning = 0
      that.$element.trigger(completeEvent)
576
577
    }

578
    this.transitioning = 1
579

580
    this.$element[method]('in')
581

582
    $.support.transition && this.$element.hasClass('collapse') ?
583
584
585
      this.$element
        .one($.support.transition.end, complete)
        .emulateTransitionEnd(350) :
586
587
      complete()
  }
588

589
590
  Collapse.prototype.toggle = function () {
    this[this.$element.hasClass('in') ? 'hide' : 'show']()
591
592
593
  }


594
595
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
596
597

  var old = $.fn.collapse
598
599
600

  $.fn.collapse = function (option) {
    return this.each(function () {
601
      var $this   = $(this)
fat's avatar
fat committed
602
      var data    = $this.data('bs.collapse')
603
604
      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)

fat's avatar
fat committed
605
      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
606
607
608
609
610
611
612
      if (typeof option == 'string') data[option]()
    })
  }

  $.fn.collapse.Constructor = Collapse


613
614
  // COLLAPSE NO CONFLICT
  // ====================
615

616
617
618
619
620
621
  $.fn.collapse.noConflict = function () {
    $.fn.collapse = old
    return this
  }


622
623
  // COLLAPSE DATA-API
  // =================
624

625
  $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
626
627
    var $this   = $(this), href
    var target  = $this.attr('data-target')
628
629
        || e.preventDefault()
        || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
630
631
632
633
    var $target = $(target)
    var data    = $target.data('bs.collapse')
    var option  = data ? 'toggle' : $this.data()
    var parent  = $this.attr('data-parent')
Mark Otto's avatar
Mark Otto committed
634
    var $parent = parent && $(parent)
635

fat's avatar
fat committed
636
    if (!data || !data.transitioning) {
fat's avatar
fat committed
637
      if ($parent) $parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not($this).addClass('collapsed')
638
      $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
fat's avatar
fat committed
639
640
    }

641
    $target.collapse(option)
642
643
  })

Mark Otto's avatar
Mark Otto committed
644
}(window.jQuery);
645
/* ========================================================================
fat's avatar
fat committed
646
 * Bootstrap: dropdown.js v3.0.0
Chris Rebert's avatar
Chris Rebert committed
647
 * http://twbs.github.com/bootstrap/javascript.html#dropdowns
648
 * ========================================================================
649
650
651
652
653
654
655
656
657
658
659
660
661
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
662
 * ======================================================================== */
663
664


665
+function ($) { "use strict";
666

667
668
  // DROPDOWN CLASS DEFINITION
  // =========================
669

670
671
672
  var backdrop = '.dropdown-backdrop'
  var toggle   = '[data-toggle=dropdown]'
  var Dropdown = function (element) {
673
    var $el = $(element).on('click.bs.dropdown', this.toggle)
674
  }
675

676
677
  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)
678

679
    if ($this.is('.disabled, :disabled')) return
680

681
682
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
683

684
    clearMenus()
fat's avatar
fat committed
685

686
    if (!isActive) {
fat's avatar
fat committed
687
688
      if ('ontouchstart' in document.documentElement) {
        // if mobile we we use a backdrop because click events don't delegate
Jacob Thornton's avatar
Jacob Thornton committed
689
        $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
fat's avatar
fat committed
690
      }
691
692
693
694
695
696
697
698

      $parent.trigger(e = $.Event('show.bs.dropdown'))

      if (e.isDefaultPrevented()) return

      $parent
        .toggleClass('open')
        .trigger('shown.bs.dropdown')
699
700
    }

701
    $this.focus()
702

703
704
    return false
  }
705

706
707
  Dropdown.prototype.keydown = function (e) {
    if (!/(38|40|27)/.test(e.keyCode)) return
708

709
    var $this = $(this)
710

711
712
    e.preventDefault()
    e.stopPropagation()
713

714
    if ($this.is('.disabled, :disabled')) return
715

716
717
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
718

719
720
721
722
    if (!isActive || (isActive && e.keyCode == 27)) {
      if (e.which == 27) $parent.find(toggle).focus()
      return $this.click()
    }
723

724
    var $items = $('[role=menu] li:not(.divider):visible a', $parent)
725

726
    if (!$items.length) return
727

728
    var index = $items.index($items.filter(':focus'))
729

730
731
732
    if (e.keyCode == 38 && index > 0)                 index--                        // up
    if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
    if (!~index)                                      index=0
733

734
    $items.eq(index).focus()
735
736
  }

Mark Otto's avatar
Mark Otto committed
737
  function clearMenus() {
738
    $(backdrop).remove()
739
    $(toggle).each(function (e) {
740
741
742
743
744
745
      var $parent = getParent($(this))
      if (!$parent.hasClass('open')) return
      $parent.trigger(e = $.Event('hide.bs.dropdown'))
      if (e.isDefaultPrevented()) return
      $parent.removeClass('open').trigger('hidden.bs.dropdown')
    })
746
747
748
749
750
751
752
  }

  function getParent($this) {
    var selector = $this.attr('data-target')

    if (!selector) {
      selector = $this.attr('href')
753
      selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
754
755
    }

756
    var $parent = selector && $(selector)
757

758
    return $parent && $parent.length ? $parent : $this.parent()
759
760
761
  }


762
763
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
764

765
766
  var old = $.fn.dropdown

767
768
769
  $.fn.dropdown = function (option) {
    return this.each(function () {
      var $this = $(this)
770
771
      var data  = $this.data('dropdown')

772
773
774
775
776
777
778
779
      if (!data) $this.data('dropdown', (data = new Dropdown(this)))
      if (typeof option == 'string') data[option].call($this)
    })
  }

  $.fn.dropdown.Constructor = Dropdown


780
781
  // DROPDOWN NO CONFLICT
  // ====================
782
783
784
785
786
787
788

  $.fn.dropdown.noConflict = function () {
    $.fn.dropdown = old
    return this
  }


789
790
791
  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

792
  $(document)
793
794
795
796
    .on('click.bs.dropdown.data-api', clearMenus)
    .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
    .on('click.bs.dropdown.data-api'  , toggle, Dropdown.prototype.toggle)
    .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
797

fat's avatar
fat committed
798
}(window.jQuery);
799
/* ========================================================================
fat's avatar
fat committed
800
 * Bootstrap: modal.js v3.0.0
Chris Rebert's avatar
Chris Rebert committed
801
 * http://twbs.github.com/bootstrap/javascript.html#modals
802
 * ========================================================================
803
804
805
806
807
808
809
810
811
812
813
814
815
 * Copyright 2012 Twitter, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
816
 * ======================================================================== */
817
818


819
+function ($) { "use strict";
820

fat's avatar
fat committed
821
822
  // MODAL CLASS DEFINITION
  // ======================
823

Jacob Thornton's avatar
Jacob Thornton committed
824
  var Modal = function (element, options) {
fat's avatar
fat committed
825
    this.options   = options
fat's avatar
fat committed
826
    this.$element  = $(element).on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
fat's avatar
fat committed
827
828
    this.$backdrop =
    this.isShown   = null
829

fat's avatar
fat committed
830
831
    if (this.options.remote) this.$element.find('.modal-body').load(this.options.remote)
  }
832

fat's avatar
fat committed
833
834
835
836
837
  Modal.DEFAULTS = {
      backdrop: true
    , keyboard: true
    , show: true
  }
838

fat's avatar
fat committed
839
840
841
  Modal.prototype.toggle = function () {
    return this[!this.isShown ? 'show' : 'hide']()
  }
842

fat's avatar
fat committed
843
844
  Modal.prototype.show = function () {
    var that = this
Mark Otto's avatar
Mark Otto committed
845
    var e    = $.Event('show.bs.modal')
846

fat's avatar
fat committed
847
    this.$element.trigger(e)
848

fat's avatar
fat committed
849
    if (this.isShown || e.isDefaultPrevented()) return
850

fat's avatar
fat committed
851
    this.isShown = true
852

fat's avatar
fat committed
853
    this.escape()
854

fat's avatar
fat committed
855
856
    this.backdrop(function () {
      var transition = $.support.transition && that.$element.hasClass('fade')
857

fat's avatar
fat committed
858
      if (!that.$element.parent().length) {
Jacob Thornton's avatar
Jacob Thornton committed
859
        that.$element.appendTo(document.body) // don't move modals dom position
fat's avatar
fat committed
860
      }
861

fat's avatar
fat committed
862
      that.$element.show()
863

fat's avatar
fat committed
864
865
866
      if (transition) {
        that.$element[0].offsetWidth // force reflow
      }
867

fat's avatar
fat committed
868
869
870
      that.$element
        .addClass('in')
        .attr('aria-hidden', false)
871

fat's avatar
fat committed
872
      that.enforceFocus()
873

fat's avatar
fat committed
874
      transition ?
875
876
877
878
879
        that.$element
          .one($.support.transition.end, function () {
            that.$element.focus().trigger('shown.bs.modal')
          })
          .emulateTransitionEnd(300) :
Mark Otto's avatar
Mark Otto committed
880
        that.$element.focus().trigger('shown.bs.modal')
fat's avatar
fat committed
881
882
    })
  }
883

fat's avatar
fat committed
884
  Modal.prototype.hide = function (e) {
fat's avatar
fat committed
885
    if (e) e.preventDefault()
886

Mark Otto's avatar
Mark Otto committed
887
    e = $.Event('hide.bs.modal')
888

fat's avatar
fat committed
889
    this.$element.trigger(e)
890

fat's avatar
fat committed
891
    if (!this.isShown || e.isDefaultPrevented()) return
892

fat's avatar
fat committed
893
    this.isShown = false
894

fat's avatar
fat committed
895
    this.escape()
896

Mark Otto's avatar
Mark Otto committed
897
    $(document).off('focusin.bs.modal')
898

fat's avatar
fat committed
899
900
901
    this.$element
      .removeClass('in')
      .attr('aria-hidden', true)
902

fat's avatar
fat committed
903
    $.support.transition && this.$element.hasClass('fade') ?
904
905
906
      this.$element
        .one($.support.transition.end, $.proxy(this.hideModal, this))
        .emulateTransitionEnd(300) :
fat's avatar
fat committed
907
908
      this.hideModal()
  }
909

fat's avatar
fat committed
910
  Modal.prototype.enforceFocus = function () {
Jacob Thornton's avatar
Jacob Thornton committed
911
912
    $(document)
      .off('focusin.bs.modal') // guard against infinite focus loop
fat's avatar
fat committed
913
914
915
916
917
      .on('focusin.bs.modal', $.proxy(function (e) {
        if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
          this.$element.focus()
        }
      }, this))
fat's avatar
fat committed
918
  }
919

fat's avatar
fat committed
920
921
  Modal.prototype.escape = function () {
    if (this.isShown && this.options.keyboard) {
fat's avatar
fat committed
922
      this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
fat's avatar
fat committed
923
        e.which == 27 && this.hide()
fat's avatar
fat committed
924
      }, this))
fat's avatar
fat committed
925
    } else if (!this.isShown) {
Mark Otto's avatar
Mark Otto committed
926
      this.$element.off('keyup.dismiss.bs.modal')
fat's avatar
fat committed
927
928
    }
  }
929

fat's avatar
fat committed
930
931
932
933
934
  Modal.prototype.hideModal = function () {
    var that = this
    this.$element.hide()
    this.backdrop(function () {
      that.removeBackdrop()
Mark Otto's avatar
Mark Otto committed
935
      that.$element.trigger('hidden.bs.modal')
fat's avatar
fat committed
936
937
    })
  }
938

fat's avatar
fat committed
939
940
941
942
  Modal.prototype.removeBackdrop = function () {
    this.$backdrop && this.$backdrop.remove()
    this.$backdrop = null
  }
943

fat's avatar
fat committed
944
945
946
  Modal.prototype.backdrop = function (callback) {
    var that    = this
    var animate = this.$element.hasClass('fade') ? 'fade' : ''
947

fat's avatar
fat committed
948
949
    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate
950

fat's avatar
fat committed
951
952
      this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
        .appendTo(document.body)
953

fat's avatar
fat committed
954
955
956
957
958
959
      this.$element.on('click', $.proxy(function (e) {
        if (e.target !== e.currentTarget) return
        this.options.backdrop == 'static'
          ? this.$element[0].focus.call(this.$element[0])
          : this.hide.call(this)
      }, this))
960

fat's avatar
fat committed
961
      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
962

fat's avatar
fat committed
963
      this.$backdrop.addClass('in')
964

fat's avatar
fat committed
965
      if (!callback) return
966

fat's avatar
fat committed
967
      doAnimate ?
968
969
970
        this.$backdrop
          .one($.support.transition.end, callback)
          .emulateTransitionEnd(150) :
fat's avatar
fat committed
971
        callback()
972

fat's avatar
fat committed
973
974
    } else if (!this.isShown && this.$backdrop) {
      this.$backdrop.removeClass('in')
975

fat's avatar
fat committed
976
      $.support.transition && this.$element.hasClass('fade')?
977
978
979
        this.$backdrop
          .one($.support.transition.end, callback)
          .emulateTransitionEnd(150) :
fat's avatar
fat committed
980
        callback()
981

fat's avatar
fat committed
982
983
984
    } else if (callback) {
      callback()
    }
985
986
987
  }


fat's avatar
fat committed
988
989
  // MODAL PLUGIN DEFINITION
  // =======================
990

991
992
  var old = $.fn.modal

993
994
  $.fn.modal = function (option) {
    return this.each(function () {
fat's avatar
fat committed
995
      var $this   = $(this)
Mark Otto's avatar
Mark Otto committed
996
      var data    = $this.data('bs.modal')
fat's avatar
fat committed
997
998
      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)

Mark Otto's avatar
Mark Otto committed
999
      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
1000
      if (typeof option == 'string') data[option]()
For faster browsing, not all history is shown. View entire blame