1/* ======================================================================== 2 * Bootstrap: affix.js v3.2.0 3 * http://getbootstrap.com/javascript/#affix 4 * ======================================================================== 5 * Copyright 2011-2014 Twitter, Inc. 6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 7 * ======================================================================== */ 8 9 10+function ($) { 11 'use strict'; 12 13 // AFFIX CLASS DEFINITION 14 // ====================== 15 16 var Affix = function (element, options) { 17 this.options = $.extend({}, Affix.DEFAULTS, options) 18 19 this.$target = $(this.options.target) 20 .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) 21 .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) 22 23 this.$element = $(element) 24 this.affixed = 25 this.unpin = 26 this.pinnedOffset = null 27 28 this.checkPosition() 29 } 30 31 Affix.VERSION = '3.2.0' 32 33 Affix.RESET = 'affix affix-top affix-bottom' 34 35 Affix.DEFAULTS = { 36 offset: 0, 37 target: window 38 } 39 40 Affix.prototype.getPinnedOffset = function () { 41 if (this.pinnedOffset) return this.pinnedOffset 42 this.$element.removeClass(Affix.RESET).addClass('affix') 43 var scrollTop = this.$target.scrollTop() 44 var position = this.$element.offset() 45 return (this.pinnedOffset = position.top - scrollTop) 46 } 47 48 Affix.prototype.checkPositionWithEventLoop = function () { 49 setTimeout($.proxy(this.checkPosition, this), 1) 50 } 51 52 Affix.prototype.checkPosition = function () { 53 if (!this.$element.is(':visible')) return 54 55 var scrollHeight = $(document).height() 56 var scrollTop = this.$target.scrollTop() 57 var position = this.$element.offset() 58 var offset = this.options.offset 59 var offsetTop = offset.top 60 var offsetBottom = offset.bottom 61 62 if (typeof offset != 'object') offsetBottom = offsetTop = offset 63 if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element) 64 if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element) 65 66 var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false : 67 offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' : 68 offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false 69 70 if (this.affixed === affix) return 71 if (this.unpin != null) this.$element.css('top', '') 72 73 var affixType = 'affix' + (affix ? '-' + affix : '') 74 var e = $.Event(affixType + '.bs.affix') 75 76 this.$element.trigger(e) 77 78 if (e.isDefaultPrevented()) return 79 80 this.affixed = affix 81 this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null 82 83 this.$element 84 .removeClass(Affix.RESET) 85 .addClass(affixType) 86 .trigger($.Event(affixType.replace('affix', 'affixed'))) 87 88 if (affix == 'bottom') { 89 this.$element.offset({ 90 top: scrollHeight - this.$element.height() - offsetBottom 91 }) 92 } 93 } 94 95 96 // AFFIX PLUGIN DEFINITION 97 // ======================= 98 99 function Plugin(option) { 100 return this.each(function () { 101 var $this = $(this) 102 var data = $this.data('bs.affix') 103 var options = typeof option == 'object' && option 104 105 if (!data) $this.data('bs.affix', (data = new Affix(this, options))) 106 if (typeof option == 'string') data[option]() 107 }) 108 } 109 110 var old = $.fn.affix 111 112 $.fn.affix = Plugin 113 $.fn.affix.Constructor = Affix 114 115 116 // AFFIX NO CONFLICT 117 // ================= 118 119 $.fn.affix.noConflict = function () { 120 $.fn.affix = old 121 return this 122 } 123 124 125 // AFFIX DATA-API 126 // ============== 127 128 $(window).on('load', function () { 129 $('[data-spy="affix"]').each(function () { 130 var $spy = $(this) 131 var data = $spy.data() 132 133 data.offset = data.offset || {} 134 135 if (data.offsetBottom) data.offset.bottom = data.offsetBottom 136 if (data.offsetTop) data.offset.top = data.offsetTop 137 138 Plugin.call($spy, data) 139 }) 140 }) 141 142}(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.