0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 !function ($) {
0022
0023 $(function () {
0024
0025 "use strict";
0026
0027
0028
0029
0030
0031 $.support.transition = (function () {
0032
0033 var transitionEnd = (function () {
0034
0035 var el = document.createElement('bootstrap')
0036 , transEndEventNames = {
0037 'WebkitTransition' : 'webkitTransitionEnd'
0038 , 'MozTransition' : 'transitionend'
0039 , 'OTransition' : 'oTransitionEnd otransitionend'
0040 , 'transition' : 'transitionend'
0041 }
0042 , name
0043
0044 for (name in transEndEventNames){
0045 if (el.style[name] !== undefined) {
0046 return transEndEventNames[name]
0047 }
0048 }
0049
0050 }())
0051
0052 return transitionEnd && {
0053 end: transitionEnd
0054 }
0055
0056 })()
0057
0058 })
0059
0060 }(window.jQuery);
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 !function ($) {
0081
0082 "use strict";
0083
0084
0085
0086
0087
0088 var dismiss = '[data-dismiss="alert"]'
0089 , Alert = function (el) {
0090 $(el).on('click', dismiss, this.close)
0091 }
0092
0093 Alert.prototype.close = function (e) {
0094 var $this = $(this)
0095 , selector = $this.attr('data-target')
0096 , $parent
0097
0098 if (!selector) {
0099 selector = $this.attr('href')
0100 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '')
0101 }
0102
0103 $parent = $(selector)
0104
0105 e && e.preventDefault()
0106
0107 $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
0108
0109 $parent.trigger(e = $.Event('close'))
0110
0111 if (e.isDefaultPrevented()) return
0112
0113 $parent.removeClass('in')
0114
0115 function removeElement() {
0116 $parent
0117 .trigger('closed')
0118 .remove()
0119 }
0120
0121 $.support.transition && $parent.hasClass('fade') ?
0122 $parent.on($.support.transition.end, removeElement) :
0123 removeElement()
0124 }
0125
0126
0127
0128
0129
0130 $.fn.alert = function (option) {
0131 return this.each(function () {
0132 var $this = $(this)
0133 , data = $this.data('alert')
0134 if (!data) $this.data('alert', (data = new Alert(this)))
0135 if (typeof option == 'string') data[option].call($this)
0136 })
0137 }
0138
0139 $.fn.alert.Constructor = Alert
0140
0141
0142
0143
0144
0145 $(function () {
0146 $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
0147 })
0148
0149 }(window.jQuery);
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 !function ($) {
0170
0171 "use strict";
0172
0173
0174
0175
0176
0177 var Button = function (element, options) {
0178 this.$element = $(element)
0179 this.options = $.extend({}, $.fn.button.defaults, options)
0180 }
0181
0182 Button.prototype.setState = function (state) {
0183 var d = 'disabled'
0184 , $el = this.$element
0185 , data = $el.data()
0186 , val = $el.is('input') ? 'val' : 'html'
0187
0188 state = state + 'Text'
0189 data.resetText || $el.data('resetText', $el[val]())
0190
0191 $el[val](data[state] || this.options[state])
0192
0193
0194 setTimeout(function () {
0195 state == 'loadingText' ?
0196 $el.addClass(d).attr(d, d) :
0197 $el.removeClass(d).removeAttr(d)
0198 }, 0)
0199 }
0200
0201 Button.prototype.toggle = function () {
0202 var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
0203
0204 $parent && $parent
0205 .find('.active')
0206 .removeClass('active')
0207
0208 this.$element.toggleClass('active')
0209 }
0210
0211
0212
0213
0214
0215 $.fn.button = function (option) {
0216 return this.each(function () {
0217 var $this = $(this)
0218 , data = $this.data('button')
0219 , options = typeof option == 'object' && option
0220 if (!data) $this.data('button', (data = new Button(this, options)))
0221 if (option == 'toggle') data.toggle()
0222 else if (option) data.setState(option)
0223 })
0224 }
0225
0226 $.fn.button.defaults = {
0227 loadingText: 'loading...'
0228 }
0229
0230 $.fn.button.Constructor = Button
0231
0232
0233
0234
0235
0236 $(function () {
0237 $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
0238 var $btn = $(e.target)
0239 if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
0240 $btn.button('toggle')
0241 })
0242 })
0243
0244 }(window.jQuery);
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264 !function ($) {
0265
0266 "use strict";
0267
0268
0269
0270
0271
0272 var Carousel = function (element, options) {
0273 this.$element = $(element)
0274 this.options = options
0275 this.options.slide && this.slide(this.options.slide)
0276 this.options.pause == 'hover' && this.$element
0277 .on('mouseenter', $.proxy(this.pause, this))
0278 .on('mouseleave', $.proxy(this.cycle, this))
0279 }
0280
0281 Carousel.prototype = {
0282
0283 cycle: function (e) {
0284 if (!e) this.paused = false
0285 this.options.interval
0286 && !this.paused
0287 && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
0288 return this
0289 }
0290
0291 , to: function (pos) {
0292 var $active = this.$element.find('.item.active')
0293 , children = $active.parent().children()
0294 , activePos = children.index($active)
0295 , that = this
0296
0297 if (pos > (children.length - 1) || pos < 0) return
0298
0299 if (this.sliding) {
0300 return this.$element.one('slid', function () {
0301 that.to(pos)
0302 })
0303 }
0304
0305 if (activePos == pos) {
0306 return this.pause().cycle()
0307 }
0308
0309 return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
0310 }
0311
0312 , pause: function (e) {
0313 if (!e) this.paused = true
0314 if (this.$element.find('.next, .prev').length && $.support.transition.end) {
0315 this.$element.trigger($.support.transition.end)
0316 this.cycle()
0317 }
0318 clearInterval(this.interval)
0319 this.interval = null
0320 return this
0321 }
0322
0323 , next: function () {
0324 if (this.sliding) return
0325 return this.slide('next')
0326 }
0327
0328 , prev: function () {
0329 if (this.sliding) return
0330 return this.slide('prev')
0331 }
0332
0333 , slide: function (type, next) {
0334 var $active = this.$element.find('.item.active')
0335 , $next = next || $active[type]()
0336 , isCycling = this.interval
0337 , direction = type == 'next' ? 'left' : 'right'
0338 , fallback = type == 'next' ? 'first' : 'last'
0339 , that = this
0340 , e = $.Event('slide', {
0341 relatedTarget: $next[0]
0342 })
0343
0344 this.sliding = true
0345
0346 isCycling && this.pause()
0347
0348 $next = $next.length ? $next : this.$element.find('.item')[fallback]()
0349
0350 if ($next.hasClass('active')) return
0351
0352 if ($.support.transition && this.$element.hasClass('slide')) {
0353 this.$element.trigger(e)
0354 if (e.isDefaultPrevented()) return
0355 $next.addClass(type)
0356 $next[0].offsetWidth
0357 $active.addClass(direction)
0358 $next.addClass(direction)
0359 this.$element.one($.support.transition.end, function () {
0360 $next.removeClass([type, direction].join(' ')).addClass('active')
0361 $active.removeClass(['active', direction].join(' '))
0362 that.sliding = false
0363 setTimeout(function () { that.$element.trigger('slid') }, 0)
0364 })
0365 } else {
0366 this.$element.trigger(e)
0367 if (e.isDefaultPrevented()) return
0368 $active.removeClass('active')
0369 $next.addClass('active')
0370 this.sliding = false
0371 this.$element.trigger('slid')
0372 }
0373
0374 isCycling && this.cycle()
0375
0376 return this
0377 }
0378
0379 }
0380
0381
0382
0383
0384
0385 $.fn.carousel = function (option) {
0386 return this.each(function () {
0387 var $this = $(this)
0388 , data = $this.data('carousel')
0389 , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
0390 , action = typeof option == 'string' ? option : options.slide
0391 if (!data) $this.data('carousel', (data = new Carousel(this, options)))
0392 if (typeof option == 'number') data.to(option)
0393 else if (action) data[action]()
0394 else if (options.interval) data.cycle()
0395 })
0396 }
0397
0398 $.fn.carousel.defaults = {
0399 interval: 5000
0400 , pause: 'hover'
0401 }
0402
0403 $.fn.carousel.Constructor = Carousel
0404
0405
0406
0407
0408
0409 $(function () {
0410 $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
0411 var $this = $(this), href
0412 , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''))
0413 , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
0414 $target.carousel(options)
0415 e.preventDefault()
0416 })
0417 })
0418
0419 }(window.jQuery);
0420
0421
0422
0423
0424
0425
0426
0427
0428
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439 !function ($) {
0440
0441 "use strict";
0442
0443
0444
0445
0446
0447 var Collapse = function (element, options) {
0448 this.$element = $(element)
0449 this.options = $.extend({}, $.fn.collapse.defaults, options)
0450
0451 if (this.options.parent) {
0452 this.$parent = $(this.options.parent)
0453 }
0454
0455 this.options.toggle && this.toggle()
0456 }
0457
0458 Collapse.prototype = {
0459
0460 constructor: Collapse
0461
0462 , dimension: function () {
0463 var hasWidth = this.$element.hasClass('width')
0464 return hasWidth ? 'width' : 'height'
0465 }
0466
0467 , show: function () {
0468 var dimension
0469 , scroll
0470 , actives
0471 , hasData
0472
0473 if (this.transitioning) return
0474
0475 dimension = this.dimension()
0476 scroll = $.camelCase(['scroll', dimension].join('-'))
0477 actives = this.$parent && this.$parent.find('> .accordion-group > .in')
0478
0479 if (actives && actives.length) {
0480 hasData = actives.data('collapse')
0481 if (hasData && hasData.transitioning) return
0482 actives.collapse('hide')
0483 hasData || actives.data('collapse', null)
0484 }
0485
0486 this.$element[dimension](0)
0487 this.transition('addClass', $.Event('show'), 'shown')
0488 $.support.transition && this.$element[dimension](this.$element[0][scroll])
0489 }
0490
0491 , hide: function () {
0492 var dimension
0493 if (this.transitioning) return
0494 dimension = this.dimension()
0495 this.reset(this.$element[dimension]())
0496 this.transition('removeClass', $.Event('hide'), 'hidden')
0497 this.$element[dimension](0)
0498 }
0499
0500 , reset: function (size) {
0501 var dimension = this.dimension()
0502
0503 this.$element
0504 .removeClass('collapse')
0505 [dimension](size || 'auto')
0506 [0].offsetWidth
0507
0508 this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
0509
0510 return this
0511 }
0512
0513 , transition: function (method, startEvent, completeEvent) {
0514 var that = this
0515 , complete = function () {
0516 if (startEvent.type == 'show') that.reset()
0517 that.transitioning = 0
0518 that.$element.trigger(completeEvent)
0519 }
0520
0521 this.$element.trigger(startEvent)
0522
0523 if (startEvent.isDefaultPrevented()) return
0524
0525 this.transitioning = 1
0526
0527 this.$element[method]('in')
0528
0529 $.support.transition && this.$element.hasClass('collapse') ?
0530 this.$element.one($.support.transition.end, complete) :
0531 complete()
0532 }
0533
0534 , toggle: function () {
0535 this[this.$element.hasClass('in') ? 'hide' : 'show']()
0536 }
0537
0538 }
0539
0540
0541
0542
0543
0544 $.fn.collapse = function (option) {
0545 return this.each(function () {
0546 var $this = $(this)
0547 , data = $this.data('collapse')
0548 , options = typeof option == 'object' && option
0549 if (!data) $this.data('collapse', (data = new Collapse(this, options)))
0550 if (typeof option == 'string') data[option]()
0551 })
0552 }
0553
0554 $.fn.collapse.defaults = {
0555 toggle: true
0556 }
0557
0558 $.fn.collapse.Constructor = Collapse
0559
0560
0561
0562
0563
0564 $(function () {
0565 $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
0566 var $this = $(this), href
0567 , target = $this.attr('data-target')
0568 || e.preventDefault()
0569 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')
0570 , option = $(target).data('collapse') ? 'toggle' : $this.data()
0571 $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
0572 $(target).collapse(option)
0573 })
0574 })
0575
0576 }(window.jQuery);
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596 !function ($) {
0597
0598 "use strict";
0599
0600
0601
0602
0603
0604 var toggle = '[data-toggle=dropdown]'
0605 , Dropdown = function (element) {
0606 var $el = $(element).on('click.dropdown.data-api', this.toggle)
0607 $('html').on('click.dropdown.data-api', function () {
0608 $el.parent().removeClass('open')
0609 })
0610 }
0611
0612 Dropdown.prototype = {
0613
0614 constructor: Dropdown
0615
0616 , toggle: function (e) {
0617 var $this = $(this)
0618 , $parent
0619 , isActive
0620
0621 if ($this.is('.disabled, :disabled')) return
0622
0623 $parent = getParent($this)
0624
0625 isActive = $parent.hasClass('open')
0626
0627 clearMenus()
0628
0629 if (!isActive) {
0630 $parent.toggleClass('open')
0631 $this.focus()
0632 }
0633
0634 return false
0635 }
0636
0637 , keydown: function (e) {
0638 var $this
0639 , $items
0640 , $active
0641 , $parent
0642 , isActive
0643 , index
0644
0645 if (!/(38|40|27)/.test(e.keyCode)) return
0646
0647 $this = $(this)
0648
0649 e.preventDefault()
0650 e.stopPropagation()
0651
0652 if ($this.is('.disabled, :disabled')) return
0653
0654 $parent = getParent($this)
0655
0656 isActive = $parent.hasClass('open')
0657
0658 if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
0659
0660 $items = $('[role=menu] li:not(.divider) a', $parent)
0661
0662 if (!$items.length) return
0663
0664 index = $items.index($items.filter(':focus'))
0665
0666 if (e.keyCode == 38 && index > 0) index--
0667 if (e.keyCode == 40 && index < $items.length - 1) index++
0668 if (!~index) index = 0
0669
0670 $items
0671 .eq(index)
0672 .focus()
0673 }
0674
0675 }
0676
0677 function clearMenus() {
0678 getParent($(toggle))
0679 .removeClass('open')
0680 }
0681
0682 function getParent($this) {
0683 var selector = $this.attr('data-target')
0684 , $parent
0685
0686 if (!selector) {
0687 selector = $this.attr('href')
0688 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '')
0689 }
0690
0691 $parent = $(selector)
0692 $parent.length || ($parent = $this.parent())
0693
0694 return $parent
0695 }
0696
0697
0698
0699
0700
0701 $.fn.dropdown = function (option) {
0702 return this.each(function () {
0703 var $this = $(this)
0704 , data = $this.data('dropdown')
0705 if (!data) $this.data('dropdown', (data = new Dropdown(this)))
0706 if (typeof option == 'string') data[option].call($this)
0707 })
0708 }
0709
0710 $.fn.dropdown.Constructor = Dropdown
0711
0712
0713
0714
0715
0716 $(function () {
0717 $('html')
0718 .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
0719 $('body')
0720 .on('click.dropdown touchstart.dropdown.data-api', '.dropdown', function (e) { e.stopPropagation() })
0721 .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
0722 .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
0723 })
0724
0725 }(window.jQuery);
0726
0727
0728
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745 !function ($) {
0746
0747 "use strict";
0748
0749
0750
0751
0752
0753 var Modal = function (element, options) {
0754 this.options = options
0755 this.$element = $(element)
0756 .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
0757 this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
0758 }
0759
0760 Modal.prototype = {
0761
0762 constructor: Modal
0763
0764 , toggle: function () {
0765 return this[!this.isShown ? 'show' : 'hide']()
0766 }
0767
0768 , show: function () {
0769 var that = this
0770 , e = $.Event('show')
0771
0772 this.$element.trigger(e)
0773
0774 if (this.isShown || e.isDefaultPrevented()) return
0775
0776 $('body').addClass('modal-open')
0777
0778 this.isShown = true
0779
0780 this.escape()
0781
0782 this.backdrop(function () {
0783 var transition = $.support.transition && that.$element.hasClass('fade')
0784
0785 if (!that.$element.parent().length) {
0786 that.$element.appendTo(document.body)
0787 }
0788
0789 that.$element
0790 .show()
0791
0792 if (transition) {
0793 that.$element[0].offsetWidth
0794 }
0795
0796 that.$element
0797 .addClass('in')
0798 .attr('aria-hidden', false)
0799 .focus()
0800
0801 that.enforceFocus()
0802
0803 transition ?
0804 that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
0805 that.$element.trigger('shown')
0806
0807 })
0808 }
0809
0810 , hide: function (e) {
0811 e && e.preventDefault()
0812
0813 var that = this
0814
0815 e = $.Event('hide')
0816
0817 this.$element.trigger(e)
0818
0819 if (!this.isShown || e.isDefaultPrevented()) return
0820
0821 this.isShown = false
0822
0823 $('body').removeClass('modal-open')
0824
0825 this.escape()
0826
0827 $(document).off('focusin.modal')
0828
0829 this.$element
0830 .removeClass('in')
0831 .attr('aria-hidden', true)
0832
0833 $.support.transition && this.$element.hasClass('fade') ?
0834 this.hideWithTransition() :
0835 this.hideModal()
0836 }
0837
0838 , enforceFocus: function () {
0839 var that = this
0840 $(document).on('focusin.modal', function (e) {
0841 if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
0842 that.$element.focus()
0843 }
0844 })
0845 }
0846
0847 , escape: function () {
0848 var that = this
0849 if (this.isShown && this.options.keyboard) {
0850 this.$element.on('keyup.dismiss.modal', function ( e ) {
0851 e.which == 27 && that.hide()
0852 })
0853 } else if (!this.isShown) {
0854 this.$element.off('keyup.dismiss.modal')
0855 }
0856 }
0857
0858 , hideWithTransition: function () {
0859 var that = this
0860 , timeout = setTimeout(function () {
0861 that.$element.off($.support.transition.end)
0862 that.hideModal()
0863 }, 500)
0864
0865 this.$element.one($.support.transition.end, function () {
0866 clearTimeout(timeout)
0867 that.hideModal()
0868 })
0869 }
0870
0871 , hideModal: function (that) {
0872 this.$element
0873 .hide()
0874 .trigger('hidden')
0875
0876 this.backdrop()
0877 }
0878
0879 , removeBackdrop: function () {
0880 this.$backdrop.remove()
0881 this.$backdrop = null
0882 }
0883
0884 , backdrop: function (callback) {
0885 var that = this
0886 , animate = this.$element.hasClass('fade') ? 'fade' : ''
0887
0888 if (this.isShown && this.options.backdrop) {
0889 var doAnimate = $.support.transition && animate
0890
0891 this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
0892 .appendTo(document.body)
0893
0894 if (this.options.backdrop != 'static') {
0895 this.$backdrop.click($.proxy(this.hide, this))
0896 }
0897
0898 if (doAnimate) this.$backdrop[0].offsetWidth
0899
0900 this.$backdrop.addClass('in')
0901
0902 doAnimate ?
0903 this.$backdrop.one($.support.transition.end, callback) :
0904 callback()
0905
0906 } else if (!this.isShown && this.$backdrop) {
0907 this.$backdrop.removeClass('in')
0908
0909 $.support.transition && this.$element.hasClass('fade')?
0910 this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
0911 this.removeBackdrop()
0912
0913 } else if (callback) {
0914 callback()
0915 }
0916 }
0917 }
0918
0919
0920
0921
0922
0923 $.fn.modal = function (option) {
0924 return this.each(function () {
0925 var $this = $(this)
0926 , data = $this.data('modal')
0927 , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
0928 if (!data) $this.data('modal', (data = new Modal(this, options)))
0929 if (typeof option == 'string') data[option]()
0930 else if (options.show) data.show()
0931 })
0932 }
0933
0934 $.fn.modal.defaults = {
0935 backdrop: true
0936 , keyboard: true
0937 , show: true
0938 }
0939
0940 $.fn.modal.Constructor = Modal
0941
0942
0943
0944
0945
0946 $(function () {
0947 $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
0948 var $this = $(this)
0949 , href = $this.attr('href')
0950 , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')))
0951 , option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
0952
0953 e.preventDefault()
0954
0955 $target
0956 .modal(option)
0957 .one('hide', function () {
0958 $this.focus()
0959 })
0960 })
0961 })
0962
0963 }(window.jQuery);
0964
0965
0966
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983
0984 !function ($) {
0985
0986 "use strict";
0987
0988
0989
0990
0991
0992 var Tooltip = function (element, options) {
0993 this.init('tooltip', element, options)
0994 }
0995
0996 Tooltip.prototype = {
0997
0998 constructor: Tooltip
0999
1000 , init: function (type, element, options) {
1001 var eventIn
1002 , eventOut
1003
1004 this.type = type
1005 this.$element = $(element)
1006 this.options = this.getOptions(options)
1007 this.enabled = true
1008
1009 if (this.options.trigger == 'click') {
1010 this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
1011 } else if (this.options.trigger != 'manual') {
1012 eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
1013 eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
1014 this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
1015 this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
1016 }
1017
1018 this.options.selector ?
1019 (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
1020 this.fixTitle()
1021 }
1022
1023 , getOptions: function (options) {
1024 options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
1025
1026 if (options.delay && typeof options.delay == 'number') {
1027 options.delay = {
1028 show: options.delay
1029 , hide: options.delay
1030 }
1031 }
1032
1033 return options
1034 }
1035
1036 , enter: function (e) {
1037 var self = $(e.currentTarget)[this.type](this._options).data(this.type)
1038
1039 if (!self.options.delay || !self.options.delay.show) return self.show()
1040
1041 clearTimeout(this.timeout)
1042 self.hoverState = 'in'
1043 this.timeout = setTimeout(function() {
1044 if (self.hoverState == 'in') self.show()
1045 }, self.options.delay.show)
1046 }
1047
1048 , leave: function (e) {
1049 var self = $(e.currentTarget)[this.type](this._options).data(this.type)
1050
1051 if (this.timeout) clearTimeout(this.timeout)
1052 if (!self.options.delay || !self.options.delay.hide) return self.hide()
1053
1054 self.hoverState = 'out'
1055 this.timeout = setTimeout(function() {
1056 if (self.hoverState == 'out') self.hide()
1057 }, self.options.delay.hide)
1058 }
1059
1060 , show: function () {
1061 var $tip
1062 , inside
1063 , pos
1064 , actualWidth
1065 , actualHeight
1066 , placement
1067 , tp
1068
1069 if (this.hasContent() && this.enabled) {
1070 $tip = this.tip()
1071 this.setContent()
1072
1073 if (this.options.animation) {
1074 $tip.addClass('fade')
1075 }
1076
1077 placement = typeof this.options.placement == 'function' ?
1078 this.options.placement.call(this, $tip[0], this.$element[0]) :
1079 this.options.placement
1080
1081 inside = /in/.test(placement)
1082
1083 $tip
1084 .remove()
1085 .css({ top: 0, left: 0, display: 'block' })
1086 .appendTo(inside ? this.$element : document.body)
1087
1088 pos = this.getPosition(inside)
1089
1090 actualWidth = $tip[0].offsetWidth
1091 actualHeight = $tip[0].offsetHeight
1092
1093 switch (inside ? placement.split(' ')[1] : placement) {
1094 case 'bottom':
1095 tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
1096 break
1097 case 'top':
1098 tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
1099 break
1100 case 'left':
1101 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
1102 break
1103 case 'right':
1104 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
1105 break
1106 }
1107
1108 $tip
1109 .css(tp)
1110 .addClass(placement)
1111 .addClass('in')
1112 }
1113 }
1114
1115 , setContent: function () {
1116 var $tip = this.tip()
1117 , title = this.getTitle()
1118
1119 $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
1120 $tip.removeClass('fade in top bottom left right')
1121 }
1122
1123 , hide: function () {
1124 var that = this
1125 , $tip = this.tip()
1126
1127 $tip.removeClass('in')
1128
1129 function removeWithAnimation() {
1130 var timeout = setTimeout(function () {
1131 $tip.off($.support.transition.end).remove()
1132 }, 500)
1133
1134 $tip.one($.support.transition.end, function () {
1135 clearTimeout(timeout)
1136 $tip.remove()
1137 })
1138 }
1139
1140 $.support.transition && this.$tip.hasClass('fade') ?
1141 removeWithAnimation() :
1142 $tip.remove()
1143
1144 return this
1145 }
1146
1147 , fixTitle: function () {
1148 var $e = this.$element
1149 if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
1150 $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
1151 }
1152 }
1153
1154 , hasContent: function () {
1155 return this.getTitle()
1156 }
1157
1158 , getPosition: function (inside) {
1159 return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
1160 width: this.$element[0].offsetWidth
1161 , height: this.$element[0].offsetHeight
1162 })
1163 }
1164
1165 , getTitle: function () {
1166 var title
1167 , $e = this.$element
1168 , o = this.options
1169
1170 title = $e.attr('data-original-title')
1171 || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
1172
1173 return title
1174 }
1175
1176 , tip: function () {
1177 return this.$tip = this.$tip || $(this.options.template)
1178 }
1179
1180 , validate: function () {
1181 if (!this.$element[0].parentNode) {
1182 this.hide()
1183 this.$element = null
1184 this.options = null
1185 }
1186 }
1187
1188 , enable: function () {
1189 this.enabled = true
1190 }
1191
1192 , disable: function () {
1193 this.enabled = false
1194 }
1195
1196 , toggleEnabled: function () {
1197 this.enabled = !this.enabled
1198 }
1199
1200 , toggle: function () {
1201 this[this.tip().hasClass('in') ? 'hide' : 'show']()
1202 }
1203
1204 , destroy: function () {
1205 this.hide().$element.off('.' + this.type).removeData(this.type)
1206 }
1207
1208 }
1209
1210
1211
1212
1213
1214 $.fn.tooltip = function ( option ) {
1215 return this.each(function () {
1216 var $this = $(this)
1217 , data = $this.data('tooltip')
1218 , options = typeof option == 'object' && option
1219 if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
1220 if (typeof option == 'string') data[option]()
1221 })
1222 }
1223
1224 $.fn.tooltip.Constructor = Tooltip
1225
1226 $.fn.tooltip.defaults = {
1227 animation: true
1228 , placement: 'top'
1229 , selector: false
1230 , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
1231 , trigger: 'hover'
1232 , title: ''
1233 , delay: 0
1234 , html: true
1235 }
1236
1237 }(window.jQuery);
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258 !function ($) {
1259
1260 "use strict";
1261
1262
1263
1264
1265
1266 var Popover = function (element, options) {
1267 this.init('popover', element, options)
1268 }
1269
1270
1271
1272
1273
1274 Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
1275
1276 constructor: Popover
1277
1278 , setContent: function () {
1279 var $tip = this.tip()
1280 , title = this.getTitle()
1281 , content = this.getContent()
1282
1283 $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
1284 $tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
1285
1286 $tip.removeClass('fade top bottom left right in')
1287 }
1288
1289 , hasContent: function () {
1290 return this.getTitle() || this.getContent()
1291 }
1292
1293 , getContent: function () {
1294 var content
1295 , $e = this.$element
1296 , o = this.options
1297
1298 content = $e.attr('data-content')
1299 || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
1300
1301 return content
1302 }
1303
1304 , tip: function () {
1305 if (!this.$tip) {
1306 this.$tip = $(this.options.template)
1307 }
1308 return this.$tip
1309 }
1310
1311 , destroy: function () {
1312 this.hide().$element.off('.' + this.type).removeData(this.type)
1313 }
1314
1315 })
1316
1317
1318
1319
1320
1321 $.fn.popover = function (option) {
1322 return this.each(function () {
1323 var $this = $(this)
1324 , data = $this.data('popover')
1325 , options = typeof option == 'object' && option
1326 if (!data) $this.data('popover', (data = new Popover(this, options)))
1327 if (typeof option == 'string') data[option]()
1328 })
1329 }
1330
1331 $.fn.popover.Constructor = Popover
1332
1333 $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
1334 placement: 'right'
1335 , trigger: 'click'
1336 , content: ''
1337 , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
1338 })
1339
1340 }(window.jQuery);
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360 !function ($) {
1361
1362 "use strict";
1363
1364
1365
1366
1367
1368 function ScrollSpy(element, options) {
1369 var process = $.proxy(this.process, this)
1370 , $element = $(element).is('body') ? $(window) : $(element)
1371 , href
1372 this.options = $.extend({}, $.fn.scrollspy.defaults, options)
1373 this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
1374 this.selector = (this.options.target
1375 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, ''))
1376 || '') + ' .nav li > a'
1377 this.$body = $('body')
1378 this.refresh()
1379 this.process()
1380 }
1381
1382 ScrollSpy.prototype = {
1383
1384 constructor: ScrollSpy
1385
1386 , refresh: function () {
1387 var self = this
1388 , $targets
1389
1390 this.offsets = $([])
1391 this.targets = $([])
1392
1393 $targets = this.$body
1394 .find(this.selector)
1395 .map(function () {
1396 var $el = $(this)
1397 , href = $el.data('target') || $el.attr('href')
1398 , $href = /^#\w/.test(href) && $(href)
1399 return ( $href
1400 && $href.length
1401 && [[ $href.position().top, href ]] ) || null
1402 })
1403 .sort(function (a, b) { return a[0] - b[0] })
1404 .each(function () {
1405 self.offsets.push(this[0])
1406 self.targets.push(this[1])
1407 })
1408 }
1409
1410 , process: function () {
1411 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
1412 , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
1413 , maxScroll = scrollHeight - this.$scrollElement.height()
1414 , offsets = this.offsets
1415 , targets = this.targets
1416 , activeTarget = this.activeTarget
1417 , i
1418
1419 if (scrollTop >= maxScroll) {
1420 return activeTarget != (i = targets.last()[0])
1421 && this.activate ( i )
1422 }
1423
1424 for (i = offsets.length; i--;) {
1425 activeTarget != targets[i]
1426 && scrollTop >= offsets[i]
1427 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
1428 && this.activate( targets[i] )
1429 }
1430 }
1431
1432 , activate: function (target) {
1433 var active
1434 , selector
1435
1436 this.activeTarget = target
1437
1438 $(this.selector)
1439 .parent('.active')
1440 .removeClass('active')
1441
1442 selector = this.selector
1443 + '[data-target="' + target + '"],'
1444 + this.selector + '[href="' + target + '"]'
1445
1446 active = $(selector)
1447 .parent('li')
1448 .addClass('active')
1449
1450 if (active.parent('.dropdown-menu').length) {
1451 active = active.closest('li.dropdown').addClass('active')
1452 }
1453
1454 active.trigger('activate')
1455 }
1456
1457 }
1458
1459
1460
1461
1462
1463 $.fn.scrollspy = function (option) {
1464 return this.each(function () {
1465 var $this = $(this)
1466 , data = $this.data('scrollspy')
1467 , options = typeof option == 'object' && option
1468 if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
1469 if (typeof option == 'string') data[option]()
1470 })
1471 }
1472
1473 $.fn.scrollspy.Constructor = ScrollSpy
1474
1475 $.fn.scrollspy.defaults = {
1476 offset: 10
1477 }
1478
1479
1480
1481
1482
1483 $(window).on('load', function () {
1484 $('[data-spy="scroll"]').each(function () {
1485 var $spy = $(this)
1486 $spy.scrollspy($spy.data())
1487 })
1488 })
1489
1490 }(window.jQuery);
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510 !function ($) {
1511
1512 "use strict";
1513
1514
1515
1516
1517
1518 var Tab = function (element) {
1519 this.element = $(element)
1520 }
1521
1522 Tab.prototype = {
1523
1524 constructor: Tab
1525
1526 , show: function () {
1527 var $this = this.element
1528 , $ul = $this.closest('ul:not(.dropdown-menu)')
1529 , selector = $this.attr('data-target')
1530 , previous
1531 , $target
1532 , e
1533
1534 if (!selector) {
1535 selector = $this.attr('href')
1536 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '')
1537 }
1538
1539 if ( $this.parent('li').hasClass('active') ) return
1540
1541 previous = $ul.find('.active a').last()[0]
1542
1543 e = $.Event('show', {
1544 relatedTarget: previous
1545 })
1546
1547 $this.trigger(e)
1548
1549 if (e.isDefaultPrevented()) return
1550
1551 $target = $(selector)
1552
1553 this.activate($this.parent('li'), $ul)
1554 this.activate($target, $target.parent(), function () {
1555 $this.trigger({
1556 type: 'shown'
1557 , relatedTarget: previous
1558 })
1559 })
1560 }
1561
1562 , activate: function ( element, container, callback) {
1563 var $active = container.find('> .active')
1564 , transition = callback
1565 && $.support.transition
1566 && $active.hasClass('fade')
1567
1568 function next() {
1569 $active
1570 .removeClass('active')
1571 .find('> .dropdown-menu > .active')
1572 .removeClass('active')
1573
1574 element.addClass('active')
1575
1576 if (transition) {
1577 element[0].offsetWidth
1578 element.addClass('in')
1579 } else {
1580 element.removeClass('fade')
1581 }
1582
1583 if ( element.parent('.dropdown-menu') ) {
1584 element.closest('li.dropdown').addClass('active')
1585 }
1586
1587 callback && callback()
1588 }
1589
1590 transition ?
1591 $active.one($.support.transition.end, next) :
1592 next()
1593
1594 $active.removeClass('in')
1595 }
1596 }
1597
1598
1599
1600
1601
1602 $.fn.tab = function ( option ) {
1603 return this.each(function () {
1604 var $this = $(this)
1605 , data = $this.data('tab')
1606 if (!data) $this.data('tab', (data = new Tab(this)))
1607 if (typeof option == 'string') data[option]()
1608 })
1609 }
1610
1611 $.fn.tab.Constructor = Tab
1612
1613
1614
1615
1616
1617 $(function () {
1618 $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
1619 e.preventDefault()
1620 $(this).tab('show')
1621 })
1622 })
1623
1624 }(window.jQuery);
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644 !function($){
1645
1646 "use strict";
1647
1648
1649
1650
1651
1652 var Typeahead = function (element, options) {
1653 this.$element = $(element)
1654 this.options = $.extend({}, $.fn.typeahead.defaults, options)
1655 this.matcher = this.options.matcher || this.matcher
1656 this.sorter = this.options.sorter || this.sorter
1657 this.highlighter = this.options.highlighter || this.highlighter
1658 this.updater = this.options.updater || this.updater
1659 this.$menu = $(this.options.menu).appendTo('body')
1660 this.source = this.options.source
1661 this.shown = false
1662 this.listen()
1663 }
1664
1665 Typeahead.prototype = {
1666
1667 constructor: Typeahead
1668
1669 , select: function () {
1670 var val = this.$menu.find('.active').attr('data-value')
1671 this.$element
1672 .val(this.updater(val))
1673 .change()
1674 return this.hide()
1675 }
1676
1677 , updater: function (item) {
1678 return item
1679 }
1680
1681 , show: function () {
1682 var pos = $.extend({}, this.$element.offset(), {
1683 height: this.$element[0].offsetHeight
1684 })
1685
1686 this.$menu.css({
1687 top: pos.top + pos.height
1688 , left: pos.left
1689 })
1690
1691 this.$menu.show()
1692 this.shown = true
1693 return this
1694 }
1695
1696 , hide: function () {
1697 this.$menu.hide()
1698 this.shown = false
1699 return this
1700 }
1701
1702 , lookup: function (event) {
1703 var items
1704
1705 this.query = this.$element.val()
1706
1707 if (!this.query || this.query.length < this.options.minLength) {
1708 return this.shown ? this.hide() : this
1709 }
1710
1711 items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
1712
1713 return items ? this.process(items) : this
1714 }
1715
1716 , process: function (items) {
1717 var that = this
1718
1719 items = $.grep(items, function (item) {
1720 return that.matcher(item)
1721 })
1722
1723 items = this.sorter(items)
1724
1725 if (!items.length) {
1726 return this.shown ? this.hide() : this
1727 }
1728
1729 return this.render(items.slice(0, this.options.items)).show()
1730 }
1731
1732 , matcher: function (item) {
1733 return ~item.toLowerCase().indexOf(this.query.toLowerCase())
1734 }
1735
1736 , sorter: function (items) {
1737 var beginswith = []
1738 , caseSensitive = []
1739 , caseInsensitive = []
1740 , item
1741
1742 while (item = items.shift()) {
1743 if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
1744 else if (~item.indexOf(this.query)) caseSensitive.push(item)
1745 else caseInsensitive.push(item)
1746 }
1747
1748 return beginswith.concat(caseSensitive, caseInsensitive)
1749 }
1750
1751 , highlighter: function (item) {
1752 var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
1753 return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
1754 return '<strong>' + match + '</strong>'
1755 })
1756 }
1757
1758 , render: function (items) {
1759 var that = this
1760
1761 items = $(items).map(function (i, item) {
1762 i = $(that.options.item).attr('data-value', item)
1763 i.find('a').html(that.highlighter(item))
1764 return i[0]
1765 })
1766
1767 items.first().addClass('active')
1768 this.$menu.html(items)
1769 return this
1770 }
1771
1772 , next: function (event) {
1773 var active = this.$menu.find('.active').removeClass('active')
1774 , next = active.next()
1775
1776 if (!next.length) {
1777 next = $(this.$menu.find('li')[0])
1778 }
1779
1780 next.addClass('active')
1781 }
1782
1783 , prev: function (event) {
1784 var active = this.$menu.find('.active').removeClass('active')
1785 , prev = active.prev()
1786
1787 if (!prev.length) {
1788 prev = this.$menu.find('li').last()
1789 }
1790
1791 prev.addClass('active')
1792 }
1793
1794 , listen: function () {
1795 this.$element
1796 .on('blur', $.proxy(this.blur, this))
1797 .on('keypress', $.proxy(this.keypress, this))
1798 .on('keyup', $.proxy(this.keyup, this))
1799
1800 if ($.browser.webkit || $.browser.msie) {
1801 this.$element.on('keydown', $.proxy(this.keydown, this))
1802 }
1803
1804 this.$menu
1805 .on('click', $.proxy(this.click, this))
1806 .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
1807 }
1808
1809 , move: function (e) {
1810 if (!this.shown) return
1811
1812 switch(e.keyCode) {
1813 case 9:
1814 case 13:
1815 case 27:
1816 e.preventDefault()
1817 break
1818
1819 case 38:
1820 e.preventDefault()
1821 this.prev()
1822 break
1823
1824 case 40:
1825 e.preventDefault()
1826 this.next()
1827 break
1828 }
1829
1830 e.stopPropagation()
1831 }
1832
1833 , keydown: function (e) {
1834 this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
1835 this.move(e)
1836 }
1837
1838 , keypress: function (e) {
1839 if (this.suppressKeyPressRepeat) return
1840 this.move(e)
1841 }
1842
1843 , keyup: function (e) {
1844 switch(e.keyCode) {
1845 case 40:
1846 case 38:
1847 break
1848
1849 case 9:
1850 case 13:
1851 if (!this.shown) return
1852 this.select()
1853 break
1854
1855 case 27:
1856 if (!this.shown) return
1857 this.hide()
1858 break
1859
1860 default:
1861 this.lookup()
1862 }
1863
1864 e.stopPropagation()
1865 e.preventDefault()
1866 }
1867
1868 , blur: function (e) {
1869 var that = this
1870 setTimeout(function () { that.hide() }, 150)
1871 }
1872
1873 , click: function (e) {
1874 e.stopPropagation()
1875 e.preventDefault()
1876 this.select()
1877 }
1878
1879 , mouseenter: function (e) {
1880 this.$menu.find('.active').removeClass('active')
1881 $(e.currentTarget).addClass('active')
1882 }
1883
1884 }
1885
1886
1887
1888
1889
1890 $.fn.typeahead = function (option) {
1891 return this.each(function () {
1892 var $this = $(this)
1893 , data = $this.data('typeahead')
1894 , options = typeof option == 'object' && option
1895 if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
1896 if (typeof option == 'string') data[option]()
1897 })
1898 }
1899
1900 $.fn.typeahead.defaults = {
1901 source: []
1902 , items: 8
1903 , menu: '<ul class="typeahead dropdown-menu"></ul>'
1904 , item: '<li><a href="#"></a></li>'
1905 , minLength: 1
1906 }
1907
1908 $.fn.typeahead.Constructor = Typeahead
1909
1910
1911
1912
1913
1914 $(function () {
1915 $('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
1916 var $this = $(this)
1917 if ($this.data('typeahead')) return
1918 e.preventDefault()
1919 $this.typeahead($this.data())
1920 })
1921 })
1922
1923 }(window.jQuery);
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944 !function ($) {
1945
1946 "use strict";
1947
1948
1949
1950
1951
1952 var Affix = function (element, options) {
1953 this.options = $.extend({}, $.fn.affix.defaults, options)
1954 this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
1955 this.$element = $(element)
1956 this.checkPosition()
1957 }
1958
1959 Affix.prototype.checkPosition = function () {
1960 if (!this.$element.is(':visible')) return
1961
1962 var scrollHeight = $(document).height()
1963 , scrollTop = this.$window.scrollTop()
1964 , position = this.$element.offset()
1965 , offset = this.options.offset
1966 , offsetBottom = offset.bottom
1967 , offsetTop = offset.top
1968 , reset = 'affix affix-top affix-bottom'
1969 , affix
1970
1971 if (typeof offset != 'object') offsetBottom = offsetTop = offset
1972 if (typeof offsetTop == 'function') offsetTop = offset.top()
1973 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
1974
1975 affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
1976 false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
1977 'bottom' : offsetTop != null && scrollTop <= offsetTop ?
1978 'top' : false
1979
1980 if (this.affixed === affix) return
1981
1982 this.affixed = affix
1983 this.unpin = affix == 'bottom' ? position.top - scrollTop : null
1984
1985 this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
1986 }
1987
1988
1989
1990
1991
1992 $.fn.affix = function (option) {
1993 return this.each(function () {
1994 var $this = $(this)
1995 , data = $this.data('affix')
1996 , options = typeof option == 'object' && option
1997 if (!data) $this.data('affix', (data = new Affix(this, options)))
1998 if (typeof option == 'string') data[option]()
1999 })
2000 }
2001
2002 $.fn.affix.Constructor = Affix
2003
2004 $.fn.affix.defaults = {
2005 offset: 0
2006 }
2007
2008
2009
2010
2011
2012 $(window).on('load', function () {
2013 $('[data-spy="affix"]').each(function () {
2014 var $spy = $(this)
2015 , data = $spy.data()
2016
2017 data.offset = data.offset || {}
2018
2019 data.offsetBottom && (data.offset.bottom = data.offsetBottom)
2020 data.offsetTop && (data.offset.top = data.offsetTop)
2021
2022 $spy.affix(data)
2023 })
2024 })
2025
2026
2027 }(window.jQuery);