bootstrap.js 57.2 KB
Newer Older
1
/*!
Mark Otto's avatar
Mark Otto committed
2
 * Bootstrap v3.1.0 (http://getbootstrap.com)
Chris Rebert's avatar
Chris Rebert committed
3
4
5
 * Copyright 2013 Twitter, Inc.
 * Licensed under http://www.apache.org/licenses/LICENSE-2.0
 */
6

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

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


XhmikosR's avatar
XhmikosR committed
29
+function ($) { 'use strict';
30

31
32
  // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  // ============================================================
33

34
35
  function transitionEnd() {
    var el = document.createElement('bootstrap')
36

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

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

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

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

Chris Rebert's avatar
Chris Rebert committed
64
}(jQuery);
65

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


XhmikosR's avatar
XhmikosR committed
86
+function ($) { 'use strict';
87

fat's avatar
fat committed
88
89
  // ALERT CLASS DEFINITION
  // ======================
90
91

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

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

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

fat's avatar
fat committed
105
    var $parent = $(selector)
106

fat's avatar
fat committed
107
    if (e) e.preventDefault()
108

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

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

    if (e.isDefaultPrevented()) return

    $parent.removeClass('in')

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

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


fat's avatar
fat committed
131
132
  // ALERT PLUGIN DEFINITION
  // =======================
133

134
135
  var old = $.fn.alert

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

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

  $.fn.alert.Constructor = Alert


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

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


fat's avatar
fat committed
158
  // ALERT DATA-API
fat's avatar
fat committed
159
  // ==============
160

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

Chris Rebert's avatar
Chris Rebert committed
163
}(jQuery);
164

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


XhmikosR's avatar
XhmikosR committed
185
+function ($) { 'use strict';
186

fat's avatar
fat committed
187
188
  // BUTTON PUBLIC CLASS DEFINITION
  // ==============================
189
190
191

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

  Button.DEFAULTS = {
    loadingText: 'loading...'
197
198
199
  }

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

    state = state + 'Text'
fat's avatar
fat committed
206
207

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

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

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

223
    if ($parent.length) {
fat's avatar
fat committed
224
      var $input = this.$element.find('input')
225
226
227
228
229
230
231
232
      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
233
    }
234

235
    if (changed) this.$element.toggleClass('active')
236
237
238
  }


fat's avatar
fat committed
239
240
  // BUTTON PLUGIN DEFINITION
  // ========================
241

242
243
  var old = $.fn.button

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

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

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

  $.fn.button.Constructor = Button


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

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


fat's avatar
fat committed
269
270
  // BUTTON DATA-API
  // ===============
271

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

Chris Rebert's avatar
Chris Rebert committed
279
}(jQuery);
280

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


XhmikosR's avatar
XhmikosR committed
301
+function ($) { 'use strict';
302

fat's avatar
fat committed
303
304
  // CAROUSEL CLASS DEFINITION
  // =========================
305
306

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

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

fat's avatar
fat committed
321
  Carousel.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
322
323
324
    interval: 5000,
    pause: 'hover',
    wrap: true
fat's avatar
fat committed
325
  }
326

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

fat's avatar
fat committed
330
    this.interval && clearInterval(this.interval)
fat's avatar
fat committed
331

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

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

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

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

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

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

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

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

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

fat's avatar
fat committed
366
    this.interval = clearInterval(this.interval)
367

fat's avatar
fat committed
368
369
    return this
  }
370

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

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

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

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

fat's avatar
fat committed
394
    this.sliding = true
395

fat's avatar
fat committed
396
    isCycling && this.pause()
fat's avatar
fat committed
397

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

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

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

fat's avatar
fat committed
434
435
436
    isCycling && this.cycle()

    return this
437
438
439
  }


fat's avatar
fat committed
440
441
  // CAROUSEL PLUGIN DEFINITION
  // ==========================
442

443
444
  var old = $.fn.carousel

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

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

  $.fn.carousel.Constructor = Carousel


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

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

fat's avatar
fat committed
470

fat's avatar
fat committed
471
472
  // CAROUSEL DATA-API
  // =================
473

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

481
    $target.carousel(options)
482
483

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

487
    e.preventDefault()
488
489
  })

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

Chris Rebert's avatar
Chris Rebert committed
497
}(jQuery);
498

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


XhmikosR's avatar
XhmikosR committed
519
+function ($) { 'use strict';
520

521
522
  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================
523
524

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

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

  Collapse.DEFAULTS = {
    toggle: true
  }
536

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

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

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

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

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

558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
    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('-'))
579

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

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

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

593
    var dimension = this.dimension()
594

595
596
597
    this.$element
      [dimension](this.$element[dimension]())
      [0].offsetHeight
598

599
    this.$element
600
      .addClass('collapsing')
601
      .removeClass('collapse')
602
      .removeClass('in')
603

604
    this.transitioning = 1
605

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

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

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

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


627
628
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
629
630

  var old = $.fn.collapse
631
632
633

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

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

  $.fn.collapse.Constructor = Collapse


646
647
  // COLLAPSE NO CONFLICT
  // ====================
648

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


655
656
  // COLLAPSE DATA-API
  // =================
657

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

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

674
    $target.collapse(option)
675
676
  })

Chris Rebert's avatar
Chris Rebert committed
677
}(jQuery);
678

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


XhmikosR's avatar
XhmikosR committed
699
+function ($) { 'use strict';
700

701
702
  // DROPDOWN CLASS DEFINITION
  // =========================
703

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

710
711
  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)
712

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

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

718
    clearMenus()
fat's avatar
fat committed
719

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

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

      if (e.isDefaultPrevented()) return

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

fat's avatar
rebuild    
fat committed
734
735
      $this.focus()
    }
736

737
738
    return false
  }
739

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

743
    var $this = $(this)
744

745
746
    e.preventDefault()
    e.stopPropagation()
747

748
    if ($this.is('.disabled, :disabled')) return
749

750
751
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
752

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

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

760
    if (!$items.length) return
761

762
    var index = $items.index($items.filter(':focus'))
763

764
765
    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
766
    if (!~index)                                      index = 0
767

768
    $items.eq(index).focus()
769
770
  }

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

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

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

790
    var $parent = selector && $(selector)
791

792
    return $parent && $parent.length ? $parent : $this.parent()
793
794
795
  }


796
797
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
798

799
800
  var old = $.fn.dropdown

801
802
803
  $.fn.dropdown = function (option) {
    return this.each(function () {
      var $this = $(this)
804
      var data  = $this.data('bs.dropdown')
805

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

  $.fn.dropdown.Constructor = Dropdown


814
815
  // DROPDOWN NO CONFLICT
  // ====================
816
817
818
819
820
821
822

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


823
824
825
  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

826
  $(document)
827
828
    .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
829
830
    .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
    .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]', Dropdown.prototype.keydown)
831

Chris Rebert's avatar
Chris Rebert committed
832
}(jQuery);
833

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


XhmikosR's avatar
XhmikosR committed
854
+function ($) { 'use strict';
855

fat's avatar
fat committed
856
857
  // MODAL CLASS DEFINITION
  // ======================
858

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

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

fat's avatar
fat committed
868
  Modal.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
869
870
871
    backdrop: true,
    keyboard: true,
    show: true
fat's avatar
fat committed
872
  }
873

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

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

fat's avatar
fat committed
882
    this.$element.trigger(e)
883

fat's avatar
fat committed
884
    if (this.isShown || e.isDefaultPrevented()) return
885

fat's avatar
fat committed
886
    this.isShown = true
887

fat's avatar
fat committed
888
    this.escape()
889

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

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

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

fat's avatar
fat committed
899
      that.$element.show()
900

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

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

fat's avatar
fat committed
909
      that.enforceFocus()
910

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

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

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

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

fat's avatar
fat committed
928
    this.$element.trigger(e)
929

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

fat's avatar
fat committed
932
    this.isShown = false
933

fat's avatar
fat committed
934
    this.escape()
935

Mark Otto's avatar
Mark Otto committed
936
    $(document).off('focusin.bs.modal')
937

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

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

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

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

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

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

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

fat's avatar
fat committed
987
988
    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate
989

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

Jacob Thornton's avatar
Jacob Thornton committed
993
      this.$element.on('click.dismiss.modal', $.proxy(function (e) {
fat's avatar
fat committed
994
995
996
997
998
        if (e.target !== e.currentTarget) return
        this.options.backdrop == 'static'
          ? this.$element[0].focus.call(this.$element[0])
          : this.hide.call(this)
      }, this))
999

fat's avatar
fat committed
1000
      if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
For faster browsing, not all history is shown. View entire blame