From a72d0d6e3a5f2691eaa7e036a7b081d021097159 Mon Sep 17 00:00:00 2001 From: fat Date: Thu, 16 May 2013 17:44:50 -0700 Subject: [PATCH] fix tests --- docs/assets/js/alert.js | 8 +- docs/assets/js/bootstrap.js | 1226 +++++++++++++++---------------- docs/assets/js/bootstrap.min.js | 2 +- docs/assets/js/carousel.js | 7 +- docs/assets/js/collapse.js | 4 +- docs/assets/js/dropdown.js | 1 - docs/assets/js/modal.js | 285 ++++--- docs/assets/js/popover.js | 103 ++- docs/assets/js/scrollspy.js | 194 +++-- docs/assets/js/tab.js | 139 ++-- docs/assets/js/tooltip.js | 490 ++++++------ docs/assets/js/transition.js | 27 +- js/collapse.js | 4 +- js/modal.js | 6 +- js/popover.js | 2 +- js/tests/unit/alert.js | 4 +- js/tests/unit/carousel.js | 14 +- js/tests/unit/collapse.js | 12 +- js/tests/unit/modal.js | 28 +- js/tests/unit/popover.js | 4 +- js/tests/unit/tab.js | 6 +- js/tests/unit/tooltip.js | 28 +- js/tooltip.js | 24 +- 23 files changed, 1268 insertions(+), 1350 deletions(-) diff --git a/docs/assets/js/alert.js b/docs/assets/js/alert.js index 9df950245c..b841b4f5aa 100644 --- a/docs/assets/js/alert.js +++ b/docs/assets/js/alert.js @@ -45,7 +45,7 @@ $parent = $this.hasClass('alert') ? $this : $this.parent() } - $parent.trigger(e = $.Event('bs-close')) + $parent.trigger(e = $.Event('bs:alert:close')) if (e.isDefaultPrevented()) return @@ -79,8 +79,8 @@ $.fn.alert.Constructor = Alert - /* ALERT NO CONFLICT - * ================= */ + // ALERT NO CONFLICT + // ================= $.fn.alert.noConflict = function () { $.fn.alert = old @@ -89,7 +89,7 @@ // ALERT DATA-API - // ============== */ + // ============== $(document).on('click.bs-alert.bs-data-api', dismiss, Alert.prototype.close) diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index 77ed438b8e..a8501d592d 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -18,34 +18,31 @@ * ========================================================== */ -!function ($) { - - "use strict"; - +!function ($) { "use strict"; - /* CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) - * ======================================================= */ + // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) + // ============================================================ function transitionEnd() { - var el = document.createElement('bootstrap'); + var el = document.createElement('bootstrap') var transEndEventNames = { - 'WebkitTransition' : 'webkitTransitionEnd' - , 'MozTransition' : 'transitionend' - , 'OTransition' : 'oTransitionEnd otransitionend' - , 'transition' : 'transitionend' - }; + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + } for (var name in transEndEventNames) { if (el.style[name] !== undefined) { - return { end: transEndEventNames[name] }; + return { end: transEndEventNames[name] } } } } $(function () { - $.support.transition = transitionEnd(); - }); + $.support.transition = transitionEnd() + }) }(window.jQuery); /* ========================================================== @@ -95,7 +92,7 @@ $parent = $this.hasClass('alert') ? $this : $this.parent() } - $parent.trigger(e = $.Event('bs-close')) + $parent.trigger(e = $.Event('bs:alert:close')) if (e.isDefaultPrevented()) return @@ -129,8 +126,8 @@ $.fn.alert.Constructor = Alert - /* ALERT NO CONFLICT - * ================= */ + // ALERT NO CONFLICT + // ================= $.fn.alert.noConflict = function () { $.fn.alert = old @@ -139,7 +136,7 @@ // ALERT DATA-API - // ============== */ + // ============== $(document).on('click.bs-alert.bs-data-api', dismiss, Alert.prototype.close) @@ -362,7 +359,7 @@ $next = $next.length ? $next : this.$element.find('.item')[fallback]() - var e = $.Event('slide', { relatedTarget: $next[0], direction: direction }) + var e = $.Event('bs:carousel:slide', { relatedTarget: $next[0], direction: direction }) if ($next.hasClass('active')) return @@ -410,11 +407,11 @@ $.fn.carousel = function (option) { return this.each(function () { var $this = $(this) - var data = $this.data('carousel') + var data = $this.data('bs-carousel') var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option) var action = typeof option == 'string' ? option : options.slide - if (!data) $this.data('carousel', (data = new Carousel(this, options))) + if (!data) $this.data('bs-carousel', (data = new Carousel(this, options))) if (typeof option == 'number') data.to(option) else if (action) data[action]() else if (options.interval) data.pause().cycle() @@ -432,6 +429,7 @@ return this } + // CAROUSEL DATA-API // ================= @@ -509,7 +507,7 @@ } this.$element[dimension](0) - this.transition('addClass', $.Event('show'), 'shown') + this.transition('addClass', $.Event('bs:collapse:show'), 'shown') if ($.support.transition) this.$element[dimension](this.$element[0][scroll]) } @@ -518,7 +516,7 @@ if (this.transitioning || !this.$element.hasClass('in')) return var dimension = this.dimension() this.reset(this.$element[dimension]()) - this.transition('removeClass', $.Event('hide'), 'hidden') + this.transition('removeClass', $.Event('bs:collapse:hide'), 'hidden') this.$element[dimension](0) } @@ -626,7 +624,6 @@ !function ($) { "use strict"; - // DROPDOWN CLASS DEFINITION // ========================= @@ -766,207 +763,198 @@ * ========================================================= */ -!function ($) { - - "use strict"; // jshint ;_; - +!function ($) { "use strict"; - /* MODAL CLASS DEFINITION - * ====================== */ + // MODAL CLASS DEFINITION + // ====================== var Modal = function (element, options) { - this.options = options - this.$element = $(element) - .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) - this.options.remote && this.$element.find('.modal-body').load(this.options.remote) - } + this.options = options + this.$element = $(element).delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) + this.$backdrop = + this.isShown = null - Modal.prototype = { + if (this.options.remote) this.$element.find('.modal-body').load(this.options.remote) + } - constructor: Modal + Modal.DEFAULTS = { + backdrop: true + , keyboard: true + , show: true + } - , toggle: function () { - return this[!this.isShown ? 'show' : 'hide']() - } + Modal.prototype.toggle = function () { + return this[!this.isShown ? 'show' : 'hide']() + } - , show: function () { - var that = this - , e = $.Event('show') + Modal.prototype.show = function () { + var that = this + var e = $.Event('bs:modal:show') - this.$element.trigger(e) + this.$element.trigger(e) - if (this.isShown || e.isDefaultPrevented()) return + if (this.isShown || e.isDefaultPrevented()) return - this.isShown = true + this.isShown = true - this.escape() + this.escape() - this.backdrop(function () { - var transition = $.support.transition && that.$element.hasClass('fade') + this.backdrop(function () { + var transition = $.support.transition && that.$element.hasClass('fade') - if (!that.$element.parent().length) { - that.$element.appendTo(document.body) //don't move modals dom position - } + if (!that.$element.parent().length) { + that.$element.appendTo(document.body) //don't move modals dom position + } - that.$element.show() + that.$element.show() - if (transition) { - that.$element[0].offsetWidth // force reflow - } + if (transition) { + that.$element[0].offsetWidth // force reflow + } - that.$element - .addClass('in') - .attr('aria-hidden', false) + that.$element + .addClass('in') + .attr('aria-hidden', false) - that.enforceFocus() + that.enforceFocus() - transition ? - that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : - that.$element.focus().trigger('shown') + transition ? + that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('bs:modal:shown') }) : + that.$element.focus().trigger('bs:modal:shown') - }) - } + }) + } - , hide: function (e) { - e && e.preventDefault() + Modal.prototype.show = function (e) { + if (e) e.preventDefault() - var that = this + e = $.Event('bs:modal:hide') - e = $.Event('hide') + this.$element.trigger(e) - this.$element.trigger(e) + if (!this.isShown || e.isDefaultPrevented()) return - if (!this.isShown || e.isDefaultPrevented()) return + this.isShown = false - this.isShown = false + this.escape() - this.escape() + $(document).off('focusin.modal') - $(document).off('focusin.modal') + this.$element + .removeClass('in') + .attr('aria-hidden', true) - this.$element - .removeClass('in') - .attr('aria-hidden', true) + $.support.transition && this.$element.hasClass('fade') ? + this.hideWithTransition() : + this.hideModal() + } - $.support.transition && this.$element.hasClass('fade') ? - this.hideWithTransition() : - this.hideModal() + Modal.prototype.enforceFocus = function () { + $(document).on('focusin.modal', function (e) { + if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { + this.$element.focus() } + }, this) + } - , enforceFocus: function () { - var that = this - $(document).on('focusin.modal', function (e) { - if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { - that.$element.focus() - } - }) - } + Modal.prototype.escape = function () { + if (this.isShown && this.options.keyboard) { + this.$element.on('keyup.dismiss.modal', function ( e ) { + e.which == 27 && this.hide() + }, this) + } else if (!this.isShown) { + this.$element.off('keyup.dismiss.modal') + } + } - , escape: function () { - var that = this - if (this.isShown && this.options.keyboard) { - this.$element.on('keyup.dismiss.modal', function ( e ) { - e.which == 27 && that.hide() - }) - } else if (!this.isShown) { - this.$element.off('keyup.dismiss.modal') - } - } + Modal.prototype.hideWithTransition = function () { + var that = this + var timeout = setTimeout(function () { + that.$element.off($.support.transition.end) + that.hideModal() + }, 500) - , hideWithTransition: function () { - var that = this - , timeout = setTimeout(function () { - that.$element.off($.support.transition.end) - that.hideModal() - }, 500) - - this.$element.one($.support.transition.end, function () { - clearTimeout(timeout) - that.hideModal() - }) - } + this.$element.one($.support.transition.end, function () { + clearTimeout(timeout) + that.hideModal() + }) + } - , hideModal: function () { - var that = this - this.$element.hide() - this.backdrop(function () { - that.removeBackdrop() - that.$element.trigger('hidden') - }) - } + Modal.prototype.hideModal = function () { + var that = this + this.$element.hide() + this.backdrop(function () { + that.removeBackdrop() + that.$element.trigger('bs:modal:hidden') + }) + } - , removeBackdrop: function () { - this.$backdrop && this.$backdrop.remove() - this.$backdrop = null - } + Modal.prototype.removeBackdrop = function () { + this.$backdrop && this.$backdrop.remove() + this.$backdrop = null + } - , backdrop: function (callback) { - var that = this - , animate = this.$element.hasClass('fade') ? 'fade' : '' + Modal.prototype.backdrop = function (callback) { + var that = this + var animate = this.$element.hasClass('fade') ? 'fade' : '' - if (this.isShown && this.options.backdrop) { - var doAnimate = $.support.transition && animate + if (this.isShown && this.options.backdrop) { + var doAnimate = $.support.transition && animate - this.$backdrop = $('