Commit 149ecd21 authored by fat's avatar fat
Browse files

straight trash wang

parent 53bc9328
Showing with 604 additions and 648 deletions
+604 -648
...@@ -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)
......
...@@ -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,207 +18,198 @@ ...@@ -18,207 +18,198 @@
* ========================================================= */ * ========================================================= */
!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)
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 () { this.backdrop(function () {
var transition = $.support.transition && that.$element.hasClass('fade') var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) { if (!that.$element.parent().length) {
that.$element.appendTo(document.body) //don't move modals dom position that.$element.appendTo(document.body) //don't move modals dom position
} }
that.$element.show() that.$element.show()
if (transition) { if (transition) {
that.$element[0].offsetWidth // force reflow that.$element[0].offsetWidth // force reflow
} }
that.$element that.$element
.addClass('in') .addClass('in')
.attr('aria-hidden', false) .attr('aria-hidden', false)
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) 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 $.support.transition && this.$element.hasClass('fade') ?
.removeClass('in') this.hideWithTransition() :
.attr('aria-hidden', true) this.hideModal()
}
$.support.transition && this.$element.hasClass('fade') ? Modal.prototype.enforceFocus = function () {
this.hideWithTransition() : $(document).on('focusin.modal', function (e) {
this.hideModal() if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
this.$element.focus()
} }
}, this)
}
, enforceFocus: function () { Modal.prototype.escape = function () {
var that = this if (this.isShown && this.options.keyboard) {
$(document).on('focusin.modal', function (e) { this.$element.on('keyup.dismiss.modal', function ( e ) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { e.which == 27 && this.hide()
that.$element.focus() }, this)
} } else if (!this.isShown) {
}) this.$element.off('keyup.dismiss.modal')
} }
}
, escape: function () { Modal.prototype.hideWithTransition = function () {
var that = this var that = this
if (this.isShown && this.options.keyboard) { var timeout = setTimeout(function () {
this.$element.on('keyup.dismiss.modal', function ( e ) { that.$element.off($.support.transition.end)
e.which == 27 && that.hide() that.hideModal()
}) }, 500)
} else if (!this.isShown) {
this.$element.off('keyup.dismiss.modal')
}
}
, hideWithTransition: function () { this.$element.one($.support.transition.end, function () {
var that = this clearTimeout(timeout)
, timeout = setTimeout(function () { that.hideModal()
that.$element.off($.support.transition.end) })
that.hideModal() }
}, 500)
this.$element.one($.support.transition.end, function () {
clearTimeout(timeout)
that.hideModal()
})
}
, 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
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body) .appendTo(document.body)
this.$backdrop.click( this.$backdrop.click(
this.options.backdrop == 'static' ? this.options.backdrop == 'static' ?
$.proxy(this.$element[0].focus, this.$element[0]) $.proxy(this.$element[0].focus, this.$element[0])
: $.proxy(this.hide, this) : $.proxy(this.hide, this)
) )
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in') this.$backdrop.addClass('in')
if (!callback) return if (!callback) return
doAnimate ? doAnimate ?
this.$backdrop.one($.support.transition.end, callback) : this.$backdrop.one($.support.transition.end, callback) :
callback() callback()
} else if (!this.isShown && this.$backdrop) { } else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in') this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')? $.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, callback) : this.$backdrop.one($.support.transition.end, callback) :
callback() callback()
} else if (callback) { } else if (callback) {
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,93 +18,88 @@ ...@@ -18,93 +18,88 @@
* =========================================================== */ * =========================================================== */
!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
========================================== */
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, { // NOTE: POPOVER EXTENDS tooltip.js
// ================================
constructor: Popover Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
, setContent: function () { Popover.prototype.constructor = Popover
var $tip = this.tip()
, title = this.getTitle()
, content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) Popover.prototype.getDefaults = function () {
$tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content) return Popover.DEFAULTS
}
$tip.removeClass('fade top bottom left right in') Popover.prototype.setContent = function () {
} var $tip = this.tip()
var title = this.getTitle()
var content = this.getContent()
, hasContent: function () { $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
return this.getTitle() || this.getContent() $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
}
, getContent: function () { $tip.removeClass('fade top bottom left right in')
var content }
, $e = this.$element
, o = this.options
content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content) Popover.prototype.hasContent = function () {
|| $e.attr('data-content') return this.getTitle() || this.getContent()
}
return content Popover.prototype.getContent = function () {
} var content = typeof this.options.content == 'function' ?
this.options.content.call($e[0]) :
this.options.content
, tip: function () { return content || this.$element.attr('data-content')
if (!this.$tip) { }
this.$tip = $(this.options.template)
}
return this.$tip
}
, destroy: function () { Popover.prototype.tip = function () {
this.hide().$element.off('.' + this.type).removeData(this.type) if (!this.$tip) this.$tip = $(this.options.template)
} return this.$tip
}
}) Popover.prototype.destroy = function () {
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,130 +18,124 @@ ...@@ -18,130 +18,124 @@
* ============================================================== */ * ============================================================== */
!function ($) { !function ($) { "use strict";
"use strict"; // jshint ;_; // SCROLLSPY CLASS DEFINITION
// ==========================
/* SCROLLSPY CLASS DEFINITION
* ========================== */
function ScrollSpy(element, options) { function ScrollSpy(element, options) {
var process = $.proxy(this.process, this) var href
, $element = $(element).is('body') ? $(window) : $(element) var process = $.proxy(this.process, this)
, href var $element = $(element).is('body') ? $(window) : $(element)
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.selector = (this.options.target this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
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 () { ScrollSpy.prototype.refresh = function () {
var self = this this.offsets = $([])
, $targets this.targets = $([])
this.offsets = $([]) var self = this
this.targets = $([]) var $targets = this.$body
.find(this.selector)
$targets = this.$body .map(function () {
.find(this.selector) var $el = $(this)
.map(function () { var href = $el.data('target') || $el.attr('href')
var $el = $(this) var $href = /^#\w/.test(href) && $(href)
, href = $el.data('target') || $el.attr('href')
, $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 () { self.offsets.push(this[0])
self.offsets.push(this[0]) self.targets.push(this[1])
self.targets.push(this[1]) })
}) }
}
, process: function () {
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
, scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
, maxScroll = scrollHeight - this.$scrollElement.height()
, offsets = this.offsets
, targets = this.targets
, activeTarget = this.activeTarget
, i
if (scrollTop >= maxScroll) {
return activeTarget != (i = targets.last()[0])
&& this.activate ( i )
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
&& this.activate( targets[i] )
}
}
, activate: function (target) {
var active
, selector
this.activeTarget = target
$(this.selector)
.parents('.active')
.removeClass('active')
selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]'
active = $(selector)
.parents('li')
.addClass('active')
if (active.parent('.dropdown-menu').length) {
active = active.closest('li.dropdown').addClass('active')
}
active.trigger('activate')
}
ScrollSpy.prototype.process = function () {
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
var maxScroll = scrollHeight - this.$scrollElement.height()
var offsets = this.offsets
var targets = this.targets
var activeTarget = this.activeTarget
var i
if (scrollTop >= maxScroll) {
return activeTarget != (i = targets.last()[0]) && this.activate(i)
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
&& this.activate( targets[i] )
}
} }
ScrollSpy.prototype.activate = function (target) {
this.activeTarget = target
$(this.selector)
.parents('.active')
.removeClass('active')
var selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]'
/* SCROLLSPY PLUGIN DEFINITION var active = $(selector)
* =========================== */ .parents('li')
.addClass('active')
if (active.parent('.dropdown-menu').length) {
active = active
.closest('li.dropdown')
.addClass('active')
}
active.trigger('activate')
}
// 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,105 +18,94 @@ ...@@ -18,105 +18,94 @@
* ======================================================== */ * ======================================================== */
!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 () {
var $this = this.element
constructor: Tab var $ul = $this.closest('ul:not(.dropdown-menu)')
var selector = $this.attr('data-target')
, show: function () {
var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target')
, previous
, $target
, e
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
if ( $this.parent('li').hasClass('active') ) return if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
previous = $ul.find('.active:last a')[0] if ($this.parent('li').hasClass('active')) return
e = $.Event('show', { var previous = $ul.find('.active:last a')[0]
relatedTarget: previous var e = $.Event('bs:tab:show', {
}) relatedTarget: previous
})
$this.trigger(e) $this.trigger(e)
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) {
var $active = container.find('> .active')
, transition = callback
&& $.support.transition
&& $active.hasClass('fade')
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
element.addClass('active')
if (transition) {
element[0].offsetWidth // reflow for transition
element.addClass('in')
} else {
element.removeClass('fade')
}
if ( element.parent('.dropdown-menu') ) {
element.closest('li.dropdown').addClass('active')
}
callback && callback() Tab.prototype.activate = function (element, container, callback) {
var $active = container.find('> .active')
var transition = callback
&& $.support.transition
&& $active.hasClass('fade')
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
element.addClass('active')
if (transition) {
element[0].offsetWidth // reflow for transition
element.addClass('in')
} else {
element.removeClass('fade')
} }
transition ? if (element.parent('.dropdown-menu')) {
$active.one($.support.transition.end, next) : element.closest('li.dropdown').addClass('active')
next() }
$active.removeClass('in') callback && callback()
} }
transition ?
$active.one($.support.transition.end, next) :
next()
$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()
......
...@@ -19,317 +19,319 @@ ...@@ -19,317 +19,319 @@
* ========================================================== */ * ========================================================== */
!function ($) { !function ($) { "use strict";
"use strict"; // jshint ;_; // TOOLTIP PUBLIC CLASS DEFINITION
// ===============================
/* TOOLTIP PUBLIC CLASS DEFINITION
* =============================== */
var Tooltip = function (element, options) { var Tooltip = function (element, options) {
this.type =
this.options =
this.enabled =
this.timeout =
this.hoverState =
this.$element = null
this.init('tooltip', element, options) this.init('tooltip', element, options)
} }
Tooltip.prototype = { Tooltip.DEFAULTS = {
animation: true
constructor: Tooltip , placement: 'top'
, selector: false
, init: function (type, element, options) { , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
var eventIn , trigger: 'hover focus'
, eventOut , title: ''
, triggers , delay: 0
, trigger , html: false
, i , container: false
}
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.enabled = true
triggers = this.options.trigger.split(' ')
for (i = triggers.length; i--;) {
trigger = triggers[i]
if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') {
eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
}
this.options.selector ? Tooltip.prototype.init = function (type, element, options) {
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : this.type = type
this.fixTitle() this.options = this.getOptions(options)
} this.enabled = true
this.$element = $(element)
, getOptions: function (options) { var triggers = this.options.trigger.split(' ')
options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') { for (var i = triggers.length; i--;) {
options.delay = { var trigger = triggers[i]
show: options.delay
, hide: options.delay if (trigger == 'click') {
} this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
} }
}
this.options.selector ?
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
}
Tooltip.prototype.getDefaults = function () {
return Tooltip.DEFAULTS
}
Tooltip.prototype.getOptions = function (options) {
options = $.extend({}, this.getDefaults(), this.$element.data(), options)
return options if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay
, hide: options.delay
}
} }
, enter: function (e) { return options
var defaults = $.fn[this.type].defaults }
, options = {}
, self
this._options && $.each(this._options, function (key, value) { Tooltip.prototype.enter = function (e) {
if (defaults[key] != value) options[key] = value var defaults = $.fn[this.type].defaults
}, this) var options = {}
self = $(e.currentTarget)[this.type](options).data(this.type) this._options && $.each(this._options, function (key, value) {
if (defaults[key] != value) options[key] = value
}, this)
if (!self.options.delay || !self.options.delay.show) return self.show() var self = $(e.currentTarget)[this.type](options).data(this.type)
clearTimeout(this.timeout) if (!self.options.delay || !self.options.delay.show) return self.show()
self.hoverState = 'in'
this.timeout = setTimeout(function() {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
}
, leave: function (e) { clearTimeout(this.timeout)
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (this.timeout) clearTimeout(this.timeout) self.hoverState = 'in'
if (!self.options.delay || !self.options.delay.hide) return self.hide() this.timeout = setTimeout(function() {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
}
self.hoverState = 'out' Tooltip.prototype.leave = function (e) {
this.timeout = setTimeout(function() { var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide) if (this.timeout) clearTimeout(this.timeout)
} if (!self.options.delay || !self.options.delay.hide) return self.hide()
, show: function () { self.hoverState = 'out'
var $tip this.timeout = setTimeout(function() {
, pos if (self.hoverState == 'out') self.hide()
, actualWidth }, self.options.delay.hide)
, actualHeight }
, placement
, tp
, e = $.Event('show')
if (this.hasContent() && this.enabled) { Tooltip.prototype.show = function () {
this.$element.trigger(e) var e = $.Event('bs:'+ this.type + ':show')
if (e.isDefaultPrevented()) return
$tip = this.tip()
this.setContent()
if (this.options.animation) { if (this.hasContent() && this.enabled) {
$tip.addClass('fade') this.$element.trigger(e)
}
placement = typeof this.options.placement == 'function' ? if (e.isDefaultPrevented()) return
this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement
$tip var $tip = this.tip()
.detach()
.css({ top: 0, left: 0, display: 'block' })
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) this.setContent()
pos = this.getPosition() if (this.options.animation) $tip.addClass('fade')
actualWidth = $tip[0].offsetWidth var placement = typeof this.options.placement == 'function' ?
actualHeight = $tip[0].offsetHeight this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement
switch (placement) { $tip
case 'bottom': .detach()
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2} .css({ top: 0, left: 0, display: 'block' })
break
case 'top': this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
break var tp
case 'left': var pos = this.getPosition()
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth} var actualWidth = $tip[0].offsetWidth
break var actualHeight = $tip[0].offsetHeight
case 'right':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width} switch (placement) {
break case 'bottom':
} tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
break
this.applyPlacement(tp, placement) case 'top':
this.$element.trigger('shown') tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
break
case 'left':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
break
case 'right':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
break
} }
this.applyPlacement(tp, placement)
this.$element.trigger('shown')
} }
, applyPlacement: function(offset, placement){ Tooltip.prototype.applyPlacement = function(offset, placement) {
var $tip = this.tip() var $tip = this.tip()
, width = $tip[0].offsetWidth var width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight var height = $tip[0].offsetHeight
, actualWidth
, actualHeight
, delta
, replace
$tip $tip
.offset(offset) .offset(offset)
.addClass(placement) .addClass(placement)
.addClass('in') .addClass('in')
actualWidth = $tip[0].offsetWidth var actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) { if (placement == 'top' && actualHeight != height) {
offset.top = offset.top + height - actualHeight var replace = true
replace = true offset.top = offset.top + height - actualHeight
} }
if (placement == 'bottom' || placement == 'top') {
var delta = 0
if (placement == 'bottom' || placement == 'top') { if (offset.left < 0){
delta = 0 delta = offset.left * -2
offset.left = 0
if (offset.left < 0){ $tip.offset(offset)
delta = offset.left * -2
offset.left = 0
$tip.offset(offset)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
}
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left') actualWidth = $tip[0].offsetWidth
} else { actualHeight = $tip[0].offsetHeight
this.replaceArrow(actualHeight - height, actualHeight, 'top')
} }
if (replace) $tip.offset(offset) this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
} else {
this.replaceArrow(actualHeight - height, actualHeight, 'top')
} }
, replaceArrow: function(delta, dimension, position){ if (replace) $tip.offset(offset)
this }
.arrow()
.css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}
, setContent: function () { Tooltip.prototype.replaceArrow = function(delta, dimension, position){
var $tip = this.tip() this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
, title = this.getTitle() }
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) Tooltip.prototype.setContent = function () {
$tip.removeClass('fade in top bottom left right') var $tip = this.tip()
} var title = this.getTitle()
, hide: function () { $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
var that = this $tip.removeClass('fade in top bottom left right')
, $tip = this.tip() }
, e = $.Event('hide')
this.$element.trigger(e) Tooltip.prototype.hide = function () {
if (e.isDefaultPrevented()) return var that = this
var $tip = this.tip()
var e = $.Event('hide')
$tip.removeClass('in') this.$element.trigger(e)
function removeWithAnimation() { if (e.isDefaultPrevented()) return
var timeout = setTimeout(function () {
$tip.off($.support.transition.end).detach()
}, 500)
$tip.one($.support.transition.end, function () { $tip.removeClass('in')
clearTimeout(timeout)
$tip.detach() function removeWithAnimation() {
}) var timeout = setTimeout(function () {
} $tip.off($.support.transition.end).detach()
}, 500)
$.support.transition && this.$tip.hasClass('fade') ? $tip.one($.support.transition.end, function () {
removeWithAnimation() : clearTimeout(timeout)
$tip.detach() $tip.detach()
})
}
this.$element.trigger('hidden') $.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() :
$tip.detach()
return this this.$element.trigger('hidden')
}
, fixTitle: function () { return this
var $e = this.$element }
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
}
}
, hasContent: function () { Tooltip.prototype.fixTitle = function () {
return this.getTitle() var $e = this.$element
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
} }
}
, getPosition: function () { Tooltip.prototype.hasContent = function () {
var el = this.$element[0] return this.getTitle()
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { }
width: el.offsetWidth
, height: el.offsetHeight
}, this.$element.offset())
}
, getTitle: function () { Tooltip.prototype.getPosition = function () {
var title var el = this.$element[0]
, $e = this.$element return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
, o = this.options width: el.offsetWidth
, height: el.offsetHeight
}, this.$element.offset())
}
title = $e.attr('data-original-title') Tooltip.prototype.getTitle = function () {
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) var title
var $e = this.$element
var o = this.options
return title title = $e.attr('data-original-title')
} || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
, tip: function () { return title
return this.$tip = this.$tip || $(this.options.template) }
}
, arrow: function(){ Tooltip.prototype.tip = function () {
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") return this.$tip = this.$tip || $(this.options.template)
} }
, validate: function () { Tooltip.prototype.arrow =function(){
if (!this.$element[0].parentNode) { return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
this.hide() }
this.$element = null
this.options = null
}
}
, enable: function () { Tooltip.prototype.validate = function () {
this.enabled = true if (!this.$element[0].parentNode) {
this.hide()
this.$element = null
this.options = null
} }
}
, disable: function () { Tooltip.prototype.enable = function () {
this.enabled = false this.enabled = true
} }
, toggleEnabled: function () { Tooltip.prototype.disable = function () {
this.enabled = !this.enabled this.enabled = false
} }
, toggle: function (e) { Tooltip.prototype.toggleEnabled = function () {
var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this this.enabled = !this.enabled
self.tip().hasClass('in') ? self.hide() : self.show() }
}
, destroy: function () { Tooltip.prototype.toggle = function (e) {
this.hide().$element.off('.' + this.type).removeData(this.type) var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
} self.tip().hasClass('in') ? self.hide() : self.show()
}
Tooltip.prototype.destroy = function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
} }
/* TOOLTIP PLUGIN DEFINITION // TOOLTIP PLUGIN DEFINITION
* ========================= */ // =========================
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)
, data = $this.data('tooltip') var data = $this.data('tooltip')
, options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('tooltip', (data = new Tooltip(this, options))) if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
...@@ -337,21 +339,9 @@ ...@@ -337,21 +339,9 @@
$.fn.tooltip.Constructor = Tooltip $.fn.tooltip.Constructor = Tooltip
$.fn.tooltip.defaults = {
animation: true
, placement: 'top'
, selector: false
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
, trigger: 'hover focus'
, title: ''
, delay: 0
, html: false
, container: false
}
/* TOOLTIP NO CONFLICT // TOOLTIP NO CONFLICT
* =================== */ // ===================
$.fn.tooltip.noConflict = function () { $.fn.tooltip.noConflict = function () {
$.fn.tooltip = old $.fn.tooltip = old
......
...@@ -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);
Supports Markdown
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