Commit 149ecd21 authored by fat's avatar fat

straight trash wang

parent 53bc9328
...@@ -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
// ========================= // =========================
......
This diff is collapsed.
...@@ -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()
......
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);
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