bootstrap.js 66.5 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
2001
2002
    return this
  }
2003

Chris Rebert's avatar
Chris Rebert committed
2004

XhmikosR's avatar
XhmikosR committed
2005
2006
  // SCROLLSPY DATA-API
  // ==================
Chris Rebert's avatar
Chris Rebert committed
2007

XhmikosR's avatar
XhmikosR committed
2008
2009
2010
2011
2012
  $(window).on('load.bs.scrollspy.data-api', function () {
    $('[data-spy="scroll"]').each(function () {
      var $spy = $(this)
      Plugin.call($spy, $spy.data())
    })
2013
  })
2014

XhmikosR's avatar
XhmikosR committed
2015
}(jQuery);
2016

2017
/* ========================================================================
Chris Rebert's avatar
Chris Rebert committed
2018
 * Bootstrap: tab.js v3.3.4
Mark Otto's avatar
Mark Otto committed
2019
 * http://getbootstrap.com/javascript/#tabs
2020
 * ========================================================================
Bootstrap's Grunt bot's avatar
Bootstrap's Grunt bot committed
2021
 * Copyright 2011-2015 Twitter, Inc.
2022
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2023
 * ======================================================================== */
2024

2025

XhmikosR's avatar
XhmikosR committed
2026
2027
+function ($) {
  'use strict';
Mark Otto's avatar
grunt    
Mark Otto committed
2028

XhmikosR's avatar
XhmikosR committed
2029
2030
  // TAB CLASS DEFINITION
  // ====================
2031

XhmikosR's avatar
XhmikosR committed
2032
2033
2034
  var Tab = function (element) {
    this.element = $(element)
  }
2035

Chris Rebert's avatar
Chris Rebert committed
2036
  Tab.VERSION = '3.3.4'
Mark Otto's avatar
grunt    
Mark Otto committed
2037

2038
2039
  Tab.TRANSITION_DURATION = 150

XhmikosR's avatar
XhmikosR committed
2040
2041
2042
2043
  Tab.prototype.show = function () {
    var $this    = this.element
    var $ul      = $this.closest('ul:not(.dropdown-menu)')
    var selector = $this.data('target')
2044

XhmikosR's avatar
XhmikosR committed
2045
2046
2047
2048
    if (!selector) {
      selector = $this.attr('href')
      selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
    }
2049

XhmikosR's avatar
XhmikosR committed
2050
    if ($this.parent('li').hasClass('active')) return
2051

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2052
2053
2054
2055
2056
2057
    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
2058
    })
2059

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2060
2061
    $previous.trigger(hideEvent)
    $this.trigger(showEvent)
2062

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2063
    if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
2064

XhmikosR's avatar
XhmikosR committed
2065
    var $target = $(selector)
2066

XhmikosR's avatar
XhmikosR committed
2067
2068
    this.activate($this.closest('li'), $ul)
    this.activate($target, $target.parent(), function () {
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2069
2070
2071
2072
      $previous.trigger({
        type: 'hidden.bs.tab',
        relatedTarget: $this[0]
      })
XhmikosR's avatar
XhmikosR committed
2073
2074
      $this.trigger({
        type: 'shown.bs.tab',
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2075
        relatedTarget: $previous[0]
2076
      })
XhmikosR's avatar
XhmikosR committed
2077
2078
    })
  }
2079

XhmikosR's avatar
XhmikosR committed
2080
2081
2082
2083
  Tab.prototype.activate = function (element, container, callback) {
    var $active    = container.find('> .active')
    var transition = callback
      && $.support.transition
Mark Otto's avatar
grunt    
Mark Otto committed
2084
      && (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
2085

XhmikosR's avatar
XhmikosR committed
2086
2087
2088
2089
    function next() {
      $active
        .removeClass('active')
        .find('> .dropdown-menu > .active')
Mark Otto's avatar
grunt    
Mark Otto committed
2090
2091
2092
2093
          .removeClass('active')
        .end()
        .find('[data-toggle="tab"]')
          .attr('aria-expanded', false)
2094

Mark Otto's avatar
grunt    
Mark Otto committed
2095
2096
2097
2098
      element
        .addClass('active')
        .find('[data-toggle="tab"]')
          .attr('aria-expanded', true)
XhmikosR's avatar
XhmikosR committed
2099
2100
2101
2102
2103
2104

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

Bootstrap's Grunt bot's avatar
Bootstrap's Grunt bot committed
2107
      if (element.parent('.dropdown-menu').length) {
Mark Otto's avatar
grunt    
Mark Otto committed
2108
2109
2110
2111
2112
2113
        element
          .closest('li.dropdown')
            .addClass('active')
          .end()
          .find('[data-toggle="tab"]')
            .attr('aria-expanded', true)
XhmikosR's avatar
XhmikosR committed
2114
      }
fat's avatar
fat committed
2115

XhmikosR's avatar
XhmikosR committed
2116
      callback && callback()
2117
    }
fat's avatar
fat committed
2118

Mark Otto's avatar
grunt    
Mark Otto committed
2119
    $active.length && transition ?
XhmikosR's avatar
XhmikosR committed
2120
2121
      $active
        .one('bsTransitionEnd', next)
2122
        .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
XhmikosR's avatar
XhmikosR committed
2123
      next()
2124

XhmikosR's avatar
XhmikosR committed
2125
2126
    $active.removeClass('in')
  }
2127
2128


XhmikosR's avatar
XhmikosR committed
2129
2130
  // TAB PLUGIN DEFINITION
  // =====================
fat's avatar
fat committed
2131

XhmikosR's avatar
XhmikosR committed
2132
2133
2134
2135
  function Plugin(option) {
    return this.each(function () {
      var $this = $(this)
      var data  = $this.data('bs.tab')
2136

XhmikosR's avatar
XhmikosR committed
2137
2138
2139
2140
      if (!data) $this.data('bs.tab', (data = new Tab(this)))
      if (typeof option == 'string') data[option]()
    })
  }
Mark Otto's avatar
Mark Otto committed
2141

XhmikosR's avatar
XhmikosR committed
2142
  var old = $.fn.tab
2143

XhmikosR's avatar
XhmikosR committed
2144
2145
  $.fn.tab             = Plugin
  $.fn.tab.Constructor = Tab
2146

2147

XhmikosR's avatar
XhmikosR committed
2148
2149
  // TAB NO CONFLICT
  // ===============
2150

XhmikosR's avatar
XhmikosR committed
2151
2152
2153
2154
  $.fn.tab.noConflict = function () {
    $.fn.tab = old
    return this
  }
2155
2156


XhmikosR's avatar
XhmikosR committed
2157
2158
2159
  // TAB DATA-API
  // ============

Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2160
  var clickHandler = function (e) {
XhmikosR's avatar
XhmikosR committed
2161
2162
    e.preventDefault()
    Plugin.call($(this), 'show')
Heinrich Fenkart's avatar
grunt    
Heinrich Fenkart committed
2163
2164
2165
2166
2167
  }

  $(document)
    .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
    .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
2168

XhmikosR's avatar
XhmikosR committed
2169
}(jQuery);
2170

2171
/* ========================================================================
Chris Rebert's avatar
Chris Rebert committed
2172
 * Bootstrap: affix.js v3.3.4
Mark Otto's avatar
Mark Otto committed
2173
 * http://getbootstrap.com/javascript/#affix
2174
 * ========================================================================
Bootstrap's Grunt bot's avatar
Bootstrap's Grunt bot committed
2175
 * Copyright 2011-2015 Twitter, Inc.
2176
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2177
 * ======================================================================== */
Mark Otto's avatar
Mark Otto committed
2178
2179


XhmikosR's avatar
XhmikosR committed
2180
2181
+function ($) {
  'use strict';
Mark Otto's avatar
grunt    
Mark Otto committed
2182

XhmikosR's avatar
XhmikosR committed
2183
2184
  // AFFIX CLASS DEFINITION
  // ======================
Mark Otto's avatar
Mark Otto committed
2185

XhmikosR's avatar
XhmikosR committed
2186
2187
  var Affix = function (element, options) {
    this.options = $.extend({}, Affix.DEFAULTS, options)
Mark Otto's avatar
Mark Otto committed
2188

XhmikosR's avatar
XhmikosR committed
2189
2190
2191
    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))
Chris Rebert's avatar
Chris Rebert committed
2192

XhmikosR's avatar
XhmikosR committed
2193
    this.$element     = $(element)
Bootstrap's Grunt bot's avatar
Bootstrap's Grunt bot committed
2194
2195
    this.affixed      = null
    this.unpin        = null
XhmikosR's avatar
XhmikosR committed
2196
    this.pinnedOffset = null
fat's avatar
fat committed
2197

XhmikosR's avatar
XhmikosR committed
2198
2199
    this.checkPosition()
  }
fat's avatar
fat committed
2200

Chris Rebert's avatar
Chris Rebert committed
2201
  Affix.VERSION  = '3.3.4'
2202

XhmikosR's avatar
XhmikosR committed
2203
  Affix.RESET    = 'affix affix-top affix-bottom'
Mark Otto's avatar
grunt    
Mark Otto committed
2204

XhmikosR's avatar
XhmikosR committed
2205
2206
2207
2208
  Affix.DEFAULTS = {
    offset: 0,
    target: window
  }
2209

2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
  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

Chris Rebert's avatar
Chris Rebert committed
2226
    if (offsetTop != null && scrollTop <= offsetTop) return 'top'
2227
2228
2229
2230
2231
    if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'

    return false
  }

XhmikosR's avatar
XhmikosR committed
2232
2233
2234
2235
2236
2237
2238
  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)
  }
2239

XhmikosR's avatar
XhmikosR committed
2240
2241
2242
  Affix.prototype.checkPositionWithEventLoop = function () {
    setTimeout($.proxy(this.checkPosition, this), 1)
  }
fat's avatar
fat committed
2243

XhmikosR's avatar
XhmikosR committed
2244
2245
  Affix.prototype.checkPosition = function () {
    if (!this.$element.is(':visible')) return
2246

2247
    var height       = this.$element.height()
XhmikosR's avatar
XhmikosR committed
2248
2249
2250
    var offset       = this.options.offset
    var offsetTop    = offset.top
    var offsetBottom = offset.bottom
Bootstrap's Grunt bot's avatar
Bootstrap's Grunt bot committed
2251
    var scrollHeight = $(document.body).height()
2252

XhmikosR's avatar
XhmikosR committed
2253
2254
2255
    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)
2256

2257
    var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)
2258

2259
2260
    if (this.affixed != affix) {
      if (this.unpin != null) this.$element.css('top', '')
2261

2262
2263
      var affixType = 'affix' + (affix ? '-' + affix : '')
      var e         = $.Event(affixType + '.bs.affix')
2264

2265
      this.$element.trigger(e)
2266

2267
      if (e.isDefaultPrevented()) return
2268

2269
2270
      this.affixed = affix
      this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
2271

2272
2273
2274
2275
2276
      this.$element
        .removeClass(Affix.RESET)
        .addClass(affixType)
        .trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
    }
2277

XhmikosR's avatar
XhmikosR committed
2278
2279
    if (affix == 'bottom') {
      this.$element.offset({
2280
        top: scrollHeight - height - offsetBottom
XhmikosR's avatar
XhmikosR committed
2281
      })
2282
    }
XhmikosR's avatar
XhmikosR committed
2283
  }
Mark Otto's avatar
Mark Otto committed
2284

2285

XhmikosR's avatar
XhmikosR committed
2286
2287
  // AFFIX PLUGIN DEFINITION
  // =======================
2288

XhmikosR's avatar
XhmikosR committed
2289
2290
2291
2292
2293
  function Plugin(option) {
    return this.each(function () {
      var $this   = $(this)
      var data    = $this.data('bs.affix')
      var options = typeof option == 'object' && option
2294

XhmikosR's avatar
XhmikosR committed
2295
2296
2297
2298
      if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
      if (typeof option == 'string') data[option]()
    })
  }
2299

XhmikosR's avatar
XhmikosR committed
2300
  var old = $.fn.affix
Mark Otto's avatar
Mark Otto committed
2301

XhmikosR's avatar
XhmikosR committed
2302
2303
  $.fn.affix             = Plugin
  $.fn.affix.Constructor = Affix
2304
2305


XhmikosR's avatar
XhmikosR committed
2306
2307
  // AFFIX NO CONFLICT
  // =================
2308

XhmikosR's avatar
XhmikosR committed
2309
2310
2311
2312
  $.fn.affix.noConflict = function () {
    $.fn.affix = old
    return this
  }
2313
2314


XhmikosR's avatar
XhmikosR committed
2315
2316
  // AFFIX DATA-API
  // ==============
2317

XhmikosR's avatar
XhmikosR committed
2318
2319
2320
2321
  $(window).on('load', function () {
    $('[data-spy="affix"]').each(function () {
      var $spy = $(this)
      var data = $spy.data()
2322

XhmikosR's avatar
XhmikosR committed
2323
      data.offset = data.offset || {}
2324

Heinrich Fenkart's avatar
Heinrich Fenkart committed
2325
2326
      if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
      if (data.offsetTop    != null) data.offset.top    = data.offsetTop
2327

XhmikosR's avatar
XhmikosR committed
2328
      Plugin.call($spy, data)
2329
    })
Mark Otto's avatar
Mark Otto committed
2330
2331
  })

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