bootstrap.js 58 KB
Newer Older
2001

Mark Otto's avatar
Mark Otto committed
2002
  function Plugin(option) {
2003
2004
2005
2006
2007
2008
2009
2010
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.affix')
      var options = typeof option == 'object' && option

      if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
      if (typeof option == 'string') data[option]()
    })
2011
2012
  }

Mark Otto's avatar
Mark Otto committed
2013
2014
2015
  var old = $.fn.affix

  $.fn.affix             = Plugin
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
  $.fn.affix.Constructor = Affix


  // AFFIX NO CONFLICT
  // =================

  $.fn.affix.noConflict = function () {
    $.fn.affix = old
    return this
  }


  // AFFIX DATA-API
  // ==============

  $(window).on('load', function () {
    $('[data-spy="affix"]').each(function () {
      var $spy = $(this)
      var data = $spy.data()

      data.offset = data.offset || {}

      if (data.offsetBottom) data.offset.bottom = data.offsetBottom
      if (data.offsetTop)    data.offset.top    = data.offsetTop

Mark Otto's avatar
Mark Otto committed
2041
      Plugin.call($spy, data)
2042
    })
Mark Otto's avatar
Mark Otto committed
2043
2044
  })

Chris Rebert's avatar
Chris Rebert committed
2045
}(jQuery);
For faster browsing, not all history is shown. View entire blame