Commit ca9c850e authored by fat's avatar fat

add getters for Version and Default where applicable

add modal my gawd
parent bbb97a86
...@@ -68,7 +68,8 @@ module.exports = function (grunt) { ...@@ -68,7 +68,8 @@ module.exports = function (grunt) {
'js/dist/button.js' : 'js/src/button.js', 'js/dist/button.js' : 'js/src/button.js',
'js/dist/carousel.js' : 'js/src/carousel.js', 'js/dist/carousel.js' : 'js/src/carousel.js',
'js/dist/collapse.js' : 'js/src/collapse.js', 'js/dist/collapse.js' : 'js/src/collapse.js',
'js/dist/dropdown.js' : 'js/src/dropdown.js' 'js/dist/dropdown.js' : 'js/src/dropdown.js',
'js/dist/modal.js' : 'js/src/modal.js'
} }
} }
}, },
...@@ -114,8 +115,7 @@ module.exports = function (grunt) { ...@@ -114,8 +115,7 @@ module.exports = function (grunt) {
'js/tooltip.js', 'js/tooltip.js',
'js/popover.js', 'js/popover.js',
'js/scrollspy.js', 'js/scrollspy.js',
'js/tab.js', 'js/tab.js'
'js/affix.js'
], ],
dest: 'dist/js/<%= pkg.name %>.js' dest: 'dist/js/<%= pkg.name %>.js'
} }
......
...@@ -10,4 +10,3 @@ require('../../js/tooltip.js') ...@@ -10,4 +10,3 @@ require('../../js/tooltip.js')
require('../../js/popover.js') require('../../js/popover.js')
require('../../js/scrollspy.js') require('../../js/scrollspy.js')
require('../../js/tab.js') require('../../js/tab.js')
require('../../js/affix.js')
\ No newline at end of file
/* ========================================================================
* Bootstrap: affix.js v3.3.4
* 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 = null
this.unpin = null
this.pinnedOffset = null
this.checkPosition()
}
Affix.VERSION = '3.3.4'
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 = Math.max($(document).height(), $(document.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);
...@@ -115,6 +115,14 @@ var Alert = (function ($) { ...@@ -115,6 +115,14 @@ var Alert = (function ($) {
$(element).detach().trigger(Event.CLOSED).remove(); $(element).detach().trigger(Event.CLOSED).remove();
} }
}], [{ }], [{
key: 'VERSION',
// getters
get: function () {
return VERSION;
}
}, {
key: '_jQueryInterface', key: '_jQueryInterface',
// static // static
......
This diff was suppressed by a .gitattributes entry.
...@@ -96,6 +96,14 @@ var Button = (function ($) { ...@@ -96,6 +96,14 @@ var Button = (function ($) {
} }
} }
}], [{ }], [{
key: 'VERSION',
// getters
get: function () {
return VERSION;
}
}, {
key: '_jQueryInterface', key: '_jQueryInterface',
// static // static
......
This diff was suppressed by a .gitattributes entry.
...@@ -25,7 +25,7 @@ var Carousel = (function ($) { ...@@ -25,7 +25,7 @@ var Carousel = (function ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME]; var JQUERY_NO_CONFLICT = $.fn[NAME];
var TRANSITION_DURATION = 600; var TRANSITION_DURATION = 600;
var Defaults = { var Default = {
interval: 5000, interval: 5000,
keyboard: true, keyboard: true,
slide: false, slide: false,
...@@ -320,6 +320,19 @@ var Carousel = (function ($) { ...@@ -320,6 +320,19 @@ var Carousel = (function ($) {
} }
} }
}], [{ }], [{
key: 'VERSION',
// getters
get: function () {
return VERSION;
}
}, {
key: 'Default',
get: function () {
return Default;
}
}, {
key: '_jQueryInterface', key: '_jQueryInterface',
// static // static
...@@ -327,7 +340,7 @@ var Carousel = (function ($) { ...@@ -327,7 +340,7 @@ var Carousel = (function ($) {
value: function _jQueryInterface(config) { value: function _jQueryInterface(config) {
return this.each(function () { return this.each(function () {
var data = $(this).data(DATA_KEY); var data = $(this).data(DATA_KEY);
var _config = $.extend({}, Defaults, $(this).data()); var _config = $.extend({}, Default, $(this).data());
if (typeof config === 'object') { if (typeof config === 'object') {
$.extend(_config, config); $.extend(_config, config);
......
This diff was suppressed by a .gitattributes entry.
...@@ -25,7 +25,7 @@ var Collapse = (function ($) { ...@@ -25,7 +25,7 @@ var Collapse = (function ($) {
var JQUERY_NO_CONFLICT = $.fn[NAME]; var JQUERY_NO_CONFLICT = $.fn[NAME];
var TRANSITION_DURATION = 600; var TRANSITION_DURATION = 600;
var Defaults = { var Default = {
toggle: true, toggle: true,
parent: null parent: null
}; };
...@@ -67,7 +67,7 @@ var Collapse = (function ($) { ...@@ -67,7 +67,7 @@ var Collapse = (function ($) {
this._isTransitioning = false; this._isTransitioning = false;
this._element = element; this._element = element;
this._config = $.extend({}, Defaults, config); this._config = $.extend({}, Default, config);
this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]'))); this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]')));
this._parent = this._config.parent ? this._getParent() : null; this._parent = this._config.parent ? this._getParent() : null;
...@@ -252,6 +252,19 @@ var Collapse = (function ($) { ...@@ -252,6 +252,19 @@ var Collapse = (function ($) {
} }
} }
}], [{ }], [{
key: 'VERSION',
// getters
get: function () {
return VERSION;
}
}, {
key: 'Default',
get: function () {
return Default;
}
}, {
key: '_getTargetFromElement', key: '_getTargetFromElement',
// static // static
...@@ -266,7 +279,7 @@ var Collapse = (function ($) { ...@@ -266,7 +279,7 @@ var Collapse = (function ($) {
return this.each(function () { return this.each(function () {
var $this = $(this); var $this = $(this);
var data = $this.data(DATA_KEY); var data = $this.data(DATA_KEY);
var _config = $.extend({}, Defaults, $this.data(), typeof config === 'object' && config); var _config = $.extend({}, Default, $this.data(), typeof config === 'object' && config);
if (!data && _config.toggle && /show|hide/.test(config)) { if (!data && _config.toggle && /show|hide/.test(config)) {
_config.toggle = false; _config.toggle = false;
......
This diff was suppressed by a .gitattributes entry.
...@@ -91,7 +91,7 @@ var Dropdown = (function ($) { ...@@ -91,7 +91,7 @@ var Dropdown = (function ($) {
$(dropdown).on('click', Dropdown._clearMenus); $(dropdown).on('click', Dropdown._clearMenus);
} }
var relatedTarget = { 'relatedTarget': this }; var relatedTarget = { relatedTarget: this };
var showEvent = $.Event(Event.SHOW, relatedTarget); var showEvent = $.Event(Event.SHOW, relatedTarget);
$(parent).trigger(showEvent); $(parent).trigger(showEvent);
...@@ -109,6 +109,14 @@ var Dropdown = (function ($) { ...@@ -109,6 +109,14 @@ var Dropdown = (function ($) {
return false; return false;
} }
}], [{ }], [{
key: 'VERSION',
// getters
get: function () {
return VERSION;
}
}, {
key: '_jQueryInterface', key: '_jQueryInterface',
// static // static
...@@ -142,7 +150,7 @@ var Dropdown = (function ($) { ...@@ -142,7 +150,7 @@ var Dropdown = (function ($) {
for (var i = 0; i < toggles.length; i++) { for (var i = 0; i < toggles.length; i++) {
var _parent = Dropdown._getParentFromElement(toggles[i]); var _parent = Dropdown._getParentFromElement(toggles[i]);
var relatedTarget = { 'relatedTarget': toggles[i] }; var relatedTarget = { relatedTarget: toggles[i] };
if (!$(_parent).hasClass(ClassName.OPEN)) { if (!$(_parent).hasClass(ClassName.OPEN)) {
continue; continue;
......
This diff was suppressed by a .gitattributes entry.
This diff is collapsed.
This diff was suppressed by a .gitattributes entry.
/* ========================================================================
* Bootstrap: dropdown.js v3.3.4
* http://getbootstrap.com/javascript/#dropdowns
* ========================================================================
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// DROPDOWN CLASS DEFINITION
// =========================
var backdrop = '.dropdown-backdrop'
var toggle = '[data-toggle="dropdown"]'
var Dropdown = function (element) {
$(element).on('click.bs.dropdown', this.toggle)
}
Dropdown.VERSION = '3.3.4'
function getParent($this) {
var selector = $this.attr('data-target')
if (!selector) {
selector = $this.attr('href')
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}
var $parent = selector && $(selector)
return $parent && $parent.length ? $parent : $this.parent()
}
function clearMenus(e) {
if (e && e.which === 3) return
$(backdrop).remove()
$(toggle).each(function () {
var $this = $(this)
var $parent = getParent($this)
var relatedTarget = { relatedTarget: this }
if (!$parent.hasClass('open')) return
if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this.attr('aria-expanded', 'false')
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
})
}
Dropdown.prototype.toggle = function (e) {
var $this = $(this)
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
// if mobile we use a backdrop because click events don't delegate
$(document.createElement('div'))
.addClass('dropdown-backdrop')
.insertAfter($(this))
.on('click', clearMenus)
}
var relatedTarget = { relatedTarget: this }
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this
.trigger('focus')
.attr('aria-expanded', 'true')
$parent
.toggleClass('open')
.trigger('shown.bs.dropdown', relatedTarget)
}
return false
}
Dropdown.prototype.keydown = function (e) {
if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
var $this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
if (!isActive && e.which != 27 || isActive && e.which == 27) {
if (e.which == 27) $parent.find(toggle).trigger('focus')
return $this.trigger('click')
}
var desc = ' li:not(.disabled):visible a'
var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
if (!$items.length) return
var index = $items.index(e.target)
if (e.which == 38 && index > 0) index-- // up
if (e.which == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items.eq(index).trigger('focus')
}
// DROPDOWN PLUGIN DEFINITION
// ==========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.dropdown')
if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
if (typeof option == 'string') data[option].call($this)
})
}
var old = $.fn.dropdown
$.fn.dropdown = Plugin
$.fn.dropdown.Constructor = Dropdown
// DROPDOWN NO CONFLICT
// ====================
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
return this
}
// APPLY TO STANDARD DROPDOWN ELEMENTS
// ===================================
$(document)
.on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
.on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
}(jQuery);
...@@ -53,6 +53,13 @@ const Alert = (($) => { ...@@ -53,6 +53,13 @@ const Alert = (($) => {
} }
// getters
static get VERSION() {
return VERSION
}
// public // public
close(element) { close(element) {
......
...@@ -52,6 +52,14 @@ const Button = (($) => { ...@@ -52,6 +52,14 @@ const Button = (($) => {
this._element = element this._element = element
} }
// getters
static get VERSION() {
return VERSION
}
// public // public
toggle() { toggle() {
......
...@@ -23,7 +23,7 @@ const Carousel = (($) => { ...@@ -23,7 +23,7 @@ const Carousel = (($) => {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
const TRANSITION_DURATION = 600 const TRANSITION_DURATION = 600
const Defaults = { const Default = {
interval : 5000, interval : 5000,
keyboard : true, keyboard : true,
slide : false, slide : false,
...@@ -72,7 +72,6 @@ const Carousel = (($) => { ...@@ -72,7 +72,6 @@ const Carousel = (($) => {
class Carousel { class Carousel {
constructor(element, config) { constructor(element, config) {
this._items = null this._items = null
this._interval = null this._interval = null
this._activeElement = null this._activeElement = null
...@@ -85,7 +84,17 @@ const Carousel = (($) => { ...@@ -85,7 +84,17 @@ const Carousel = (($) => {
this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0] this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0]
this._addEventListeners() this._addEventListeners()
}
// getters
static get VERSION() {
return VERSION
}
static get Default() {
return Default
} }
...@@ -331,7 +340,7 @@ const Carousel = (($) => { ...@@ -331,7 +340,7 @@ const Carousel = (($) => {
static _jQueryInterface(config) { static _jQueryInterface(config) {
return this.each(function () { return this.each(function () {
let data = $(this).data(DATA_KEY) let data = $(this).data(DATA_KEY)
let _config = $.extend({}, Defaults, $(this).data()) let _config = $.extend({}, Default, $(this).data())
if (typeof config === 'object') { if (typeof config === 'object') {
$.extend(_config, config) $.extend(_config, config)
......
...@@ -23,7 +23,7 @@ const Collapse = (($) => { ...@@ -23,7 +23,7 @@ const Collapse = (($) => {
const JQUERY_NO_CONFLICT = $.fn[NAME] const JQUERY_NO_CONFLICT = $.fn[NAME]
const TRANSITION_DURATION = 600 const TRANSITION_DURATION = 600
const Defaults = { const Default = {
toggle : true, toggle : true,
parent : null parent : null
} }
...@@ -63,10 +63,9 @@ const Collapse = (($) => { ...@@ -63,10 +63,9 @@ const Collapse = (($) => {
class Collapse { class Collapse {
constructor(element, config) { constructor(element, config) {
this._isTransitioning = false this._isTransitioning = false
this._element = element this._element = element
this._config = $.extend({}, Defaults, config) this._config = $.extend({}, Default, config)
this._triggerArray = $.makeArray($( this._triggerArray = $.makeArray($(
`[data-toggle="collapse"][href="#${element.id}"],` + `[data-toggle="collapse"][href="#${element.id}"],` +
`[data-toggle="collapse"][data-target="#${element.id}"]` `[data-toggle="collapse"][data-target="#${element.id}"]`
...@@ -81,9 +80,20 @@ const Collapse = (($) => { ...@@ -81,9 +80,20 @@ const Collapse = (($) => {
if (this._config.toggle) { if (this._config.toggle) {
this.toggle() this.toggle()
} }
}
// getters
static get VERSION() {
return VERSION
} }
static get Default() {
return Default
}
// public // public
toggle() { toggle() {
...@@ -284,7 +294,7 @@ const Collapse = (($) => { ...@@ -284,7 +294,7 @@ const Collapse = (($) => {
let data = $this.data(DATA_KEY) let data = $this.data(DATA_KEY)
let _config = $.extend( let _config = $.extend(
{}, {},
Defaults, Default,
$this.data(), $this.data(),
typeof config === 'object' && config typeof config === 'object' && config
) )
......
...@@ -62,6 +62,14 @@ const Dropdown = (($) => { ...@@ -62,6 +62,14 @@ const Dropdown = (($) => {
$(element).on(Event.CLICK, this.toggle) $(element).on(Event.CLICK, this.toggle)
} }
// getters
static get VERSION() {
return VERSION
}
// public // public
toggle() { toggle() {
......
This diff is collapsed.
...@@ -136,14 +136,13 @@ ...@@ -136,14 +136,13 @@
<script src="../../js/dist/carousel.js"></script> <script src="../../js/dist/carousel.js"></script>
<script src="../../js/dist/collapse.js"></script> <script src="../../js/dist/collapse.js"></script>
<script src="../../js/dist/dropdown.js"></script> <script src="../../js/dist/dropdown.js"></script>
<script src="../../js/dist/modal.js"></script>
<!-- Old Plugin sources --> <!-- Old Plugin sources -->
<script src="../../js/modal.js"></script>
<script src="../../js/scrollspy.js"></script> <script src="../../js/scrollspy.js"></script>
<script src="../../js/tab.js"></script> <script src="../../js/tab.js"></script>
<script src="../../js/tooltip.js"></script> <script src="../../js/tooltip.js"></script>
<script src="../../js/popover.js"></script> <script src="../../js/popover.js"></script>
<script src="../../js/affix.js"></script>
<!-- Unit tests --> <!-- Unit tests -->
<script src="unit/alert.js"></script> <script src="unit/alert.js"></script>
...@@ -156,7 +155,6 @@ ...@@ -156,7 +155,6 @@
<script src="unit/tab.js"></script> <script src="unit/tab.js"></script>
<script src="unit/tooltip.js"></script> <script src="unit/tooltip.js"></script>
<script src="unit/popover.js"></script> <script src="unit/popover.js"></script>
<script src="unit/affix.js"></script>
</head> </head>
<body> <body>
......
$(function () {
'use strict';
QUnit.module('affix plugin')
QUnit.test('should be defined on jquery object', function (assert) {
assert.expect(1)
assert.ok($(document.body).affix, 'affix method is defined')
})
QUnit.module('affix', {
beforeEach: 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()
},
afterEach: function () {
$.fn.affix = $.fn.bootstrapAffix
delete $.fn.bootstrapAffix
}
})
QUnit.test('should provide no conflict', function (assert) {
assert.expect(1)
assert.strictEqual($.fn.affix, undefined, 'affix was set back to undefined (org value)')
})
QUnit.test('should return jquery collection containing the element', function (assert) {
assert.expect(2)
var $el = $('<div/>')
var $affix = $el.bootstrapAffix()
assert.ok($affix instanceof $, 'returns jquery collection')
assert.strictEqual($affix[0], $el[0], 'collection contains element')
})
QUnit.test('should exit early if element is not visible', function (assert) {
assert.expect(1)
var $affix = $('<div style="display: none"/>').bootstrapAffix()
$affix.data('bs.affix').checkPosition()
assert.ok(!$affix.hasClass('affix'), 'affix class was not added')
})
QUnit.test('should trigger affixed event after affix', function (assert) {
assert.expect(2)
var done = assert.async()
var templateHTML = '<div id="affixTarget">'
+ '<ul>'
+ '<li>Please affix</li>'
+ '<li>And unaffix</li>'
+ '</ul>'
+ '</div>'
+ '<div id="affixAfter" style="height: 20000px; display: block;"/>'
$(templateHTML).appendTo(document.body)
$('#affixTarget').bootstrapAffix({
offset: $('#affixTarget ul').position()
})
$('#affixTarget')
.on('affix.bs.affix', function () {
assert.ok(true, 'affix event fired')
}).on('affixed.bs.affix', function () {
assert.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)
})
QUnit.test('should affix-top when scrolling up to offset when parent has padding', function (assert) {
assert.expect(1)
var done = assert.async()
var templateHTML = '<div id="padding-offset" style="padding-top: 20px;">'
+ '<div id="affixTopTarget">'
+ '<p>Testing affix-top class is added</p>'
+ '</div>'
+ '<div style="height: 1000px; display: block;"/>'
+ '</div>'
$(templateHTML).appendTo(document.body)
$('#affixTopTarget')
.bootstrapAffix({
offset: { top: 120, bottom: 0 }
})
.on('affixed-top.bs.affix', function () {
assert.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)
})
})
...@@ -34,7 +34,7 @@ $(function () { ...@@ -34,7 +34,7 @@ $(function () {
QUnit.test('should expose defaults var for settings', function (assert) { QUnit.test('should expose defaults var for settings', function (assert) {
assert.expect(1) assert.expect(1)
assert.ok($.fn.bootstrapModal.Constructor.DEFAULTS, 'default object exposed') assert.ok($.fn.bootstrapModal.Constructor.Default, 'default object exposed')
}) })
QUnit.test('should insert into dom when show method is called', function (assert) { QUnit.test('should insert into dom when show method is called', function (assert) {
......
This diff is collapsed.
This diff is collapsed.
...@@ -141,20 +141,23 @@ ...@@ -141,20 +141,23 @@
<!-- JavaScript Includes --> <!-- JavaScript Includes -->
<script src="../vendor/jquery.min.js"></script> <script src="../vendor/jquery.min.js"></script>
<script src="../../transition.js"></script>
<script src="../../modal.js"></script> <script src="../../dist/util.js"></script>
<script src="../../dist/modal.js"></script>
<script src="../../dist/collapse.js"></script>
<!-- <script src="../../transition.js"></script>
<script src="../../tooltip.js"></script> <script src="../../tooltip.js"></script>
<script src="../../popover.js"></script> <script src="../../popover.js"></script> -->
<script src="../../collapse.js"></script>
<!-- JavaScript Test --> <!-- JavaScript Test -->
<script> <script>
$(function () { $(function () {
$('.js-popover').popover() // $('.js-popover').popover()
$('.js-tooltip').tooltip() // $('.js-tooltip').tooltip()
$('#tall-toggle').click(function () { // $('#tall-toggle').click(function () {
$('#tall').toggle() // $('#tall').toggle()
}) // })
}) })
</script> </script>
......
/* ========================================================================
* Bootstrap: transition.js v3.3.4
* http://getbootstrap.com/javascript/#transitions
* ========================================================================
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
// ============================================================
function transitionEnd() {
var el = document.createElement('bootstrap')
var transEndEventNames = {
WebkitTransition : 'webkitTransitionEnd',
MozTransition : 'transitionend',
OTransition : 'oTransitionEnd otransitionend',
transition : 'transitionend'
}
for (var name in transEndEventNames) {
if (el.style[name] !== undefined) {
return { end: transEndEventNames[name] }
}
}
return false // explicit for ie8 ( ._.)
}
// http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function (duration) {
var called = false
var $el = this
$(this).one('bsTransitionEnd', function () { called = true })
var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
setTimeout(callback, duration)
return this
}
$(function () {
$.support.transition = transitionEnd()
if (!$.support.transition) return
$.event.special.bsTransitionEnd = {
bindType: $.support.transition.end,
delegateType: $.support.transition.end,
handle: function (e) {
if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
}
}
})
}(jQuery);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment