Commit a72d0d6e authored by fat's avatar fat

fix tests

parent 19de2e86
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
$parent = $this.hasClass('alert') ? $this : $this.parent() $parent = $this.hasClass('alert') ? $this : $this.parent()
} }
$parent.trigger(e = $.Event('bs-close')) $parent.trigger(e = $.Event('bs:alert:close'))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
...@@ -79,8 +79,8 @@ ...@@ -79,8 +79,8 @@
$.fn.alert.Constructor = Alert $.fn.alert.Constructor = Alert
/* ALERT NO CONFLICT // ALERT NO CONFLICT
* ================= */ // =================
$.fn.alert.noConflict = function () { $.fn.alert.noConflict = function () {
$.fn.alert = old $.fn.alert = old
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
// ALERT DATA-API // ALERT DATA-API
// ============== */ // ==============
$(document).on('click.bs-alert.bs-data-api', dismiss, Alert.prototype.close) $(document).on('click.bs-alert.bs-data-api', dismiss, Alert.prototype.close)
......
This diff is collapsed.
This diff is collapsed.
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
$next = $next.length ? $next : this.$element.find('.item')[fallback]() $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 if ($next.hasClass('active')) return
...@@ -159,11 +159,11 @@ ...@@ -159,11 +159,11 @@
$.fn.carousel = function (option) { $.fn.carousel = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('carousel') var data = $this.data('bs-carousel')
var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option) var options = $.extend({}, Carousel.DEFAULTS, typeof option == 'object' && option)
var action = typeof option == 'string' ? option : options.slide 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) if (typeof option == 'number') data.to(option)
else if (action) data[action]() else if (action) data[action]()
else if (options.interval) data.pause().cycle() else if (options.interval) data.pause().cycle()
...@@ -181,6 +181,7 @@ ...@@ -181,6 +181,7 @@
return this return this
} }
// CAROUSEL DATA-API // CAROUSEL DATA-API
// ================= // =================
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
} }
this.$element[dimension](0) 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]) if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
} }
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
if (this.transitioning || !this.$element.hasClass('in')) return if (this.transitioning || !this.$element.hasClass('in')) return
var dimension = this.dimension() var dimension = this.dimension()
this.reset(this.$element[dimension]()) this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('hide'), 'hidden') this.transition('removeClass', $.Event('bs:collapse:hide'), 'hidden')
this.$element[dimension](0) this.$element[dimension](0)
} }
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
!function ($) { "use strict"; !function ($) { "use strict";
// DROPDOWN CLASS DEFINITION // DROPDOWN CLASS DEFINITION
// ========================= // =========================
......
...@@ -18,32 +18,33 @@ ...@@ -18,32 +18,33 @@
* ========================================================= */ * ========================================================= */
!function ($) { !function ($) { "use strict";
"use strict"; // jshint ;_; // MODAL CLASS DEFINITION
// ======================
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function (element, options) { var Modal = function (element, options) {
this.options = options this.options = options
this.$element = $(element) this.$element = $(element).delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) this.$backdrop =
this.options.remote && this.$element.find('.modal-body').load(this.options.remote) 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 () { Modal.prototype.toggle = function () {
return this[!this.isShown ? 'show' : 'hide']() return this[!this.isShown ? 'show' : 'hide']()
} }
, show: function () { Modal.prototype.show = function () {
var that = this var that = this
, e = $.Event('show') var e = $.Event('bs:modal:show')
this.$element.trigger(e) this.$element.trigger(e)
...@@ -73,18 +74,16 @@ ...@@ -73,18 +74,16 @@
that.enforceFocus() that.enforceFocus()
transition ? transition ?
that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('bs:modal:shown') }) :
that.$element.focus().trigger('shown') that.$element.focus().trigger('bs:modal:shown')
}) })
} }
, hide: function (e) { Modal.prototype.show = function (e) {
e && e.preventDefault() if (e) e.preventDefault()
var that = this e = $.Event('bs:modal:hide')
e = $.Event('hide')
this.$element.trigger(e) this.$element.trigger(e)
...@@ -105,29 +104,27 @@ ...@@ -105,29 +104,27 @@
this.hideModal() this.hideModal()
} }
, enforceFocus: function () { Modal.prototype.enforceFocus = function () {
var that = this
$(document).on('focusin.modal', function (e) { $(document).on('focusin.modal', function (e) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
that.$element.focus() this.$element.focus()
} }
}) }, this)
} }
, escape: function () { Modal.prototype.escape = function () {
var that = this
if (this.isShown && this.options.keyboard) { if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.modal', function ( e ) { this.$element.on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide() e.which == 27 && this.hide()
}) }, this)
} else if (!this.isShown) { } else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal') this.$element.off('keyup.dismiss.modal')
} }
} }
, hideWithTransition: function () { Modal.prototype.hideWithTransition = function () {
var that = this var that = this
, timeout = setTimeout(function () { var timeout = setTimeout(function () {
that.$element.off($.support.transition.end) that.$element.off($.support.transition.end)
that.hideModal() that.hideModal()
}, 500) }, 500)
...@@ -138,23 +135,23 @@ ...@@ -138,23 +135,23 @@
}) })
} }
, hideModal: function () { Modal.prototype.hideModal = function () {
var that = this var that = this
this.$element.hide() this.$element.hide()
this.backdrop(function () { this.backdrop(function () {
that.removeBackdrop() that.removeBackdrop()
that.$element.trigger('hidden') that.$element.trigger('bs:modal:hidden')
}) })
} }
, removeBackdrop: function () { Modal.prototype.removeBackdrop = function () {
this.$backdrop && this.$backdrop.remove() this.$backdrop && this.$backdrop.remove()
this.$backdrop = null this.$backdrop = null
} }
, backdrop: function (callback) { Modal.prototype.backdrop = function (callback) {
var that = this var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : '' var animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.options.backdrop) { if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate var doAnimate = $.support.transition && animate
...@@ -189,36 +186,30 @@ ...@@ -189,36 +186,30 @@
callback() callback()
} }
} }
}
/* MODAL PLUGIN DEFINITION // MODAL PLUGIN DEFINITION
* ======================= */ // =======================
var old = $.fn.modal var old = $.fn.modal
$.fn.modal = function (option) { $.fn.modal = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('modal') var data = $this.data('bs-modal')
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option) var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options)))
if (!data) $this.data('bs-modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
else if (options.show) data.show() else if (options.show) data.show()
}) })
} }
$.fn.modal.defaults = {
backdrop: true
, keyboard: true
, show: true
}
$.fn.modal.Constructor = Modal $.fn.modal.Constructor = Modal
/* MODAL NO CONFLICT // MODAL NO CONFLICT
* ================= */ // =================
$.fn.modal.noConflict = function () { $.fn.modal.noConflict = function () {
$.fn.modal = old $.fn.modal = old
...@@ -226,14 +217,14 @@ ...@@ -226,14 +217,14 @@
} }
/* MODAL DATA-API // MODAL DATA-API
* ============== */ // ==============
$(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
var $this = $(this) var $this = $(this)
, href = $this.attr('href') var href = $this.attr('href')
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data()) var option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault() e.preventDefault()
...@@ -245,7 +236,7 @@ ...@@ -245,7 +236,7 @@
}) })
var $body = $(document.body) var $body = $(document.body)
.on('shown', '.modal', function () { $body.addClass('modal-open') }) .on('bs:modal:shown', '.modal', function () { $body.addClass('modal-open') })
.on('hidden', '.modal', function () { $body.removeClass('modal-open') }) .on('bs:modal:hidden', '.modal', function () { $body.removeClass('modal-open') })
}(window.jQuery); }(window.jQuery);
...@@ -18,30 +18,38 @@ ...@@ -18,30 +18,38 @@
* =========================================================== */ * =========================================================== */
!function ($) { !function ($) { "use strict";
"use strict"; // jshint ;_; // POPOVER PUBLIC CLASS DEFINITION
// ===============================
/* POPOVER PUBLIC CLASS DEFINITION
* =============================== */
var Popover = function (element, options) { var Popover = function (element, options) {
this.init('popover', element, options) this.init('popover', element, options)
} }
Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
placement: 'right'
, trigger: 'click'
, content: ''
, template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
})
/* NOTE: POPOVER EXTENDS tooltip.js // NOTE: POPOVER EXTENDS tooltip.js
========================================== */ // ================================
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, { Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
constructor: Popover Popover.prototype.constructor = Popover
, setContent: function () { Popover.prototype.getDefaults = function () {
return Popover.DEFAULTS
}
Popover.prototype.setContent = function () {
var $tip = this.tip() var $tip = this.tip()
, title = this.getTitle() var title = this.getTitle()
, content = this.getContent() var content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
$tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content) $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
...@@ -49,62 +57,49 @@ ...@@ -49,62 +57,49 @@
$tip.removeClass('fade top bottom left right in') $tip.removeClass('fade top bottom left right in')
} }
, hasContent: function () { Popover.prototype.hasContent = function () {
return this.getTitle() || this.getContent() return this.getTitle() || this.getContent()
} }
, getContent: function () { Popover.prototype.getContent = function () {
var content var content = typeof this.options.content == 'function' ?
, $e = this.$element this.options.content.call(this.$element[0]) :
, o = this.options this.options.content
content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
|| $e.attr('data-content')
return content return content || this.$element.attr('data-content')
} }
, tip: function () { Popover.prototype.tip = function () {
if (!this.$tip) { if (!this.$tip) this.$tip = $(this.options.template)
this.$tip = $(this.options.template)
}
return this.$tip return this.$tip
} }
, destroy: function () { Popover.prototype.destroy = function () {
this.hide().$element.off('.' + this.type).removeData(this.type) this.hide().$element.off('.' + this.type).removeData(this.type)
} }
})
/* POPOVER PLUGIN DEFINITION // POPOVER PLUGIN DEFINITION
* ======================= */ // =========================
var old = $.fn.popover var old = $.fn.popover
$.fn.popover = function (option) { $.fn.popover = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('popover') var data = $this.data('bs-popover')
, options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('popover', (data = new Popover(this, options)))
if (!data) $this.data('bs-popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
$.fn.popover.Constructor = Popover $.fn.popover.Constructor = Popover
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
placement: 'right'
, trigger: 'click'
, content: ''
, template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
})
/* POPOVER NO CONFLICT // POPOVER NO CONFLICT
* =================== */ // ===================
$.fn.popover.noConflict = function () { $.fn.popover.noConflict = function () {
$.fn.popover = old $.fn.popover = old
......
...@@ -18,48 +18,49 @@ ...@@ -18,48 +18,49 @@
* ============================================================== */ * ============================================================== */
!function ($) { !function ($) { "use strict";
"use strict"; // jshint ;_; // SCROLLSPY CLASS DEFINITION
// ==========================
/* SCROLLSPY CLASS DEFINITION
* ========================== */
function ScrollSpy(element, options) { function ScrollSpy(element, options) {
var href
var process = $.proxy(this.process, this) var process = $.proxy(this.process, this)
, $element = $(element).is('body') ? $(window) : $(element) var $element = $(element).is('body') ? $(window) : $(element)
, href
this.options = $.extend({}, $.fn.scrollspy.defaults, options) this.$body = $('body')
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process) this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
this.selector = (this.options.target this.selector = (this.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|| '') + ' .nav li > a' || '') + ' .nav li > a'
this.$body = $('body') this.offsets = $([])
this.targets = $([])
this.activeTarget = null
this.refresh() this.refresh()
this.process() this.process()
} }
ScrollSpy.prototype = { ScrollSpy.DEFAULTS = {
offset: 10
constructor: ScrollSpy }
, refresh: function () {
var self = this
, $targets
ScrollSpy.prototype.refresh = function () {
this.offsets = $([]) this.offsets = $([])
this.targets = $([]) this.targets = $([])
$targets = this.$body var self = this
var $targets = this.$body
.find(this.selector) .find(this.selector)
.map(function () { .map(function () {
var $el = $(this) var $el = $(this)
, href = $el.data('target') || $el.attr('href') var href = $el.data('target') || $el.attr('href')
, $href = /^#\w/.test(href) && $(href) var $href = /^#\w/.test(href) && $(href)
return ( $href
return ($href
&& $href.length && $href.length
&& [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
}) })
.sort(function (a, b) { return a[0] - b[0] }) .sort(function (a, b) { return a[0] - b[0] })
.each(function () { .each(function () {
...@@ -68,18 +69,17 @@ ...@@ -68,18 +69,17 @@
}) })
} }
, process: function () { ScrollSpy.prototype.process = function () {
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
, scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
, maxScroll = scrollHeight - this.$scrollElement.height() var maxScroll = scrollHeight - this.$scrollElement.height()
, offsets = this.offsets var offsets = this.offsets
, targets = this.targets var targets = this.targets
, activeTarget = this.activeTarget var activeTarget = this.activeTarget
, i var i
if (scrollTop >= maxScroll) { if (scrollTop >= maxScroll) {
return activeTarget != (i = targets.last()[0]) return activeTarget != (i = targets.last()[0]) && this.activate(i)
&& this.activate ( i )
} }
for (i = offsets.length; i--;) { for (i = offsets.length; i--;) {
...@@ -90,58 +90,52 @@ ...@@ -90,58 +90,52 @@
} }
} }
, activate: function (target) { ScrollSpy.prototype.activate = function (target) {
var active
, selector
this.activeTarget = target this.activeTarget = target
$(this.selector) $(this.selector)
.parents('.active') .parents('.active')
.removeClass('active') .removeClass('active')
selector = this.selector var selector = this.selector
+ '[data-target="' + target + '"],' + '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]' + this.selector + '[href="' + target + '"]'
active = $(selector) var active = $(selector)
.parents('li') .parents('li')
.addClass('active') .addClass('active')
if (active.parent('.dropdown-menu').length) { if (active.parent('.dropdown-menu').length) {
active = active.closest('li.dropdown').addClass('active') active = active
.closest('li.dropdown')
.addClass('active')
} }
active.trigger('activate') active.trigger('activate')
} }
}
// SCROLLSPY PLUGIN DEFINITION
/* SCROLLSPY PLUGIN DEFINITION // ===========================
* =========================== */
var old = $.fn.scrollspy var old = $.fn.scrollspy
$.fn.scrollspy = function (option) { $.fn.scrollspy = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('scrollspy') var data = $this.data('bs-scrollspy')
, options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
if (!data) $this.data('bs-scrollspy', (data = new ScrollSpy(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
$.fn.scrollspy.Constructor = ScrollSpy $.fn.scrollspy.Constructor = ScrollSpy
$.fn.scrollspy.defaults = {
offset: 10
}
/* SCROLLSPY NO CONFLICT // SCROLLSPY NO CONFLICT
* ===================== */ // =====================
$.fn.scrollspy.noConflict = function () { $.fn.scrollspy.noConflict = function () {
$.fn.scrollspy = old $.fn.scrollspy = old
...@@ -149,8 +143,8 @@ ...@@ -149,8 +143,8 @@
} }
/* SCROLLSPY DATA-API // SCROLLSPY DATA-API
* ================== */ // ==================
$(window).on('load', function () { $(window).on('load', function () {
$('[data-spy="scroll"]').each(function () { $('[data-spy="scroll"]').each(function () {
......
...@@ -18,40 +18,29 @@ ...@@ -18,40 +18,29 @@
* ======================================================== */ * ======================================================== */
!function ($) { !function ($) { "use strict";
"use strict"; // jshint ;_; // TAB CLASS DEFINITION
// ====================
/* TAB CLASS DEFINITION
* ==================== */
var Tab = function (element) { var Tab = function (element) {
this.element = $(element) this.element = $(element)
} }
Tab.prototype = { Tab.prototype.show = function () {
constructor: Tab
, show: function () {
var $this = this.element var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)') var $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target') var selector = $this.attr('data-target')
, previous
, $target
, e
if (!selector) { if (!selector) {
selector = $this.attr('href') selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
} }
if ( $this.parent('li').hasClass('active') ) return if ($this.parent('li').hasClass('active')) return
previous = $ul.find('.active:last a')[0] var previous = $ul.find('.active:last a')[0]
var e = $.Event('bs:tab:show', {
e = $.Event('show', {
relatedTarget: previous relatedTarget: previous
}) })
...@@ -59,20 +48,20 @@ ...@@ -59,20 +48,20 @@
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
$target = $(selector) var $target = $(selector)
this.activate($this.parent('li'), $ul) this.activate($this.parent('li'), $ul)
this.activate($target, $target.parent(), function () { this.activate($target, $target.parent(), function () {
$this.trigger({ $this.trigger({
type: 'shown' type: 'bs:tab:shown'
, relatedTarget: previous , relatedTarget: previous
}) })
}) })
} }
, activate: function ( element, container, callback) { Tab.prototype.activate = function (element, container, callback) {
var $active = container.find('> .active') var $active = container.find('> .active')
, transition = callback var transition = callback
&& $.support.transition && $.support.transition
&& $active.hasClass('fade') && $active.hasClass('fade')
...@@ -91,7 +80,7 @@ ...@@ -91,7 +80,7 @@
element.removeClass('fade') element.removeClass('fade')
} }
if ( element.parent('.dropdown-menu') ) { if (element.parent('.dropdown-menu')) {
element.closest('li.dropdown').addClass('active') element.closest('li.dropdown').addClass('active')
} }
...@@ -104,19 +93,19 @@ ...@@ -104,19 +93,19 @@
$active.removeClass('in') $active.removeClass('in')
} }
}
/* TAB PLUGIN DEFINITION // TAB PLUGIN DEFINITION
* ===================== */ // =====================
var old = $.fn.tab var old = $.fn.tab
$.fn.tab = function ( option ) { $.fn.tab = function ( option ) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('tab') var data = $this.data('bs-tab')
if (!data) $this.data('tab', (data = new Tab(this)))
if (!data) $this.data('bs-tab', (data = new Tab(this)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
...@@ -124,8 +113,8 @@ ...@@ -124,8 +113,8 @@
$.fn.tab.Constructor = Tab $.fn.tab.Constructor = Tab
/* TAB NO CONFLICT // TAB NO CONFLICT
* =============== */ // ===============
$.fn.tab.noConflict = function () { $.fn.tab.noConflict = function () {
$.fn.tab = old $.fn.tab = old
...@@ -133,8 +122,8 @@ ...@@ -133,8 +122,8 @@
} }
/* TAB DATA-API // TAB DATA-API
* ============ */ // ============
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { $(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault() e.preventDefault()
......
This diff is collapsed.
...@@ -18,33 +18,30 @@ ...@@ -18,33 +18,30 @@
* ========================================================== */ * ========================================================== */
!function ($) { !function ($) { "use strict";
"use strict"; // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
// ============================================================
/* CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
* ======================================================= */
function transitionEnd() { function transitionEnd() {
var el = document.createElement('bootstrap'); var el = document.createElement('bootstrap')
var transEndEventNames = { var transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd' 'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend' , 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd otransitionend' , 'OTransition' : 'oTransitionEnd otransitionend'
, 'transition' : 'transitionend' , 'transition' : 'transitionend'
}; }
for (var name in transEndEventNames) { for (var name in transEndEventNames) {
if (el.style[name] !== undefined) { if (el.style[name] !== undefined) {
return { end: transEndEventNames[name] }; return { end: transEndEventNames[name] }
} }
} }
} }
$(function () { $(function () {
$.support.transition = transitionEnd(); $.support.transition = transitionEnd()
}); })
}(window.jQuery); }(window.jQuery);
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
} }
this.$element[dimension](0) this.$element[dimension](0)
this.transition('addClass', $.Event('bs:collapse:show'), 'shown') this.transition('addClass', $.Event('bs:collapse:show'), 'bs:collapse:shown')
if ($.support.transition) this.$element[dimension](this.$element[0][scroll]) if ($.support.transition) this.$element[dimension](this.$element[0][scroll])
} }
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
Collapse.prototype.transition = function (method, startEvent, completeEvent) { Collapse.prototype.transition = function (method, startEvent, completeEvent) {
var that = this var that = this
var complete = function () { var complete = function () {
if (startEvent.type == 'show') that.reset() if (startEvent.type == 'bs:collapse:show') that.reset()
that.transitioning = 0 that.transitioning = 0
that.$element.trigger(completeEvent) that.$element.trigger(completeEvent)
} }
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
}) })
} }
Modal.prototype.show = function (e) { Modal.prototype.hide = function (e) {
if (e) e.preventDefault() if (e) e.preventDefault()
e = $.Event('bs:modal:hide') e = $.Event('bs:modal:hide')
...@@ -144,12 +144,12 @@ ...@@ -144,12 +144,12 @@
}) })
} }
Modal.prototype.removeBackdrop: function () { Modal.prototype.removeBackdrop = function () {
this.$backdrop && this.$backdrop.remove() this.$backdrop && this.$backdrop.remove()
this.$backdrop = null this.$backdrop = null
} }
Modal.prototype.backdrop: function (callback) { Modal.prototype.backdrop = function (callback) {
var that = this var that = this
var animate = this.$element.hasClass('fade') ? 'fade' : '' var animate = this.$element.hasClass('fade') ? 'fade' : ''
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
Popover.prototype.getContent = function () { Popover.prototype.getContent = function () {
var content = typeof this.options.content == 'function' ? var content = typeof this.options.content == 'function' ?
this.options.content.call($e[0]) : this.options.content.call(this.$element[0]) :
this.options.content this.options.content
return content || this.$element.attr('data-content') return content || this.$element.attr('data-content')
......
...@@ -48,12 +48,12 @@ $(function () { ...@@ -48,12 +48,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop(); stop();
$('<div class="alert"/>') $('<div class="alert"/>')
.bind('bs-close', function (e) { .bind('bs:alert:close', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('bs-closed', function () { .bind('bs:alert:closed', function () {
ok(false); ok(false);
}) })
.alert('close') .alert('close')
......
...@@ -20,12 +20,12 @@ $(function () { ...@@ -20,12 +20,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$('<div class="carousel"/>') $('<div class="carousel"/>')
.bind('slide', function (e) { .bind('bs:carousel:slide', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('slid', function () { .bind('bs:carousel:slid', function () {
ok(false); ok(false);
}) })
.carousel('next') .carousel('next')
...@@ -35,7 +35,7 @@ $(function () { ...@@ -35,7 +35,7 @@ $(function () {
var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div></div><a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a><a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a></div>' var template = '<div id="myCarousel" class="carousel slide"><div class="carousel-inner"><div class="item active"><img alt=""><div class="carousel-caption"><h4>{{_i}}First Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Second Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div><div class="item"><img alt=""><div class="carousel-caption"><h4>{{_i}}Third Thumbnail label{{/i}}</h4><p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p></div></div></div><a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a><a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a></div>'
$.support.transition = false $.support.transition = false
stop() stop()
$(template).on('slide', function (e) { $(template).on('bs:carousel:slide', function (e) {
e.preventDefault() e.preventDefault()
ok(e.direction) ok(e.direction)
ok(e.direction === 'right' || e.direction === 'left') ok(e.direction === 'right' || e.direction === 'left')
...@@ -48,7 +48,7 @@ $(function () { ...@@ -48,7 +48,7 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$(template) $(template)
.on('slide', function (e) { .on('bs:carousel:slide', function (e) {
e.preventDefault(); e.preventDefault();
ok(e.relatedTarget); ok(e.relatedTarget);
ok($(e.relatedTarget).hasClass('item')); ok($(e.relatedTarget).hasClass('item'));
...@@ -63,19 +63,19 @@ $(function () { ...@@ -63,19 +63,19 @@ $(function () {
template.appendTo("body"); template.appendTo("body");
$('[data-slide]').first().click(); $('[data-slide]').first().click();
ok($('#myCarousel').data('carousel').options.interval == 1814); ok($('#myCarousel').data('bs-carousel').options.interval == 1814);
$('#myCarousel').remove(); $('#myCarousel').remove();
template.appendTo("body").attr("data-modal", "foobar"); template.appendTo("body").attr("data-modal", "foobar");
$('[data-slide]').first().click(); $('[data-slide]').first().click();
ok($('#myCarousel').data('carousel').options.interval == 1814, "even if there is an data-modal attribute set"); ok($('#myCarousel').data('bs-carousel').options.interval == 1814, "even if there is an data-modal attribute set");
$('#myCarousel').remove(); $('#myCarousel').remove();
template.appendTo("body"); template.appendTo("body");
$('[data-slide]').first().click(); $('[data-slide]').first().click();
$('#myCarousel').attr('data-interval', 1860); $('#myCarousel').attr('data-interval', 1860);
$('[data-slide]').first().click(); $('[data-slide]').first().click();
ok($('#myCarousel').data('carousel').options.interval == 1814, "attributes should be read only on intitialization"); ok($('#myCarousel').data('bs-carousel').options.interval == 1814, "attributes should be read only on intitialization");
$('#myCarousel').remove(); $('#myCarousel').remove();
}) })
}) })
...@@ -32,12 +32,12 @@ $(function () { ...@@ -32,12 +32,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$('<div class="collapse"/>') $('<div class="collapse"/>')
.bind('show', function (e) { .bind('bs:collapse:show', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('shown', function () { .bind('bs:collapse:shown', function () {
ok(false); ok(false);
}) })
.collapse('show') .collapse('show')
...@@ -47,10 +47,10 @@ $(function () { ...@@ -47,10 +47,10 @@ $(function () {
$.support.transition = false $.support.transition = false
stop() stop()
$('<div class="collapse" style="height: 0px"/>') $('<div class="collapse" style="height: 0px"/>')
.bind('show', function () { .bind('bs:collapse:show', function () {
ok(this.style.height == '0px') ok(this.style.height == '0px')
}) })
.bind('shown', function () { .bind('bs:collapse:shown', function () {
ok(this.style.height == 'auto') ok(this.style.height == 'auto')
start() start()
}) })
...@@ -66,7 +66,7 @@ $(function () { ...@@ -66,7 +66,7 @@ $(function () {
var collapsible = $('<div id="test1"></div>') var collapsible = $('<div id="test1"></div>')
.appendTo($('#qunit-fixture')) .appendTo($('#qunit-fixture'))
.on('show', function () { .on('bs:collapse:show', function () {
ok(!target.hasClass('collapsed')) ok(!target.hasClass('collapsed'))
start() start()
}) })
...@@ -83,7 +83,7 @@ $(function () { ...@@ -83,7 +83,7 @@ $(function () {
var collapsible = $('<div id="test1" class="in"></div>') var collapsible = $('<div id="test1" class="in"></div>')
.appendTo($('#qunit-fixture')) .appendTo($('#qunit-fixture'))
.on('hide', function () { .on('bs:collapse:hide', function () {
ok(target.hasClass('collapsed')) ok(target.hasClass('collapsed'))
start() start()
}) })
......
...@@ -20,14 +20,14 @@ $(function () { ...@@ -20,14 +20,14 @@ $(function () {
}) })
test("should expose defaults var for settings", function () { test("should expose defaults var for settings", function () {
ok($.fn.modal.defaults, 'default object exposed') ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed')
}) })
test("should insert into dom when show method is called", function () { test("should insert into dom when show method is called", function () {
stop() stop()
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("shown", function () { .bind("bs:modal:shown", function () {
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
$(this).remove() $(this).remove()
start() start()
...@@ -39,10 +39,10 @@ $(function () { ...@@ -39,10 +39,10 @@ $(function () {
stop() stop()
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("show", function () { .bind("bs:modal:show", function () {
ok(true, "show was called") ok(true, "show was called")
}) })
.bind("shown", function () { .bind("bs:modal:shown", function () {
$(this).remove() $(this).remove()
start() start()
}) })
...@@ -53,12 +53,12 @@ $(function () { ...@@ -53,12 +53,12 @@ $(function () {
stop() stop()
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("show", function (e) { .bind("bs:modal:show", function (e) {
e.preventDefault() e.preventDefault()
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
.bind("shown", function () { .bind("bs:modal:shown", function () {
ok(false, "shown was called") ok(false, "shown was called")
}) })
.modal("show") .modal("show")
...@@ -69,12 +69,12 @@ $(function () { ...@@ -69,12 +69,12 @@ $(function () {
$.support.transition = false $.support.transition = false
$("<div id='modal-test'></div>") $("<div id='modal-test'></div>")
.bind("shown", function () { .bind("bs:modal:shown", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
$(this).modal("hide") $(this).modal("hide")
}) })
.bind("hidden", function() { .bind("bs:modal:hidden", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
$('#modal-test').remove() $('#modal-test').remove()
start() start()
...@@ -87,12 +87,12 @@ $(function () { ...@@ -87,12 +87,12 @@ $(function () {
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'></div>") var div = $("<div id='modal-test'></div>")
div div
.bind("shown", function () { .bind("bs:modal:shown", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.modal("toggle") div.modal("toggle")
}) })
.bind("hidden", function() { .bind("bs:modal:hidden", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove() div.remove()
start() start()
...@@ -105,12 +105,12 @@ $(function () { ...@@ -105,12 +105,12 @@ $(function () {
$.support.transition = false $.support.transition = false
var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>") var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>")
div div
.bind("shown", function () { .bind("bs:modal:shown", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
ok($('#modal-test').length, 'modal insterted into dom') ok($('#modal-test').length, 'modal insterted into dom')
div.find('.close').click() div.find('.close').click()
}) })
.bind("hidden", function() { .bind("bs:modal:hidden", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove() div.remove()
start() start()
...@@ -123,11 +123,11 @@ $(function () { ...@@ -123,11 +123,11 @@ $(function () {
$.support.transition = false $.support.transition = false
var div = $("<div>", { id: 'modal-test', "data-backdrop": false }) var div = $("<div>", { id: 'modal-test', "data-backdrop": false })
div div
.bind("shown", function () { .bind("bs:modal:shown", function () {
ok($('#modal-test').is(":visible"), 'modal visible') ok($('#modal-test').is(":visible"), 'modal visible')
div.modal("hide") div.modal("hide")
}) })
.bind("hidden", function() { .bind("bs:modal:hidden", function() {
ok(!$('#modal-test').is(":visible"), 'modal hidden') ok(!$('#modal-test').is(":visible"), 'modal hidden')
div.remove() div.remove()
start() start()
......
...@@ -34,7 +34,7 @@ $(function () { ...@@ -34,7 +34,7 @@ $(function () {
var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>') var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
.popover() .popover()
ok(!!popover.data('popover'), 'popover instance exists') ok(!!popover.data('bs-popover'), 'popover instance exists')
}) })
test("should get title and content from options", function () { test("should get title and content from options", function () {
...@@ -99,7 +99,7 @@ $(function () { ...@@ -99,7 +99,7 @@ $(function () {
test("should destroy popover", function () { test("should destroy popover", function () {
var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){}) var popover = $('<div/>').popover({trigger: 'hover'}).on('click.foo', function(){})
ok(popover.data('popover'), 'popover has data') ok(popover.data('bs-popover'), 'popover has data')
ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event') ok($._data(popover[0], 'events').mouseover && $._data(popover[0], 'events').mouseout, 'popover has hover event')
ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event') ok($._data(popover[0], 'events').click[0].namespace == 'foo', 'popover has extra click.foo event')
popover.popover('show') popover.popover('show')
......
...@@ -53,12 +53,12 @@ $(function () { ...@@ -53,12 +53,12 @@ $(function () {
$.support.transition = false $.support.transition = false
stop(); stop();
$('<div class="tab"/>') $('<div class="tab"/>')
.bind('show', function (e) { .bind('bs:tab:show', function (e) {
e.preventDefault(); e.preventDefault();
ok(true); ok(true);
start(); start();
}) })
.bind('shown', function () { .bind('bs:tab:shown', function () {
ok(false); ok(false);
}) })
.tab('show') .tab('show')
...@@ -78,7 +78,7 @@ $(function () { ...@@ -78,7 +78,7 @@ $(function () {
$(dropHTML).find('ul>li:first a').tab('show').end() $(dropHTML).find('ul>li:first a').tab('show').end()
.find('ul>li:last a').on('show', function(event){ .find('ul>li:last a').on('show', function(event){
equals(event.relatedTarget.hash, "#1-1") equals(event.relatedTarget.hash, "#1-1")
}).on('shown', function(event){ }).on('bs:tab:shown', function(event){
equals(event.relatedTarget.hash, "#1-1") equals(event.relatedTarget.hash, "#1-1")
}).tab('show') }).tab('show')
}) })
......
...@@ -19,7 +19,7 @@ $(function () { ...@@ -19,7 +19,7 @@ $(function () {
}) })
test("should expose default settings", function () { test("should expose default settings", function () {
ok(!!$.fn.tooltip.defaults, 'defaults is defined') ok(!!$.fn.tooltip.Constructor.DEFAULTS, 'defaults is defined')
}) })
test("should empty title attribute", function () { test("should empty title attribute", function () {
...@@ -69,7 +69,7 @@ $(function () { ...@@ -69,7 +69,7 @@ $(function () {
test("should fire show event", function () { test("should fire show event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("show", function() { .bind("bs:tooltip:show", function() {
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
...@@ -79,7 +79,7 @@ $(function () { ...@@ -79,7 +79,7 @@ $(function () {
test("should fire shown event", function () { test("should fire shown event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
ok(true, "shown was called") ok(true, "shown was called")
start() start()
}) })
...@@ -89,12 +89,12 @@ $(function () { ...@@ -89,12 +89,12 @@ $(function () {
test("should not fire shown event when default prevented", function () { test("should not fire shown event when default prevented", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("show", function(e) { .bind("bs:tooltip:show", function(e) {
e.preventDefault() e.preventDefault()
ok(true, "show was called") ok(true, "show was called")
start() start()
}) })
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
ok(false, "shown was called") ok(false, "shown was called")
}) })
.tooltip('show') .tooltip('show')
...@@ -103,10 +103,10 @@ $(function () { ...@@ -103,10 +103,10 @@ $(function () {
test("should fire hide event", function () { test("should fire hide event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("hide", function() { .bind("bs:tooltip:hide", function() {
ok(true, "hide was called") ok(true, "hide was called")
start() start()
}) })
...@@ -116,10 +116,10 @@ $(function () { ...@@ -116,10 +116,10 @@ $(function () {
test("should fire hidden event", function () { test("should fire hidden event", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("hidden", function() { .bind("bs:tooltip:hidden", function() {
ok(true, "hidden was called") ok(true, "hidden was called")
start() start()
}) })
...@@ -129,15 +129,15 @@ $(function () { ...@@ -129,15 +129,15 @@ $(function () {
test("should not fire hidden event when default prevented", function () { test("should not fire hidden event when default prevented", function () {
stop() stop()
var tooltip = $('<div title="tooltip title"></div>') var tooltip = $('<div title="tooltip title"></div>')
.bind("shown", function() { .bind("bs:tooltip:shown", function() {
$(this).tooltip('hide') $(this).tooltip('hide')
}) })
.bind("hide", function(e) { .bind("bs:tooltip:hide", function(e) {
e.preventDefault() e.preventDefault()
ok(true, "hide was called") ok(true, "hide was called")
start() start()
}) })
.bind("hidden", function() { .bind("bs:tooltip:hidden", function() {
ok(false, "hidden was called") ok(false, "hidden was called")
}) })
.tooltip('show') .tooltip('show')
...@@ -214,13 +214,13 @@ $(function () { ...@@ -214,13 +214,13 @@ $(function () {
test("should destroy tooltip", function () { test("should destroy tooltip", function () {
var tooltip = $('<div/>').tooltip().on('click.foo', function(){}) var tooltip = $('<div/>').tooltip().on('click.foo', function(){})
ok(tooltip.data('tooltip'), 'tooltip has data') ok(tooltip.data('bs-tooltip'), 'tooltip has data')
ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event') ok($._data(tooltip[0], 'events').mouseover && $._data(tooltip[0], 'events').mouseout, 'tooltip has hover event')
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event') ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip has extra click.foo event')
tooltip.tooltip('show') tooltip.tooltip('show')
tooltip.tooltip('destroy') tooltip.tooltip('destroy')
ok(!tooltip.hasClass('in'), 'tooltip is hidden') ok(!tooltip.hasClass('in'), 'tooltip is hidden')
ok(!$._data(tooltip[0], 'tooltip'), 'tooltip does not have data') ok(!$._data(tooltip[0], 'bs-tooltip'), 'tooltip does not have data')
ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo') ok($._data(tooltip[0], 'events').click[0].namespace == 'foo', 'tooltip still has click.foo')
ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events') ok(!$._data(tooltip[0], 'events').mouseover && !$._data(tooltip[0], 'events').mouseout, 'tooltip does not have any events')
}) })
......
...@@ -48,10 +48,10 @@ ...@@ -48,10 +48,10 @@
} }
Tooltip.prototype.init = function (type, element, options) { Tooltip.prototype.init = function (type, element, options) {
this.type = type
this.options = this.getOptions(options)
this.enabled = true this.enabled = true
this.type = type
this.$element = $(element) this.$element = $(element)
this.options = this.getOptions(options)
var triggers = this.options.trigger.split(' ') var triggers = this.options.trigger.split(' ')
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
if (defaults[key] != value) options[key] = value if (defaults[key] != value) options[key] = value
}, this) }, this)
var self = $(e.currentTarget)[this.type](options).data(this.type) var self = $(e.currentTarget)[this.type](options).data('bs-' + this.type)
if (!self.options.delay || !self.options.delay.show) return self.show() if (!self.options.delay || !self.options.delay.show) return self.show()
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
} }
Tooltip.prototype.leave = function (e) { Tooltip.prototype.leave = function (e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type) var self = $(e.currentTarget)[this.type](this._options).data('bs-' + this.type)
if (this.timeout) clearTimeout(this.timeout) if (this.timeout) clearTimeout(this.timeout)
if (!self.options.delay || !self.options.delay.hide) return self.hide() if (!self.options.delay || !self.options.delay.hide) return self.hide()
...@@ -168,10 +168,12 @@ ...@@ -168,10 +168,12 @@
} }
this.applyPlacement(tp, placement) this.applyPlacement(tp, placement)
this.$element.trigger('shown') this.$element.trigger('bs:' + this.type + ':shown')
}
} }
Tooltip.prototype.applyPlacement = function(offset, placement) { Tooltip.prototype.applyPlacement = function(offset, placement) {
var replace
var $tip = this.tip() var $tip = this.tip()
var width = $tip[0].offsetWidth var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight var height = $tip[0].offsetHeight
...@@ -185,7 +187,7 @@ ...@@ -185,7 +187,7 @@
var actualHeight = $tip[0].offsetHeight var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) { if (placement == 'top' && actualHeight != height) {
var replace = true replace = true
offset.top = offset.top + height - actualHeight offset.top = offset.top + height - actualHeight
} }
...@@ -210,7 +212,7 @@ ...@@ -210,7 +212,7 @@
if (replace) $tip.offset(offset) if (replace) $tip.offset(offset)
} }
Tooltip.prototype.replaceArrow = function(delta, dimension, position){ Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
} }
...@@ -248,7 +250,7 @@ ...@@ -248,7 +250,7 @@
removeWithAnimation() : removeWithAnimation() :
$tip.detach() $tip.detach()
this.$element.trigger('hidden') this.$element.trigger('bs:' + this.type + ':hidden')
return this return this
} }
...@@ -312,12 +314,12 @@ ...@@ -312,12 +314,12 @@
} }
Tooltip.prototype.toggle = function (e) { Tooltip.prototype.toggle = function (e) {
var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this var self = e ? $(e.currentTarget)[this.type](this._options).data('bs-' + this.type) : this
self.tip().hasClass('in') ? self.hide() : self.show() self.tip().hasClass('in') ? self.hide() : self.show()
} }
Tooltip.prototype.destroy = function () { Tooltip.prototype.destroy = function () {
this.hide().$element.off('.' + this.type).removeData(this.type) this.hide().$element.off('.' + this.type).removeData('bs-' + this.type)
} }
...@@ -326,7 +328,7 @@ ...@@ -326,7 +328,7 @@
var old = $.fn.tooltip var old = $.fn.tooltip
$.fn.tooltip = function ( option ) { $.fn.tooltip = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs-tooltip') var data = $this.data('bs-tooltip')
......
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