bootstrap.js 52.4 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
160

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

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

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

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

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

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

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

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

204
    if (changed) this.$element.toggleClass('active')
205
206
207
  }


fat's avatar
fat committed
208
209
  // BUTTON PLUGIN DEFINITION
  // ========================
210

211
212
  var old = $.fn.button

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

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

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

  $.fn.button.Constructor = Button


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

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


fat's avatar
fat committed
238
239
  // BUTTON DATA-API
  // ===============
240

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

Chris Rebert's avatar
Chris Rebert committed
248
}(jQuery);
249

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


XhmikosR's avatar
XhmikosR committed
259
+function ($) { 'use strict';
260

fat's avatar
fat committed
261
262
  // CAROUSEL CLASS DEFINITION
  // =========================
263
264

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

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

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

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

fat's avatar
fat committed
288
    this.interval && clearInterval(this.interval)
fat's avatar
fat committed
289

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

fat's avatar
fat committed
294
295
    return this
  }
296

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

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

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

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

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

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

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

fat's avatar
fat committed
324
    this.interval = clearInterval(this.interval)
325

fat's avatar
fat committed
326
327
    return this
  }
328

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

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

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

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

352
    if ($next.hasClass('active')) return
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
356
    this.$element.trigger(e)
    if (e.isDefaultPrevented()) return
357

358
359
360
    this.sliding = true

    isCycling && this.pause()
fat's avatar
fat committed
361
362
363

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