From 1e9e3316b6718af09bfe473f5eb364e4f9475731 Mon Sep 17 00:00:00 2001 From: fat Date: Wed, 11 Feb 2015 11:40:57 -0800 Subject: [PATCH] kill affix --- dist/js/bootstrap.js | 149 ------------------------------------- dist/js/npm.js | 1 - docs/dist/js/npm.js | 1 - js/affix.js | 162 ----------------------------------------- js/tests/unit/affix.js | 101 ------------------------- 5 files changed, 414 deletions(-) delete mode 100644 js/affix.js delete mode 100644 js/tests/unit/affix.js diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index 5d3f63040d..b22c41b9ac 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -181,155 +181,6 @@ $(function () { $.event.special[Bootstrap.TRANSITION_END] = Bootstrap.getSpecialTransitionEndEvent() }) -$(document).on('mq4hsChange', function (e) { - $(document.documentElement).toggleClass('bs-true-hover', e.trueHover) -}) - -/*! - * mq4-hover-shim v0.1.0 - * https://github.com/twbs/mq4-hover-shim - * Copyright (c) 2014-2015 Christopher Rebert - * Licensed under the MIT License (https://github.com/twbs/mq4-hover-shim/blob/master/LICENSE). - */ - -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.mq4HoverShim=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0); - /* jshint +W018 */ - triggerEvent(); - return; - } - - // Mozilla's -moz-touch-enabled - // https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries#-moz-touch-enabled - var touchEnabledQuery = window.matchMedia("(touch-enabled),(-moz-touch-enabled),(-ms-touch-enabled),(-webkit-touch-enabled)"); - if (touchEnabledQuery.matches) { - canTrulyHover = false; - triggerEvent(); - return; - } - - // W3C Touch Events REC, 10 October 2013 - // http://www.w3.org/TR/2013/REC-touch-events-20131010/ - if ("ontouchstart" in window) { - canTrulyHover = false; - triggerEvent(); - return; - } - - // UA's pointer is non-touch and thus likely either supports true hovering or at least does not try to emulate it. - canTrulyHover = true; - triggerEvent(); -})();function supportsTrueHover() { - return canTrulyHover; -} -exports.__esModule = true; -},{"jquery":undefined}]},{},[1])(1) -}); /** ======================================================================= * Bootstrap: alert.js v4.0.0 * http://getbootstrap.com/javascript/#alerts diff --git a/dist/js/npm.js b/dist/js/npm.js index ed761ca338..f9e8027f18 100644 --- a/dist/js/npm.js +++ b/dist/js/npm.js @@ -1,6 +1,5 @@ // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. require('../../js/util.js') -require('../../node_modules/mq4-hover-shim/dist/browser/mq4-hover-shim.js') require('../../js/alert.js') require('../../js/button.js') require('../../js/carousel.js') diff --git a/docs/dist/js/npm.js b/docs/dist/js/npm.js index bf6aa80602..9060ae2dfc 100644 --- a/docs/dist/js/npm.js +++ b/docs/dist/js/npm.js @@ -10,4 +10,3 @@ require('../../js/tooltip.js') require('../../js/popover.js') require('../../js/scrollspy.js') require('../../js/tab.js') -require('../../js/affix.js') \ No newline at end of file diff --git a/js/affix.js b/js/affix.js deleted file mode 100644 index aaebc8c0f6..0000000000 --- a/js/affix.js +++ /dev/null @@ -1,162 +0,0 @@ -/* ======================================================================== - * Bootstrap: affix.js v3.3.2 - * http://getbootstrap.com/javascript/#affix - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * 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) - this.affixed = - this.unpin = - this.pinnedOffset = null - - this.checkPosition() - } - - Affix.VERSION = '3.3.2' - - Affix.RESET = 'affix affix-top affix-bottom' - - Affix.DEFAULTS = { - offset: 0, - target: window - } - - 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 - - if (offsetTop != null && scrollTop <= offsetTop) return 'top' - if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom' - - return false - } - - 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 - - var height = this.$element.height() - var offset = this.options.offset - var offsetTop = offset.top - var offsetBottom = offset.bottom - var scrollHeight = $('body').height() - - 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) - - var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom) - - if (this.affixed != affix) { - if (this.unpin != null) this.$element.css('top', '') - - var affixType = 'affix' + (affix ? '-' + affix : '') - var e = $.Event(affixType + '.bs.affix') - - this.$element.trigger(e) - - if (e.isDefaultPrevented()) return - - this.affixed = affix - this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null - - this.$element - .removeClass(Affix.RESET) - .addClass(affixType) - .trigger(affixType.replace('affix', 'affixed') + '.bs.affix') - } - - if (affix == 'bottom') { - this.$element.offset({ - top: scrollHeight - height - offsetBottom - }) - } - } - - - // 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 || {} - - if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom - if (data.offsetTop != null) data.offset.top = data.offsetTop - - Plugin.call($spy, data) - }) - }) - -}(jQuery); diff --git a/js/tests/unit/affix.js b/js/tests/unit/affix.js deleted file mode 100644 index 040fe98030..0000000000 --- a/js/tests/unit/affix.js +++ /dev/null @@ -1,101 +0,0 @@ -$(function () { - 'use strict'; - - module('affix plugin') - - test('should be defined on jquery object', function () { - ok($(document.body).affix, 'affix method is defined') - }) - - module('affix', { - setup: function () { - // Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode - $.fn.bootstrapAffix = $.fn.affix.noConflict() - }, - teardown: function () { - $.fn.affix = $.fn.bootstrapAffix - delete $.fn.bootstrapAffix - } - }) - - test('should provide no conflict', function () { - strictEqual($.fn.affix, undefined, 'affix was set back to undefined (org value)') - }) - - test('should return jquery collection containing the element', function () { - var $el = $('
') - var $affix = $el.bootstrapAffix() - ok($affix instanceof $, 'returns jquery collection') - strictEqual($affix[0], $el[0], 'collection contains element') - }) - - test('should exit early if element is not visible', function () { - var $affix = $('
').bootstrapAffix() - $affix.data('bs.affix').checkPosition() - ok(!$affix.hasClass('affix'), 'affix class was not added') - }) - - test('should trigger affixed event after affix', function (assert) { - var done = assert.async() - - var templateHTML = '
' - + '
    ' - + '
  • Please affix
  • ' - + '
  • And unaffix
  • ' - + '
' - + '
' - + '
' - $(templateHTML).appendTo(document.body) - - $('#affixTarget').bootstrapAffix({ - offset: $('#affixTarget ul').position() - }) - - $('#affixTarget') - .on('affix.bs.affix', function () { - ok(true, 'affix event fired') - }).on('affixed.bs.affix', function () { - ok(true, 'affixed event fired') - $('#affixTarget, #affixAfter').remove() - done() - }) - - setTimeout(function () { - window.scrollTo(0, document.body.scrollHeight) - - setTimeout(function () { - window.scroll(0, 0) - }, 16) // for testing in a browser - }, 0) - }) - - test('should affix-top when scrolling up to offset when parent has padding', function (assert) { - var done = assert.async() - - var templateHTML = '
' - + '
' - + '

Testing affix-top class is added

' - + '
' - + '
' - + '
' - $(templateHTML).appendTo(document.body) - - $('#affixTopTarget') - .bootstrapAffix({ - offset: { top: 120, bottom: 0 } - }) - .on('affixed-top.bs.affix', function () { - ok($('#affixTopTarget').hasClass('affix-top'), 'affix-top class applied') - $('#padding-offset').remove() - done() - }) - - setTimeout(function () { - window.scrollTo(0, document.body.scrollHeight) - - setTimeout(function () { - window.scroll(0, 119) - }, 250) - }, 250) - }) -})