bootstrap.js 53.3 KB
Newer Older
1
/*!
2
 * Bootstrap v3.0.3 (http://getbootstrap.com)
Chris Rebert's avatar
Chris Rebert committed
3
 * Copyright 2013 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

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

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


XhmikosR's avatar
XhmikosR committed
18
+function ($) { 'use strict';
19

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

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

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

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

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

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

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

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

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


XhmikosR's avatar
XhmikosR committed
66
+function ($) { 'use strict';
67

fat's avatar
fat committed
68
69
  // ALERT CLASS DEFINITION
  // ======================
70
71

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

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

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

fat's avatar
fat committed
85
    var $parent = $(selector)
86

fat's avatar
fat committed
87
    if (e) e.preventDefault()
88

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

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

    if (e.isDefaultPrevented()) return

    $parent.removeClass('in')

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

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


fat's avatar
fat committed
111
112
  // ALERT PLUGIN DEFINITION
  // =======================
113

114
115
  var old = $.fn.alert

116
117
118
  $.fn.alert = function (option) {
    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
126
127
128
      if (typeof option == 'string') data[option].call($this)
    })
  }

  $.fn.alert.Constructor = Alert


fat's avatar
fat committed
129
130
  // ALERT NO CONFLICT
  // =================
131
132
133
134
135
136
137

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


fat's avatar
fat committed
138
  // ALERT DATA-API
fat's avatar
fat committed
139
  // ==============
140

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

Chris Rebert's avatar
Chris Rebert committed
143
}(jQuery);
144

145
/* ========================================================================
146
 * Bootstrap: button.js v3.0.3
Mark Otto's avatar
Mark Otto committed
147
 * http://getbootstrap.com/javascript/#buttons
148
 * ========================================================================
fat's avatar
fat committed
149
 * Copyright 2013 Twitter, Inc.
150
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
151
 * ======================================================================== */
152
153


XhmikosR's avatar
XhmikosR committed
154
+function ($) { 'use strict';
155

fat's avatar
fat committed
156
157
  // BUTTON PUBLIC CLASS DEFINITION
  // ==============================
158
159

  var Button = function (element, options) {
fat's avatar
fat committed
160
161
162
    this.$element  = $(element)
    this.options   = $.extend({}, Button.DEFAULTS, options)
    this.isLoading = false
fat's avatar
fat committed
163
164
165
166
  }

  Button.DEFAULTS = {
    loadingText: 'loading...'
167
168
169
  }

  Button.prototype.setState = function (state) {
fat's avatar
fat committed
170
171
172
173
    var d    = 'disabled'
    var $el  = this.$element
    var val  = $el.is('input') ? 'val' : 'html'
    var data = $el.data()
174
175

    state = state + 'Text'
fat's avatar
fat committed
176
177

    if (!data.resetText) $el.data('resetText', $el[val]())
178
179
180
181

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

    // push to event loop to allow forms to submit
fat's avatar
fat committed
182
183
184
185
186
187
188
189
190
    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)
191
192
193
  }

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

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

206
    if (changed) this.$element.toggleClass('active')
207
208
209
  }


fat's avatar
fat committed
210
211
  // BUTTON PLUGIN DEFINITION
  // ========================
212

213
214
  var old = $.fn.button

215
216
  $.fn.button = function (option) {
    return this.each(function () {
fat's avatar
fat committed
217
      var $this   = $(this)
fat's avatar
fat committed
218
      var data    = $this.data('bs.button')
fat's avatar
fat committed
219
220
      var options = typeof option == 'object' && option

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

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

  $.fn.button.Constructor = Button


fat's avatar
fat committed
231
232
  // BUTTON NO CONFLICT
  // ==================
233
234
235
236
237
238
239

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


fat's avatar
fat committed
240
241
  // BUTTON DATA-API
  // ===============
242

Mark Otto's avatar
Mark Otto committed
243
  $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
244
245
246
    var $btn = $(e.target)
    if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
    $btn.button('toggle')
247
    e.preventDefault()
248
249
  })

Chris Rebert's avatar
Chris Rebert committed
250
}(jQuery);
251

252
/* ========================================================================
253
 * Bootstrap: carousel.js v3.0.3
Mark Otto's avatar
Mark Otto committed
254
 * http://getbootstrap.com/javascript/#carousel
255
 * ========================================================================
256
 * Copyright 2013 Twitter, Inc.
257
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
258
 * ======================================================================== */
259
260


XhmikosR's avatar
XhmikosR committed
261
+function ($) { 'use strict';
262

fat's avatar
fat committed
263
264
  // CAROUSEL CLASS DEFINITION
  // =========================
265
266

  var Carousel = function (element, options) {
fat's avatar
fat committed
267
    this.$element    = $(element)
fat's avatar
fat committed
268
    this.$indicators = this.$element.find('.carousel-indicators')
fat's avatar
fat committed
269
270
271
272
273
274
275
    this.options     = options
    this.paused      =
    this.sliding     =
    this.interval    =
    this.$active     =
    this.$items      = null

276
277
278
279
280
    this.options.pause == 'hover' && this.$element
      .on('mouseenter', $.proxy(this.pause, this))
      .on('mouseleave', $.proxy(this.cycle, this))
  }

fat's avatar
fat committed
281
  Carousel.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
282
283
284
    interval: 5000,
    pause: 'hover',
    wrap: true
fat's avatar
fat committed
285
  }
286

fat's avatar
fat committed
287
288
  Carousel.prototype.cycle =  function (e) {
    e || (this.paused = false)
289

fat's avatar
fat committed
290
    this.interval && clearInterval(this.interval)
fat's avatar
fat committed
291

fat's avatar
fat committed
292
293
294
    this.options.interval
      && !this.paused
      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
295

fat's avatar
fat committed
296
297
    return this
  }
298

fat's avatar
fat committed
299
300
301
  Carousel.prototype.getActiveIndex = function () {
    this.$active = this.$element.find('.item.active')
    this.$items  = this.$active.parent().children()
302

fat's avatar
fat committed
303
304
    return this.$items.index(this.$active)
  }
305

fat's avatar
fat committed
306
307
308
  Carousel.prototype.to = function (pos) {
    var that        = this
    var activeIndex = this.getActiveIndex()
309

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

312
    if (this.sliding)       return this.$element.one('slid.bs.carousel', function () { that.to(pos) })
fat's avatar
fat committed
313
314
315
316
    if (activeIndex == pos) return this.pause().cycle()

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

fat's avatar
fat committed
318
319
320
321
322
323
  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)
324
325
    }

fat's avatar
fat committed
326
    this.interval = clearInterval(this.interval)
327

fat's avatar
fat committed
328
329
    return this
  }
330

fat's avatar
fat committed
331
332
333
334
  Carousel.prototype.next = function () {
    if (this.sliding) return
    return this.slide('next')
  }
335

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

fat's avatar
fat committed
341
342
343
344
345
346
347
  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
348

Jacob Thornton's avatar
Jacob Thornton committed
349
350
351
352
353
    if (!$next.length) {
      if (!this.options.wrap) return
      $next = this.$element.find('.item')[fallback]()
    }

354
    if ($next.hasClass('active')) return
fat's avatar
fat committed
355

Mark Otto's avatar
Mark Otto committed
356
    var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
357
358
    this.$element.trigger(e)
    if (e.isDefaultPrevented()) return
359

360
361
362
    this.sliding = true

    isCycling && this.pause()
fat's avatar
fat committed
363
364
365

    if (this.$indicators.length) {
      this.$indicators.find('.active').removeClass('active')
366
      this.$element.one('slid.bs.carousel', function () {
fat's avatar
fat committed
367
368
369
370
371
372
373
374
375
376
        var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
        $nextIndicator && $nextIndicator.addClass('active')
      })
    }

    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
377
      $active
378
379
380
381
        .one($.support.transition.end, function () {
          $next.removeClass([type, direction].join(' ')).addClass('active')
          $active.removeClass(['active', direction].join(' '))
          that.sliding = false
382
          setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0)
383
        })
Mark Otto's avatar
Mark Otto committed
384
        .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
fat's avatar
fat committed
385
386
387
388
    } else {
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
389
      this.$element.trigger('slid.bs.carousel')
390
391
    }

fat's avatar
fat committed
392
393
394
    isCycling && this.cycle()

    return this
395
396
397
  }


fat's avatar
fat committed
398
399
  // CAROUSEL PLUGIN DEFINITION
  // ==========================
400

401
402
  var old = $.fn.carousel

403
404
  $.fn.carousel = function (option) {
    return this.each(function () {
fat's avatar
fat committed
405
      var $this   = $(this)
Mark Otto's avatar
Mark Otto committed
406
      var data    = $this.data('bs.carousel')
Jacob Thornton's avatar
Jacob Thornton committed
407
      var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
fat's avatar
fat committed
408
409
      var action  = typeof option == 'string' ? option : options.slide

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

  $.fn.carousel.Constructor = Carousel


fat's avatar
fat committed
420
421
  // CAROUSEL NO CONFLICT
  // ====================
422
423
424
425
426
427

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

fat's avatar
fat committed
428

fat's avatar
fat committed
429
430
  // CAROUSEL DATA-API
  // =================
431

432
  $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
fat's avatar
fat committed
433
    var $this   = $(this), href
fat's avatar
fat committed
434
435
    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
436
437
    var slideIndex = $this.attr('data-slide-to')
    if (slideIndex) options.interval = false
438

439
    $target.carousel(options)
440
441

    if (slideIndex = $this.attr('data-slide-to')) {
fat's avatar
fat committed
442
      $target.data('bs.carousel').to(slideIndex)
443
444
    }

445
    e.preventDefault()
446
447
  })

fat's avatar
fat committed
448
449
450
451
452
453
454
  $(window).on('load', function () {
    $('[data-ride="carousel"]').each(function () {
      var $carousel = $(this)
      $carousel.carousel($carousel.data())
    })
  })

Chris Rebert's avatar
Chris Rebert committed
455
}(jQuery);
456

457
/* ========================================================================
458
 * Bootstrap: collapse.js v3.0.3
Mark Otto's avatar
Mark Otto committed
459
 * http://getbootstrap.com/javascript/#collapse
460
 * ========================================================================
461
 * Copyright 2013 Twitter, Inc.
462
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
463
 * ======================================================================== */
464
465


XhmikosR's avatar
XhmikosR committed
466
+function ($) { 'use strict';
467

468
469
  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================
470
471

  var Collapse = function (element, options) {
472
473
474
    this.$element      = $(element)
    this.options       = $.extend({}, Collapse.DEFAULTS, options)
    this.transitioning = null
475

476
477
478
479
480
481
482
    if (this.options.parent) this.$parent = $(this.options.parent)
    if (this.options.toggle) this.toggle()
  }

  Collapse.DEFAULTS = {
    toggle: true
  }
483

484
485
486
  Collapse.prototype.dimension = function () {
    var hasWidth = this.$element.hasClass('width')
    return hasWidth ? 'width' : 'height'
487
488
  }

489
490
  Collapse.prototype.show = function () {
    if (this.transitioning || this.$element.hasClass('in')) return
491

fat's avatar
fat committed
492
493
494
495
    var startEvent = $.Event('show.bs.collapse')
    this.$element.trigger(startEvent)
    if (startEvent.isDefaultPrevented()) return

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

498
    if (actives && actives.length) {
fat's avatar
fat committed
499
      var hasData = actives.data('bs.collapse')
500
501
      if (hasData && hasData.transitioning) return
      actives.collapse('hide')
fat's avatar
fat committed
502
      hasData || actives.data('bs.collapse', null)
503
504
    }

505
506
507
508
509
510
511
512
513
514
515
516
    var dimension = this.dimension()

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

    this.transitioning = 1

    var complete = function () {
      this.$element
        .removeClass('collapsing')
fat's avatar
fat committed
517
        .addClass('collapse in')
518
519
520
521
522
523
524
525
        [dimension]('auto')
      this.transitioning = 0
      this.$element.trigger('shown.bs.collapse')
    }

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

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

527
528
529
530
    this.$element
      .one($.support.transition.end, $.proxy(complete, this))
      .emulateTransitionEnd(350)
      [dimension](this.$element[0][scrollSize])
531
  }
532

533
534
  Collapse.prototype.hide = function () {
    if (this.transitioning || !this.$element.hasClass('in')) return
fat's avatar
fat committed
535
536
537
538
539

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

540
    var dimension = this.dimension()
541

542
543
544
    this.$element
      [dimension](this.$element[dimension]())
      [0].offsetHeight
545

546
    this.$element
547
      .addClass('collapsing')
548
      .removeClass('collapse')
549
      .removeClass('in')
550

551
    this.transitioning = 1
552

553
    var complete = function () {
554
555
556
557
558
      this.transitioning = 0
      this.$element
        .trigger('hidden.bs.collapse')
        .removeClass('collapsing')
        .addClass('collapse')
559
560
    }

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

563
564
565
566
    this.$element
      [dimension](0)
      .one($.support.transition.end, $.proxy(complete, this))
      .emulateTransitionEnd(350)
567
  }
568

569
570
  Collapse.prototype.toggle = function () {
    this[this.$element.hasClass('in') ? 'hide' : 'show']()
571
572
573
  }


574
575
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
576
577

  var old = $.fn.collapse
578
579
580

  $.fn.collapse = function (option) {
    return this.each(function () {
581
      var $this   = $(this)
fat's avatar
fat committed
582
      var data    = $this.data('bs.collapse')
583
584
      var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)

fat's avatar
fat committed
585
      if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
586
587
588
589
590
591
592
      if (typeof option == 'string') data[option]()
    })
  }

  $.fn.collapse.Constructor = Collapse


593
594
  // COLLAPSE NO CONFLICT
  // ====================
595

596
597
598
599
600
601
  $.fn.collapse.noConflict = function () {
    $.fn.collapse = old
    return this
  }


602
603
  // COLLAPSE DATA-API
  // =================
604

605
  $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
606
607
    var $this   = $(this), href
    var target  = $this.attr('data-target')
608
609
        || e.preventDefault()
        || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
610
611
612
613
    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
614
    var $parent = parent && $(parent)
615

fat's avatar
fat committed
616
    if (!data || !data.transitioning) {
617
      if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
618
      $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
fat's avatar
fat committed
619
620
    }

621
    $target.collapse(option)
622
623
  })

Chris Rebert's avatar
Chris Rebert committed
624
}(jQuery);
625

626
/* ========================================================================
627
 * Bootstrap: dropdown.js v3.0.3
Mark Otto's avatar
Mark Otto committed
628
 * http://getbootstrap.com/javascript/#dropdowns
629
 * ========================================================================
630
 * Copyright 2013 Twitter, Inc.
631
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
632
 * ======================================================================== */
633
634


XhmikosR's avatar
XhmikosR committed
635
+function ($) { 'use strict';
636

637
638
  // DROPDOWN CLASS DEFINITION
  // =========================
639

640
641
642
  var backdrop = '.dropdown-backdrop'
  var toggle   = '[data-toggle=dropdown]'
  var Dropdown = function (element) {
643
    $(element).on('click.bs.dropdown', this.toggle)
644
  }
645

646
647
  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)
648

649
    if ($this.is('.disabled, :disabled')) return
650

651
652
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
653

654
    clearMenus()
fat's avatar
fat committed
655

656
    if (!isActive) {
fat's avatar
fat committed
657
      if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
Mark Otto's avatar
Mark Otto committed
658
        // if mobile we use a backdrop because click events don't delegate
Jacob Thornton's avatar
Jacob Thornton committed
659
        $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
fat's avatar
fat committed
660
      }
661
662
663
664
665
666
667
668

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

      if (e.isDefaultPrevented()) return

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

fat's avatar
rebuild    
fat committed
670
671
      $this.focus()
    }
672

673
674
    return false
  }
675

676
677
  Dropdown.prototype.keydown = function (e) {
    if (!/(38|40|27)/.test(e.keyCode)) return
678

679
    var $this = $(this)
680

681
682
    e.preventDefault()
    e.stopPropagation()
683

684
    if ($this.is('.disabled, :disabled')) return
685

686
687
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
688

689
690
691
692
    if (!isActive || (isActive && e.keyCode == 27)) {
      if (e.which == 27) $parent.find(toggle).focus()
      return $this.click()
    }
693

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

696
    if (!$items.length) return
697

698
    var index = $items.index($items.filter(':focus'))
699

700
701
    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
702
    if (!~index)                                      index = 0
703

704
    $items.eq(index).focus()
705
706
  }

Mark Otto's avatar
Mark Otto committed
707
  function clearMenus() {
708
    $(backdrop).remove()
709
    $(toggle).each(function (e) {
710
711
712
713
714
715
      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')
    })
716
717
718
719
720
721
722
  }

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

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

726
    var $parent = selector && $(selector)
727

728
    return $parent && $parent.length ? $parent : $this.parent()
729
730
731
  }


732
733
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
734

735
736
  var old = $.fn.dropdown

737
738
739
  $.fn.dropdown = function (option) {
    return this.each(function () {
      var $this = $(this)
740
      var data  = $this.data('bs.dropdown')
741

742
      if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
743
744
745
746
747
748
749
      if (typeof option == 'string') data[option].call($this)
    })
  }

  $.fn.dropdown.Constructor = Dropdown


750
751
  // DROPDOWN NO CONFLICT
  // ====================
752
753
754
755
756
757
758

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


759
760
761
  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

762
  $(document)
763
764
    .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
765
766
    .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
    .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]', Dropdown.prototype.keydown)
767

Chris Rebert's avatar
Chris Rebert committed
768
}(jQuery);
769

770
/* ========================================================================
771
 * Bootstrap: modal.js v3.0.3
Mark Otto's avatar
Mark Otto committed
772
 * http://getbootstrap.com/javascript/#modals
773
 * ========================================================================
774
 * Copyright 2013 Twitter, Inc.
775
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
776
 * ======================================================================== */
777
778


XhmikosR's avatar
XhmikosR committed
779
+function ($) { 'use strict';
780

fat's avatar
fat committed
781
782
  // MODAL CLASS DEFINITION
  // ======================
783

Jacob Thornton's avatar
Jacob Thornton committed
784
  var Modal = function (element, options) {
fat's avatar
fat committed
785
    this.options   = options
fat's avatar
rebuild    
fat committed
786
    this.$element  = $(element)
fat's avatar
fat committed
787
788
    this.$backdrop =
    this.isShown   = null
789

790
791
792
    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
793
  }
794

fat's avatar
fat committed
795
  Modal.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
796
797
798
    backdrop: true,
    keyboard: true,
    show: true
fat's avatar
fat committed
799
  }
800

Jacob Thornton's avatar
Jacob Thornton committed
801
802
  Modal.prototype.toggle = function (_relatedTarget) {
    return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
fat's avatar
fat committed
803
  }
804

Jacob Thornton's avatar
Jacob Thornton committed
805
  Modal.prototype.show = function (_relatedTarget) {
fat's avatar
fat committed
806
    var that = this
Jacob Thornton's avatar
Jacob Thornton committed
807
    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
808

fat's avatar
fat committed
809
    this.$element.trigger(e)
810

fat's avatar
fat committed
811
    if (this.isShown || e.isDefaultPrevented()) return
812

fat's avatar
fat committed
813
    this.isShown = true
814

fat's avatar
fat committed
815
    this.escape()
816

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

fat's avatar
fat committed
819
820
    this.backdrop(function () {
      var transition = $.support.transition && that.$element.hasClass('fade')
821

fat's avatar
fat committed
822
      if (!that.$element.parent().length) {
Jacob Thornton's avatar
Jacob Thornton committed
823
        that.$element.appendTo(document.body) // don't move modals dom position
fat's avatar
fat committed
824
      }
825

fat's avatar
fat committed
826
      that.$element.show()
827

fat's avatar
fat committed
828
829
830
      if (transition) {
        that.$element[0].offsetWidth // force reflow
      }
831

fat's avatar
fat committed
832
833
834
      that.$element
        .addClass('in')
        .attr('aria-hidden', false)
835

fat's avatar
fat committed
836
      that.enforceFocus()
837

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

fat's avatar
fat committed
840
      transition ?
fat's avatar
fat committed
841
        that.$element.find('.modal-dialog') // wait for modal to slide in
842
          .one($.support.transition.end, function () {
Jacob Thornton's avatar
Jacob Thornton committed
843
            that.$element.focus().trigger(e)
844
845
          })
          .emulateTransitionEnd(300) :
Jacob Thornton's avatar
Jacob Thornton committed
846
        that.$element.focus().trigger(e)
fat's avatar
fat committed
847
848
    })
  }
849

fat's avatar
fat committed
850
  Modal.prototype.hide = function (e) {
fat's avatar
fat committed
851
    if (e) e.preventDefault()
852

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

fat's avatar
fat committed
855
    this.$element.trigger(e)
856

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

fat's avatar
fat committed
859
    this.isShown = false
860

fat's avatar
fat committed
861
    this.escape()
862

Mark Otto's avatar
Mark Otto committed
863
    $(document).off('focusin.bs.modal')
864

fat's avatar
fat committed
865
866
867
    this.$element
      .removeClass('in')
      .attr('aria-hidden', true)
Jacob Thornton's avatar
Jacob Thornton committed
868
      .off('click.dismiss.modal')
869

fat's avatar
fat committed
870
    $.support.transition && this.$element.hasClass('fade') ?
871
872
873
      this.$element
        .one($.support.transition.end, $.proxy(this.hideModal, this))
        .emulateTransitionEnd(300) :
fat's avatar
fat committed
874
875
      this.hideModal()
  }
876

fat's avatar
fat committed
877
  Modal.prototype.enforceFocus = function () {
Jacob Thornton's avatar
Jacob Thornton committed
878
879
    $(document)
      .off('focusin.bs.modal') // guard against infinite focus loop
fat's avatar
fat committed
880
881
882
883
884
      .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
885
  }
886

fat's avatar
fat committed
887
888
  Modal.prototype.escape = function () {
    if (this.isShown && this.options.keyboard) {
fat's avatar
fat committed
889
      this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
fat's avatar
fat committed
890
        e.which == 27 && this.hide()
fat's avatar
fat committed
891
      }, this))
fat's avatar
fat committed
892
    } else if (!this.isShown) {
Mark Otto's avatar
Mark Otto committed
893
      this.$element.off('keyup.dismiss.bs.modal')
fat's avatar
fat committed
894
895
    }
  }
896

fat's avatar
fat committed
897
898
899
900
901
  Modal.prototype.hideModal = function () {
    var that = this
    this.$element.hide()
    this.backdrop(function () {
      that.removeBackdrop()
Mark Otto's avatar
Mark Otto committed
902
      that.$element.trigger('hidden.bs.modal')
fat's avatar
fat committed
903
904
    })
  }
905

fat's avatar
fat committed
906
907
908
909
  Modal.prototype.removeBackdrop = function () {
    this.$backdrop && this.$backdrop.remove()
    this.$backdrop = null
  }
910

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

fat's avatar
fat committed
914
915
    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate
916

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

Jacob Thornton's avatar
Jacob Thornton committed
920
      this.$element.on('click.dismiss.modal', $.proxy(function (e) {
fat's avatar
fat committed
921
922
923
924
925
        if (e.target !== e.currentTarget) return
        this.options.backdrop == 'static'
          ? this.$element[0].focus.call(this.$element[0])
          : this.hide.call(this)
      }, this))
926

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

fat's avatar
fat committed
929
      this.$backdrop.addClass('in')
930

fat's avatar
fat committed
931
      if (!callback) return
932

fat's avatar
fat committed
933
      doAnimate ?
934
935
936
        this.$backdrop
          .one($.support.transition.end, callback)
          .emulateTransitionEnd(150) :
fat's avatar
fat committed
937
        callback()
938

fat's avatar
fat committed
939
940
    } else if (!this.isShown && this.$backdrop) {
      this.$backdrop.removeClass('in')
941

Mark Otto's avatar
Mark Otto committed
942
      $.support.transition && this.$element.hasClass('fade') ?
943
944
945
        this.$backdrop
          .one($.support.transition.end, callback)
          .emulateTransitionEnd(150) :
fat's avatar
fat committed
946
        callback()
947

fat's avatar
fat committed
948
949
950
    } else if (callback) {
      callback()
    }
951
952
953
  }


fat's avatar
fat committed
954
955
  // MODAL PLUGIN DEFINITION
  // =======================
956

957
958
  var old = $.fn.modal

Jacob Thornton's avatar
Jacob Thornton committed
959
  $.fn.modal = function (option, _relatedTarget) {
960
    return this.each(function () {
fat's avatar
fat committed
961
      var $this   = $(this)
Mark Otto's avatar
Mark Otto committed
962
      var data    = $this.data('bs.modal')
fat's avatar
fat committed
963
964
      var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)

Mark Otto's avatar
Mark Otto committed
965
      if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
Jacob Thornton's avatar
Jacob Thornton committed
966
967
      if (typeof option == 'string') data[option](_relatedTarget)
      else if (options.show) data.show(_relatedTarget)
968
969
970
971
972
973
    })
  }

  $.fn.modal.Constructor = Modal


fat's avatar
fat committed
974
975
  // MODAL NO CONFLICT
  // =================
976
977
978
979
980
981
982

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


fat's avatar
fat committed
983
984
  // MODAL DATA-API
  // ==============
985

Mark Otto's avatar
Mark Otto committed
986
  $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
fat's avatar
fat committed
987
988
989
    var $this   = $(this)
    var href    = $this.attr('href')
    var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
fat's avatar
fat committed
990
    var option  = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
991

fat's avatar
fat committed
992
    if ($this.is('a')) e.preventDefault()
993

994
    $target
Jacob Thornton's avatar
Jacob Thornton committed
995
      .modal(option, this)
996
      .one('hide', function () {
997
        $this.is(':visible') && $this.focus()
998
      })
Jacob Thornton's avatar
Jacob Thornton committed
999
  })
1000

For faster browsing, not all history is shown. View entire blame