bootstrap.js 57.8 KB
Newer Older
1
/*!
Mark Otto's avatar
Mark Otto committed
2
 * Bootstrap v3.1.1 (http://getbootstrap.com)
3
 * Copyright 2011-2014 Twitter, Inc.
Mark Otto's avatar
Mark Otto committed
4
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
Chris Rebert's avatar
Chris Rebert committed
5
 */
6

7
if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
8

9
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
10
 * Bootstrap: transition.js v3.1.1
Mark Otto's avatar
Mark Otto committed
11
 * http://getbootstrap.com/javascript/#transitions
12
 * ========================================================================
13
 * Copyright 2011-2014 Twitter, Inc.
14
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
15
 * ======================================================================== */
16
17


18
19
+function ($) {
  'use strict';
20

21
22
  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  // ============================================================
23

24
25
  function transitionEnd() {
    var el = document.createElement('bootstrap')
26

27
    var transEndEventNames = {
XhmikosR's avatar
XhmikosR committed
28
29
30
31
      WebkitTransition : 'webkitTransitionEnd',
      MozTransition    : 'transitionend',
      OTransition      : 'oTransitionEnd otransitionend',
      transition       : 'transitionend'
fat's avatar
fat committed
32
    }
33

34
35
36
37
38
    for (var name in transEndEventNames) {
      if (el.style[name] !== undefined) {
        return { end: transEndEventNames[name] }
      }
    }
39
40

    return false // explicit for ie8 (  ._.)
41
42
  }

43
44
  // http://blog.alexmaccaw.com/css-transitions
  $.fn.emulateTransitionEnd = function (duration) {
45
    var called = false, $el = this
liuyl's avatar
liuyl committed
46
47
    $(this).one($.support.transition.end, function () { called = true })
    var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
48
    setTimeout(callback, duration)
49
    return this
50
51
  }

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

Chris Rebert's avatar
Chris Rebert committed
56
}(jQuery);
57

58
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
59
 * Bootstrap: alert.js v3.1.1
Mark Otto's avatar
Mark Otto committed
60
 * http://getbootstrap.com/javascript/#alerts
61
 * ========================================================================
62
 * Copyright 2011-2014 Twitter, Inc.
63
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
64
 * ======================================================================== */
65
66


67
68
+function ($) {
  'use strict';
69

fat's avatar
fat committed
70
71
  // ALERT CLASS DEFINITION
  // ======================
72
73

  var dismiss = '[data-dismiss="alert"]'
fat's avatar
fat committed
74
75
76
  var Alert   = function (el) {
    $(el).on('click', dismiss, this.close)
  }
77
78

  Alert.prototype.close = function (e) {
fat's avatar
fat committed
79
80
    var $this    = $(this)
    var selector = $this.attr('data-target')
81
82
83

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

fat's avatar
fat committed
87
    var $parent = $(selector)
88

fat's avatar
fat committed
89
    if (e) e.preventDefault()
90

fat's avatar
fat committed
91
92
93
    if (!$parent.length) {
      $parent = $this.hasClass('alert') ? $this : $this.parent()
    }
94

Mark Otto's avatar
Mark Otto committed
95
    $parent.trigger(e = $.Event('close.bs.alert'))
96
97
98
99
100
101

    if (e.isDefaultPrevented()) return

    $parent.removeClass('in')

    function removeElement() {
Mark Otto's avatar
Mark Otto committed
102
      $parent.trigger('closed.bs.alert').remove()
103
104
105
    }

    $.support.transition && $parent.hasClass('fade') ?
106
107
108
      $parent
        .one($.support.transition.end, removeElement)
        .emulateTransitionEnd(150) :
109
110
111
112
      removeElement()
  }


fat's avatar
fat committed
113
114
  // ALERT PLUGIN DEFINITION
  // =======================
115

Mark Otto's avatar
Mark Otto committed
116
  function Plugin(option) {
117
118
    return this.each(function () {
      var $this = $(this)
Mark Otto's avatar
Mark Otto committed
119
      var data  = $this.data('bs.alert')
fat's avatar
fat committed
120

Mark Otto's avatar
Mark Otto committed
121
      if (!data) $this.data('bs.alert', (data = new Alert(this)))
122
123
124
125
      if (typeof option == 'string') data[option].call($this)
    })
  }

Mark Otto's avatar
Mark Otto committed
126
127
128
  var old = $.fn.alert

  $.fn.alert             = Plugin
129
130
131
  $.fn.alert.Constructor = Alert


fat's avatar
fat committed
132
133
  // ALERT NO CONFLICT
  // =================
134
135
136
137
138
139
140

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


fat's avatar
fat committed
141
  // ALERT DATA-API
fat's avatar
fat committed
142
  // ==============
143

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

Chris Rebert's avatar
Chris Rebert committed
146
}(jQuery);
147

148
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
149
 * Bootstrap: button.js v3.1.1
Mark Otto's avatar
Mark Otto committed
150
 * http://getbootstrap.com/javascript/#buttons
151
 * ========================================================================
152
 * Copyright 2011-2014 Twitter, Inc.
153
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
154
 * ======================================================================== */
155
156


157
158
+function ($) {
  'use strict';
159

fat's avatar
fat committed
160
161
  // BUTTON PUBLIC CLASS DEFINITION
  // ==============================
162
163

  var Button = function (element, options) {
fat's avatar
fat committed
164
165
166
    this.$element  = $(element)
    this.options   = $.extend({}, Button.DEFAULTS, options)
    this.isLoading = false
fat's avatar
fat committed
167
168
169
170
  }

  Button.DEFAULTS = {
    loadingText: 'loading...'
171
172
173
  }

  Button.prototype.setState = function (state) {
fat's avatar
fat committed
174
175
176
177
    var d    = 'disabled'
    var $el  = this.$element
    var val  = $el.is('input') ? 'val' : 'html'
    var data = $el.data()
178
179

    state = state + 'Text'
fat's avatar
fat committed
180
181

    if (!data.resetText) $el.data('resetText', $el[val]())
182
183
184
185

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

    // push to event loop to allow forms to submit
fat's avatar
fat committed
186
187
188
189
190
191
192
193
194
    setTimeout($.proxy(function () {
      if (state == 'loadingText') {
        this.isLoading = true
        $el.addClass(d).attr(d, d)
      } else if (this.isLoading) {
        this.isLoading = false
        $el.removeClass(d).removeAttr(d)
      }
    }, this), 0)
195
196
197
  }

  Button.prototype.toggle = function () {
198
    var changed = true
fat's avatar
fat committed
199
    var $parent = this.$element.closest('[data-toggle="buttons"]')
200

201
    if ($parent.length) {
fat's avatar
fat committed
202
      var $input = this.$element.find('input')
fat's avatar
fat committed
203
204
205
      if ($input.prop('type') == 'radio') {
        if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
        else $parent.find('.active').removeClass('active')
206
207
      }
      if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
fat's avatar
fat committed
208
    }
209

210
    if (changed) this.$element.toggleClass('active')
211
212
213
  }


fat's avatar
fat committed
214
215
  // BUTTON PLUGIN DEFINITION
  // ========================
216

Mark Otto's avatar
Mark Otto committed
217
  function Plugin(option) {
218
    return this.each(function () {
fat's avatar
fat committed
219
      var $this   = $(this)
fat's avatar
fat committed
220
      var data    = $this.data('bs.button')
fat's avatar
fat committed
221
222
      var options = typeof option == 'object' && option

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

225
226
227
228
229
      if (option == 'toggle') data.toggle()
      else if (option) data.setState(option)
    })
  }

Mark Otto's avatar
Mark Otto committed
230
231
232
  var old = $.fn.button

  $.fn.button             = Plugin
233
234
235
  $.fn.button.Constructor = Button


fat's avatar
fat committed
236
237
  // BUTTON NO CONFLICT
  // ==================
238
239
240
241
242
243
244

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


fat's avatar
fat committed
245
246
  // BUTTON DATA-API
  // ===============
247

Chris Rebert's avatar
Chris Rebert committed
248
  $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
249
250
    var $btn = $(e.target)
    if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
Mark Otto's avatar
Mark Otto committed
251
    Plugin.call($btn, 'toggle')
252
    e.preventDefault()
253
254
  })

Chris Rebert's avatar
Chris Rebert committed
255
}(jQuery);
256

257
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
258
 * Bootstrap: carousel.js v3.1.1
Mark Otto's avatar
Mark Otto committed
259
 * http://getbootstrap.com/javascript/#carousel
260
 * ========================================================================
261
 * Copyright 2011-2014 Twitter, Inc.
262
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
263
 * ======================================================================== */
264
265


266
267
+function ($) {
  'use strict';
268

fat's avatar
fat committed
269
270
  // CAROUSEL CLASS DEFINITION
  // =========================
271
272

  var Carousel = function (element, options) {
fat's avatar
fat committed
273
    this.$element    = $(element)
fat's avatar
fat committed
274
    this.$indicators = this.$element.find('.carousel-indicators')
fat's avatar
fat committed
275
276
277
278
279
280
281
    this.options     = options
    this.paused      =
    this.sliding     =
    this.interval    =
    this.$active     =
    this.$items      = null

282
283
284
285
286
    this.options.pause == 'hover' && this.$element
      .on('mouseenter', $.proxy(this.pause, this))
      .on('mouseleave', $.proxy(this.cycle, this))
  }

fat's avatar
fat committed
287
  Carousel.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
288
289
290
    interval: 5000,
    pause: 'hover',
    wrap: true
fat's avatar
fat committed
291
  }
292

fat's avatar
fat committed
293
294
  Carousel.prototype.cycle =  function (e) {
    e || (this.paused = false)
295

fat's avatar
fat committed
296
    this.interval && clearInterval(this.interval)
fat's avatar
fat committed
297

fat's avatar
fat committed
298
299
300
    this.options.interval
      && !this.paused
      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
301

fat's avatar
fat committed
302
303
    return this
  }
304

fat's avatar
fat committed
305
306
  Carousel.prototype.getActiveIndex = function () {
    this.$active = this.$element.find('.item.active')
Mark Otto's avatar
grunt    
Mark Otto committed
307
    this.$items  = this.$active.parent().children('.item')
308

fat's avatar
fat committed
309
310
    return this.$items.index(this.$active)
  }
311

fat's avatar
fat committed
312
313
314
  Carousel.prototype.to = function (pos) {
    var that        = this
    var activeIndex = this.getActiveIndex()
315

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

Mark Otto's avatar
Mark Otto committed
318
    if (this.sliding)       return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
fat's avatar
fat committed
319
320
321
322
    if (activeIndex == pos) return this.pause().cycle()

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

fat's avatar
fat committed
324
325
326
  Carousel.prototype.pause = function (e) {
    e || (this.paused = true)

327
    if (this.$element.find('.next, .prev').length && $.support.transition) {
fat's avatar
fat committed
328
329
      this.$element.trigger($.support.transition.end)
      this.cycle(true)
330
331
    }

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

fat's avatar
fat committed
334
335
    return this
  }
336

fat's avatar
fat committed
337
338
339
340
  Carousel.prototype.next = function () {
    if (this.sliding) return
    return this.slide('next')
  }
341

fat's avatar
fat committed
342
343
344
345
  Carousel.prototype.prev = function () {
    if (this.sliding) return
    return this.slide('prev')
  }
346

fat's avatar
fat committed
347
348
349
350
351
352
353
  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
354

Jacob Thornton's avatar
Jacob Thornton committed
355
356
357
358
359
    if (!$next.length) {
      if (!this.options.wrap) return
      $next = this.$element.find('.item')[fallback]()
    }

360
    if ($next.hasClass('active')) return this.sliding = false
fat's avatar
fat committed
361

Mark Otto's avatar
Mark Otto committed
362
363
364
365
    var relatedTarget = $next[0]
    var slideEvent = $.Event('slide.bs.carousel', { relatedTarget: relatedTarget, direction: direction })
    this.$element.trigger(slideEvent)
    if (slideEvent.isDefaultPrevented()) return
366

367
368
369
    this.sliding = true

    isCycling && this.pause()
fat's avatar
fat committed
370
371
372

    if (this.$indicators.length) {
      this.$indicators.find('.active').removeClass('active')
Mark Otto's avatar
Mark Otto committed
373
      this.$element.one('slid.bs.carousel', function () { // yes, "slid"
fat's avatar
fat committed
374
375
376
377
378
        var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
        $nextIndicator && $nextIndicator.addClass('active')
      })
    }

Mark Otto's avatar
Mark Otto committed
379
    var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
fat's avatar
fat committed
380
381
382
383
384
    if ($.support.transition && this.$element.hasClass('slide')) {
      $next.addClass(type)
      $next[0].offsetWidth // force reflow
      $active.addClass(direction)
      $next.addClass(direction)
Jacob Thornton's avatar
Jacob Thornton committed
385
      $active
386
387
388
389
        .one($.support.transition.end, function () {
          $next.removeClass([type, direction].join(' ')).addClass('active')
          $active.removeClass(['active', direction].join(' '))
          that.sliding = false
Mark Otto's avatar
Mark Otto committed
390
          setTimeout(function () { that.$element.trigger(slidEvent) }, 0)
391
        })
Mark Otto's avatar
Mark Otto committed
392
        .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
fat's avatar
fat committed
393
394
395
396
    } else {
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
Mark Otto's avatar
Mark Otto committed
397
      this.$element.trigger(slidEvent)
398
399
    }

fat's avatar
fat committed
400
401
402
    isCycling && this.cycle()

    return this
403
404
405
  }


fat's avatar
fat committed
406
407
  // CAROUSEL PLUGIN DEFINITION
  // ==========================
408

Mark Otto's avatar
Mark Otto committed
409
  function Plugin(option) {
410
    return this.each(function () {
fat's avatar
fat committed
411
      var $this   = $(this)
Mark Otto's avatar
Mark Otto committed
412
      var data    = $this.data('bs.carousel')
Jacob Thornton's avatar
Jacob Thornton committed
413
      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
fat's avatar
fat committed
414
415
      var action  = typeof option == 'string' ? option : options.slide

Mark Otto's avatar
Mark Otto committed
416
      if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
417
      if (typeof option == 'number') data.to(option)
Jacob Thornton's avatar
Jacob Thornton committed
418
      else if (action) data[action]()
Mark Otto's avatar
Mark Otto committed
419
      else if (options.interval) data.pause().cycle()
420
421
422
    })
  }

Mark Otto's avatar
Mark Otto committed
423
424
425
  var old = $.fn.carousel

  $.fn.carousel             = Plugin
426
427
428
  $.fn.carousel.Constructor = Carousel


fat's avatar
fat committed
429
430
  // CAROUSEL NO CONFLICT
  // ====================
431
432
433
434
435
436

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

fat's avatar
fat committed
437

fat's avatar
fat committed
438
439
  // CAROUSEL DATA-API
  // =================
440

441
  $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
fat's avatar
fat committed
442
    var $this   = $(this), href
fat's avatar
fat committed
443
444
    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
445
446
    var slideIndex = $this.attr('data-slide-to')
    if (slideIndex) options.interval = false
447

Mark Otto's avatar
Mark Otto committed
448
    Plugin.call($target, options)
449
450

    if (slideIndex = $this.attr('data-slide-to')) {
fat's avatar
fat committed
451
      $target.data('bs.carousel').to(slideIndex)
452
453
    }

454
    e.preventDefault()
455
456
  })

fat's avatar
fat committed
457
458
459
  $(window).on('load', function () {
    $('[data-ride="carousel"]').each(function () {
      var $carousel = $(this)
Mark Otto's avatar
Mark Otto committed
460
      Plugin.call($carousel, $carousel.data())
fat's avatar
fat committed
461
462
463
    })
  })

Chris Rebert's avatar
Chris Rebert committed
464
}(jQuery);
465

466
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
467
 * Bootstrap: collapse.js v3.1.1
Mark Otto's avatar
Mark Otto committed
468
 * http://getbootstrap.com/javascript/#collapse
469
 * ========================================================================
470
 * Copyright 2011-2014 Twitter, Inc.
471
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
472
 * ======================================================================== */
473
474


475
476
+function ($) {
  'use strict';
477

478
479
  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================
480
481

  var Collapse = function (element, options) {
482
483
484
    this.$element      = $(element)
    this.options       = $.extend({}, Collapse.DEFAULTS, options)
    this.transitioning = null
485

486
487
488
489
490
491
492
    if (this.options.parent) this.$parent = $(this.options.parent)
    if (this.options.toggle) this.toggle()
  }

  Collapse.DEFAULTS = {
    toggle: true
  }
493

494
495
496
  Collapse.prototype.dimension = function () {
    var hasWidth = this.$element.hasClass('width')
    return hasWidth ? 'width' : 'height'
497
498
  }

499
500
  Collapse.prototype.show = function () {
    if (this.transitioning || this.$element.hasClass('in')) return
501

fat's avatar
fat committed
502
503
504
505
    var startEvent = $.Event('show.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

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

508
    if (actives && actives.length) {
fat's avatar
fat committed
509
      var hasData = actives.data('bs.collapse')
510
      if (hasData && hasData.transitioning) return
Mark Otto's avatar
Mark Otto committed
511
      Plugin.call(actives, 'hide')
fat's avatar
fat committed
512
      hasData || actives.data('bs.collapse', null)
513
514
    }

515
516
517
518
    var dimension = this.dimension()

    this.$element
      .removeClass('collapse')
XhmikosR's avatar
XhmikosR committed
519
      .addClass('collapsing')[dimension](0)
520
521
522

    this.transitioning = 1

fat's avatar
fat committed
523
    var complete = function (e) {
Mark Otto's avatar
Mark Otto committed
524
525
526
527
528
      if (e && e.target != this.$element[0]) {
        this.$element
          .one($.support.transition.end, $.proxy(complete, this))
        return
      }
529
530
      this.$element
        .removeClass('collapsing')
Chris Rebert's avatar
Chris Rebert committed
531
        .addClass('collapse in')[dimension]('')
532
      this.transitioning = 0
XhmikosR's avatar
XhmikosR committed
533
534
535
      this.$element
        .off($.support.transition.end + '.bs.collapse')
        .trigger('shown.bs.collapse')
536
537
538
539
540
    }

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

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

542
    this.$element
XhmikosR's avatar
XhmikosR committed
543
      .on($.support.transition.end + '.bs.collapse', $.proxy(complete, this))
XhmikosR's avatar
XhmikosR committed
544
      .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
545
  }
546

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

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

554
    var dimension = this.dimension()
555

XhmikosR's avatar
XhmikosR committed
556
    this.$element[dimension](this.$element[dimension]())[0].offsetHeight
557

558
    this.$element
559
      .addClass('collapsing')
560
      .removeClass('collapse')
561
      .removeClass('in')
562

563
    this.transitioning = 1
564

fat's avatar
fat committed
565
    var complete = function (e) {
Mark Otto's avatar
Mark Otto committed
566
567
568
569
570
      if (e && e.target != this.$element[0]) {
        this.$element
          .one($.support.transition.end, $.proxy(complete, this))
        return
      }
571
572
573
574
575
      this.transitioning = 0
      this.$element
        .trigger('hidden.bs.collapse')
        .removeClass('collapsing')
        .addClass('collapse')
576
577
    }

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

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

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


591
592
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
593

Mark Otto's avatar
Mark Otto committed
594
  function Plugin(option) {
595
    return this.each(function () {
596
      var $this   = $(this)
fat's avatar
fat committed
597
      var data    = $this.data('bs.collapse')
598
599
      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)

600
      if (!data && options.toggle && option == 'show') option = !option
fat's avatar
fat committed
601
      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
602
603
604
605
      if (typeof option == 'string') data[option]()
    })
  }

Mark Otto's avatar
Mark Otto committed
606
607
608
  var old = $.fn.collapse

  $.fn.collapse             = Plugin
609
610
611
  $.fn.collapse.Constructor = Collapse


612
613
  // COLLAPSE NO CONFLICT
  // ====================
614

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


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

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

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

Mark Otto's avatar
Mark Otto committed
640
    Plugin.call($target, option)
641
642
  })

Chris Rebert's avatar
Chris Rebert committed
643
}(jQuery);
644

645
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
646
 * Bootstrap: dropdown.js v3.1.1
Mark Otto's avatar
Mark Otto committed
647
 * http://getbootstrap.com/javascript/#dropdowns
648
 * ========================================================================
649
 * Copyright 2011-2014 Twitter, Inc.
650
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
651
 * ======================================================================== */
652
653


654
655
+function ($) {
  'use strict';
656

657
658
  // DROPDOWN CLASS DEFINITION
  // =========================
659

660
  var backdrop = '.dropdown-backdrop'
Mark Otto's avatar
grunt    
Mark Otto committed
661
  var toggle   = '[data-toggle="dropdown"]'
662
  var Dropdown = function (element) {
663
    $(element).on('click.bs.dropdown', this.toggle)
664
  }
665

666
667
  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)
668

669
    if ($this.is('.disabled, :disabled')) return
670

671
672
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
673

674
    clearMenus()
fat's avatar
fat committed
675

676
    if (!isActive) {
fat's avatar
fat committed
677
      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
Mark Otto's avatar
Mark Otto committed
678
        // if mobile we use a backdrop because click events don't delegate
Jacob Thornton's avatar
Jacob Thornton committed
679
        $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
fat's avatar
fat committed
680
      }
681

682
683
      var relatedTarget = { relatedTarget: this }
      $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
684
685
686

      if (e.isDefaultPrevented()) return

Mark Otto's avatar
Mark Otto committed
687
688
      $this.trigger('focus')

689
690
      $parent
        .toggleClass('open')
691
        .trigger('shown.bs.dropdown', relatedTarget)
fat's avatar
rebuild    
fat committed
692
    }
693

694
695
    return false
  }
696

697
698
  Dropdown.prototype.keydown = function (e) {
    if (!/(38|40|27)/.test(e.keyCode)) return
699

700
    var $this = $(this)
701

702
703
    e.preventDefault()
    e.stopPropagation()
704

705
    if ($this.is('.disabled, :disabled')) return
706

707
708
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
709

710
    if (!isActive || (isActive && e.keyCode == 27)) {
711
712
      if (e.which == 27) $parent.find(toggle).trigger('focus')
      return $this.trigger('click')
713
    }
714

fat's avatar
fat committed
715
    var desc = ' li:not(.divider):visible a'
Mark Otto's avatar
grunt    
Mark Otto committed
716
    var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
717

718
    if (!$items.length) return
719

720
    var index = $items.index($items.filter(':focus'))
721

722
723
    if (e.keyCode == 38 && index > 0)                 index--                        // up
    if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
Mark Otto's avatar
Mark Otto committed
724
    if (!~index)                                      index = 0
725

726
    $items.eq(index).trigger('focus')
727
728
  }

729
  function clearMenus(e) {
Chris Rebert's avatar
Chris Rebert committed
730
    if (e && e.which === 3) return
731
    $(backdrop).remove()
732
    $(toggle).each(function () {
733
      var $parent = getParent($(this))
734
      var relatedTarget = { relatedTarget: this }
735
      if (!$parent.hasClass('open')) return
736
      $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
737
      if (e.isDefaultPrevented()) return
738
      $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
739
    })
740
741
742
743
744
745
746
  }

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

    if (!selector) {
      selector = $this.attr('href')
747
      selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
748
749
    }

750
    var $parent = selector && $(selector)
751

752
    return $parent && $parent.length ? $parent : $this.parent()
753
754
755
  }


756
757
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
758

Mark Otto's avatar
Mark Otto committed
759
  function Plugin(option) {
760
761
    return this.each(function () {
      var $this = $(this)
762
      var data  = $this.data('bs.dropdown')
763

764
      if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
765
766
767
768
      if (typeof option == 'string') data[option].call($this)
    })
  }

Mark Otto's avatar
Mark Otto committed
769
770
771
  var old = $.fn.dropdown

  $.fn.dropdown             = Plugin
772
773
774
  $.fn.dropdown.Constructor = Dropdown


775
776
  // DROPDOWN NO CONFLICT
  // ====================
777
778
779
780
781
782
783

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


784
785
786
  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

787
  $(document)
788
789
    .on('click.bs.dropdown.data-api', clearMenus)
    .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
Mark Otto's avatar
Mark Otto committed
790
    .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
Mark Otto's avatar
grunt    
Mark Otto committed
791
    .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
792

Chris Rebert's avatar
Chris Rebert committed
793
}(jQuery);
794

795
/* ========================================================================
Mark Otto's avatar
Mark Otto committed
796
 * Bootstrap: modal.js v3.1.1
Mark Otto's avatar
Mark Otto committed
797
 * http://getbootstrap.com/javascript/#modals
798
 * ========================================================================
799
 * Copyright 2011-2014 Twitter, Inc.
800
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
801
 * ======================================================================== */
802
803


804
805
+function ($) {
  'use strict';
806

fat's avatar
fat committed
807
808
  // MODAL CLASS DEFINITION
  // ======================
809

Jacob Thornton's avatar
Jacob Thornton committed
810
  var Modal = function (element, options) {
811
812
813
814
815
816
    this.options        = options
    this.$body          = $(document.body)
    this.$element       = $(element)
    this.$backdrop      =
    this.isShown        = null
    this.scrollbarWidth = 0
817

818
819
820
821
822
823
824
    if (this.options.remote) {
      this.$element
        .find('.modal-content')
        .load(this.options.remote, $.proxy(function () {
          this.$element.trigger('loaded.bs.modal')
        }, this))
    }
fat's avatar
fat committed
825
  }
826

fat's avatar
fat committed
827
  Modal.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
828
829
830
    backdrop: true,
    keyboard: true,
    show: true
fat's avatar
fat committed
831
  }
832

Jacob Thornton's avatar
Jacob Thornton committed
833
  Modal.prototype.toggle = function (_relatedTarget) {
834
    return this.isShown ? this.hide() : this.show(_relatedTarget)
fat's avatar
fat committed
835
  }
836

Jacob Thornton's avatar
Jacob Thornton committed
837
  Modal.prototype.show = function (_relatedTarget) {
fat's avatar
fat committed
838
    var that = this
Jacob Thornton's avatar
Jacob Thornton committed
839
    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
840

fat's avatar
fat committed
841
    this.$element.trigger(e)
842

fat's avatar
fat committed
843
    if (this.isShown || e.isDefaultPrevented()) return
844

fat's avatar
fat committed
845
    this.isShown = true
846

847
    this.checkScrollbar()
fat's avatar
build    
fat committed
848
849
850
    this.$body.addClass('modal-open')

    this.setScrollbar()
fat's avatar
fat committed
851
    this.escape()
852

853
    this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
fat's avatar
rebuild    
fat committed
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) {
fat's avatar
build    
fat committed
859
        that.$element.appendTo(that.$body) // don't move modals dom position
fat's avatar
fat committed
860
      }
861

862
863
864
      that.$element
        .show()
        .scrollTop(0)
865

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

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

fat's avatar
fat committed
874
      that.enforceFocus()
875

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

fat's avatar
fat committed
878
      transition ?
fat's avatar
fat committed
879
        that.$element.find('.modal-dialog') // wait for modal to slide in
880
          .one($.support.transition.end, function () {
881
            that.$element.trigger('focus').trigger(e)
882
883
          })
          .emulateTransitionEnd(300) :
884
        that.$element.trigger('focus').trigger(e)
fat's avatar
fat committed
885
886
    })
  }
887

fat's avatar
fat committed
888
  Modal.prototype.hide = function (e) {
fat's avatar
fat committed
889
    if (e) e.preventDefault()
890

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

fat's avatar
fat committed
893
    this.$element.trigger(e)
894

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

fat's avatar
fat committed
897
    this.isShown = false
898

fat's avatar
build    
fat committed
899
900
901
    this.$body.removeClass('modal-open')

    this.resetScrollbar()
fat's avatar
fat committed
902
    this.escape()
903

Mark Otto's avatar
Mark Otto committed
904
    $(document).off('focusin.bs.modal')
905

fat's avatar
fat committed
906
907
908
    this.$element
      .removeClass('in')
      .attr('aria-hidden', true)
909
      .off('click.dismiss.bs.modal')
910

fat's avatar
fat committed
911
    $.support.transition && this.$element.hasClass('fade') ?
912
913
914
      this.$element
        .one($.support.transition.end, $.proxy(this.hideModal, this))
        .emulateTransitionEnd(300) :
fat's avatar
fat committed
915
916
      this.hideModal()
  }
917

fat's avatar
fat committed
918
  Modal.prototype.enforceFocus = function () {
Jacob Thornton's avatar
Jacob Thornton committed
919
920
    $(document)
      .off('focusin.bs.modal') // guard against infinite focus loop
fat's avatar
fat committed
921
922
      .on('focusin.bs.modal', $.proxy(function (e) {
        if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
923
          this.$element.trigger('focus')
fat's avatar
fat committed
924
925
        }
      }, this))
fat's avatar
fat committed
926
  }
927

fat's avatar
fat committed
928
929
  Modal.prototype.escape = function () {
    if (this.isShown && this.options.keyboard) {
fat's avatar
fat committed
930
      this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
fat's avatar
fat committed
931
        e.which == 27 && this.hide()
fat's avatar
fat committed
932
      }, this))
fat's avatar
fat committed
933
    } else if (!this.isShown) {
Mark Otto's avatar
Mark Otto committed
934
      this.$element.off('keyup.dismiss.bs.modal')
fat's avatar
fat committed
935
936
    }
  }
937

fat's avatar
fat committed
938
939
940
941
  Modal.prototype.hideModal = function () {
    var that = this
    this.$element.hide()
    this.backdrop(function () {
Mark Otto's avatar
Mark Otto committed
942
      that.$element.trigger('hidden.bs.modal')
fat's avatar
fat committed
943
944
    })
  }
945

fat's avatar
fat committed
946
947
948
949
  Modal.prototype.removeBackdrop = function () {
    this.$backdrop && this.$backdrop.remove()
    this.$backdrop = null
  }
950

fat's avatar
fat committed
951
  Modal.prototype.backdrop = function (callback) {
Chris Rebert's avatar
Chris Rebert committed
952
    var that = this
fat's avatar
fat committed
953
    var animate = this.$element.hasClass('fade') ? 'fade' : ''
954

fat's avatar
fat committed
955
956
    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate
957

fat's avatar
fat committed
958
      this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
fat's avatar
build    
fat committed
959
        .appendTo(this.$body)
960

961
      this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
fat's avatar
fat committed
962
963
964
965
966
        if (e.target !== e.currentTarget) return
        this.options.backdrop == 'static'
          ? this.$element[0].focus.call(this.$element[0])
          : this.hide.call(this)
      }, this))
967

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

fat's avatar
fat committed
970
      this.$backdrop.addClass('in')
971

fat's avatar
fat committed
972
      if (!callback) return
973

fat's avatar
fat committed
974
      doAnimate ?
975
976
977
        this.$backdrop
          .one($.support.transition.end, callback)
          .emulateTransitionEnd(150) :
fat's avatar
fat committed
978
        callback()
979

fat's avatar
fat committed
980
981
    } else if (!this.isShown && this.$backdrop) {
      this.$backdrop.removeClass('in')
982

Chris Rebert's avatar
Chris Rebert committed
983
984
985
986
      var callbackRemove = function() {
        that.removeBackdrop()
        callback && callback()
      }
Mark Otto's avatar
Mark Otto committed
987
      $.support.transition && this.$element.hasClass('fade') ?
988
        this.$backdrop
Chris Rebert's avatar
Chris Rebert committed
989
          .one($.support.transition.end, callbackRemove)
990
          .emulateTransitionEnd(150) :
Chris Rebert's avatar
Chris Rebert committed
991
        callbackRemove()
992

fat's avatar
fat committed
993
994
995
    } else if (callback) {
      callback()
    }
996
997
  }

998
999
1000
  Modal.prototype.checkScrollbar = function () {
    if (document.body.clientWidth >= window.innerWidth) return
    this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
For faster browsing, not all history is shown. View entire blame