bootstrap.js 52.1 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
  }

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

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

Chris Rebert's avatar
Chris Rebert committed
53
}(jQuery);
54

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


XhmikosR's avatar
XhmikosR committed
64
+function ($) { 'use strict';
65

fat's avatar
fat committed
66
67
  // ALERT CLASS DEFINITION
  // ======================
68
69

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

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

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

fat's avatar
fat committed
83
    var $parent = $(selector)
84

fat's avatar
fat committed
85
    if (e) e.preventDefault()
86

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

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

    if (e.isDefaultPrevented()) return

    $parent.removeClass('in')

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

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


fat's avatar
fat committed
109
110
  // ALERT PLUGIN DEFINITION
  // =======================
111

112
113
  var old = $.fn.alert

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

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

  $.fn.alert.Constructor = Alert


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

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


fat's avatar
fat committed
136
  // ALERT DATA-API
fat's avatar
fat committed
137
  // ==============
138

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

Chris Rebert's avatar
Chris Rebert committed
141
}(jQuery);
142

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


XhmikosR's avatar
XhmikosR committed
152
+function ($) { 'use strict';
153

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

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

  Button.DEFAULTS = {
    loadingText: 'loading...'
164
165
166
  }

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

    state = state + 'Text'
fat's avatar
fat committed
173
174

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

    $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
182
        $el.removeClass(d).removeAttr(d);
183
184
185
186
    }, 0)
  }

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

190
    if ($parent.length) {
fat's avatar
fat committed
191
      var $input = this.$element.find('input')
192
193
194
195
196
197
198
199
      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
200
    }
201

202
    if (changed) this.$element.toggleClass('active')
203
204
205
  }


fat's avatar
fat committed
206
207
  // BUTTON PLUGIN DEFINITION
  // ========================
208

209
210
  var old = $.fn.button

211
212
  $.fn.button = function (option) {
    return this.each(function () {
fat's avatar
fat committed
213
      var $this   = $(this)
fat's avatar
fat committed
214
      var data    = $this.data('bs.button')
fat's avatar
fat committed
215
216
      var options = typeof option == 'object' && option

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

219
220
221
222
223
224
225
226
      if (option == 'toggle') data.toggle()
      else if (option) data.setState(option)
    })
  }

  $.fn.button.Constructor = Button


fat's avatar
fat committed
227
228
  // BUTTON NO CONFLICT
  // ==================
229
230
231
232
233
234
235

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


fat's avatar
fat committed
236
237
  // BUTTON DATA-API
  // ===============
238

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

Chris Rebert's avatar
Chris Rebert committed
246
}(jQuery);
247

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


XhmikosR's avatar
XhmikosR committed
257
+function ($) { 'use strict';
258

fat's avatar
fat committed
259
260
  // CAROUSEL CLASS DEFINITION
  // =========================
261
262

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

272
273
274
275
276
    this.options.pause == 'hover' && this.$element
      .on('mouseenter', $.proxy(this.pause, this))
      .on('mouseleave', $.proxy(this.cycle, this))
  }

fat's avatar
fat committed
277
  Carousel.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
278
279
280
    interval: 5000,
    pause: 'hover',
    wrap: true
fat's avatar
fat committed
281
  }
282

fat's avatar
fat committed
283
284
  Carousel.prototype.cycle =  function (e) {
    e || (this.paused = false)
285

fat's avatar
fat committed
286
    this.interval && clearInterval(this.interval)
fat's avatar
fat committed
287

fat's avatar
fat committed
288
289
290
    this.options.interval
      && !this.paused
      && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
291

fat's avatar
fat committed
292
293
    return this
  }
294

fat's avatar
fat committed
295
296
297
  Carousel.prototype.getActiveIndex = function () {
    this.$active = this.$element.find('.item.active')
    this.$items  = this.$active.parent().children()
298

fat's avatar
fat committed
299
300
    return this.$items.index(this.$active)
  }
301

fat's avatar
fat committed
302
303
304
  Carousel.prototype.to = function (pos) {
    var that        = this
    var activeIndex = this.getActiveIndex()
305

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

308
    if (this.sliding)       return this.$element.one('slid.bs.carousel', function () { that.to(pos) })
fat's avatar
fat committed
309
310
311
312
    if (activeIndex == pos) return this.pause().cycle()

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

fat's avatar
fat committed
314
315
316
317
318
319
  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)
320
321
    }

fat's avatar
fat committed
322
    this.interval = clearInterval(this.interval)
323

fat's avatar
fat committed
324
325
    return this
  }
326

fat's avatar
fat committed
327
328
329
330
  Carousel.prototype.next = function () {
    if (this.sliding) return
    return this.slide('next')
  }
331

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

fat's avatar
fat committed
337
338
339
340
341
342
343
  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
344

Jacob Thornton's avatar
Jacob Thornton committed
345
346
347
348
349
    if (!$next.length) {
      if (!this.options.wrap) return
      $next = this.$element.find('.item')[fallback]()
    }

fat's avatar
fat committed
350
    this.sliding = true
351

fat's avatar
fat committed
352
    isCycling && this.pause()
fat's avatar
fat committed
353

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

fat's avatar
fat committed
356
357
358
359
    if ($next.hasClass('active')) return

    if (this.$indicators.length) {
      this.$indicators.find('.active').removeClass('active')
360
      this.$element.one('slid.bs.carousel', function () {
fat's avatar
fat committed
361
362
363
364
365
366
367
368
369
370
371
372
        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
373
      $active
374
375
376
377
        .one($.support.transition.end, function () {
          $next.removeClass([type, direction].join(' ')).addClass('active')
          $active.removeClass(['active', direction].join(' '))
          that.sliding = false
378
          setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0)
379
        })
Mark Otto's avatar
Mark Otto committed
380
        .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
fat's avatar
fat committed
381
382
383
384
385
386
    } else {
      this.$element.trigger(e)
      if (e.isDefaultPrevented()) return
      $active.removeClass('active')
      $next.addClass('active')
      this.sliding = false
387
      this.$element.trigger('slid.bs.carousel')
388
389
    }

fat's avatar
fat committed
390
391
392
    isCycling && this.cycle()

    return this
393
394
395
  }


fat's avatar
fat committed
396
397
  // CAROUSEL PLUGIN DEFINITION
  // ==========================
398

399
400
  var old = $.fn.carousel

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

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

  $.fn.carousel.Constructor = Carousel


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

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

fat's avatar
fat committed
426

fat's avatar
fat committed
427
428
  // CAROUSEL DATA-API
  // =================
429

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

437
    $target.carousel(options)
438
439

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

443
    e.preventDefault()
444
445
  })

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

Chris Rebert's avatar
Chris Rebert committed
453
}(jQuery);
454

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


XhmikosR's avatar
XhmikosR committed
464
+function ($) { 'use strict';
465

466
467
  // COLLAPSE PUBLIC CLASS DEFINITION
  // ================================
468
469

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

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

  Collapse.DEFAULTS = {
    toggle: true
  }
481

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

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

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

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

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

503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
    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('-'))
524

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

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

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

538
    var dimension = this.dimension()
539

540
541
542
    this.$element
      [dimension](this.$element[dimension]())
      [0].offsetHeight
543

544
    this.$element
545
      .addClass('collapsing')
546
      .removeClass('collapse')
547
      .removeClass('in')
548

549
    this.transitioning = 1
550

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

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

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

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


572
573
  // COLLAPSE PLUGIN DEFINITION
  // ==========================
574
575

  var old = $.fn.collapse
576
577
578

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

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

  $.fn.collapse.Constructor = Collapse


591
592
  // COLLAPSE NO CONFLICT
  // ====================
593

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


600
601
  // COLLAPSE DATA-API
  // =================
602

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

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

619
    $target.collapse(option)
620
621
  })

Chris Rebert's avatar
Chris Rebert committed
622
}(jQuery);
623

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


XhmikosR's avatar
XhmikosR committed
633
+function ($) { 'use strict';
634

635
636
  // DROPDOWN CLASS DEFINITION
  // =========================
637

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

644
645
  Dropdown.prototype.toggle = function (e) {
    var $this = $(this)
646

647
    if ($this.is('.disabled, :disabled')) return
648

649
650
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
651

652
    clearMenus()
fat's avatar
fat committed
653

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

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

      if (e.isDefaultPrevented()) return

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

fat's avatar
rebuild    
fat committed
668
669
      $this.focus()
    }
670

671
672
    return false
  }
673

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

677
    var $this = $(this)
678

679
680
    e.preventDefault()
    e.stopPropagation()
681

682
    if ($this.is('.disabled, :disabled')) return
683

684
685
    var $parent  = getParent($this)
    var isActive = $parent.hasClass('open')
686

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

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

694
    if (!$items.length) return
695

696
    var index = $items.index($items.filter(':focus'))
697

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

702
    $items.eq(index).focus()
703
704
  }

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

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

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

724
    var $parent = selector && $(selector)
725

726
    return $parent && $parent.length ? $parent : $this.parent()
727
728
729
  }


730
731
  // DROPDOWN PLUGIN DEFINITION
  // ==========================
732

733
734
  var old = $.fn.dropdown

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

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

  $.fn.dropdown.Constructor = Dropdown


748
749
  // DROPDOWN NO CONFLICT
  // ====================
750
751
752
753
754
755
756

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


757
758
759
  // APPLY TO STANDARD DROPDOWN ELEMENTS
  // ===================================

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

Chris Rebert's avatar
Chris Rebert committed
766
}(jQuery);
767

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


XhmikosR's avatar
XhmikosR committed
777
+function ($) { 'use strict';
778

fat's avatar
fat committed
779
780
  // MODAL CLASS DEFINITION
  // ======================
781

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

788
    if (this.options.remote) this.$element.find('.modal-content').load(this.options.remote)
fat's avatar
fat committed
789
  }
790

fat's avatar
fat committed
791
  Modal.DEFAULTS = {
Mark Otto's avatar
Mark Otto committed
792
793
794
    backdrop: true,
    keyboard: true,
    show: true
fat's avatar
fat committed
795
  }
796

Jacob Thornton's avatar
Jacob Thornton committed
797
798
  Modal.prototype.toggle = function (_relatedTarget) {
    return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
fat's avatar
fat committed
799
  }
800

Jacob Thornton's avatar
Jacob Thornton committed
801
  Modal.prototype.show = function (_relatedTarget) {
fat's avatar
fat committed
802
    var that = this
Jacob Thornton's avatar
Jacob Thornton committed
803
    var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
804

fat's avatar
fat committed
805
    this.$element.trigger(e)
806

fat's avatar
fat committed
807
    if (this.isShown || e.isDefaultPrevented()) return
808

fat's avatar
fat committed
809
    this.isShown = true
810

fat's avatar
fat committed
811
    this.escape()
812

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

fat's avatar
fat committed
815
816
    this.backdrop(function () {
      var transition = $.support.transition && that.$element.hasClass('fade')
817

fat's avatar
fat committed
818
      if (!that.$element.parent().length) {
Jacob Thornton's avatar
Jacob Thornton committed
819
        that.$element.appendTo(document.body) // don't move modals dom position
fat's avatar
fat committed
820
      }
821

fat's avatar
fat committed
822
      that.$element.show()
823

fat's avatar
fat committed
824
825
826
      if (transition) {
        that.$element[0].offsetWidth // force reflow
      }
827

fat's avatar
fat committed
828
829
830
      that.$element
        .addClass('in')
        .attr('aria-hidden', false)
831

fat's avatar
fat committed
832
      that.enforceFocus()
833

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

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

fat's avatar
fat committed
846
  Modal.prototype.hide = function (e) {
fat's avatar
fat committed
847
    if (e) e.preventDefault()
848

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

fat's avatar
fat committed
851
    this.$element.trigger(e)
852

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

fat's avatar
fat committed
855
    this.isShown = false
856

fat's avatar
fat committed
857
    this.escape()
858

Mark Otto's avatar
Mark Otto committed
859
    $(document).off('focusin.bs.modal')
860

fat's avatar
fat committed
861
862
863
    this.$element
      .removeClass('in')
      .attr('aria-hidden', true)
Jacob Thornton's avatar
Jacob Thornton committed
864
      .off('click.dismiss.modal')
865

fat's avatar
fat committed
866
    $.support.transition && this.$element.hasClass('fade') ?
867
868
869
      this.$element
        .one($.support.transition.end, $.proxy(this.hideModal, this))
        .emulateTransitionEnd(300) :
fat's avatar
fat committed
870
871
      this.hideModal()
  }
872

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

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

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

fat's avatar
fat committed
902
903
904
905
  Modal.prototype.removeBackdrop = function () {
    this.$backdrop && this.$backdrop.remove()
    this.$backdrop = null
  }
906

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

fat's avatar
fat committed
910
911
    if (this.isShown && this.options.backdrop) {
      var doAnimate = $.support.transition && animate
912

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

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

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

fat's avatar
fat committed
925
      this.$backdrop.addClass('in')
926

fat's avatar
fat committed
927
      if (!callback) return
928

fat's avatar
fat committed
929
      doAnimate ?
930
931
932
        this.$backdrop
          .one($.support.transition.end, callback)
          .emulateTransitionEnd(150) :
fat's avatar
fat committed
933
        callback()
934

fat's avatar
fat committed
935
936
    } else if (!this.isShown && this.$backdrop) {
      this.$backdrop.removeClass('in')
937

Mark Otto's avatar
Mark Otto committed
938
      $.support.transition && this.$element.hasClass('fade') ?
939
940
941
        this.$backdrop
          .one($.support.transition.end, callback)
          .emulateTransitionEnd(150) :
fat's avatar
fat committed
942
        callback()
943

fat's avatar
fat committed
944
945
946
    } else if (callback) {
      callback()
    }
947
948
949
  }


fat's avatar
fat committed
950
951
  // MODAL PLUGIN DEFINITION
  // =======================
952

953
954
  var old = $.fn.modal

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

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

  $.fn.modal.Constructor = Modal


fat's avatar
fat committed
970
971
  // MODAL NO CONFLICT
  // =================
972
973
974
975
976
977
978

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


fat's avatar
fat committed
979
980
  // MODAL DATA-API
  // ==============
981

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

988
    e.preventDefault()
989

990
    $target
Jacob Thornton's avatar
Jacob Thornton committed
991
      .modal(option, this)
992
      .one('hide', function () {
993
        $this.is(':visible') && $this.focus()
994
      })
Jacob Thornton's avatar
Jacob Thornton committed
995
  })
996

Jacob Thornton's avatar
Jacob Thornton committed
997
  $(document)
fat's avatar
fat committed
998
    .on('show.bs.modal',  '.modal', function () { $(document.body).addClass('modal-open') })
Jacob Thornton's avatar
Jacob Thornton committed
999
    .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
1000

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