Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Otto <markotto@twitter.com>2012-07-24 10:01:38 +0400
committerMark Otto <markotto@twitter.com>2012-07-24 10:01:38 +0400
commitf085dbadd18208386649717f4f1bcba62d6119de (patch)
treee8aa445377a1877816ea4636f015117c06096404 /docs/assets/js/bootstrap-affix.js
parent0dda2c4659c6e0407b5b9fda6618ab5c8c12a897 (diff)
parent614d52bd7f86591a0b0ab09e1c16ee888610d8a3 (diff)
Merge branch '2.1.0-wip' of github.com:twitter/bootstrap into 2.1.0-wip
Conflicts: docs/assets/css/docs.css docs/base-css.html docs/components.html docs/customize.html docs/getting-started.html docs/javascript.html docs/scaffolding.html docs/templates/pages/base-css.mustache docs/templates/pages/components.mustache docs/templates/pages/customize.mustache docs/templates/pages/getting-started.mustache docs/templates/pages/javascript.mustache docs/templates/pages/scaffolding.mustache
Diffstat (limited to 'docs/assets/js/bootstrap-affix.js')
-rw-r--r--docs/assets/js/bootstrap-affix.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/docs/assets/js/bootstrap-affix.js b/docs/assets/js/bootstrap-affix.js
new file mode 100644
index 0000000000..7563029b14
--- /dev/null
+++ b/docs/assets/js/bootstrap-affix.js
@@ -0,0 +1,102 @@
+/* ==========================================================
+ * bootstrap-affix.js v2.1.0
+ * http://twitter.github.com/bootstrap/javascript.html#affix
+ * ==========================================================
+ * Copyright 2012 Twitter, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================== */
+
+
+!function ($) {
+
+ "use strict"; // jshint ;_;
+
+
+ /* AFFIX CLASS DEFINITION
+ * ====================== */
+
+ var Affix = function (element, options) {
+ this.options = $.extend({}, $.fn.affix.defaults, options)
+ this.$window = $(window)
+ .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
+ .on('resize.affix.data-api', $.proxy(this.refresh, this))
+ this.$element = $(element)
+ this.refresh()
+ }
+
+ Affix.prototype.refresh = function () {
+ this.position = this.$element.offset()
+ }
+
+ Affix.prototype.checkPosition = function () {
+ if (!this.$element.is(':visible')) return
+
+ var scrollLeft = this.$window.scrollLeft()
+ , scrollTop = this.$window.scrollTop()
+ , position = this.position
+ , offset = this.options.offset
+ , affix
+
+ if (typeof offset != 'object') offset = { x: offset, y: offset }
+
+ affix = (offset.x == null || (position.left - scrollLeft <= offset.x))
+ && (offset.y == null || (position.top - scrollTop <= offset.y))
+
+ if (affix == this.affixed) return
+
+ this.affixed = affix
+
+ this.$element[affix ? 'addClass' : 'removeClass']('affix')
+ }
+
+
+ /* AFFIX PLUGIN DEFINITION
+ * ======================= */
+
+ $.fn.affix = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('affix')
+ , options = typeof option == 'object' && option
+ if (!data) $this.data('affix', (data = new Affix(this, options)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.affix.Constructor = Affix
+
+ $.fn.affix.defaults = {
+ offset: 0
+ }
+
+
+ /* AFFIX DATA-API
+ * ============== */
+
+ $(function () {
+ $('[data-spy="affix"]').each(function () {
+ var $spy = $(this)
+ , data = $spy.data()
+
+ data.offset = data.offset || {}
+
+ data.offsetX && (data.offset.x = data.offsetX)
+ data.offsetY && (data.offset.y = data.offsetY)
+
+ $spy.affix(data)
+ })
+ })
+
+
+}(window.jQuery); \ No newline at end of file