bootstrap.js 67.3 KB
Newer Older
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2001
2002
2003
      .removeClass('active')
  }

XhmikosR's avatar
XhmikosR committed
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
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
2041
2042
2043
2044
2045
2046

  // SCROLLSPY PLUGIN DEFINITION
  // ===========================

  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.scrollspy')
      var options = typeof option == 'object' && option

      if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.scrollspy

  $.fn.scrollspy             = Plugin
  $.fn.scrollspy.Constructor = ScrollSpy


  // SCROLLSPY NO CONFLICT
  // =====================

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


  // SCROLLSPY DATA-API
  // ==================

  $(window).on('load.bs.scrollspy.data-api', function () {
    $('[data-spy="scroll"]').each(function () {
      var $spy = $(this)
      Plugin.call($spy, $spy.data())
    })
  })

}(jQuery);

/* ========================================================================
Chris Rebert's avatar
Chris Rebert committed
2047
 * Bootstrap: tab.js v3.3.4
XhmikosR's avatar
XhmikosR committed
2048
2049
 * http://getbootstrap.com/javascript/#tabs
 * ========================================================================
Mark Otto's avatar
grunt    
Mark Otto committed
2050
 * Copyright 2011-2015 Twitter, Inc.
XhmikosR's avatar
XhmikosR committed
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // TAB CLASS DEFINITION
  // ====================

  var Tab = function (element) {
XhmikosR's avatar
XhmikosR committed
2062
    // jscs:disable requireDollarBeforejQueryAssignment
XhmikosR's avatar
XhmikosR committed
2063
    this.element = $(element)
XhmikosR's avatar
XhmikosR committed
2064
    // jscs:enable requireDollarBeforejQueryAssignment
XhmikosR's avatar
XhmikosR committed
2065
2066
  }

Chris Rebert's avatar
Chris Rebert committed
2067
  Tab.VERSION = '3.3.4'
XhmikosR's avatar
XhmikosR committed
2068

2069
2070
  Tab.TRANSITION_DURATION = 150

XhmikosR's avatar
XhmikosR committed
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
  Tab.prototype.show = function () {
    var $this    = this.element
    var $ul      = $this.closest('ul:not(.dropdown-menu)')
    var selector = $this.data('target')

    if (!selector) {
      selector = $this.attr('href')
      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
    }

    if ($this.parent('li').hasClass('active')) return

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2083
2084
2085
2086
2087
2088
    var $previous = $ul.find('.active:last a')
    var hideEvent = $.Event('hide.bs.tab', {
      relatedTarget: $this[0]
    })
    var showEvent = $.Event('show.bs.tab', {
      relatedTarget: $previous[0]
XhmikosR's avatar
XhmikosR committed
2089
2090
    })

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2091
2092
    $previous.trigger(hideEvent)
    $this.trigger(showEvent)
XhmikosR's avatar
XhmikosR committed
2093

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2094
    if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
XhmikosR's avatar
XhmikosR committed
2095
2096
2097
2098
2099

    var $target = $(selector)

    this.activate($this.closest('li'), $ul)
    this.activate($target, $target.parent(), function () {
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2100
2101
2102
2103
      $previous.trigger({
        type: 'hidden.bs.tab',
        relatedTarget: $this[0]
      })
XhmikosR's avatar
XhmikosR committed
2104
2105
      $this.trigger({
        type: 'shown.bs.tab',
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2106
        relatedTarget: $previous[0]
XhmikosR's avatar
XhmikosR committed
2107
2108
2109
2110
2111
2112
2113
2114
      })
    })
  }

  Tab.prototype.activate = function (element, container, callback) {
    var $active    = container.find('> .active')
    var transition = callback
      && $.support.transition
2115
      && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
XhmikosR's avatar
XhmikosR committed
2116
2117
2118
2119
2120

    function next() {
      $active
        .removeClass('active')
        .find('> .dropdown-menu > .active')
Mark Otto's avatar
grunt    
Mark Otto committed
2121
2122
2123
2124
          .removeClass('active')
        .end()
        .find('[data-toggle="tab"]')
          .attr('aria-expanded', false)
XhmikosR's avatar
XhmikosR committed
2125

Mark Otto's avatar
grunt    
Mark Otto committed
2126
2127
2128
2129
      element
        .addClass('active')
        .find('[data-toggle="tab"]')
          .attr('aria-expanded', true)
XhmikosR's avatar
XhmikosR committed
2130
2131
2132
2133
2134
2135
2136
2137

      if (transition) {
        element[0].offsetWidth // reflow for transition
        element.addClass('in')
      } else {
        element.removeClass('fade')
      }

XhmikosR's avatar
XhmikosR committed
2138
      if (element.parent('.dropdown-menu').length) {
Mark Otto's avatar
grunt    
Mark Otto committed
2139
2140
2141
2142
2143
2144
        element
          .closest('li.dropdown')
            .addClass('active')
          .end()
          .find('[data-toggle="tab"]')
            .attr('aria-expanded', true)
XhmikosR's avatar
XhmikosR committed
2145
2146
2147
2148
2149
      }

      callback && callback()
    }

Mark Otto's avatar
grunt    
Mark Otto committed
2150
    $active.length && transition ?
XhmikosR's avatar
XhmikosR committed
2151
2152
      $active
        .one('bsTransitionEnd', next)
2153
        .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
XhmikosR's avatar
XhmikosR committed
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
      next()

    $active.removeClass('in')
  }


  // TAB PLUGIN DEFINITION
  // =====================

  function Plugin(option) {
    return this.each(function () {
      var $this = $(this)
      var data  = $this.data('bs.tab')

      if (!data) $this.data('bs.tab', (data = new Tab(this)))
      if (typeof option == 'string') data[option]()
    })
  }

  var old = $.fn.tab

  $.fn.tab             = Plugin
  $.fn.tab.Constructor = Tab


  // TAB NO CONFLICT
  // ===============

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


  // TAB DATA-API
  // ============

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2191
  var clickHandler = function (e) {
XhmikosR's avatar
XhmikosR committed
2192
2193
    e.preventDefault()
    Plugin.call($(this), 'show')
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2194
2195
2196
2197
2198
  }

  $(document)
    .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
    .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
XhmikosR's avatar
XhmikosR committed
2199
2200
2201
2202

}(jQuery);

/* ========================================================================
Chris Rebert's avatar
Chris Rebert committed
2203
 * Bootstrap: affix.js v3.3.4
XhmikosR's avatar
XhmikosR committed
2204
2205
 * http://getbootstrap.com/javascript/#affix
 * ========================================================================
Mark Otto's avatar
grunt    
Mark Otto committed
2206
 * Copyright 2011-2015 Twitter, Inc.
XhmikosR's avatar
XhmikosR committed
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+function ($) {
  'use strict';

  // AFFIX CLASS DEFINITION
  // ======================

  var Affix = function (element, options) {
    this.options = $.extend({}, Affix.DEFAULTS, options)

    this.$target = $(this.options.target)
      .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
      .on('click.bs.affix.data-api',  $.proxy(this.checkPositionWithEventLoop, this))

    this.$element     = $(element)
XhmikosR's avatar
XhmikosR committed
2225
2226
    this.affixed      = null
    this.unpin        = null
XhmikosR's avatar
XhmikosR committed
2227
2228
2229
2230
2231
    this.pinnedOffset = null

    this.checkPosition()
  }

Chris Rebert's avatar
Chris Rebert committed
2232
  Affix.VERSION  = '3.3.4'
XhmikosR's avatar
XhmikosR committed
2233
2234
2235
2236
2237
2238
2239
2240

  Affix.RESET    = 'affix affix-top affix-bottom'

  Affix.DEFAULTS = {
    offset: 0,
    target: window
  }

2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
  Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
    var scrollTop    = this.$target.scrollTop()
    var position     = this.$element.offset()
    var targetHeight = this.$target.height()

    if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false

    if (this.affixed == 'bottom') {
      if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
      return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
    }

    var initializing   = this.affixed == null
    var colliderTop    = initializing ? scrollTop : position.top
    var colliderHeight = initializing ? targetHeight : height

XhmikosR's avatar
XhmikosR committed
2257
    if (offsetTop != null && scrollTop <= offsetTop) return 'top'
2258
2259
2260
2261
2262
    if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'

    return false
  }

XhmikosR's avatar
XhmikosR committed
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
  Affix.prototype.getPinnedOffset = function () {
    if (this.pinnedOffset) return this.pinnedOffset
    this.$element.removeClass(Affix.RESET).addClass('affix')
    var scrollTop = this.$target.scrollTop()
    var position  = this.$element.offset()
    return (this.pinnedOffset = position.top - scrollTop)
  }

  Affix.prototype.checkPositionWithEventLoop = function () {
    setTimeout($.proxy(this.checkPosition, this), 1)
  }

  Affix.prototype.checkPosition = function () {
    if (!this.$element.is(':visible')) return

2278
    var height       = this.$element.height()
XhmikosR's avatar
XhmikosR committed
2279
2280
2281
    var offset       = this.options.offset
    var offsetTop    = offset.top
    var offsetBottom = offset.bottom
XhmikosR's avatar
XhmikosR committed
2282
    var scrollHeight = Math.max($(document).height(), $(document.body).height())
XhmikosR's avatar
XhmikosR committed
2283
2284
2285
2286
2287

    if (typeof offset != 'object')         offsetBottom = offsetTop = offset
    if (typeof offsetTop == 'function')    offsetTop    = offset.top(this.$element)
    if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)

2288
    var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)
XhmikosR's avatar
XhmikosR committed
2289

2290
2291
    if (this.affixed != affix) {
      if (this.unpin != null) this.$element.css('top', '')
XhmikosR's avatar
XhmikosR committed
2292

2293
2294
      var affixType = 'affix' + (affix ? '-' + affix : '')
      var e         = $.Event(affixType + '.bs.affix')
XhmikosR's avatar
XhmikosR committed
2295

2296
      this.$element.trigger(e)
XhmikosR's avatar
XhmikosR committed
2297

2298
      if (e.isDefaultPrevented()) return
XhmikosR's avatar
XhmikosR committed
2299

2300
2301
      this.affixed = affix
      this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
XhmikosR's avatar
XhmikosR committed
2302

2303
2304
2305
2306
2307
      this.$element
        .removeClass(Affix.RESET)
        .addClass(affixType)
        .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
    }
XhmikosR's avatar
XhmikosR committed
2308
2309
2310

    if (affix == 'bottom') {
      this.$element.offset({
2311
        top: scrollHeight - height - offsetBottom
XhmikosR's avatar
XhmikosR committed
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
      })
    }
  }


  // AFFIX PLUGIN DEFINITION
  // =======================

  function Plugin(option) {
    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]()
    })
  }

  var old = $.fn.affix

  $.fn.affix             = Plugin
  $.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 || {}

Heinrich Fenkart's avatar
Heinrich Fenkart committed
2356
2357
      if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
      if (data.offsetTop    != null) data.offset.top    = data.offsetTop
XhmikosR's avatar
XhmikosR committed
2358
2359
2360
2361
2362
2363

      Plugin.call($spy, data)
    })
  })

}(jQuery);
For faster browsing, not all history is shown. View entire blame