msb protocol synch change
[msb/apigateway.git] / msb-core / apiroute / apiroute-service / src / main / resources / iui-metrics / js / bootstrap / js / bootstrap.js
1 if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript requires jQuery') }
2
3 /* ========================================================================
4  * Bootstrap: transition.js v3.1.1
5  * http://getbootstrap.com/javascript/#transitions
6  * ========================================================================
7  * Copyright 2011-2014 Twitter, Inc.
8  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
9  * ======================================================================== */
10
11
12 +function ($) {
13   'use strict';
14
15   // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
16   // ============================================================
17
18   function transitionEnd() {
19     var el = document.createElement('bootstrap')
20
21     var transEndEventNames = {
22       'WebkitTransition' : 'webkitTransitionEnd',
23       'MozTransition'    : 'transitionend',
24       'OTransition'      : 'oTransitionEnd otransitionend',
25       'transition'       : 'transitionend'
26     }
27
28     for (var name in transEndEventNames) {
29       if (el.style[name] !== undefined) {
30         return { end: transEndEventNames[name] }
31       }
32     }
33
34     return false // explicit for ie8 (  ._.)
35   }
36
37   // http://blog.alexmaccaw.com/css-transitions
38   $.fn.emulateTransitionEnd = function (duration) {
39     var called = false, $el = this
40     $(this).one($.support.transition.end, function () { called = true })
41     var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
42     setTimeout(callback, duration)
43     return this
44   }
45
46   $(function () {
47     $.support.transition = transitionEnd()
48   })
49
50 }(jQuery);
51
52 /* ========================================================================
53  * Bootstrap: alert.js v3.1.1
54  * http://getbootstrap.com/javascript/#alerts
55  * ========================================================================
56  * Copyright 2011-2014 Twitter, Inc.
57  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
58  * ======================================================================== */
59
60
61 +function ($) {
62   'use strict';
63
64   // ALERT CLASS DEFINITION
65   // ======================
66
67   var dismiss = '[data-dismiss="alert"]'
68   var Alert   = function (el) {
69     $(el).on('click', dismiss, this.close)
70   }
71
72   Alert.prototype.close = function (e) {
73     var $this    = $(this)
74     var selector = $this.attr('data-target')
75
76     if (!selector) {
77       selector = $this.attr('href')
78       selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
79     }
80
81     var $parent = $(selector)
82
83     if (e) e.preventDefault()
84
85     if (!$parent.length) {
86       $parent = $this.hasClass('alert') ? $this : $this.parent()
87     }
88
89     $parent.trigger(e = $.Event('close.bs.alert'))
90
91     if (e.isDefaultPrevented()) return
92
93     $parent.removeClass('in')
94
95     function removeElement() {
96       $parent.trigger('closed.bs.alert').remove()
97     }
98
99     $.support.transition && $parent.hasClass('fade') ?
100       $parent
101         .one($.support.transition.end, removeElement)
102         .emulateTransitionEnd(150) :
103       removeElement()
104   }
105
106
107   // ALERT PLUGIN DEFINITION
108   // =======================
109
110   var old = $.fn.alert
111
112   $.fn.alert = function (option) {
113     return this.each(function () {
114       var $this = $(this)
115       var data  = $this.data('bs.alert')
116
117       if (!data) $this.data('bs.alert', (data = new Alert(this)))
118       if (typeof option == 'string') data[option].call($this)
119     })
120   }
121
122   $.fn.alert.Constructor = Alert
123
124
125   // ALERT NO CONFLICT
126   // =================
127
128   $.fn.alert.noConflict = function () {
129     $.fn.alert = old
130     return this
131   }
132
133
134   // ALERT DATA-API
135   // ==============
136
137   $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
138
139 }(jQuery);
140
141 /* ========================================================================
142  * Bootstrap: button.js v3.1.1
143  * http://getbootstrap.com/javascript/#buttons
144  * ========================================================================
145  * Copyright 2011-2014 Twitter, Inc.
146  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
147  * ======================================================================== */
148
149
150 +function ($) {
151   'use strict';
152
153   // BUTTON PUBLIC CLASS DEFINITION
154   // ==============================
155
156   var Button = function (element, options) {
157     this.$element  = $(element)
158     this.options   = $.extend({}, Button.DEFAULTS, options)
159     this.isLoading = false
160   }
161
162   Button.DEFAULTS = {
163     loadingText: 'loading...'
164   }
165
166   Button.prototype.setState = function (state) {
167     var d    = 'disabled'
168     var $el  = this.$element
169     var val  = $el.is('input') ? 'val' : 'html'
170     var data = $el.data()
171
172     state = state + 'Text'
173
174     if (!data.resetText) $el.data('resetText', $el[val]())
175
176     $el[val](data[state] || this.options[state])
177
178     // push to event loop to allow forms to submit
179     setTimeout($.proxy(function () {
180       if (state == 'loadingText') {
181         this.isLoading = true
182         $el.addClass(d).attr(d, d)
183       } else if (this.isLoading) {
184         this.isLoading = false
185         $el.removeClass(d).removeAttr(d)
186       }
187     }, this), 0)
188   }
189
190   Button.prototype.toggle = function () {
191     var changed = true
192     var $parent = this.$element.closest('[data-toggle="buttons"]')
193
194     if ($parent.length) {
195       var $input = this.$element.find('input')
196       if ($input.prop('type') == 'radio') {
197         if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
198         else $parent.find('.active').removeClass('active')
199       }
200       if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
201     }
202
203     if (changed) this.$element.toggleClass('active')
204   }
205
206
207   // BUTTON PLUGIN DEFINITION
208   // ========================
209
210   var old = $.fn.button
211
212   $.fn.button = function (option) {
213     return this.each(function () {
214       var $this   = $(this)
215       var data    = $this.data('bs.button')
216       var options = typeof option == 'object' && option
217
218       if (!data) $this.data('bs.button', (data = new Button(this, options)))
219
220       if (option == 'toggle') data.toggle()
221       else if (option) data.setState(option)
222     })
223   }
224
225   $.fn.button.Constructor = Button
226
227
228   // BUTTON NO CONFLICT
229   // ==================
230
231   $.fn.button.noConflict = function () {
232     $.fn.button = old
233     return this
234   }
235
236
237   // BUTTON DATA-API
238   // ===============
239
240   $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
241     var $btn = $(e.target)
242     if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
243     $btn.button('toggle')
244     e.preventDefault()
245   })
246
247 }(jQuery);
248
249 /* ========================================================================
250  * Bootstrap: carousel.js v3.1.1
251  * http://getbootstrap.com/javascript/#carousel
252  * ========================================================================
253  * Copyright 2011-2014 Twitter, Inc.
254  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
255  * ======================================================================== */
256
257
258 +function ($) {
259   'use strict';
260
261   // CAROUSEL CLASS DEFINITION
262   // =========================
263
264   var Carousel = function (element, options) {
265     this.$element    = $(element)
266     this.$indicators = this.$element.find('.carousel-indicators')
267     this.options     = options
268     this.paused      =
269     this.sliding     =
270     this.interval    =
271     this.$active     =
272     this.$items      = null
273
274     this.options.pause == 'hover' && this.$element
275       .on('mouseenter', $.proxy(this.pause, this))
276       .on('mouseleave', $.proxy(this.cycle, this))
277   }
278
279   Carousel.DEFAULTS = {
280     interval: 5000,
281     pause: 'hover',
282     wrap: true
283   }
284
285   Carousel.prototype.cycle =  function (e) {
286     e || (this.paused = false)
287
288     this.interval && clearInterval(this.interval)
289
290     this.options.interval
291       && !this.paused
292       && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
293
294     return this
295   }
296
297   Carousel.prototype.getActiveIndex = function () {
298     this.$active = this.$element.find('.item.active')
299     this.$items  = this.$active.parent().children()
300
301     return this.$items.index(this.$active)
302   }
303
304   Carousel.prototype.to = function (pos) {
305     var that        = this
306     var activeIndex = this.getActiveIndex()
307
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) })
311     if (activeIndex == pos) return this.pause().cycle()
312
313     return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
314   }
315
316   Carousel.prototype.pause = function (e) {
317     e || (this.paused = true)
318
319     if (this.$element.find('.next, .prev').length && $.support.transition) {
320       this.$element.trigger($.support.transition.end)
321       this.cycle(true)
322     }
323
324     this.interval = clearInterval(this.interval)
325
326     return this
327   }
328
329   Carousel.prototype.next = function () {
330     if (this.sliding) return
331     return this.slide('next')
332   }
333
334   Carousel.prototype.prev = function () {
335     if (this.sliding) return
336     return this.slide('prev')
337   }
338
339   Carousel.prototype.slide = function (type, next) {
340     var $active   = this.$element.find('.item.active')
341     var $next     = next || $active[type]()
342     var isCycling = this.interval
343     var direction = type == 'next' ? 'left' : 'right'
344     var fallback  = type == 'next' ? 'first' : 'last'
345     var that      = this
346
347     if (!$next.length) {
348       if (!this.options.wrap) return
349       $next = this.$element.find('.item')[fallback]()
350     }
351
352     if ($next.hasClass('active')) return this.sliding = false
353
354     var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction })
355     this.$element.trigger(e)
356     if (e.isDefaultPrevented()) return
357
358     this.sliding = true
359
360     isCycling && this.pause()
361
362     if (this.$indicators.length) {
363       this.$indicators.find('.active').removeClass('active')
364       this.$element.one('slid.bs.carousel', function () {
365         var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
366         $nextIndicator && $nextIndicator.addClass('active')
367       })
368     }
369
370     if ($.support.transition && this.$element.hasClass('slide')) {
371       $next.addClass(type)
372       $next[0].offsetWidth // force reflow
373       $active.addClass(direction)
374       $next.addClass(direction)
375       $active
376         .one($.support.transition.end, function () {
377           $next.removeClass([type, direction].join(' ')).addClass('active')
378           $active.removeClass(['active', direction].join(' '))
379           that.sliding = false
380           setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0)
381         })
382         .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
383     } else {
384       $active.removeClass('active')
385       $next.addClass('active')
386       this.sliding = false
387       this.$element.trigger('slid.bs.carousel')
388     }
389
390     isCycling && this.cycle()
391
392     return this
393   }
394
395
396   // CAROUSEL PLUGIN DEFINITION
397   // ==========================
398
399   var old = $.fn.carousel
400
401   $.fn.carousel = function (option) {
402     return this.each(function () {
403       var $this   = $(this)
404       var data    = $this.data('bs.carousel')
405       var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
406       var action  = typeof option == 'string' ? option : options.slide
407
408       if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
409       if (typeof option == 'number') data.to(option)
410       else if (action) data[action]()
411       else if (options.interval) data.pause().cycle()
412     })
413   }
414
415   $.fn.carousel.Constructor = Carousel
416
417
418   // CAROUSEL NO CONFLICT
419   // ====================
420
421   $.fn.carousel.noConflict = function () {
422     $.fn.carousel = old
423     return this
424   }
425
426
427   // CAROUSEL DATA-API
428   // =================
429
430   $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
431     var $this   = $(this), href
432     var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
433     var options = $.extend({}, $target.data(), $this.data())
434     var slideIndex = $this.attr('data-slide-to')
435     if (slideIndex) options.interval = false
436
437     $target.carousel(options)
438
439     if (slideIndex = $this.attr('data-slide-to')) {
440       $target.data('bs.carousel').to(slideIndex)
441     }
442
443     e.preventDefault()
444   })
445
446   $(window).on('load', function () {
447     $('[data-ride="carousel"]').each(function () {
448       var $carousel = $(this)
449       $carousel.carousel($carousel.data())
450     })
451   })
452
453 }(jQuery);
454
455 /* ========================================================================
456  * Bootstrap: collapse.js v3.1.1
457  * http://getbootstrap.com/javascript/#collapse
458  * ========================================================================
459  * Copyright 2011-2014 Twitter, Inc.
460  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
461  * ======================================================================== */
462
463
464 +function ($) {
465   'use strict';
466
467   // COLLAPSE PUBLIC CLASS DEFINITION
468   // ================================
469
470   var Collapse = function (element, options) {
471     this.$element      = $(element)
472     this.options       = $.extend({}, Collapse.DEFAULTS, options)
473     this.transitioning = null
474
475     if (this.options.parent) this.$parent = $(this.options.parent)
476     if (this.options.toggle) this.toggle()
477   }
478
479   Collapse.DEFAULTS = {
480     toggle: true
481   }
482
483   Collapse.prototype.dimension = function () {
484     var hasWidth = this.$element.hasClass('width')
485     return hasWidth ? 'width' : 'height'
486   }
487
488   Collapse.prototype.show = function () {
489     if (this.transitioning || this.$element.hasClass('in')) return
490
491     var startEvent = $.Event('show.bs.collapse')
492     this.$element.trigger(startEvent)
493     if (startEvent.isDefaultPrevented()) return
494
495     var actives = this.$parent && this.$parent.find('> .panel > .in')
496
497     if (actives && actives.length) {
498       var hasData = actives.data('bs.collapse')
499       if (hasData && hasData.transitioning) return
500       actives.collapse('hide')
501       hasData || actives.data('bs.collapse', null)
502     }
503
504     var dimension = this.dimension()
505
506     this.$element
507       .removeClass('collapse')
508       .addClass('collapsing')
509       [dimension](0)
510
511     this.transitioning = 1
512
513     var complete = function () {
514       this.$element
515         .removeClass('collapsing')
516         .addClass('collapse in')
517         [dimension]('auto')
518       this.transitioning = 0
519       this.$element.trigger('shown.bs.collapse')
520     }
521
522     if (!$.support.transition) return complete.call(this)
523
524     var scrollSize = $.camelCase(['scroll', dimension].join('-'))
525
526     this.$element
527       .one($.support.transition.end, $.proxy(complete, this))
528       .emulateTransitionEnd(350)
529       [dimension](this.$element[0][scrollSize])
530   }
531
532   Collapse.prototype.hide = function () {
533     if (this.transitioning || !this.$element.hasClass('in')) return
534
535     var startEvent = $.Event('hide.bs.collapse')
536     this.$element.trigger(startEvent)
537     if (startEvent.isDefaultPrevented()) return
538
539     var dimension = this.dimension()
540
541     this.$element
542       [dimension](this.$element[dimension]())
543       [0].offsetHeight
544
545     this.$element
546       .addClass('collapsing')
547       .removeClass('collapse')
548       .removeClass('in')
549
550     this.transitioning = 1
551
552     var complete = function () {
553       this.transitioning = 0
554       this.$element
555         .trigger('hidden.bs.collapse')
556         .removeClass('collapsing')
557         .addClass('collapse')
558     }
559
560     if (!$.support.transition) return complete.call(this)
561
562     this.$element
563       [dimension](0)
564       .one($.support.transition.end, $.proxy(complete, this))
565       .emulateTransitionEnd(350)
566   }
567
568   Collapse.prototype.toggle = function () {
569     this[this.$element.hasClass('in') ? 'hide' : 'show']()
570   }
571
572
573   // COLLAPSE PLUGIN DEFINITION
574   // ==========================
575
576   var old = $.fn.collapse
577
578   $.fn.collapse = function (option) {
579     return this.each(function () {
580       var $this   = $(this)
581       var data    = $this.data('bs.collapse')
582       var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
583
584       if (!data && options.toggle && option == 'show') option = !option
585       if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
586       if (typeof option == 'string') data[option]()
587     })
588   }
589
590   $.fn.collapse.Constructor = Collapse
591
592
593   // COLLAPSE NO CONFLICT
594   // ====================
595
596   $.fn.collapse.noConflict = function () {
597     $.fn.collapse = old
598     return this
599   }
600
601
602   // COLLAPSE DATA-API
603   // =================
604
605   $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) {
606     var $this   = $(this), href
607     var target  = $this.attr('data-target')
608         || e.preventDefault()
609         || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
610     var $target = $(target)
611     var data    = $target.data('bs.collapse')
612     var option  = data ? 'toggle' : $this.data()
613     var parent  = $this.attr('data-parent')
614     var $parent = parent && $(parent)
615
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')
619     }
620
621     $target.collapse(option)
622   })
623
624 }(jQuery);
625
626 /* ========================================================================
627  * Bootstrap: dropdown.js v3.1.1
628  * http://getbootstrap.com/javascript/#dropdowns
629  * ========================================================================
630  * Copyright 2011-2014 Twitter, Inc.
631  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
632  * ======================================================================== */
633
634
635 +function ($) {
636   'use strict';
637
638   // DROPDOWN CLASS DEFINITION
639   // =========================
640
641   var backdrop = '.dropdown-backdrop'
642   var toggle   = '[data-toggle=dropdown]'
643   var Dropdown = function (element) {
644     $(element).on('click.bs.dropdown', this.toggle)
645   }
646
647   Dropdown.prototype.toggle = function (e) {
648     var $this = $(this)
649
650     if ($this.is('.disabled, :disabled')) return
651
652     var $parent  = getParent($this)
653     var isActive = $parent.hasClass('open')
654
655     clearMenus()
656
657     if (!isActive) {
658       if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
659         // if mobile we use a backdrop because click events don't delegate
660         $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
661       }
662
663       var relatedTarget = { relatedTarget: this }
664       $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
665
666       if (e.isDefaultPrevented()) return
667
668       $parent
669         .toggleClass('open')
670         .trigger('shown.bs.dropdown', relatedTarget)
671
672       $this.focus()
673     }
674
675     return false
676   }
677
678   Dropdown.prototype.keydown = function (e) {
679     if (!/(38|40|27)/.test(e.keyCode)) return
680
681     var $this = $(this)
682
683     e.preventDefault()
684     e.stopPropagation()
685
686     if ($this.is('.disabled, :disabled')) return
687
688     var $parent  = getParent($this)
689     var isActive = $parent.hasClass('open')
690
691     if (!isActive || (isActive && e.keyCode == 27)) {
692       if (e.which == 27) $parent.find(toggle).focus()
693       return $this.click()
694     }
695
696     var desc = ' li:not(.divider):visible a'
697     var $items = $parent.find('[role=menu]' + desc + ', [role=listbox]' + desc)
698
699     if (!$items.length) return
700
701     var index = $items.index($items.filter(':focus'))
702
703     if (e.keyCode == 38 && index > 0)                 index--                        // up
704     if (e.keyCode == 40 && index < $items.length - 1) index++                        // down
705     if (!~index)                                      index = 0
706
707     $items.eq(index).focus()
708   }
709
710   function clearMenus(e) {
711     $(backdrop).remove()
712     $(toggle).each(function () {
713       var $parent = getParent($(this))
714       var relatedTarget = { relatedTarget: this }
715       if (!$parent.hasClass('open')) return
716       $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
717       if (e.isDefaultPrevented()) return
718       $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
719     })
720   }
721
722   function getParent($this) {
723     var selector = $this.attr('data-target')
724
725     if (!selector) {
726       selector = $this.attr('href')
727       selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
728     }
729
730     var $parent = selector && $(selector)
731
732     return $parent && $parent.length ? $parent : $this.parent()
733   }
734
735
736   // DROPDOWN PLUGIN DEFINITION
737   // ==========================
738
739   var old = $.fn.dropdown
740
741   $.fn.dropdown = function (option) {
742     return this.each(function () {
743       var $this = $(this)
744       var data  = $this.data('bs.dropdown')
745
746       if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
747       if (typeof option == 'string') data[option].call($this)
748     })
749   }
750
751   $.fn.dropdown.Constructor = Dropdown
752
753
754   // DROPDOWN NO CONFLICT
755   // ====================
756
757   $.fn.dropdown.noConflict = function () {
758     $.fn.dropdown = old
759     return this
760   }
761
762
763   // APPLY TO STANDARD DROPDOWN ELEMENTS
764   // ===================================
765
766   $(document)
767     .on('click.bs.dropdown.data-api', clearMenus)
768     .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
769     .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
770     .on('keydown.bs.dropdown.data-api', toggle + ', [role=menu], [role=listbox]', Dropdown.prototype.keydown)
771
772 }(jQuery);
773
774 /* ========================================================================
775  * Bootstrap: modal.js v3.1.1
776  * http://getbootstrap.com/javascript/#modals
777  * ========================================================================
778  * Copyright 2011-2014 Twitter, Inc.
779  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
780  * ======================================================================== */
781
782
783 +function ($) {
784   'use strict';
785
786   // MODAL CLASS DEFINITION
787   // ======================
788
789   var Modal = function (element, options) {
790     this.options   = options
791     this.$element  = $(element)
792     this.$backdrop =
793     this.isShown   = null
794
795     if (this.options.remote) {
796       this.$element
797         .find('.modal-content')
798         .load(this.options.remote, $.proxy(function () {
799           this.$element.trigger('loaded.bs.modal')
800         }, this))
801     }
802   }
803
804   Modal.DEFAULTS = {
805     backdrop: true,
806     keyboard: true,
807     show: true
808   }
809
810   Modal.prototype.toggle = function (_relatedTarget) {
811     return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
812   }
813
814   Modal.prototype.show = function (_relatedTarget) {
815     var that = this
816     var e    = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
817
818     this.$element.trigger(e)
819
820     if (this.isShown || e.isDefaultPrevented()) return
821
822     this.isShown = true
823
824     this.escape()
825
826     this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
827
828     this.backdrop(function () {
829       var transition = $.support.transition && that.$element.hasClass('fade')
830
831       if (!that.$element.parent().length) {
832         that.$element.appendTo(document.body) // don't move modals dom position
833       }
834
835       that.$element
836         .show()
837         .scrollTop(0)
838
839       if (transition) {
840         that.$element[0].offsetWidth // force reflow
841       }
842
843       that.$element
844         .addClass('in')
845         .attr('aria-hidden', false)
846
847       that.enforceFocus()
848
849       var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
850
851       transition ?
852         that.$element.find('.modal-dialog') // wait for modal to slide in
853           .one($.support.transition.end, function () {
854             that.$element.focus().trigger(e)
855           })
856           .emulateTransitionEnd(300) :
857         that.$element.focus().trigger(e)
858     })
859   }
860
861   Modal.prototype.hide = function (e) {
862     if (e) e.preventDefault()
863
864     e = $.Event('hide.bs.modal')
865
866     this.$element.trigger(e)
867
868     if (!this.isShown || e.isDefaultPrevented()) return
869
870     this.isShown = false
871
872     this.escape()
873
874     $(document).off('focusin.bs.modal')
875
876     this.$element
877       .removeClass('in')
878       .attr('aria-hidden', true)
879       .off('click.dismiss.bs.modal')
880
881     $.support.transition && this.$element.hasClass('fade') ?
882       this.$element
883         .one($.support.transition.end, $.proxy(this.hideModal, this))
884         .emulateTransitionEnd(300) :
885       this.hideModal()
886   }
887
888   Modal.prototype.enforceFocus = function () {
889     $(document)
890       .off('focusin.bs.modal') // guard against infinite focus loop
891       .on('focusin.bs.modal', $.proxy(function (e) {
892         if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
893           this.$element.focus()
894         }
895       }, this))
896   }
897
898   Modal.prototype.escape = function () {
899     if (this.isShown && this.options.keyboard) {
900       this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
901         e.which == 27 && this.hide()
902       }, this))
903     } else if (!this.isShown) {
904       this.$element.off('keyup.dismiss.bs.modal')
905     }
906   }
907
908   Modal.prototype.hideModal = function () {
909     var that = this
910     this.$element.hide()
911     this.backdrop(function () {
912       that.removeBackdrop()
913       that.$element.trigger('hidden.bs.modal')
914     })
915   }
916
917   Modal.prototype.removeBackdrop = function () {
918     this.$backdrop && this.$backdrop.remove()
919     this.$backdrop = null
920   }
921
922   Modal.prototype.backdrop = function (callback) {
923     var animate = this.$element.hasClass('fade') ? 'fade' : ''
924
925     if (this.isShown && this.options.backdrop) {
926       var doAnimate = $.support.transition && animate
927
928       this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
929         .appendTo(document.body)
930
931       this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
932         if (e.target !== e.currentTarget) return
933         this.options.backdrop == 'static'
934           ? this.$element[0].focus.call(this.$element[0])
935           : this.hide.call(this)
936       }, this))
937
938       if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
939
940       this.$backdrop.addClass('in')
941
942       if (!callback) return
943
944       doAnimate ?
945         this.$backdrop
946           .one($.support.transition.end, callback)
947           .emulateTransitionEnd(150) :
948         callback()
949
950     } else if (!this.isShown && this.$backdrop) {
951       this.$backdrop.removeClass('in')
952
953       $.support.transition && this.$element.hasClass('fade') ?
954         this.$backdrop
955           .one($.support.transition.end, callback)
956           .emulateTransitionEnd(150) :
957         callback()
958
959     } else if (callback) {
960       callback()
961     }
962   }
963
964
965   // MODAL PLUGIN DEFINITION
966   // =======================
967
968   var old = $.fn.modal
969
970   $.fn.modal = function (option, _relatedTarget) {
971     return this.each(function () {
972       var $this   = $(this)
973       var data    = $this.data('bs.modal')
974       var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
975
976       if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
977       if (typeof option == 'string') data[option](_relatedTarget)
978       else if (options.show) data.show(_relatedTarget)
979     })
980   }
981
982   $.fn.modal.Constructor = Modal
983
984
985   // MODAL NO CONFLICT
986   // =================
987
988   $.fn.modal.noConflict = function () {
989     $.fn.modal = old
990     return this
991   }
992
993
994   // MODAL DATA-API
995   // ==============
996
997   $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
998     var $this   = $(this)
999     var href    = $this.attr('href')
1000     var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
1001     var option  = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
1002
1003     if ($this.is('a')) e.preventDefault()
1004
1005     $target
1006       .modal(option, this)
1007       .one('hide', function () {
1008         $this.is(':visible') && $this.focus()
1009       })
1010   })
1011
1012   $(document)
1013     .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
1014     .on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
1015
1016 }(jQuery);
1017
1018 /* ========================================================================
1019  * Bootstrap: tooltip.js v3.1.1
1020  * http://getbootstrap.com/javascript/#tooltip
1021  * Inspired by the original jQuery.tipsy by Jason Frame
1022  * ========================================================================
1023  * Copyright 2011-2014 Twitter, Inc.
1024  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
1025  * ======================================================================== */
1026
1027
1028 +function ($) {
1029   'use strict';
1030
1031   // TOOLTIP PUBLIC CLASS DEFINITION
1032   // ===============================
1033
1034   var Tooltip = function (element, options) {
1035     this.type       =
1036     this.options    =
1037     this.enabled    =
1038     this.timeout    =
1039     this.hoverState =
1040     this.$element   = null
1041
1042     this.init('tooltip', element, options)
1043   }
1044
1045   Tooltip.DEFAULTS = {
1046     animation: true,
1047     placement: 'top',
1048     selector: false,
1049     template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
1050     trigger: 'hover focus',
1051     title: '',
1052     delay: 0,
1053     html: false,
1054     container: false
1055   }
1056
1057   Tooltip.prototype.init = function (type, element, options) {
1058     this.enabled  = true
1059     this.type     = type
1060     this.$element = $(element)
1061     this.options  = this.getOptions(options)
1062
1063     var triggers = this.options.trigger.split(' ')
1064
1065     for (var i = triggers.length; i--;) {
1066       var trigger = triggers[i]
1067
1068       if (trigger == 'click') {
1069         this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
1070       } else if (trigger != 'manual') {
1071         var eventIn  = trigger == 'hover' ? 'mouseenter' : 'focusin'
1072         var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
1073
1074         this.$element.on(eventIn  + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
1075         this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
1076       }
1077     }
1078
1079     this.options.selector ?
1080       (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
1081       this.fixTitle()
1082   }
1083
1084   Tooltip.prototype.getDefaults = function () {
1085     return Tooltip.DEFAULTS
1086   }
1087
1088   Tooltip.prototype.getOptions = function (options) {
1089     options = $.extend({}, this.getDefaults(), this.$element.data(), options)
1090
1091     if (options.delay && typeof options.delay == 'number') {
1092       options.delay = {
1093         show: options.delay,
1094         hide: options.delay
1095       }
1096     }
1097
1098     return options
1099   }
1100
1101   Tooltip.prototype.getDelegateOptions = function () {
1102     var options  = {}
1103     var defaults = this.getDefaults()
1104
1105     this._options && $.each(this._options, function (key, value) {
1106       if (defaults[key] != value) options[key] = value
1107     })
1108
1109     return options
1110   }
1111
1112   Tooltip.prototype.enter = function (obj) {
1113     var self = obj instanceof this.constructor ?
1114       obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
1115
1116     clearTimeout(self.timeout)
1117
1118     self.hoverState = 'in'
1119
1120     if (!self.options.delay || !self.options.delay.show) return self.show()
1121
1122     self.timeout = setTimeout(function () {
1123       if (self.hoverState == 'in') self.show()
1124     }, self.options.delay.show)
1125   }
1126
1127   Tooltip.prototype.leave = function (obj) {
1128     var self = obj instanceof this.constructor ?
1129       obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
1130
1131     clearTimeout(self.timeout)
1132
1133     self.hoverState = 'out'
1134
1135     if (!self.options.delay || !self.options.delay.hide) return self.hide()
1136
1137     self.timeout = setTimeout(function () {
1138       if (self.hoverState == 'out') self.hide()
1139     }, self.options.delay.hide)
1140   }
1141
1142   Tooltip.prototype.show = function () {
1143     var e = $.Event('show.bs.' + this.type)
1144
1145     if (this.hasContent() && this.enabled) {
1146       this.$element.trigger(e)
1147
1148       if (e.isDefaultPrevented()) return
1149       var that = this;
1150
1151       var $tip = this.tip()
1152
1153       this.setContent()
1154
1155       if (this.options.animation) $tip.addClass('fade')
1156
1157       var placement = typeof this.options.placement == 'function' ?
1158         this.options.placement.call(this, $tip[0], this.$element[0]) :
1159         this.options.placement
1160
1161       var autoToken = /\s?auto?\s?/i
1162       var autoPlace = autoToken.test(placement)
1163       if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
1164
1165       $tip
1166         .detach()
1167         .css({ top: 0, left: 0, display: 'block' })
1168         .addClass(placement)
1169
1170       this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
1171
1172       var pos          = this.getPosition()
1173       var actualWidth  = $tip[0].offsetWidth
1174       var actualHeight = $tip[0].offsetHeight
1175
1176       if (autoPlace) {
1177         var $parent = this.$element.parent()
1178
1179         var orgPlacement = placement
1180         var docScroll    = document.documentElement.scrollTop || document.body.scrollTop
1181         var parentWidth  = this.options.container == 'body' ? window.innerWidth  : $parent.outerWidth()
1182         var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
1183         var parentLeft   = this.options.container == 'body' ? 0 : $parent.offset().left
1184
1185         placement = placement == 'bottom' && pos.top   + pos.height  + actualHeight - docScroll > parentHeight  ? 'top'    :
1186                     placement == 'top'    && pos.top   - docScroll   - actualHeight < 0                         ? 'bottom' :
1187                     placement == 'right'  && pos.right + actualWidth > parentWidth                              ? 'left'   :
1188                     placement == 'left'   && pos.left  - actualWidth < parentLeft                               ? 'right'  :
1189                     placement
1190
1191         $tip
1192           .removeClass(orgPlacement)
1193           .addClass(placement)
1194       }
1195
1196       var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
1197
1198       this.applyPlacement(calculatedOffset, placement)
1199       this.hoverState = null
1200
1201       var complete = function() {
1202         that.$element.trigger('shown.bs.' + that.type)
1203       }
1204
1205       $.support.transition && this.$tip.hasClass('fade') ?
1206         $tip
1207           .one($.support.transition.end, complete)
1208           .emulateTransitionEnd(150) :
1209         complete()
1210     }
1211   }
1212
1213   Tooltip.prototype.applyPlacement = function (offset, placement) {
1214     var replace
1215     var $tip   = this.tip()
1216     var width  = $tip[0].offsetWidth
1217     var height = $tip[0].offsetHeight
1218
1219     // manually read margins because getBoundingClientRect includes difference
1220     var marginTop = parseInt($tip.css('margin-top'), 10)
1221     var marginLeft = parseInt($tip.css('margin-left'), 10)
1222
1223     // we must check for NaN for ie 8/9
1224     if (isNaN(marginTop))  marginTop  = 0
1225     if (isNaN(marginLeft)) marginLeft = 0
1226
1227     offset.top  = offset.top  + marginTop
1228     offset.left = offset.left + marginLeft
1229
1230     // $.fn.offset doesn't round pixel values
1231     // so we use setOffset directly with our own function B-0
1232     $.offset.setOffset($tip[0], $.extend({
1233       using: function (props) {
1234         $tip.css({
1235           top: Math.round(props.top),
1236           left: Math.round(props.left)
1237         })
1238       }
1239     }, offset), 0)
1240
1241     $tip.addClass('in')
1242
1243     // check to see if placing tip in new offset caused the tip to resize itself
1244     var actualWidth  = $tip[0].offsetWidth
1245     var actualHeight = $tip[0].offsetHeight
1246
1247     if (placement == 'top' && actualHeight != height) {
1248       replace = true
1249       offset.top = offset.top + height - actualHeight
1250     }
1251
1252     if (/bottom|top/.test(placement)) {
1253       var delta = 0
1254
1255       if (offset.left < 0) {
1256         delta       = offset.left * -2
1257         offset.left = 0
1258
1259         $tip.offset(offset)
1260
1261         actualWidth  = $tip[0].offsetWidth
1262         actualHeight = $tip[0].offsetHeight
1263       }
1264
1265       this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
1266     } else {
1267       this.replaceArrow(actualHeight - height, actualHeight, 'top')
1268     }
1269
1270     if (replace) $tip.offset(offset)
1271   }
1272
1273   Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
1274     this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
1275   }
1276
1277   Tooltip.prototype.setContent = function () {
1278     var $tip  = this.tip()
1279     var title = this.getTitle()
1280
1281     $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
1282     $tip.removeClass('fade in top bottom left right')
1283   }
1284
1285   Tooltip.prototype.hide = function () {
1286     var that = this
1287     var $tip = this.tip()
1288     var e    = $.Event('hide.bs.' + this.type)
1289
1290     function complete() {
1291       if (that.hoverState != 'in') $tip.detach()
1292       that.$element.trigger('hidden.bs.' + that.type)
1293     }
1294
1295     this.$element.trigger(e)
1296
1297     if (e.isDefaultPrevented()) return
1298
1299     $tip.removeClass('in')
1300
1301     $.support.transition && this.$tip.hasClass('fade') ?
1302       $tip
1303         .one($.support.transition.end, complete)
1304         .emulateTransitionEnd(150) :
1305       complete()
1306
1307     this.hoverState = null
1308
1309     return this
1310   }
1311
1312   Tooltip.prototype.fixTitle = function () {
1313     var $e = this.$element
1314     if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
1315       $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
1316     }
1317   }
1318
1319   Tooltip.prototype.hasContent = function () {
1320     return this.getTitle()
1321   }
1322
1323   Tooltip.prototype.getPosition = function () {
1324     var el = this.$element[0]
1325     return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
1326       width: el.offsetWidth,
1327       height: el.offsetHeight
1328     }, this.$element.offset())
1329   }
1330
1331   Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
1332     return placement == 'bottom' ? { top: pos.top + pos.height,   left: pos.left + pos.width / 2 - actualWidth / 2  } :
1333            placement == 'top'    ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2  } :
1334            placement == 'left'   ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
1335         /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width   }
1336   }
1337
1338   Tooltip.prototype.getTitle = function () {
1339     var title
1340     var $e = this.$element
1341     var o  = this.options
1342
1343     title = $e.attr('data-original-title')
1344       || (typeof o.title == 'function' ? o.title.call($e[0]) :  o.title)
1345
1346     return title
1347   }
1348
1349   Tooltip.prototype.tip = function () {
1350     return this.$tip = this.$tip || $(this.options.template)
1351   }
1352
1353   Tooltip.prototype.arrow = function () {
1354     return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
1355   }
1356
1357   Tooltip.prototype.validate = function () {
1358     if (!this.$element[0].parentNode) {
1359       this.hide()
1360       this.$element = null
1361       this.options  = null
1362     }
1363   }
1364
1365   Tooltip.prototype.enable = function () {
1366     this.enabled = true
1367   }
1368
1369   Tooltip.prototype.disable = function () {
1370     this.enabled = false
1371   }
1372
1373   Tooltip.prototype.toggleEnabled = function () {
1374     this.enabled = !this.enabled
1375   }
1376
1377   Tooltip.prototype.toggle = function (e) {
1378     var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
1379     self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
1380   }
1381
1382   Tooltip.prototype.destroy = function () {
1383     clearTimeout(this.timeout)
1384     this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
1385   }
1386
1387
1388   // TOOLTIP PLUGIN DEFINITION
1389   // =========================
1390
1391   var old = $.fn.tooltip
1392
1393   $.fn.tooltip = function (option) {
1394     return this.each(function () {
1395       var $this   = $(this)
1396       var data    = $this.data('bs.tooltip')
1397       var options = typeof option == 'object' && option
1398
1399       if (!data && option == 'destroy') return
1400       if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
1401       if (typeof option == 'string') data[option]()
1402     })
1403   }
1404
1405   $.fn.tooltip.Constructor = Tooltip
1406
1407
1408   // TOOLTIP NO CONFLICT
1409   // ===================
1410
1411   $.fn.tooltip.noConflict = function () {
1412     $.fn.tooltip = old
1413     return this
1414   }
1415
1416 }(jQuery);
1417
1418 /* ========================================================================
1419  * Bootstrap: popover.js v3.1.1
1420  * http://getbootstrap.com/javascript/#popovers
1421  * ========================================================================
1422  * Copyright 2011-2014 Twitter, Inc.
1423  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
1424  * ======================================================================== */
1425
1426
1427 +function ($) {
1428   'use strict';
1429
1430   // POPOVER PUBLIC CLASS DEFINITION
1431   // ===============================
1432
1433   var Popover = function (element, options) {
1434     this.init('popover', element, options)
1435   }
1436
1437   if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
1438
1439   Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
1440     placement: 'right',
1441     trigger: 'click',
1442     content: '',
1443     template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
1444   })
1445
1446
1447   // NOTE: POPOVER EXTENDS tooltip.js
1448   // ================================
1449
1450   Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
1451
1452   Popover.prototype.constructor = Popover
1453
1454   Popover.prototype.getDefaults = function () {
1455     return Popover.DEFAULTS
1456   }
1457
1458   Popover.prototype.setContent = function () {
1459     var $tip    = this.tip()
1460     var title   = this.getTitle()
1461     var content = this.getContent()
1462
1463     $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1464     $tip.find('.popover-content')[ // we use append for html objects to maintain js events
1465       this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
1466     ](content)
1467
1468     $tip.removeClass('fade top bottom left right in')
1469
1470     // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
1471     // this manually by checking the contents.
1472     if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
1473   }
1474
1475   Popover.prototype.hasContent = function () {
1476     return this.getTitle() || this.getContent()
1477   }
1478
1479   Popover.prototype.getContent = function () {
1480     var $e = this.$element
1481     var o  = this.options
1482
1483     return $e.attr('data-content')
1484       || (typeof o.content == 'function' ?
1485             o.content.call($e[0]) :
1486             o.content)
1487   }
1488
1489   Popover.prototype.arrow = function () {
1490     return this.$arrow = this.$arrow || this.tip().find('.arrow')
1491   }
1492
1493   Popover.prototype.tip = function () {
1494     if (!this.$tip) this.$tip = $(this.options.template)
1495     return this.$tip
1496   }
1497
1498
1499   // POPOVER PLUGIN DEFINITION
1500   // =========================
1501
1502   var old = $.fn.popover
1503
1504   $.fn.popover = function (option) {
1505     return this.each(function () {
1506       var $this   = $(this)
1507       var data    = $this.data('bs.popover')
1508       var options = typeof option == 'object' && option
1509
1510       if (!data && option == 'destroy') return
1511       if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
1512       if (typeof option == 'string') data[option]()
1513     })
1514   }
1515
1516   $.fn.popover.Constructor = Popover
1517
1518
1519   // POPOVER NO CONFLICT
1520   // ===================
1521
1522   $.fn.popover.noConflict = function () {
1523     $.fn.popover = old
1524     return this
1525   }
1526
1527 }(jQuery);
1528
1529 /* ========================================================================
1530  * Bootstrap: scrollspy.js v3.1.1
1531  * http://getbootstrap.com/javascript/#scrollspy
1532  * ========================================================================
1533  * Copyright 2011-2014 Twitter, Inc.
1534  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
1535  * ======================================================================== */
1536
1537
1538 +function ($) {
1539   'use strict';
1540
1541   // SCROLLSPY CLASS DEFINITION
1542   // ==========================
1543
1544   function ScrollSpy(element, options) {
1545     var href
1546     var process  = $.proxy(this.process, this)
1547
1548     this.$element       = $(element).is('body') ? $(window) : $(element)
1549     this.$body          = $('body')
1550     this.$scrollElement = this.$element.on('scroll.bs.scroll-spy.data-api', process)
1551     this.options        = $.extend({}, ScrollSpy.DEFAULTS, options)
1552     this.selector       = (this.options.target
1553       || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1554       || '') + ' .nav li > a'
1555     this.offsets        = $([])
1556     this.targets        = $([])
1557     this.activeTarget   = null
1558
1559     this.refresh()
1560     this.process()
1561   }
1562
1563   ScrollSpy.DEFAULTS = {
1564     offset: 10
1565   }
1566
1567   ScrollSpy.prototype.refresh = function () {
1568     var offsetMethod = this.$element[0] == window ? 'offset' : 'position'
1569
1570     this.offsets = $([])
1571     this.targets = $([])
1572
1573     var self     = this
1574     var $targets = this.$body
1575       .find(this.selector)
1576       .map(function () {
1577         var $el   = $(this)
1578         var href  = $el.data('target') || $el.attr('href')
1579         var $href = /^#./.test(href) && $(href)
1580
1581         return ($href
1582           && $href.length
1583           && $href.is(':visible')
1584           && [[ $href[offsetMethod]().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
1585       })
1586       .sort(function (a, b) { return a[0] - b[0] })
1587       .each(function () {
1588         self.offsets.push(this[0])
1589         self.targets.push(this[1])
1590       })
1591   }
1592
1593   ScrollSpy.prototype.process = function () {
1594     var scrollTop    = this.$scrollElement.scrollTop() + this.options.offset
1595     var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
1596     var maxScroll    = scrollHeight - this.$scrollElement.height()
1597     var offsets      = this.offsets
1598     var targets      = this.targets
1599     var activeTarget = this.activeTarget
1600     var i
1601
1602     if (scrollTop >= maxScroll) {
1603       return activeTarget != (i = targets.last()[0]) && this.activate(i)
1604     }
1605
1606     if (activeTarget && scrollTop <= offsets[0]) {
1607       return activeTarget != (i = targets[0]) && this.activate(i)
1608     }
1609
1610     for (i = offsets.length; i--;) {
1611       activeTarget != targets[i]
1612         && scrollTop >= offsets[i]
1613         && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
1614         && this.activate( targets[i] )
1615     }
1616   }
1617
1618   ScrollSpy.prototype.activate = function (target) {
1619     this.activeTarget = target
1620
1621     $(this.selector)
1622       .parentsUntil(this.options.target, '.active')
1623       .removeClass('active')
1624
1625     var selector = this.selector +
1626         '[data-target="' + target + '"],' +
1627         this.selector + '[href="' + target + '"]'
1628
1629     var active = $(selector)
1630       .parents('li')
1631       .addClass('active')
1632
1633     if (active.parent('.dropdown-menu').length) {
1634       active = active
1635         .closest('li.dropdown')
1636         .addClass('active')
1637     }
1638
1639     active.trigger('activate.bs.scrollspy')
1640   }
1641
1642
1643   // SCROLLSPY PLUGIN DEFINITION
1644   // ===========================
1645
1646   var old = $.fn.scrollspy
1647
1648   $.fn.scrollspy = function (option) {
1649     return this.each(function () {
1650       var $this   = $(this)
1651       var data    = $this.data('bs.scrollspy')
1652       var options = typeof option == 'object' && option
1653
1654       if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
1655       if (typeof option == 'string') data[option]()
1656     })
1657   }
1658
1659   $.fn.scrollspy.Constructor = ScrollSpy
1660
1661
1662   // SCROLLSPY NO CONFLICT
1663   // =====================
1664
1665   $.fn.scrollspy.noConflict = function () {
1666     $.fn.scrollspy = old
1667     return this
1668   }
1669
1670
1671   // SCROLLSPY DATA-API
1672   // ==================
1673
1674   $(window).on('load', function () {
1675     $('[data-spy="scroll"]').each(function () {
1676       var $spy = $(this)
1677       $spy.scrollspy($spy.data())
1678     })
1679   })
1680
1681 }(jQuery);
1682
1683 /* ========================================================================
1684  * Bootstrap: tab.js v3.1.1
1685  * http://getbootstrap.com/javascript/#tabs
1686  * ========================================================================
1687  * Copyright 2011-2014 Twitter, Inc.
1688  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
1689  * ======================================================================== */
1690
1691
1692 +function ($) {
1693   'use strict';
1694
1695   // TAB CLASS DEFINITION
1696   // ====================
1697
1698   var Tab = function (element) {
1699     this.element = $(element)
1700   }
1701
1702   Tab.prototype.show = function () {
1703     var $this    = this.element
1704     var $ul      = $this.closest('ul:not(.dropdown-menu)')
1705     var selector = $this.data('target')
1706
1707     if (!selector) {
1708       selector = $this.attr('href')
1709       selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1710     }
1711
1712     if ($this.parent('li').hasClass('active')) return
1713
1714     var previous = $ul.find('.active:last a')[0]
1715     var e        = $.Event('show.bs.tab', {
1716       relatedTarget: previous
1717     })
1718
1719     $this.trigger(e)
1720
1721     if (e.isDefaultPrevented()) return
1722
1723     var $target = $(selector)
1724
1725     this.activate($this.parent('li'), $ul)
1726     this.activate($target, $target.parent(), function () {
1727       $this.trigger({
1728         type: 'shown.bs.tab',
1729         relatedTarget: previous
1730       })
1731     })
1732   }
1733
1734   Tab.prototype.activate = function (element, container, callback) {
1735     var $active    = container.find('> .active')
1736     var transition = callback
1737       && $.support.transition
1738       && $active.hasClass('fade')
1739
1740     function next() {
1741       $active
1742         .removeClass('active')
1743         .find('> .dropdown-menu > .active')
1744         .removeClass('active')
1745
1746       element.addClass('active')
1747
1748       if (transition) {
1749         element[0].offsetWidth // reflow for transition
1750         element.addClass('in')
1751       } else {
1752         element.removeClass('fade')
1753       }
1754
1755       if (element.parent('.dropdown-menu')) {
1756         element.closest('li.dropdown').addClass('active')
1757       }
1758
1759       callback && callback()
1760     }
1761
1762     transition ?
1763       $active
1764         .one($.support.transition.end, next)
1765         .emulateTransitionEnd(150) :
1766       next()
1767
1768     $active.removeClass('in')
1769   }
1770
1771
1772   // TAB PLUGIN DEFINITION
1773   // =====================
1774
1775   var old = $.fn.tab
1776
1777   $.fn.tab = function ( option ) {
1778     return this.each(function () {
1779       var $this = $(this)
1780       var data  = $this.data('bs.tab')
1781
1782       if (!data) $this.data('bs.tab', (data = new Tab(this)))
1783       if (typeof option == 'string') data[option]()
1784     })
1785   }
1786
1787   $.fn.tab.Constructor = Tab
1788
1789
1790   // TAB NO CONFLICT
1791   // ===============
1792
1793   $.fn.tab.noConflict = function () {
1794     $.fn.tab = old
1795     return this
1796   }
1797
1798
1799   // TAB DATA-API
1800   // ============
1801
1802   $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1803     e.preventDefault()
1804     $(this).tab('show')
1805   })
1806
1807 }(jQuery);
1808
1809 /* ========================================================================
1810  * Bootstrap: affix.js v3.1.1
1811  * http://getbootstrap.com/javascript/#affix
1812  * ========================================================================
1813  * Copyright 2011-2014 Twitter, Inc.
1814  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
1815  * ======================================================================== */
1816
1817
1818 +function ($) {
1819   'use strict';
1820
1821   // AFFIX CLASS DEFINITION
1822   // ======================
1823
1824   var Affix = function (element, options) {
1825     this.options = $.extend({}, Affix.DEFAULTS, options)
1826     this.$window = $(window)
1827       .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
1828       .on('click.bs.affix.data-api',  $.proxy(this.checkPositionWithEventLoop, this))
1829
1830     this.$element     = $(element)
1831     this.affixed      =
1832     this.unpin        =
1833     this.pinnedOffset = null
1834
1835     this.checkPosition()
1836   }
1837
1838   Affix.RESET = 'affix affix-top affix-bottom'
1839
1840   Affix.DEFAULTS = {
1841     offset: 0
1842   }
1843
1844   Affix.prototype.getPinnedOffset = function () {
1845     if (this.pinnedOffset) return this.pinnedOffset
1846     this.$element.removeClass(Affix.RESET).addClass('affix')
1847     var scrollTop = this.$window.scrollTop()
1848     var position  = this.$element.offset()
1849     return (this.pinnedOffset = position.top - scrollTop)
1850   }
1851
1852   Affix.prototype.checkPositionWithEventLoop = function () {
1853     setTimeout($.proxy(this.checkPosition, this), 1)
1854   }
1855
1856   Affix.prototype.checkPosition = function () {
1857     if (!this.$element.is(':visible')) return
1858
1859     var scrollHeight = $(document).height()
1860     var scrollTop    = this.$window.scrollTop()
1861     var position     = this.$element.offset()
1862     var offset       = this.options.offset
1863     var offsetTop    = offset.top
1864     var offsetBottom = offset.bottom
1865
1866     if (this.affixed == 'top') position.top += scrollTop
1867
1868     if (typeof offset != 'object')         offsetBottom = offsetTop = offset
1869     if (typeof offsetTop == 'function')    offsetTop    = offset.top(this.$element)
1870     if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
1871
1872     var affix = this.unpin   != null && (scrollTop + this.unpin <= position.top) ? false :
1873                 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
1874                 offsetTop    != null && (scrollTop <= offsetTop) ? 'top' : false
1875
1876     if (this.affixed === affix) return
1877     if (this.unpin) this.$element.css('top', '')
1878
1879     var affixType = 'affix' + (affix ? '-' + affix : '')
1880     var e         = $.Event(affixType + '.bs.affix')
1881
1882     this.$element.trigger(e)
1883
1884     if (e.isDefaultPrevented()) return
1885
1886     this.affixed = affix
1887     this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
1888
1889     this.$element
1890       .removeClass(Affix.RESET)
1891       .addClass(affixType)
1892       .trigger($.Event(affixType.replace('affix', 'affixed')))
1893
1894     if (affix == 'bottom') {
1895       this.$element.offset({ top: scrollHeight - offsetBottom - this.$element.height() })
1896     }
1897   }
1898
1899
1900   // AFFIX PLUGIN DEFINITION
1901   // =======================
1902
1903   var old = $.fn.affix
1904
1905   $.fn.affix = function (option) {
1906     return this.each(function () {
1907       var $this   = $(this)
1908       var data    = $this.data('bs.affix')
1909       var options = typeof option == 'object' && option
1910
1911       if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
1912       if (typeof option == 'string') data[option]()
1913     })
1914   }
1915
1916   $.fn.affix.Constructor = Affix
1917
1918
1919   // AFFIX NO CONFLICT
1920   // =================
1921
1922   $.fn.affix.noConflict = function () {
1923     $.fn.affix = old
1924     return this
1925   }
1926
1927
1928   // AFFIX DATA-API
1929   // ==============
1930
1931   $(window).on('load', function () {
1932     $('[data-spy="affix"]').each(function () {
1933       var $spy = $(this)
1934       var data = $spy.data()
1935
1936       data.offset = data.offset || {}
1937
1938       if (data.offsetBottom) data.offset.bottom = data.offsetBottom
1939       if (data.offsetTop)    data.offset.top    = data.offsetTop
1940
1941       $spy.affix(data)
1942     })
1943   })
1944
1945 }(jQuery);