bootstrap.js 58 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() {
Chris Rebert's avatar
Chris Rebert committed
102
103
      // detach from parent, fire event then clean up data
      $parent.detach().trigger('closed.bs.alert').remove()
104
105
106
    }

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


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

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

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

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

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


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

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


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

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

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

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


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

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

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

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

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

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

Chris Rebert's avatar
Chris Rebert committed
182
    if (data.resetText == null) $el.data('resetText', $el[val]())
183

Chris Rebert's avatar
Chris Rebert committed
184
    $el[val](data[state] == null ? this.options[state] : data[state])
185
186

    // push to event loop to allow forms to submit
fat's avatar
fat committed
187
188
189
190
191
192
193
194
195
    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)
196
197
198
  }

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

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

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


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

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

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

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

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

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


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

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


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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

368
369
370
    this.sliding = true

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

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

Mark Otto's avatar
Mark Otto committed
380
    var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
fat's avatar
fat committed
381
382
383
384
385
    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
386
      $active
387
388
389
390
        .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
391
          setTimeout(function () { that.$element.trigger(slidEvent) }, 0)
392
        })
Mark Otto's avatar
Mark Otto committed
393
        .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
fat's avatar
fat committed
394
395
396
397
    } else {
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
Mark Otto's avatar
Mark Otto committed
398
      this.$element.trigger(slidEvent)
399
400
    }

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

    return this
404
405
406
  }


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

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

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

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

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


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

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

fat's avatar
fat committed
438

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

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

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

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

455
    e.preventDefault()
456
457
  })

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

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

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


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

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

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

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

  Collapse.DEFAULTS = {
    toggle: true
  }
494

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

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

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

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

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

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

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

    this.transitioning = 1

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

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

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

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

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

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

555
    var dimension = this.dimension()
556

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

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

564
    this.transitioning = 1
565

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

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

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

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


592
593
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
594

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

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

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

  $.fn.collapse             = Plugin
610
611
612
  $.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

Mark Otto's avatar
grunt    
Mark Otto committed
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) {
Mark Otto's avatar
grunt    
Mark Otto 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
    }

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

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

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


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

658
659
  // DROPDOWN CLASS DEFINITION
  // =========================
660

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

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

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

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

675
    clearMenus()
fat's avatar
fat committed
676

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

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

      if (e.isDefaultPrevented()) return

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

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

695
696
    return false
  }
697

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

701
    var $this = $(this)
702

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

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

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

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

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

719
    if (!$items.length) return
720

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

723
724
    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
725
    if (!~index)                                      index = 0
726

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

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

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

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

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

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


757
758
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
759

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

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

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

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


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

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


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

788
  $(document)
789
790
    .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
791
    .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
Mark Otto's avatar
grunt    
Mark Otto committed
792
    .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
793

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

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


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

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

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

819
820
821
822
823
824
825
    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
826
  }
827

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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