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