indvd00m@0: /* ========================================================== indvd00m@0: * bootstrap-affix.js v2.3.1 indvd00m@0: * http://twitter.github.com/bootstrap/javascript.html#affix indvd00m@0: * ========================================================== indvd00m@0: * Copyright 2012 Twitter, Inc. indvd00m@0: * indvd00m@0: * Licensed under the Apache License, Version 2.0 (the "License"); indvd00m@0: * you may not use this file except in compliance with the License. indvd00m@0: * You may obtain a copy of the License at indvd00m@0: * indvd00m@0: * http://www.apache.org/licenses/LICENSE-2.0 indvd00m@0: * indvd00m@0: * Unless required by applicable law or agreed to in writing, software indvd00m@0: * distributed under the License is distributed on an "AS IS" BASIS, indvd00m@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. indvd00m@0: * See the License for the specific language governing permissions and indvd00m@0: * limitations under the License. indvd00m@0: * ========================================================== */ indvd00m@0: indvd00m@0: indvd00m@0: !function ($) { indvd00m@0: indvd00m@0: "use strict"; // jshint ;_; indvd00m@0: indvd00m@0: indvd00m@0: /* AFFIX CLASS DEFINITION indvd00m@0: * ====================== */ indvd00m@0: indvd00m@0: var Affix = function (element, options) { indvd00m@0: this.options = $.extend({}, $.fn.affix.defaults, options) indvd00m@0: this.$window = $(window) indvd00m@0: .on('scroll.affix.data-api', $.proxy(this.checkPosition, this)) indvd00m@0: .on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this)) indvd00m@0: this.$element = $(element) indvd00m@0: this.checkPosition() indvd00m@0: } indvd00m@0: indvd00m@0: Affix.prototype.checkPosition = function () { indvd00m@0: if (!this.$element.is(':visible')) return indvd00m@0: indvd00m@0: var scrollHeight = $(document).height() indvd00m@0: , scrollTop = this.$window.scrollTop() indvd00m@0: , position = this.$element.offset() indvd00m@0: , offset = this.options.offset indvd00m@0: , offsetBottom = offset.bottom indvd00m@0: , offsetTop = offset.top indvd00m@0: , reset = 'affix affix-top affix-bottom' indvd00m@0: , affix indvd00m@0: indvd00m@0: if (typeof offset != 'object') offsetBottom = offsetTop = offset indvd00m@0: if (typeof offsetTop == 'function') offsetTop = offset.top() indvd00m@0: if (typeof offsetBottom == 'function') offsetBottom = offset.bottom() indvd00m@0: indvd00m@0: affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? indvd00m@0: false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? indvd00m@0: 'bottom' : offsetTop != null && scrollTop <= offsetTop ? indvd00m@0: 'top' : false indvd00m@0: indvd00m@0: if (this.affixed === affix) return indvd00m@0: indvd00m@0: this.affixed = affix indvd00m@0: this.unpin = affix == 'bottom' ? position.top - scrollTop : null indvd00m@0: indvd00m@0: this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : '')) indvd00m@0: } indvd00m@0: indvd00m@0: indvd00m@0: /* AFFIX PLUGIN DEFINITION indvd00m@0: * ======================= */ indvd00m@0: indvd00m@0: var old = $.fn.affix indvd00m@0: indvd00m@0: $.fn.affix = function (option) { indvd00m@0: return this.each(function () { indvd00m@0: var $this = $(this) indvd00m@0: , data = $this.data('affix') indvd00m@0: , options = typeof option == 'object' && option indvd00m@0: if (!data) $this.data('affix', (data = new Affix(this, options))) indvd00m@0: if (typeof option == 'string') data[option]() indvd00m@0: }) indvd00m@0: } indvd00m@0: indvd00m@0: $.fn.affix.Constructor = Affix indvd00m@0: indvd00m@0: $.fn.affix.defaults = { indvd00m@0: offset: 0 indvd00m@0: } indvd00m@0: indvd00m@0: indvd00m@0: /* AFFIX NO CONFLICT indvd00m@0: * ================= */ indvd00m@0: indvd00m@0: $.fn.affix.noConflict = function () { indvd00m@0: $.fn.affix = old indvd00m@0: return this indvd00m@0: } indvd00m@0: indvd00m@0: indvd00m@0: /* AFFIX DATA-API indvd00m@0: * ============== */ indvd00m@0: indvd00m@0: $(window).on('load', function () { indvd00m@0: $('[data-spy="affix"]').each(function () { indvd00m@0: var $spy = $(this) indvd00m@0: , data = $spy.data() indvd00m@0: indvd00m@0: data.offset = data.offset || {} indvd00m@0: indvd00m@0: data.offsetBottom && (data.offset.bottom = data.offsetBottom) indvd00m@0: data.offsetTop && (data.offset.top = data.offsetTop) indvd00m@0: indvd00m@0: $spy.affix(data) indvd00m@0: }) indvd00m@0: }) indvd00m@0: indvd00m@0: indvd00m@0: }(window.jQuery);