bootstrap.js 57.2 KB
Newer Older
1
/*!
Mark Otto's avatar
Mark Otto committed
2
 * Bootstrap v3.0.2 by @fat and @mdo
Chris Rebert's avatar
Chris Rebert committed
3
4
5
6
7
 * Copyright 2013 Twitter, Inc.
 * Licensed under http://www.apache.org/licenses/LICENSE-2.0
 *
 * Designed and built with all the love in the world by @mdo and @fat.
 */
8

Mark Otto's avatar
Mark Otto committed
9
if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery") }
10

11
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
12
 * Bootstrap: transition.js v3.0.2
Mark Otto's avatar
Mark Otto committed
13
 * http://getbootstrap.com/javascript/#transitions
14
 * ========================================================================
15
 * Copyright 2013 Twitter, Inc.
16
17
18
19
20
21
22
23
24
25
26
27
 *
 * 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.
28
 * ======================================================================== */
29
30


31
+function ($) { "use strict";
32

33
34
  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  // ============================================================
35

36
37
  function transitionEnd() {
    var el = document.createElement('bootstrap')
38

39
40
41
42
43
    var transEndEventNames = {
      'WebkitTransition' : 'webkitTransitionEnd'
    , 'MozTransition'    : 'transitionend'
    , 'OTransition'      : 'oTransitionEnd otransitionend'
    , 'transition'       : 'transitionend'
fat's avatar
fat committed
44
    }
45

46
47
48
49
50
    for (var name in transEndEventNames) {
      if (el.style[name] !== undefined) {
        return { end: transEndEventNames[name] }
      }
    }
51
52
  }

53
54
  // http://blog.alexmaccaw.com/css-transitions
  $.fn.emulateTransitionEnd = function (duration) {
55
    var called = false, $el = this
liuyl's avatar
liuyl committed
56
57
    $(this).one($.support.transition.end, function () { called = true })
    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
58
    setTimeout(callback, duration)
59
    return this
60
61
  }

62
63
  $(function () {
    $.support.transition = transitionEnd()
fat's avatar
fat committed
64
  })
65

Chris Rebert's avatar
Chris Rebert committed
66
}(jQuery);
67

68
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
69
 * Bootstrap: alert.js v3.0.2
Mark Otto's avatar
Mark Otto committed
70
 * http://getbootstrap.com/javascript/#alerts
71
 * ========================================================================
fat's avatar
fat committed
72
 * Copyright 2013 Twitter, Inc.
73
74
75
76
77
78
79
80
81
82
83
84
 *
 * 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.
85
 * ======================================================================== */
86
87


88
+function ($) { "use strict";
89

fat's avatar
fat committed
90
91
  // ALERT CLASS DEFINITION
  // ======================
92
93

  var dismiss = '[data-dismiss="alert"]'
fat's avatar
fat committed
94
95
96
  var Alert   = function (el) {
    $(el).on('click', dismiss, this.close)
  }
97
98

  Alert.prototype.close = function (e) {
fat's avatar
fat committed
99
100
    var $this    = $(this)
    var selector = $this.attr('data-target')
101
102
103

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

fat's avatar
fat committed
107
    var $parent = $(selector)
108

fat's avatar
fat committed
109
    if (e) e.preventDefault()
110

fat's avatar
fat committed
111
112
113
    if (!$parent.length) {
      $parent = $this.hasClass('alert') ? $this : $this.parent()
    }
114

Mark Otto's avatar
Mark Otto committed
115
    $parent.trigger(e = $.Event('close.bs.alert'))
116
117
118
119
120
121

    if (e.isDefaultPrevented()) return

    $parent.removeClass('in')

    function removeElement() {
Mark Otto's avatar
Mark Otto committed
122
      $parent.trigger('closed.bs.alert').remove()
123
124
125
    }

    $.support.transition && $parent.hasClass('fade') ?
126
127
128
      $parent
        .one($.support.transition.end, removeElement)
        .emulateTransitionEnd(150) :
129
130
131
132
      removeElement()
  }


fat's avatar
fat committed
133
134
  // ALERT PLUGIN DEFINITION
  // =======================
135

136
137
  var old = $.fn.alert

138
139
140
  $.fn.alert = function (option) {
    return this.each(function () {
      var $this = $(this)
Mark Otto's avatar
Mark Otto committed
141
      var data  = $this.data('bs.alert')
fat's avatar
fat committed
142

Mark Otto's avatar
Mark Otto committed
143
      if (!data) $this.data('bs.alert', (data = new Alert(this)))
144
145
146
147
148
149
150
      if (typeof option == 'string') data[option].call($this)
    })
  }

  $.fn.alert.Constructor = Alert


fat's avatar
fat committed
151
152
  // ALERT NO CONFLICT
  // =================
153
154
155
156
157
158
159

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


fat's avatar
fat committed
160
  // ALERT DATA-API
fat's avatar
fat committed
161
  // ==============
162

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

Chris Rebert's avatar
Chris Rebert committed
165
}(jQuery);
166

167
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
168
 * Bootstrap: button.js v3.0.2
Mark Otto's avatar
Mark Otto committed
169
 * http://getbootstrap.com/javascript/#buttons
170
 * ========================================================================
fat's avatar
fat committed
171
 * Copyright 2013 Twitter, Inc.
172
173
174
175
176
177
178
179
180
181
182
183
 *
 * 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.
184
 * ======================================================================== */
185
186


187
+function ($) { "use strict";
188

fat's avatar
fat committed
189
190
  // BUTTON PUBLIC CLASS DEFINITION
  // ==============================
191
192
193

  var Button = function (element, options) {
    this.$element = $(element)
fat's avatar
fat committed
194
195
196
197
198
    this.options  = $.extend({}, Button.DEFAULTS, options)
  }

  Button.DEFAULTS = {
    loadingText: 'loading...'
199
200
201
  }

  Button.prototype.setState = function (state) {
fat's avatar
fat committed
202
203
204
205
    var d    = 'disabled'
    var $el  = this.$element
    var val  = $el.is('input') ? 'val' : 'html'
    var data = $el.data()
206
207

    state = state + 'Text'
fat's avatar
fat committed
208
209

    if (!data.resetText) $el.data('resetText', $el[val]())
210
211
212
213
214
215
216

    $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
217
        $el.removeClass(d).removeAttr(d);
218
219
220
221
    }, 0)
  }

  Button.prototype.toggle = function () {
222
    var $parent = this.$element.closest('[data-toggle="buttons"]')
223
    var changed = true
224

225
    if ($parent.length) {
fat's avatar
fat committed
226
      var $input = this.$element.find('input')
227
228
229
230
231
232
233
234
      if ($input.prop('type') === 'radio') {
        // see if clicking on current one
        if ($input.prop('checked') && this.$element.hasClass('active'))
          changed = false
        else
          $parent.find('.active').removeClass('active')
      }
      if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
fat's avatar
fat committed
235
    }
236

237
    if (changed) this.$element.toggleClass('active')
238
239
240
  }


fat's avatar
fat committed
241
242
  // BUTTON PLUGIN DEFINITION
  // ========================
243

244
245
  var old = $.fn.button

246
247
  $.fn.button = function (option) {
    return this.each(function () {
fat's avatar
fat committed
248
      var $this   = $(this)
fat's avatar
fat committed
249
      var data    = $this.data('bs.button')
fat's avatar
fat committed
250
251
      var options = typeof option == 'object' && option

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

254
255
256
257
258
259
260
261
      if (option == 'toggle') data.toggle()
      else if (option) data.setState(option)
    })
  }

  $.fn.button.Constructor = Button


fat's avatar
fat committed
262
263
  // BUTTON NO CONFLICT
  // ==================
264
265
266
267
268
269
270

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


fat's avatar
fat committed
271
272
  // BUTTON DATA-API
  // ===============
273

Mark Otto's avatar
Mark Otto committed
274
  $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
275
276
277
    var $btn = $(e.target)
    if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
    $btn.button('toggle')
278
    e.preventDefault()
279
280
  })

Chris Rebert's avatar
Chris Rebert committed
281
}(jQuery);
282

283
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
284
 * Bootstrap: carousel.js v3.0.2
Mark Otto's avatar
Mark Otto committed
285
 * http://getbootstrap.com/javascript/#carousel
286
 * ========================================================================
287
 * Copyright 2013 Twitter, Inc.
288
289
290
291
292
293
294
295
296
297
298
299
 *
 * 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.
300
 * ======================================================================== */
301
302


303
+function ($) { "use strict";
304

fat's avatar
fat committed
305
306
  // CAROUSEL CLASS DEFINITION
  // =========================
307
308

  var Carousel = function (element, options) {
fat's avatar
fat committed
309
    this.$element    = $(element)
fat's avatar
fat committed
310
    this.$indicators = this.$element.find('.carousel-indicators')
fat's avatar
fat committed
311
312
313
314
315
316
317
    this.options     = options
    this.paused      =
    this.sliding     =
    this.interval    =
    this.$active     =
    this.$items      = null

318
319
320
321
322
    this.options.pause == 'hover' && this.$element
      .on('mouseenter', $.proxy(this.pause, this))
      .on('mouseleave', $.proxy(this.cycle, this))
  }

fat's avatar
fat committed
323
324
325
  Carousel.DEFAULTS = {
    interval: 5000
  , pause: 'hover'
Jacob Thornton's avatar
Jacob Thornton committed
326
  , wrap: true
fat's avatar
fat committed
327
  }
328

fat's avatar
fat committed
329
330
  Carousel.prototype.cycle =  function (e) {
    e || (this.paused = false)
331

fat's avatar
fat committed
332
    this.interval && clearInterval(this.interval)
fat's avatar
fat committed
333

fat's avatar
fat committed
334
335
336
    this.options.interval
      && !this.paused
      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
337

fat's avatar
fat committed
338
339
    return this
  }
340

fat's avatar
fat committed
341
342
343
  Carousel.prototype.getActiveIndex = function () {
    this.$active = this.$element.find('.item.active')
    this.$items  = this.$active.parent().children()
344

fat's avatar
fat committed
345
346
    return this.$items.index(this.$active)
  }
347

fat's avatar
fat committed
348
349
350
  Carousel.prototype.to = function (pos) {
    var that        = this
    var activeIndex = this.getActiveIndex()
351

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

354
    if (this.sliding)       return this.$element.one('slid.bs.carousel', function () { that.to(pos) })
fat's avatar
fat committed
355
356
357
358
    if (activeIndex == pos) return this.pause().cycle()

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

fat's avatar
fat committed
360
361
362
363
364
365
  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)
366
367
    }

fat's avatar
fat committed
368
    this.interval = clearInterval(this.interval)
369

fat's avatar
fat committed
370
371
    return this
  }
372

fat's avatar
fat committed
373
374
375
376
  Carousel.prototype.next = function () {
    if (this.sliding) return
    return this.slide('next')
  }
377

fat's avatar
fat committed
378
379
380
381
  Carousel.prototype.prev = function () {
    if (this.sliding) return
    return this.slide('prev')
  }
382

fat's avatar
fat committed
383
384
385
386
387
388
389
  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
390

Jacob Thornton's avatar
Jacob Thornton committed
391
392
393
394
395
    if (!$next.length) {
      if (!this.options.wrap) return
      $next = this.$element.find('.item')[fallback]()
    }

fat's avatar
fat committed
396
    this.sliding = true
397

fat's avatar
fat committed
398
    isCycling && this.pause()
fat's avatar
fat committed
399

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

fat's avatar
fat committed
402
403
404
405
    if ($next.hasClass('active')) return

    if (this.$indicators.length) {
      this.$indicators.find('.active').removeClass('active')
406
      this.$element.one('slid.bs.carousel', function () {
fat's avatar
fat committed
407
408
409
410
411
412
413
414
415
416
417
418
        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
419
      $active
420
421
422
423
        .one($.support.transition.end, function () {
          $next.removeClass([type, direction].join(' ')).addClass('active')
          $active.removeClass(['active', direction].join(' '))
          that.sliding = false
424
          setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0)
425
426
        })
        .emulateTransitionEnd(600)
fat's avatar
fat committed
427
428
429
430
431
432
    } else {
      this.$element.trigger(e)
      if (e.isDefaultPrevented()) return
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
433
      this.$element.trigger('slid.bs.carousel')
434
435
    }

fat's avatar
fat committed
436
437
438
    isCycling && this.cycle()

    return this
439
440
441
  }


fat's avatar
fat committed
442
443
  // CAROUSEL PLUGIN DEFINITION
  // ==========================
444

445
446
  var old = $.fn.carousel

447
448
  $.fn.carousel = function (option) {
    return this.each(function () {
fat's avatar
fat committed
449
      var $this   = $(this)
Mark Otto's avatar
Mark Otto committed
450
      var data    = $this.data('bs.carousel')
Jacob Thornton's avatar
Jacob Thornton committed
451
      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
fat's avatar
fat committed
452
453
      var action  = typeof option == 'string' ? option : options.slide

Mark Otto's avatar
Mark Otto committed
454
      if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
455
      if (typeof option == 'number') data.to(option)
Jacob Thornton's avatar
Jacob Thornton committed
456
      else if (action) data[action]()
Mark Otto's avatar
Mark Otto committed
457
      else if (options.interval) data.pause().cycle()
458
459
460
461
462
463
    })
  }

  $.fn.carousel.Constructor = Carousel


fat's avatar
fat committed
464
465
  // CAROUSEL NO CONFLICT
  // ====================
466
467
468
469
470
471

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

fat's avatar
fat committed
472

fat's avatar
fat committed
473
474
  // CAROUSEL DATA-API
  // =================
475

476
  $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
fat's avatar
fat committed
477
    var $this   = $(this), href
fat's avatar
fat committed
478
479
    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
480
481
    var slideIndex = $this.attr('data-slide-to')
    if (slideIndex) options.interval = false
482

483
    $target.carousel(options)
484
485

    if (slideIndex = $this.attr('data-slide-to')) {
fat's avatar
fat committed
486
      $target.data('bs.carousel').to(slideIndex)
487
488
    }

489
    e.preventDefault()
490
491
  })

fat's avatar
fat committed
492
493
494
495
496
497
498
  $(window).on('load', function () {
    $('[data-ride="carousel"]').each(function () {
      var $carousel = $(this)
      $carousel.carousel($carousel.data())
    })
  })

Chris Rebert's avatar
Chris Rebert committed
499
}(jQuery);
500

501
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
502
 * Bootstrap: collapse.js v3.0.2
Mark Otto's avatar
Mark Otto committed
503
 * http://getbootstrap.com/javascript/#collapse
504
 * ========================================================================
505
 * Copyright 2013 Twitter, Inc.
506
507
508
509
510
511
512
513
514
515
516
517
 *
 * 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.
518
 * ======================================================================== */
519
520


521
+function ($) { "use strict";
522

523
524
  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================
525
526

  var Collapse = function (element, options) {
527
528
529
    this.$element      = $(element)
    this.options       = $.extend({}, Collapse.DEFAULTS, options)
    this.transitioning = null
530

531
532
533
534
535
536
537
    if (this.options.parent) this.$parent = $(this.options.parent)
    if (this.options.toggle) this.toggle()
  }

  Collapse.DEFAULTS = {
    toggle: true
  }
538

539
540
541
  Collapse.prototype.dimension = function () {
    var hasWidth = this.$element.hasClass('width')
    return hasWidth ? 'width' : 'height'
542
543
  }

544
545
  Collapse.prototype.show = function () {
    if (this.transitioning || this.$element.hasClass('in')) return
546

fat's avatar
fat committed
547
548
549
550
    var startEvent = $.Event('show.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

Mark Otto's avatar
Mark Otto committed
551
    var actives = this.$parent && this.$parent.find('> .panel > .in')
552

553
    if (actives && actives.length) {
fat's avatar
fat committed
554
      var hasData = actives.data('bs.collapse')
555
556
      if (hasData && hasData.transitioning) return
      actives.collapse('hide')
fat's avatar
fat committed
557
      hasData || actives.data('bs.collapse', null)
558
559
    }

560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
    var dimension = this.dimension()

    this.$element
      .removeClass('collapse')
      .addClass('collapsing')
      [dimension](0)

    this.transitioning = 1

    var complete = function () {
      this.$element
        .removeClass('collapsing')
        .addClass('in')
        [dimension]('auto')
      this.transitioning = 0
      this.$element.trigger('shown.bs.collapse')
    }

    if (!$.support.transition) return complete.call(this)

    var scrollSize = $.camelCase(['scroll', dimension].join('-'))
581

582
583
584
585
    this.$element
      .one($.support.transition.end, $.proxy(complete, this))
      .emulateTransitionEnd(350)
      [dimension](this.$element[0][scrollSize])
586
  }
587

588
589
  Collapse.prototype.hide = function () {
    if (this.transitioning || !this.$element.hasClass('in')) return
fat's avatar
fat committed
590
591
592
593
594

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

595
    var dimension = this.dimension()
596

597
598
599
    this.$element
      [dimension](this.$element[dimension]())
      [0].offsetHeight
600

601
    this.$element
602
      .addClass('collapsing')
603
      .removeClass('collapse')
604
      .removeClass('in')
605

606
    this.transitioning = 1
607

608
    var complete = function () {
609
610
611
612
613
      this.transitioning = 0
      this.$element
        .trigger('hidden.bs.collapse')
        .removeClass('collapsing')
        .addClass('collapse')
614
615
    }

616
    if (!$.support.transition) return complete.call(this)
617

618
619
620
621
    this.$element
      [dimension](0)
      .one($.support.transition.end, $.proxy(complete, this))
      .emulateTransitionEnd(350)
622
  }
623

624
625
  Collapse.prototype.toggle = function () {
    this[this.$element.hasClass('in') ? 'hide' : 'show']()
626
627
628
  }


629
630
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
631
632

  var old = $.fn.collapse
633
634
635

  $.fn.collapse = function (option) {
    return this.each(function () {
636
      var $this   = $(this)
fat's avatar
fat committed
637
      var data    = $this.data('bs.collapse')
638
639
      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)

fat's avatar
fat committed
640
      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
641
642
643
644
645
646
647
      if (typeof option == 'string') data[option]()
    })
  }

  $.fn.collapse.Constructor = Collapse


648
649
  // COLLAPSE NO CONFLICT
  // ====================
650

651
652
653
654
655
656
  $.fn.collapse.noConflict = function () {
    $.fn.collapse = old
    return this
  }


657
658
  // COLLAPSE DATA-API
  // =================
659

660
  $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
661
662
    var $this   = $(this), href
    var target  = $this.attr('data-target')
663
664
        || e.preventDefault()
        || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
665
666
667
668
    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
669
    var $parent = parent && $(parent)
670

fat's avatar
fat committed
671
    if (!data || !data.transitioning) {
672
      if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
673
      $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
fat's avatar
fat committed
674
675
    }

676
    $target.collapse(option)
677
678
  })

Chris Rebert's avatar
Chris Rebert committed
679
}(jQuery);
680

681
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
682
 * Bootstrap: dropdown.js v3.0.2
Mark Otto's avatar
Mark Otto committed
683
 * http://getbootstrap.com/javascript/#dropdowns
684
 * ========================================================================
685
 * Copyright 2013 Twitter, Inc.
686
687
688
689
690
691
692
693
694
695
696
697
 *
 * 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.
698
 * ======================================================================== */
699
700


701
+function ($) { "use strict";
702

703
704
  // DROPDOWN CLASS DEFINITION
  // =========================
705

706
707
708
  var backdrop = '.dropdown-backdrop'
  var toggle   = '[data-toggle=dropdown]'
  var Dropdown = function (element) {
709
    var $el = $(element).on('click.bs.dropdown', this.toggle)
710
  }
711

712
713
  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)
714

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

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

720
    clearMenus()
fat's avatar
fat committed
721

722
    if (!isActive) {
fat's avatar
fat committed
723
      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
fat's avatar
fat committed
724
        // if mobile we we use a backdrop because click events don't delegate
Jacob Thornton's avatar
Jacob Thornton committed
725
        $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
fat's avatar
fat committed
726
      }
727
728
729
730
731
732
733
734

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

      if (e.isDefaultPrevented()) return

      $parent
        .toggleClass('open')
        .trigger('shown.bs.dropdown')
735

fat's avatar
rebuild    
fat committed
736
737
      $this.focus()
    }
738

739
740
    return false
  }
741

742
743
  Dropdown.prototype.keydown = function (e) {
    if (!/(38|40|27)/.test(e.keyCode)) return
744

745
    var $this = $(this)
746

747
748
    e.preventDefault()
    e.stopPropagation()
749

750
    if ($this.is('.disabled, :disabled')) return
751

752
753
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
754

755
756
757
758
    if (!isActive || (isActive && e.keyCode == 27)) {
      if (e.which == 27) $parent.find(toggle).focus()
      return $this.click()
    }
759

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

762
    if (!$items.length) return
763

764
    var index = $items.index($items.filter(':focus'))
765

766
767
768
    if (e.keyCode == 38 && index > 0)                 index--                        // up
    if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
    if (!~index)                                      index=0
769

770
    $items.eq(index).focus()
771
772
  }

Mark Otto's avatar
Mark Otto committed
773
  function clearMenus() {
774
    $(backdrop).remove()
775
    $(toggle).each(function (e) {
776
777
778
779
780
781
      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')
    })
782
783
784
785
786
787
788
  }

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

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

792
    var $parent = selector && $(selector)
793

794
    return $parent && $parent.length ? $parent : $this.parent()
795
796
797
  }


798
799
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
800

801
802
  var old = $.fn.dropdown

803
804
805
  $.fn.dropdown = function (option) {
    return this.each(function () {
      var $this = $(this)
806
807
      var data  = $this.data('dropdown')

808
809
810
811
812
813
814
815
      if (!data) $this.data('dropdown', (data = new Dropdown(this)))
      if (typeof option == 'string') data[option].call($this)
    })
  }

  $.fn.dropdown.Constructor = Dropdown


816
817
  // DROPDOWN NO CONFLICT
  // ====================
818
819
820
821
822
823
824

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


825
826
827
  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

828
  $(document)
829
830
831
832
    .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)
833

Chris Rebert's avatar
Chris Rebert committed
834
}(jQuery);
835

836
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
837
 * Bootstrap: modal.js v3.0.2
Mark Otto's avatar
Mark Otto committed
838
 * http://getbootstrap.com/javascript/#modals
839
 * ========================================================================
840
 * Copyright 2013 Twitter, Inc.
841
842
843
844
845
846
847
848
849
850
851
852
 *
 * 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.
853
 * ======================================================================== */
854
855


856
+function ($) { "use strict";
857

fat's avatar
fat committed
858
859
  // MODAL CLASS DEFINITION
  // ======================
860

Jacob Thornton's avatar
Jacob Thornton committed
861
  var Modal = function (element, options) {
fat's avatar
fat committed
862
    this.options   = options
fat's avatar
rebuild    
fat committed
863
    this.$element  = $(element)
fat's avatar
fat committed
864
865
    this.$backdrop =
    this.isShown   = null
866

Jacob Thornton's avatar
Jacob Thornton committed
867
    if (this.options.remote) this.$element.load(this.options.remote)
fat's avatar
fat committed
868
  }
869

fat's avatar
fat committed
870
871
872
873
874
  Modal.DEFAULTS = {
      backdrop: true
    , keyboard: true
    , show: true
  }
875

Jacob Thornton's avatar
Jacob Thornton committed
876
877
  Modal.prototype.toggle = function (_relatedTarget) {
    return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
fat's avatar
fat committed
878
  }
879

Jacob Thornton's avatar
Jacob Thornton committed
880
  Modal.prototype.show = function (_relatedTarget) {
fat's avatar
fat committed
881
    var that = this
Jacob Thornton's avatar
Jacob Thornton committed
882
    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
883

fat's avatar
fat committed
884
    this.$element.trigger(e)
885

fat's avatar
fat committed
886
    if (this.isShown || e.isDefaultPrevented()) return
887

fat's avatar
fat committed
888
    this.isShown = true
889

fat's avatar
fat committed
890
    this.escape()
891

fat's avatar
rebuild    
fat committed
892
893
    this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))

fat's avatar
fat committed
894
895
    this.backdrop(function () {
      var transition = $.support.transition && that.$element.hasClass('fade')
896

fat's avatar
fat committed
897
      if (!that.$element.parent().length) {
Jacob Thornton's avatar
Jacob Thornton committed
898
        that.$element.appendTo(document.body) // don't move modals dom position
fat's avatar
fat committed
899
      }
900

fat's avatar
fat committed
901
      that.$element.show()
902

fat's avatar
fat committed
903
904
905
      if (transition) {
        that.$element[0].offsetWidth // force reflow
      }
906

fat's avatar
fat committed
907
908
909
      that.$element
        .addClass('in')
        .attr('aria-hidden', false)
910

fat's avatar
fat committed
911
      that.enforceFocus()
912

Jacob Thornton's avatar
Jacob Thornton committed
913
914
      var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })

fat's avatar
fat committed
915
      transition ?
fat's avatar
fat committed
916
        that.$element.find('.modal-dialog') // wait for modal to slide in
917
          .one($.support.transition.end, function () {
Jacob Thornton's avatar
Jacob Thornton committed
918
            that.$element.focus().trigger(e)
919
920
          })
          .emulateTransitionEnd(300) :
Jacob Thornton's avatar
Jacob Thornton committed
921
        that.$element.focus().trigger(e)
fat's avatar
fat committed
922
923
    })
  }
924

fat's avatar
fat committed
925
  Modal.prototype.hide = function (e) {
fat's avatar
fat committed
926
    if (e) e.preventDefault()
927

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

fat's avatar
fat committed
930
    this.$element.trigger(e)
931

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

fat's avatar
fat committed
934
    this.isShown = false
935

fat's avatar
fat committed
936
    this.escape()
937

Mark Otto's avatar
Mark Otto committed
938
    $(document).off('focusin.bs.modal')
939

fat's avatar
fat committed
940
941
942
    this.$element
      .removeClass('in')
      .attr('aria-hidden', true)
Jacob Thornton's avatar
Jacob Thornton committed
943
      .off('click.dismiss.modal')
944

fat's avatar
fat committed
945
    $.support.transition && this.$element.hasClass('fade') ?
946
947
948
      this.$element
        .one($.support.transition.end, $.proxy(this.hideModal, this))
        .emulateTransitionEnd(300) :
fat's avatar
fat committed
949
950
      this.hideModal()
  }
951

fat's avatar
fat committed
952
  Modal.prototype.enforceFocus = function () {
Jacob Thornton's avatar
Jacob Thornton committed
953
954
    $(document)
      .off('focusin.bs.modal') // guard against infinite focus loop
fat's avatar
fat committed
955
956
957
958
959
      .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
960
  }
961

fat's avatar
fat committed
962
963
  Modal.prototype.escape = function () {
    if (this.isShown && this.options.keyboard) {
fat's avatar
fat committed
964
      this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
fat's avatar
fat committed
965
        e.which == 27 && this.hide()
fat's avatar
fat committed
966
      }, this))
fat's avatar
fat committed
967
    } else if (!this.isShown) {
Mark Otto's avatar
Mark Otto committed
968
      this.$element.off('keyup.dismiss.bs.modal')
fat's avatar
fat committed
969
970
    }
  }
971

fat's avatar
fat committed
972
973
974
975
976
  Modal.prototype.hideModal = function () {
    var that = this
    this.$element.hide()
    this.backdrop(function () {
      that.removeBackdrop()
Mark Otto's avatar
Mark Otto committed
977
      that.$element.trigger('hidden.bs.modal')
fat's avatar
fat committed
978
979
    })
  }
980

fat's avatar
fat committed
981
982
983
984
  Modal.prototype.removeBackdrop = function () {
    this.$backdrop && this.$backdrop.remove()
    this.$backdrop = null
  }
985

fat's avatar
fat committed
986
987
988
  Modal.prototype.backdrop = function (callback) {
    var that    = this
    var animate = this.$element.hasClass('fade') ? 'fade' : ''
989

fat's avatar
fat committed
990
991
    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate
992

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

Jacob Thornton's avatar
Jacob Thornton committed
996
      this.$element.on('click.dismiss.modal', $.proxy(function (e) {
fat's avatar
fat committed
997
998
999
1000
        if (e.target !== e.currentTarget) return
        this.options.backdrop == 'static'
          ? this.$element[0].focus.call(this.$element[0])
          : this.hide.call(this)
For faster browsing, not all history is shown. View entire blame