From 513b43109fb6b1fe4451544390f9199a61967a86 Mon Sep 17 00:00:00 2001
From: liuninge <749416752@qq.com>
Date: Wed, 20 May 2015 10:18:29 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmodal=20show=E7=9A=84?=
=?UTF-8?q?=E6=97=B6=E5=80=99=20=E9=87=8D=E5=A4=8D=E7=BB=91=E5=AE=9Ascroll?=
=?UTF-8?q?=20resize=E4=BA=8B=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/js/bootstrap.js | 524 +++++++++++++++++++++++---------------------
1 file changed, 274 insertions(+), 250 deletions(-)
diff --git a/src/js/bootstrap.js b/src/js/bootstrap.js
index 288aede..6b3c666 100755
--- a/src/js/bootstrap.js
+++ b/src/js/bootstrap.js
@@ -34,11 +34,11 @@
var el = document.createElement('bootstrap')
, transEndEventNames = {
- 'WebkitTransition' : 'webkitTransitionEnd'
+ 'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd otransitionend'
, 'transition' : 'transitionend'
- }
+ }
, name
for (name in transEndEventNames){
@@ -50,8 +50,8 @@
}())
return transitionEnd && {
- end: transitionEnd
- }
+ end: transitionEnd
+ }
})()
@@ -96,6 +96,8 @@
this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
+ // add by @liuning-geek
+ this.isPushSetPosQueue = false;
}
Modal.prototype = {
@@ -135,9 +137,12 @@
// add by @sofish
// set margin to adjust the window
this.setPos(that.$element);
- $(window).bind('scroll resize', function(){
- that.setPos(that.$element);
- });
+
+ // add by @liuning-geek
+ if (!that.isPushSetPosQueue) {
+ that.isPushSetPosQueue = true;
+ pushSetPosQueue(function() { that.setPos(that.$element); });
+ }
if(data) data['setPos'] = this.setPos;
@@ -192,10 +197,29 @@
}
+ /* MODAL PRIVATE PROPERTY
+ * ===================== */
+
+ // add by @liuning-geek
+ var setPosQueue = [];
+
/* MODAL PRIVATE METHODS
* ===================== */
+ // add by @liuning-geek
+ function pushSetPosQueue(func) {
+ // If this is the first time a push in the window binding events
+ if (setPosQueue.length === 0) {
+ $(window).bind('scroll resize', function(){
+ for (var i = 0, len = setPosQueue.length; i < len; i++)
+ setPosQueue[i]();
+ });
+ }
+
+ setPosQueue.push(func);
+ }
+
function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
@@ -343,22 +367,22 @@
"use strict"; // jshint ;_;
- /* DROPDOWN CLASS DEFINITION
- * ========================= */
+ /* DROPDOWN CLASS DEFINITION
+ * ========================= */
var toggle = '[data-toggle=dropdown]'
, Dropdown = function (element) {
- var $el = $(element).on('click.dropdown.data-api', this.toggle)
- $('html').on('click.dropdown.data-api', function () {
- $el.parent().removeClass('open')
- })
- }
+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
+ $('html').on('click.dropdown.data-api', function () {
+ $el.parent().removeClass('open')
+ })
+ }
Dropdown.prototype = {
constructor: Dropdown
- , toggle: function (e) {
+ , toggle: function (e) {
var $this = $(this)
, $parent
, isActive
@@ -380,7 +404,7 @@
return false
}
- , keydown: function (e) {
+ , keydown: function (e) {
var $this
, $items
, $active
@@ -463,8 +487,8 @@
$.fn.dropdown.Constructor = Dropdown
- /* DROPDOWN NO CONFLICT
- * ==================== */
+ /* DROPDOWN NO CONFLICT
+ * ==================== */
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
@@ -509,8 +533,8 @@
"use strict"; // jshint ;_;
- /* SCROLLSPY CLASS DEFINITION
- * ========================== */
+ /* SCROLLSPY CLASS DEFINITION
+ * ========================== */
function ScrollSpy(element, options) {
var process = $.proxy(this.process, this)
@@ -519,8 +543,8 @@
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
this.selector = (this.options.target
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
- || '') + ' .nav li > a'
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
+ || '') + ' .nav li > a'
this.$body = $('body')
this.refresh()
this.process()
@@ -528,84 +552,84 @@
ScrollSpy.prototype = {
- constructor: ScrollSpy
+ constructor: ScrollSpy
, refresh: function () {
- var self = this
- , $targets
-
- this.offsets = $([])
- this.targets = $([])
-
- $targets = this.$body
- .find(this.selector)
- .map(function () {
- var $el = $(this)
- , href = $el.data('target') || $el.attr('href')
- , $href = /^#\w/.test(href) && $(href)
- return ( $href
- && $href.length
- && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
- })
- .sort(function (a, b) { return a[0] - b[0] })
- .each(function () {
- self.offsets.push(this[0])
- self.targets.push(this[1])
- })
- }
+ var self = this
+ , $targets
+
+ this.offsets = $([])
+ this.targets = $([])
+
+ $targets = this.$body
+ .find(this.selector)
+ .map(function () {
+ var $el = $(this)
+ , href = $el.data('target') || $el.attr('href')
+ , $href = /^#\w/.test(href) && $(href)
+ return ( $href
+ && $href.length
+ && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
+ })
+ .sort(function (a, b) { return a[0] - b[0] })
+ .each(function () {
+ self.offsets.push(this[0])
+ 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 )
- }
+ 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
- for (i = offsets.length; i--;) {
- activeTarget != targets[i]
- && scrollTop >= offsets[i]
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
- && this.activate( targets[i] )
- }
+ if (scrollTop >= maxScroll) {
+ return activeTarget != (i = targets.last()[0])
+ && this.activate ( i )
}
- , activate: function (target) {
- var active
- , selector
+ for (i = offsets.length; i--;) {
+ activeTarget != targets[i]
+ && scrollTop >= offsets[i]
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
+ && this.activate( targets[i] )
+ }
+ }
- this.activeTarget = target
+ , activate: function (target) {
+ var active
+ , selector
- $(this.selector)
- .parent('.active')
- .removeClass('active')
+ this.activeTarget = target
- selector = this.selector
- + '[data-target="' + target + '"],'
- + this.selector + '[href="' + target + '"]'
+ $(this.selector)
+ .parent('.active')
+ .removeClass('active')
- active = $(selector)
- .parent('li')
- .addClass('active')
+ selector = this.selector
+ + '[data-target="' + target + '"],'
+ + this.selector + '[href="' + target + '"]'
- if (active.parent('.dropdown-menu').length) {
- active = active.closest('li.dropdown').addClass('active')
- }
+ active = $(selector)
+ .parent('li')
+ .addClass('active')
- active.trigger('activate')
+ if (active.parent('.dropdown-menu').length) {
+ active = active.closest('li.dropdown').addClass('active')
}
+ active.trigger('activate')
+ }
+
}
- /* SCROLLSPY PLUGIN DEFINITION
- * =========================== */
+ /* SCROLLSPY PLUGIN DEFINITION
+ * =========================== */
var old = $.fn.scrollspy
@@ -626,8 +650,8 @@
}
- /* SCROLLSPY NO CONFLICT
- * ===================== */
+ /* SCROLLSPY NO CONFLICT
+ * ===================== */
$.fn.scrollspy.noConflict = function () {
$.fn.scrollspy = old
@@ -635,8 +659,8 @@
}
- /* SCROLLSPY DATA-API
- * ================== */
+ /* SCROLLSPY DATA-API
+ * ================== */
$(window).on('load', function () {
$('[data-spy="scroll"]').each(function () {
@@ -671,8 +695,8 @@
"use strict"; // jshint ;_;
- /* TAB CLASS DEFINITION
- * ==================== */
+ /* TAB CLASS DEFINITION
+ * ==================== */
var Tab = function (element) {
this.element = $(element)
@@ -682,7 +706,7 @@
constructor: Tab
- , show: function () {
+ , show: function () {
var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target')
@@ -713,16 +737,16 @@
this.activate($target, $target.parent(), function () {
$this.trigger({
type: 'shown'
- , relatedTarget: previous
+ , relatedTarget: previous
})
})
}
- , activate: function ( element, container, callback) {
+ , activate: function ( element, container, callback) {
var $active = container.find('> .active')
, transition = callback
- && $.support.transition
- && $active.hasClass('fade')
+ && $.support.transition
+ && $active.hasClass('fade')
function next() {
$active
@@ -755,8 +779,8 @@
}
- /* TAB PLUGIN DEFINITION
- * ===================== */
+ /* TAB PLUGIN DEFINITION
+ * ===================== */
var old = $.fn.tab
@@ -772,8 +796,8 @@
$.fn.tab.Constructor = Tab
- /* TAB NO CONFLICT
- * =============== */
+ /* TAB NO CONFLICT
+ * =============== */
$.fn.tab.noConflict = function () {
$.fn.tab = old
@@ -781,8 +805,8 @@
}
- /* TAB DATA-API
- * ============ */
+ /* TAB DATA-API
+ * ============ */
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault()
@@ -816,8 +840,8 @@
"use strict"; // jshint ;_;
- /* TOOLTIP PUBLIC CLASS DEFINITION
- * =============================== */
+ /* TOOLTIP PUBLIC CLASS DEFINITION
+ * =============================== */
var Tooltip = function (element, options) {
this.init('tooltip', element, options)
@@ -827,7 +851,7 @@
constructor: Tooltip
- , init: function (type, element, options) {
+ , init: function (type, element, options) {
var eventIn
, eventOut
, triggers
@@ -858,20 +882,20 @@
this.fixTitle()
}
- , getOptions: function (options) {
+ , getOptions: function (options) {
options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay
- , hide: options.delay
+ , hide: options.delay
}
}
return options
}
- , enter: function (e) {
+ , enter: function (e) {
var defaults = $.fn[this.type].defaults
, options = {}
, self
@@ -891,7 +915,7 @@
}, self.options.delay.show)
}
- , leave: function (e) {
+ , leave: function (e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (this.timeout) clearTimeout(this.timeout)
@@ -903,7 +927,7 @@
}, self.options.delay.hide)
}
- , show: function () {
+ , show: function () {
var $tip
, pos
, actualWidth
@@ -957,7 +981,7 @@
}
}
- , applyPlacement: function(offset, placement){
+ , applyPlacement: function(offset, placement){
var $tip = this.tip()
, width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight
@@ -998,13 +1022,13 @@
if (replace) $tip.offset(offset)
}
- , replaceArrow: function(delta, dimension, position){
+ , replaceArrow: function(delta, dimension, position){
this
.arrow()
.css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}
- , setContent: function () {
+ , setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
@@ -1012,7 +1036,7 @@
$tip.removeClass('fade in top bottom left right')
}
- , hide: function () {
+ , hide: function () {
var that = this
, $tip = this.tip()
, e = $.Event('hide')
@@ -1042,45 +1066,45 @@
return this
}
- , fixTitle: function () {
+ , fixTitle: function () {
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 () {
+ , hasContent: function () {
return this.getTitle()
}
- , getPosition: function () {
+ , getPosition: function () {
var el = this.$element[0]
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
width: el.offsetWidth
- , height: el.offsetHeight
+ , height: el.offsetHeight
}, this.$element.offset())
}
- , getTitle: function () {
+ , getTitle: function () {
var title
, $e = this.$element
, o = this.options
title = $e.attr('data-original-title')
- || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
return title
}
- , tip: function () {
+ , tip: function () {
return this.$tip = this.$tip || $(this.options.template)
}
- , arrow: function(){
+ , arrow: function(){
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
}
- , validate: function () {
+ , validate: function () {
if (!this.$element[0].parentNode) {
this.hide()
this.$element = null
@@ -1088,32 +1112,32 @@
}
}
- , enable: function () {
+ , enable: function () {
this.enabled = true
}
- , disable: function () {
+ , disable: function () {
this.enabled = false
}
- , toggleEnabled: function () {
+ , toggleEnabled: function () {
this.enabled = !this.enabled
}
- , toggle: function (e) {
+ , toggle: function (e) {
var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
self.tip().hasClass('in') ? self.hide() : self.show()
}
- , destroy: function () {
+ , destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
}
- /* TOOLTIP PLUGIN DEFINITION
- * ========================= */
+ /* TOOLTIP PLUGIN DEFINITION
+ * ========================= */
var old = $.fn.tooltip
@@ -1131,19 +1155,19 @@
$.fn.tooltip.defaults = {
animation: true
- , placement: 'top'
- , selector: false
- , template: '
'
- , trigger: 'hover focus'
- , title: ''
- , delay: 0
- , html: false
- , container: false
+ , placement: 'top'
+ , selector: false
+ , template: ''
+ , trigger: 'hover focus'
+ , title: ''
+ , delay: 0
+ , html: false
+ , container: false
}
- /* TOOLTIP NO CONFLICT
- * =================== */
+ /* TOOLTIP NO CONFLICT
+ * =================== */
$.fn.tooltip.noConflict = function () {
$.fn.tooltip = old
@@ -1177,8 +1201,8 @@
"use strict"; // jshint ;_;
- /* POPOVER PUBLIC CLASS DEFINITION
- * =============================== */
+ /* POPOVER PUBLIC CLASS DEFINITION
+ * =============================== */
var Popover = function (element, options) {
this.init('popover', element, options)
@@ -1186,13 +1210,13 @@
/* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
- ========================================== */
+ ========================================== */
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
constructor: Popover
- , setContent: function () {
+ , setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
, content = this.getContent()
@@ -1203,37 +1227,37 @@
$tip.removeClass('fade top bottom left right in')
}
- , hasContent: function () {
+ , hasContent: function () {
return this.getTitle() || this.getContent()
}
- , getContent: function () {
+ , getContent: function () {
var content
, $e = this.$element
, o = this.options
content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
- || $e.attr('data-content')
+ || $e.attr('data-content')
return content
}
- , tip: function () {
+ , tip: function () {
if (!this.$tip) {
this.$tip = $(this.options.template)
}
return this.$tip
}
- , destroy: function () {
+ , destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
})
- /* POPOVER PLUGIN DEFINITION
- * ======================= */
+ /* POPOVER PLUGIN DEFINITION
+ * ======================= */
var old = $.fn.popover
@@ -1251,14 +1275,14 @@
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
placement: 'right'
- , trigger: 'click'
- , content: ''
- , template: ''
+ , trigger: 'click'
+ , content: ''
+ , template: ''
})
- /* POPOVER NO CONFLICT
- * =================== */
+ /* POPOVER NO CONFLICT
+ * =================== */
$.fn.popover.noConflict = function () {
$.fn.popover = old
@@ -1292,8 +1316,8 @@
"use strict"; // jshint ;_;
- /* AFFIX CLASS DEFINITION
- * ====================== */
+ /* AFFIX CLASS DEFINITION
+ * ====================== */
var Affix = function (element, options) {
this.options = $.extend({}, $.fn.affix.defaults, options)
@@ -1334,8 +1358,8 @@
}
- /* AFFIX PLUGIN DEFINITION
- * ======================= */
+ /* AFFIX PLUGIN DEFINITION
+ * ======================= */
var old = $.fn.affix
@@ -1356,8 +1380,8 @@
}
- /* AFFIX NO CONFLICT
- * ================= */
+ /* AFFIX NO CONFLICT
+ * ================= */
$.fn.affix.noConflict = function () {
$.fn.affix = old
@@ -1365,8 +1389,8 @@
}
- /* AFFIX DATA-API
- * ============== */
+ /* AFFIX DATA-API
+ * ============== */
$(window).on('load', function () {
$('[data-spy="affix"]').each(function () {
@@ -1409,13 +1433,13 @@
"use strict"; // jshint ;_;
- /* ALERT CLASS DEFINITION
- * ====================== */
+ /* ALERT CLASS DEFINITION
+ * ====================== */
var dismiss = '[data-dismiss="alert"]'
, Alert = function (el) {
- $(el).on('click', dismiss, this.close)
- }
+ $(el).on('click', dismiss, this.close)
+ }
Alert.prototype.close = function (e) {
var $this = $(this)
@@ -1451,8 +1475,8 @@
}
- /* ALERT PLUGIN DEFINITION
- * ======================= */
+ /* ALERT PLUGIN DEFINITION
+ * ======================= */
var old = $.fn.alert
@@ -1468,8 +1492,8 @@
$.fn.alert.Constructor = Alert
- /* ALERT NO CONFLICT
- * ================= */
+ /* ALERT NO CONFLICT
+ * ================= */
$.fn.alert.noConflict = function () {
$.fn.alert = old
@@ -1477,8 +1501,8 @@
}
- /* ALERT DATA-API
- * ============== */
+ /* ALERT DATA-API
+ * ============== */
$(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
@@ -1508,8 +1532,8 @@
"use strict"; // jshint ;_;
- /* BUTTON PUBLIC CLASS DEFINITION
- * ============================== */
+ /* BUTTON PUBLIC CLASS DEFINITION
+ * ============================== */
var Button = function (element, options) {
this.$element = $(element)
@@ -1546,8 +1570,8 @@
}
- /* BUTTON PLUGIN DEFINITION
- * ======================== */
+ /* BUTTON PLUGIN DEFINITION
+ * ======================== */
var old = $.fn.button
@@ -1569,8 +1593,8 @@
$.fn.button.Constructor = Button
- /* BUTTON NO CONFLICT
- * ================== */
+ /* BUTTON NO CONFLICT
+ * ================== */
$.fn.button.noConflict = function () {
$.fn.button = old
@@ -1578,8 +1602,8 @@
}
- /* BUTTON DATA-API
- * =============== */
+ /* BUTTON DATA-API
+ * =============== */
$(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target)
@@ -1613,8 +1637,8 @@
"use strict"; // jshint ;_;
- /* COLLAPSE PUBLIC CLASS DEFINITION
- * ================================ */
+ /* COLLAPSE PUBLIC CLASS DEFINITION
+ * ================================ */
var Collapse = function (element, options) {
this.$element = $(element)
@@ -1631,12 +1655,12 @@
constructor: Collapse
- , dimension: function () {
+ , dimension: function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
- , show: function () {
+ , show: function () {
var dimension
, scroll
, actives
@@ -1660,7 +1684,7 @@
$.support.transition && this.$element[dimension](this.$element[0][scroll])
}
- , hide: function () {
+ , hide: function () {
var dimension
if (this.transitioning || !this.$element.hasClass('in')) return
dimension = this.dimension()
@@ -1669,7 +1693,7 @@
this.$element[dimension](0)
}
- , reset: function (size) {
+ , reset: function (size) {
var dimension = this.dimension()
this.$element
@@ -1682,13 +1706,13 @@
return this
}
- , transition: function (method, startEvent, completeEvent) {
+ , transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function () {
- if (startEvent.type == 'show') that.reset()
- that.transitioning = 0
- that.$element.trigger(completeEvent)
- }
+ if (startEvent.type == 'show') that.reset()
+ that.transitioning = 0
+ that.$element.trigger(completeEvent)
+ }
this.$element.trigger(startEvent)
@@ -1703,15 +1727,15 @@
complete()
}
- , toggle: function () {
+ , toggle: function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
}
- /* COLLAPSE PLUGIN DEFINITION
- * ========================== */
+ /* COLLAPSE PLUGIN DEFINITION
+ * ========================== */
var old = $.fn.collapse
@@ -1732,8 +1756,8 @@
$.fn.collapse.Constructor = Collapse
- /* COLLAPSE NO CONFLICT
- * ==================== */
+ /* COLLAPSE NO CONFLICT
+ * ==================== */
$.fn.collapse.noConflict = function () {
$.fn.collapse = old
@@ -1741,8 +1765,8 @@
}
- /* COLLAPSE DATA-API
- * ================= */
+ /* COLLAPSE DATA-API
+ * ================= */
$(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
var $this = $(this), href
@@ -1780,8 +1804,8 @@
"use strict"; // jshint ;_;
- /* CAROUSEL CLASS DEFINITION
- * ========================= */
+ /* CAROUSEL CLASS DEFINITION
+ * ========================= */
var Carousel = function (element, options) {
this.$element = $(element)
@@ -1798,18 +1822,18 @@
if (!e) this.paused = false
if (this.interval) clearInterval(this.interval);
this.options.interval
- && !this.paused
- && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
+ && !this.paused
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
- , getActiveIndex: function () {
+ , getActiveIndex: function () {
this.$active = this.$element.find('.item.active')
this.$items = this.$active.parent().children()
return this.$items.index(this.$active)
}
- , to: function (pos) {
+ , to: function (pos) {
var activeIndex = this.getActiveIndex()
, that = this
@@ -1828,7 +1852,7 @@
return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
}
- , pause: function (e) {
+ , pause: function (e) {
if (!e) this.paused = true
if (this.$element.find('.next, .prev').length && $.support.transition.end) {
this.$element.trigger($.support.transition.end)
@@ -1839,17 +1863,17 @@
return this
}
- , next: function () {
+ , next: function () {
if (this.sliding) return
return this.slide('next')
}
- , prev: function () {
+ , prev: function () {
if (this.sliding) return
return this.slide('prev')
}
- , slide: function (type, next) {
+ , slide: function (type, next) {
var $active = this.$element.find('.item.active')
, $next = next || $active[type]()
, isCycling = this.interval
@@ -1866,7 +1890,7 @@
e = $.Event('slide', {
relatedTarget: $next[0]
- , direction: direction
+ , direction: direction
})
if ($next.hasClass('active')) return
@@ -1909,8 +1933,8 @@
}
- /* CAROUSEL PLUGIN DEFINITION
- * ========================== */
+ /* CAROUSEL PLUGIN DEFINITION
+ * ========================== */
var old = $.fn.carousel
@@ -1929,22 +1953,22 @@
$.fn.carousel.defaults = {
interval: 5000
- , pause: 'hover'
+ , pause: 'hover'
}
$.fn.carousel.Constructor = Carousel
- /* CAROUSEL NO CONFLICT
- * ==================== */
+ /* CAROUSEL NO CONFLICT
+ * ==================== */
$.fn.carousel.noConflict = function () {
$.fn.carousel = old
return this
}
- /* CAROUSEL DATA-API
- * ================= */
+ /* CAROUSEL DATA-API
+ * ================= */
$(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
var $this = $(this), href
@@ -1987,8 +2011,8 @@
"use strict"; // jshint ;_;
- /* TYPEAHEAD PUBLIC CLASS DEFINITION
- * ================================= */
+ /* TYPEAHEAD PUBLIC CLASS DEFINITION
+ * ================================= */
var Typeahead = function (element, options) {
this.$element = $(element)
@@ -2007,7 +2031,7 @@
constructor: Typeahead
- , select: function () {
+ , select: function () {
var val = this.$menu.find('.active').attr('data-value')
this.$element
.val(this.updater(val))
@@ -2015,11 +2039,11 @@
return this.hide()
}
- , updater: function (item) {
+ , updater: function (item) {
return item
}
- , show: function () {
+ , show: function () {
var pos = $.extend({}, this.$element.position(), {
height: this.$element[0].offsetHeight
})
@@ -2028,7 +2052,7 @@
.insertAfter(this.$element)
.css({
top: pos.top + pos.height
- , left: pos.left
+ , left: pos.left
})
.show()
@@ -2036,13 +2060,13 @@
return this
}
- , hide: function () {
+ , hide: function () {
this.$menu.hide()
this.shown = false
return this
}
- , lookup: function (event) {
+ , lookup: function (event) {
var items
this.query = this.$element.val()
@@ -2056,7 +2080,7 @@
return items ? this.process(items) : this
}
- , process: function (items) {
+ , process: function (items) {
var that = this
items = $.grep(items, function (item) {
@@ -2072,11 +2096,11 @@
return this.render(items.slice(0, this.options.items)).show()
}
- , matcher: function (item) {
+ , matcher: function (item) {
return ~item.toLowerCase().indexOf(this.query.toLowerCase())
}
- , sorter: function (items) {
+ , sorter: function (items) {
var beginswith = []
, caseSensitive = []
, caseInsensitive = []
@@ -2091,14 +2115,14 @@
return beginswith.concat(caseSensitive, caseInsensitive)
}
- , highlighter: function (item) {
+ , highlighter: function (item) {
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '' + match + ''
})
}
- , render: function (items) {
+ , render: function (items) {
var that = this
items = $(items).map(function (i, item) {
@@ -2112,7 +2136,7 @@
return this
}
- , next: function (event) {
+ , next: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, next = active.next()
@@ -2123,7 +2147,7 @@
next.addClass('active')
}
- , prev: function (event) {
+ , prev: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, prev = active.prev()
@@ -2134,7 +2158,7 @@
prev.addClass('active')
}
- , listen: function () {
+ , listen: function () {
this.$element
.on('focus', $.proxy(this.focus, this))
.on('blur', $.proxy(this.blur, this))
@@ -2151,7 +2175,7 @@
.on('mouseleave', 'li', $.proxy(this.mouseleave, this))
}
- , eventSupported: function(eventName) {
+ , eventSupported: function(eventName) {
var isSupported = eventName in this.$element
if (!isSupported) {
this.$element.setAttribute(eventName, 'return;')
@@ -2160,7 +2184,7 @@
return isSupported
}
- , move: function (e) {
+ , move: function (e) {
if (!this.shown) return
switch(e.keyCode) {
@@ -2184,17 +2208,17 @@
e.stopPropagation()
}
- , keydown: function (e) {
+ , keydown: function (e) {
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
this.move(e)
}
- , keypress: function (e) {
+ , keypress: function (e) {
if (this.suppressKeyPressRepeat) return
this.move(e)
}
- , keyup: function (e) {
+ , keyup: function (e) {
switch(e.keyCode) {
case 40: // down arrow
case 38: // up arrow
@@ -2220,31 +2244,31 @@
e.stopPropagation()
e.preventDefault()
- }
+ }
- , focus: function (e) {
+ , focus: function (e) {
this.focused = true
}
- , blur: function (e) {
+ , blur: function (e) {
this.focused = false
if (!this.mousedover && this.shown) this.hide()
}
- , click: function (e) {
+ , click: function (e) {
e.stopPropagation()
e.preventDefault()
this.select()
this.$element.focus()
}
- , mouseenter: function (e) {
+ , mouseenter: function (e) {
this.mousedover = true
this.$menu.find('.active').removeClass('active')
$(e.currentTarget).addClass('active')
}
- , mouseleave: function (e) {
+ , mouseleave: function (e) {
this.mousedover = false
if (!this.focused && this.shown) this.hide()
}
@@ -2269,17 +2293,17 @@
$.fn.typeahead.defaults = {
source: []
- , items: 8
- , menu: ''
- , item: ''
- , minLength: 1
+ , items: 8
+ , menu: ''
+ , item: ''
+ , minLength: 1
}
$.fn.typeahead.Constructor = Typeahead
- /* TYPEAHEAD NO CONFLICT
- * =================== */
+ /* TYPEAHEAD NO CONFLICT
+ * =================== */
$.fn.typeahead.noConflict = function () {
$.fn.typeahead = old
@@ -2287,8 +2311,8 @@
}
- /* TYPEAHEAD DATA-API
- * ================== */
+ /* TYPEAHEAD DATA-API
+ * ================== */
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
var $this = $(this)
From 59eeefa0f62c49256e91ae8cb5e840e4742e468d Mon Sep 17 00:00:00 2001
From: liuninge <749416752@qq.com>
Date: Wed, 20 May 2015 10:25:13 +0800
Subject: [PATCH 2/3] reset
---
src/js/bootstrap.js | 524 +++++++++++++++++++++-----------------------
1 file changed, 250 insertions(+), 274 deletions(-)
diff --git a/src/js/bootstrap.js b/src/js/bootstrap.js
index 6b3c666..288aede 100755
--- a/src/js/bootstrap.js
+++ b/src/js/bootstrap.js
@@ -34,11 +34,11 @@
var el = document.createElement('bootstrap')
, transEndEventNames = {
- 'WebkitTransition' : 'webkitTransitionEnd'
+ 'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd otransitionend'
, 'transition' : 'transitionend'
- }
+ }
, name
for (name in transEndEventNames){
@@ -50,8 +50,8 @@
}())
return transitionEnd && {
- end: transitionEnd
- }
+ end: transitionEnd
+ }
})()
@@ -96,8 +96,6 @@
this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
- // add by @liuning-geek
- this.isPushSetPosQueue = false;
}
Modal.prototype = {
@@ -137,12 +135,9 @@
// add by @sofish
// set margin to adjust the window
this.setPos(that.$element);
-
- // add by @liuning-geek
- if (!that.isPushSetPosQueue) {
- that.isPushSetPosQueue = true;
- pushSetPosQueue(function() { that.setPos(that.$element); });
- }
+ $(window).bind('scroll resize', function(){
+ that.setPos(that.$element);
+ });
if(data) data['setPos'] = this.setPos;
@@ -197,29 +192,10 @@
}
- /* MODAL PRIVATE PROPERTY
- * ===================== */
-
- // add by @liuning-geek
- var setPosQueue = [];
-
/* MODAL PRIVATE METHODS
* ===================== */
- // add by @liuning-geek
- function pushSetPosQueue(func) {
- // If this is the first time a push in the window binding events
- if (setPosQueue.length === 0) {
- $(window).bind('scroll resize', function(){
- for (var i = 0, len = setPosQueue.length; i < len; i++)
- setPosQueue[i]();
- });
- }
-
- setPosQueue.push(func);
- }
-
function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
@@ -367,22 +343,22 @@
"use strict"; // jshint ;_;
- /* DROPDOWN CLASS DEFINITION
- * ========================= */
+ /* DROPDOWN CLASS DEFINITION
+ * ========================= */
var toggle = '[data-toggle=dropdown]'
, Dropdown = function (element) {
- var $el = $(element).on('click.dropdown.data-api', this.toggle)
- $('html').on('click.dropdown.data-api', function () {
- $el.parent().removeClass('open')
- })
- }
+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
+ $('html').on('click.dropdown.data-api', function () {
+ $el.parent().removeClass('open')
+ })
+ }
Dropdown.prototype = {
constructor: Dropdown
- , toggle: function (e) {
+ , toggle: function (e) {
var $this = $(this)
, $parent
, isActive
@@ -404,7 +380,7 @@
return false
}
- , keydown: function (e) {
+ , keydown: function (e) {
var $this
, $items
, $active
@@ -487,8 +463,8 @@
$.fn.dropdown.Constructor = Dropdown
- /* DROPDOWN NO CONFLICT
- * ==================== */
+ /* DROPDOWN NO CONFLICT
+ * ==================== */
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
@@ -533,8 +509,8 @@
"use strict"; // jshint ;_;
- /* SCROLLSPY CLASS DEFINITION
- * ========================== */
+ /* SCROLLSPY CLASS DEFINITION
+ * ========================== */
function ScrollSpy(element, options) {
var process = $.proxy(this.process, this)
@@ -543,8 +519,8 @@
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
this.selector = (this.options.target
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
- || '') + ' .nav li > a'
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
+ || '') + ' .nav li > a'
this.$body = $('body')
this.refresh()
this.process()
@@ -552,84 +528,84 @@
ScrollSpy.prototype = {
- constructor: ScrollSpy
+ constructor: ScrollSpy
, refresh: function () {
- var self = this
- , $targets
-
- this.offsets = $([])
- this.targets = $([])
-
- $targets = this.$body
- .find(this.selector)
- .map(function () {
- var $el = $(this)
- , href = $el.data('target') || $el.attr('href')
- , $href = /^#\w/.test(href) && $(href)
- return ( $href
- && $href.length
- && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
- })
- .sort(function (a, b) { return a[0] - b[0] })
- .each(function () {
- self.offsets.push(this[0])
- self.targets.push(this[1])
- })
- }
+ var self = this
+ , $targets
+
+ this.offsets = $([])
+ this.targets = $([])
+
+ $targets = this.$body
+ .find(this.selector)
+ .map(function () {
+ var $el = $(this)
+ , href = $el.data('target') || $el.attr('href')
+ , $href = /^#\w/.test(href) && $(href)
+ return ( $href
+ && $href.length
+ && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
+ })
+ .sort(function (a, b) { return a[0] - b[0] })
+ .each(function () {
+ self.offsets.push(this[0])
+ 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 )
- }
+ 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] )
+ 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
+ var active
+ , selector
- this.activeTarget = target
+ this.activeTarget = target
- $(this.selector)
- .parent('.active')
- .removeClass('active')
+ $(this.selector)
+ .parent('.active')
+ .removeClass('active')
- selector = this.selector
- + '[data-target="' + target + '"],'
- + this.selector + '[href="' + target + '"]'
+ selector = this.selector
+ + '[data-target="' + target + '"],'
+ + this.selector + '[href="' + target + '"]'
- active = $(selector)
- .parent('li')
- .addClass('active')
+ active = $(selector)
+ .parent('li')
+ .addClass('active')
- if (active.parent('.dropdown-menu').length) {
- active = active.closest('li.dropdown').addClass('active')
- }
+ if (active.parent('.dropdown-menu').length) {
+ active = active.closest('li.dropdown').addClass('active')
+ }
- active.trigger('activate')
- }
+ active.trigger('activate')
+ }
}
- /* SCROLLSPY PLUGIN DEFINITION
- * =========================== */
+ /* SCROLLSPY PLUGIN DEFINITION
+ * =========================== */
var old = $.fn.scrollspy
@@ -650,8 +626,8 @@
}
- /* SCROLLSPY NO CONFLICT
- * ===================== */
+ /* SCROLLSPY NO CONFLICT
+ * ===================== */
$.fn.scrollspy.noConflict = function () {
$.fn.scrollspy = old
@@ -659,8 +635,8 @@
}
- /* SCROLLSPY DATA-API
- * ================== */
+ /* SCROLLSPY DATA-API
+ * ================== */
$(window).on('load', function () {
$('[data-spy="scroll"]').each(function () {
@@ -695,8 +671,8 @@
"use strict"; // jshint ;_;
- /* TAB CLASS DEFINITION
- * ==================== */
+ /* TAB CLASS DEFINITION
+ * ==================== */
var Tab = function (element) {
this.element = $(element)
@@ -706,7 +682,7 @@
constructor: Tab
- , show: function () {
+ , show: function () {
var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target')
@@ -737,16 +713,16 @@
this.activate($target, $target.parent(), function () {
$this.trigger({
type: 'shown'
- , relatedTarget: previous
+ , relatedTarget: previous
})
})
}
- , activate: function ( element, container, callback) {
+ , activate: function ( element, container, callback) {
var $active = container.find('> .active')
, transition = callback
- && $.support.transition
- && $active.hasClass('fade')
+ && $.support.transition
+ && $active.hasClass('fade')
function next() {
$active
@@ -779,8 +755,8 @@
}
- /* TAB PLUGIN DEFINITION
- * ===================== */
+ /* TAB PLUGIN DEFINITION
+ * ===================== */
var old = $.fn.tab
@@ -796,8 +772,8 @@
$.fn.tab.Constructor = Tab
- /* TAB NO CONFLICT
- * =============== */
+ /* TAB NO CONFLICT
+ * =============== */
$.fn.tab.noConflict = function () {
$.fn.tab = old
@@ -805,8 +781,8 @@
}
- /* TAB DATA-API
- * ============ */
+ /* TAB DATA-API
+ * ============ */
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault()
@@ -840,8 +816,8 @@
"use strict"; // jshint ;_;
- /* TOOLTIP PUBLIC CLASS DEFINITION
- * =============================== */
+ /* TOOLTIP PUBLIC CLASS DEFINITION
+ * =============================== */
var Tooltip = function (element, options) {
this.init('tooltip', element, options)
@@ -851,7 +827,7 @@
constructor: Tooltip
- , init: function (type, element, options) {
+ , init: function (type, element, options) {
var eventIn
, eventOut
, triggers
@@ -882,20 +858,20 @@
this.fixTitle()
}
- , getOptions: function (options) {
+ , getOptions: function (options) {
options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay
- , hide: options.delay
+ , hide: options.delay
}
}
return options
}
- , enter: function (e) {
+ , enter: function (e) {
var defaults = $.fn[this.type].defaults
, options = {}
, self
@@ -915,7 +891,7 @@
}, self.options.delay.show)
}
- , leave: function (e) {
+ , leave: function (e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (this.timeout) clearTimeout(this.timeout)
@@ -927,7 +903,7 @@
}, self.options.delay.hide)
}
- , show: function () {
+ , show: function () {
var $tip
, pos
, actualWidth
@@ -981,7 +957,7 @@
}
}
- , applyPlacement: function(offset, placement){
+ , applyPlacement: function(offset, placement){
var $tip = this.tip()
, width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight
@@ -1022,13 +998,13 @@
if (replace) $tip.offset(offset)
}
- , replaceArrow: function(delta, dimension, position){
+ , replaceArrow: function(delta, dimension, position){
this
.arrow()
.css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}
- , setContent: function () {
+ , setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
@@ -1036,7 +1012,7 @@
$tip.removeClass('fade in top bottom left right')
}
- , hide: function () {
+ , hide: function () {
var that = this
, $tip = this.tip()
, e = $.Event('hide')
@@ -1066,45 +1042,45 @@
return this
}
- , fixTitle: function () {
+ , fixTitle: function () {
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 () {
+ , hasContent: function () {
return this.getTitle()
}
- , getPosition: function () {
+ , getPosition: function () {
var el = this.$element[0]
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
width: el.offsetWidth
- , height: el.offsetHeight
+ , height: el.offsetHeight
}, this.$element.offset())
}
- , getTitle: function () {
+ , getTitle: function () {
var title
, $e = this.$element
, o = this.options
title = $e.attr('data-original-title')
- || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
return title
}
- , tip: function () {
+ , tip: function () {
return this.$tip = this.$tip || $(this.options.template)
}
- , arrow: function(){
+ , arrow: function(){
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
}
- , validate: function () {
+ , validate: function () {
if (!this.$element[0].parentNode) {
this.hide()
this.$element = null
@@ -1112,32 +1088,32 @@
}
}
- , enable: function () {
+ , enable: function () {
this.enabled = true
}
- , disable: function () {
+ , disable: function () {
this.enabled = false
}
- , toggleEnabled: function () {
+ , toggleEnabled: function () {
this.enabled = !this.enabled
}
- , toggle: function (e) {
+ , toggle: function (e) {
var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
self.tip().hasClass('in') ? self.hide() : self.show()
}
- , destroy: function () {
+ , destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
}
- /* TOOLTIP PLUGIN DEFINITION
- * ========================= */
+ /* TOOLTIP PLUGIN DEFINITION
+ * ========================= */
var old = $.fn.tooltip
@@ -1155,19 +1131,19 @@
$.fn.tooltip.defaults = {
animation: true
- , placement: 'top'
- , selector: false
- , template: ''
- , trigger: 'hover focus'
- , title: ''
- , delay: 0
- , html: false
- , container: false
+ , placement: 'top'
+ , selector: false
+ , template: ''
+ , trigger: 'hover focus'
+ , title: ''
+ , delay: 0
+ , html: false
+ , container: false
}
- /* TOOLTIP NO CONFLICT
- * =================== */
+ /* TOOLTIP NO CONFLICT
+ * =================== */
$.fn.tooltip.noConflict = function () {
$.fn.tooltip = old
@@ -1201,8 +1177,8 @@
"use strict"; // jshint ;_;
- /* POPOVER PUBLIC CLASS DEFINITION
- * =============================== */
+ /* POPOVER PUBLIC CLASS DEFINITION
+ * =============================== */
var Popover = function (element, options) {
this.init('popover', element, options)
@@ -1210,13 +1186,13 @@
/* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
- ========================================== */
+ ========================================== */
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
constructor: Popover
- , setContent: function () {
+ , setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
, content = this.getContent()
@@ -1227,37 +1203,37 @@
$tip.removeClass('fade top bottom left right in')
}
- , hasContent: function () {
+ , hasContent: function () {
return this.getTitle() || this.getContent()
}
- , getContent: function () {
+ , getContent: function () {
var content
, $e = this.$element
, o = this.options
content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
- || $e.attr('data-content')
+ || $e.attr('data-content')
return content
}
- , tip: function () {
+ , tip: function () {
if (!this.$tip) {
this.$tip = $(this.options.template)
}
return this.$tip
}
- , destroy: function () {
+ , destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
})
- /* POPOVER PLUGIN DEFINITION
- * ======================= */
+ /* POPOVER PLUGIN DEFINITION
+ * ======================= */
var old = $.fn.popover
@@ -1275,14 +1251,14 @@
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
placement: 'right'
- , trigger: 'click'
- , content: ''
- , template: ''
+ , trigger: 'click'
+ , content: ''
+ , template: ''
})
- /* POPOVER NO CONFLICT
- * =================== */
+ /* POPOVER NO CONFLICT
+ * =================== */
$.fn.popover.noConflict = function () {
$.fn.popover = old
@@ -1316,8 +1292,8 @@
"use strict"; // jshint ;_;
- /* AFFIX CLASS DEFINITION
- * ====================== */
+ /* AFFIX CLASS DEFINITION
+ * ====================== */
var Affix = function (element, options) {
this.options = $.extend({}, $.fn.affix.defaults, options)
@@ -1358,8 +1334,8 @@
}
- /* AFFIX PLUGIN DEFINITION
- * ======================= */
+ /* AFFIX PLUGIN DEFINITION
+ * ======================= */
var old = $.fn.affix
@@ -1380,8 +1356,8 @@
}
- /* AFFIX NO CONFLICT
- * ================= */
+ /* AFFIX NO CONFLICT
+ * ================= */
$.fn.affix.noConflict = function () {
$.fn.affix = old
@@ -1389,8 +1365,8 @@
}
- /* AFFIX DATA-API
- * ============== */
+ /* AFFIX DATA-API
+ * ============== */
$(window).on('load', function () {
$('[data-spy="affix"]').each(function () {
@@ -1433,13 +1409,13 @@
"use strict"; // jshint ;_;
- /* ALERT CLASS DEFINITION
- * ====================== */
+ /* ALERT CLASS DEFINITION
+ * ====================== */
var dismiss = '[data-dismiss="alert"]'
, Alert = function (el) {
- $(el).on('click', dismiss, this.close)
- }
+ $(el).on('click', dismiss, this.close)
+ }
Alert.prototype.close = function (e) {
var $this = $(this)
@@ -1475,8 +1451,8 @@
}
- /* ALERT PLUGIN DEFINITION
- * ======================= */
+ /* ALERT PLUGIN DEFINITION
+ * ======================= */
var old = $.fn.alert
@@ -1492,8 +1468,8 @@
$.fn.alert.Constructor = Alert
- /* ALERT NO CONFLICT
- * ================= */
+ /* ALERT NO CONFLICT
+ * ================= */
$.fn.alert.noConflict = function () {
$.fn.alert = old
@@ -1501,8 +1477,8 @@
}
- /* ALERT DATA-API
- * ============== */
+ /* ALERT DATA-API
+ * ============== */
$(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
@@ -1532,8 +1508,8 @@
"use strict"; // jshint ;_;
- /* BUTTON PUBLIC CLASS DEFINITION
- * ============================== */
+ /* BUTTON PUBLIC CLASS DEFINITION
+ * ============================== */
var Button = function (element, options) {
this.$element = $(element)
@@ -1570,8 +1546,8 @@
}
- /* BUTTON PLUGIN DEFINITION
- * ======================== */
+ /* BUTTON PLUGIN DEFINITION
+ * ======================== */
var old = $.fn.button
@@ -1593,8 +1569,8 @@
$.fn.button.Constructor = Button
- /* BUTTON NO CONFLICT
- * ================== */
+ /* BUTTON NO CONFLICT
+ * ================== */
$.fn.button.noConflict = function () {
$.fn.button = old
@@ -1602,8 +1578,8 @@
}
- /* BUTTON DATA-API
- * =============== */
+ /* BUTTON DATA-API
+ * =============== */
$(document).on('click.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target)
@@ -1637,8 +1613,8 @@
"use strict"; // jshint ;_;
- /* COLLAPSE PUBLIC CLASS DEFINITION
- * ================================ */
+ /* COLLAPSE PUBLIC CLASS DEFINITION
+ * ================================ */
var Collapse = function (element, options) {
this.$element = $(element)
@@ -1655,12 +1631,12 @@
constructor: Collapse
- , dimension: function () {
+ , dimension: function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
- , show: function () {
+ , show: function () {
var dimension
, scroll
, actives
@@ -1684,7 +1660,7 @@
$.support.transition && this.$element[dimension](this.$element[0][scroll])
}
- , hide: function () {
+ , hide: function () {
var dimension
if (this.transitioning || !this.$element.hasClass('in')) return
dimension = this.dimension()
@@ -1693,7 +1669,7 @@
this.$element[dimension](0)
}
- , reset: function (size) {
+ , reset: function (size) {
var dimension = this.dimension()
this.$element
@@ -1706,13 +1682,13 @@
return this
}
- , transition: function (method, startEvent, completeEvent) {
+ , transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function () {
- if (startEvent.type == 'show') that.reset()
- that.transitioning = 0
- that.$element.trigger(completeEvent)
- }
+ if (startEvent.type == 'show') that.reset()
+ that.transitioning = 0
+ that.$element.trigger(completeEvent)
+ }
this.$element.trigger(startEvent)
@@ -1727,15 +1703,15 @@
complete()
}
- , toggle: function () {
+ , toggle: function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
}
- /* COLLAPSE PLUGIN DEFINITION
- * ========================== */
+ /* COLLAPSE PLUGIN DEFINITION
+ * ========================== */
var old = $.fn.collapse
@@ -1756,8 +1732,8 @@
$.fn.collapse.Constructor = Collapse
- /* COLLAPSE NO CONFLICT
- * ==================== */
+ /* COLLAPSE NO CONFLICT
+ * ==================== */
$.fn.collapse.noConflict = function () {
$.fn.collapse = old
@@ -1765,8 +1741,8 @@
}
- /* COLLAPSE DATA-API
- * ================= */
+ /* COLLAPSE DATA-API
+ * ================= */
$(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
var $this = $(this), href
@@ -1804,8 +1780,8 @@
"use strict"; // jshint ;_;
- /* CAROUSEL CLASS DEFINITION
- * ========================= */
+ /* CAROUSEL CLASS DEFINITION
+ * ========================= */
var Carousel = function (element, options) {
this.$element = $(element)
@@ -1822,18 +1798,18 @@
if (!e) this.paused = false
if (this.interval) clearInterval(this.interval);
this.options.interval
- && !this.paused
- && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
+ && !this.paused
+ && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
return this
}
- , getActiveIndex: function () {
+ , getActiveIndex: function () {
this.$active = this.$element.find('.item.active')
this.$items = this.$active.parent().children()
return this.$items.index(this.$active)
}
- , to: function (pos) {
+ , to: function (pos) {
var activeIndex = this.getActiveIndex()
, that = this
@@ -1852,7 +1828,7 @@
return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
}
- , pause: function (e) {
+ , pause: function (e) {
if (!e) this.paused = true
if (this.$element.find('.next, .prev').length && $.support.transition.end) {
this.$element.trigger($.support.transition.end)
@@ -1863,17 +1839,17 @@
return this
}
- , next: function () {
+ , next: function () {
if (this.sliding) return
return this.slide('next')
}
- , prev: function () {
+ , prev: function () {
if (this.sliding) return
return this.slide('prev')
}
- , slide: function (type, next) {
+ , slide: function (type, next) {
var $active = this.$element.find('.item.active')
, $next = next || $active[type]()
, isCycling = this.interval
@@ -1890,7 +1866,7 @@
e = $.Event('slide', {
relatedTarget: $next[0]
- , direction: direction
+ , direction: direction
})
if ($next.hasClass('active')) return
@@ -1933,8 +1909,8 @@
}
- /* CAROUSEL PLUGIN DEFINITION
- * ========================== */
+ /* CAROUSEL PLUGIN DEFINITION
+ * ========================== */
var old = $.fn.carousel
@@ -1953,22 +1929,22 @@
$.fn.carousel.defaults = {
interval: 5000
- , pause: 'hover'
+ , pause: 'hover'
}
$.fn.carousel.Constructor = Carousel
- /* CAROUSEL NO CONFLICT
- * ==================== */
+ /* CAROUSEL NO CONFLICT
+ * ==================== */
$.fn.carousel.noConflict = function () {
$.fn.carousel = old
return this
}
- /* CAROUSEL DATA-API
- * ================= */
+ /* CAROUSEL DATA-API
+ * ================= */
$(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
var $this = $(this), href
@@ -2011,8 +1987,8 @@
"use strict"; // jshint ;_;
- /* TYPEAHEAD PUBLIC CLASS DEFINITION
- * ================================= */
+ /* TYPEAHEAD PUBLIC CLASS DEFINITION
+ * ================================= */
var Typeahead = function (element, options) {
this.$element = $(element)
@@ -2031,7 +2007,7 @@
constructor: Typeahead
- , select: function () {
+ , select: function () {
var val = this.$menu.find('.active').attr('data-value')
this.$element
.val(this.updater(val))
@@ -2039,11 +2015,11 @@
return this.hide()
}
- , updater: function (item) {
+ , updater: function (item) {
return item
}
- , show: function () {
+ , show: function () {
var pos = $.extend({}, this.$element.position(), {
height: this.$element[0].offsetHeight
})
@@ -2052,7 +2028,7 @@
.insertAfter(this.$element)
.css({
top: pos.top + pos.height
- , left: pos.left
+ , left: pos.left
})
.show()
@@ -2060,13 +2036,13 @@
return this
}
- , hide: function () {
+ , hide: function () {
this.$menu.hide()
this.shown = false
return this
}
- , lookup: function (event) {
+ , lookup: function (event) {
var items
this.query = this.$element.val()
@@ -2080,7 +2056,7 @@
return items ? this.process(items) : this
}
- , process: function (items) {
+ , process: function (items) {
var that = this
items = $.grep(items, function (item) {
@@ -2096,11 +2072,11 @@
return this.render(items.slice(0, this.options.items)).show()
}
- , matcher: function (item) {
+ , matcher: function (item) {
return ~item.toLowerCase().indexOf(this.query.toLowerCase())
}
- , sorter: function (items) {
+ , sorter: function (items) {
var beginswith = []
, caseSensitive = []
, caseInsensitive = []
@@ -2115,14 +2091,14 @@
return beginswith.concat(caseSensitive, caseInsensitive)
}
- , highlighter: function (item) {
+ , highlighter: function (item) {
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
return '' + match + ''
})
}
- , render: function (items) {
+ , render: function (items) {
var that = this
items = $(items).map(function (i, item) {
@@ -2136,7 +2112,7 @@
return this
}
- , next: function (event) {
+ , next: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, next = active.next()
@@ -2147,7 +2123,7 @@
next.addClass('active')
}
- , prev: function (event) {
+ , prev: function (event) {
var active = this.$menu.find('.active').removeClass('active')
, prev = active.prev()
@@ -2158,7 +2134,7 @@
prev.addClass('active')
}
- , listen: function () {
+ , listen: function () {
this.$element
.on('focus', $.proxy(this.focus, this))
.on('blur', $.proxy(this.blur, this))
@@ -2175,7 +2151,7 @@
.on('mouseleave', 'li', $.proxy(this.mouseleave, this))
}
- , eventSupported: function(eventName) {
+ , eventSupported: function(eventName) {
var isSupported = eventName in this.$element
if (!isSupported) {
this.$element.setAttribute(eventName, 'return;')
@@ -2184,7 +2160,7 @@
return isSupported
}
- , move: function (e) {
+ , move: function (e) {
if (!this.shown) return
switch(e.keyCode) {
@@ -2208,17 +2184,17 @@
e.stopPropagation()
}
- , keydown: function (e) {
+ , keydown: function (e) {
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27])
this.move(e)
}
- , keypress: function (e) {
+ , keypress: function (e) {
if (this.suppressKeyPressRepeat) return
this.move(e)
}
- , keyup: function (e) {
+ , keyup: function (e) {
switch(e.keyCode) {
case 40: // down arrow
case 38: // up arrow
@@ -2244,31 +2220,31 @@
e.stopPropagation()
e.preventDefault()
- }
+ }
- , focus: function (e) {
+ , focus: function (e) {
this.focused = true
}
- , blur: function (e) {
+ , blur: function (e) {
this.focused = false
if (!this.mousedover && this.shown) this.hide()
}
- , click: function (e) {
+ , click: function (e) {
e.stopPropagation()
e.preventDefault()
this.select()
this.$element.focus()
}
- , mouseenter: function (e) {
+ , mouseenter: function (e) {
this.mousedover = true
this.$menu.find('.active').removeClass('active')
$(e.currentTarget).addClass('active')
}
- , mouseleave: function (e) {
+ , mouseleave: function (e) {
this.mousedover = false
if (!this.focused && this.shown) this.hide()
}
@@ -2293,17 +2269,17 @@
$.fn.typeahead.defaults = {
source: []
- , items: 8
- , menu: ''
- , item: ''
- , minLength: 1
+ , items: 8
+ , menu: ''
+ , item: ''
+ , minLength: 1
}
$.fn.typeahead.Constructor = Typeahead
- /* TYPEAHEAD NO CONFLICT
- * =================== */
+ /* TYPEAHEAD NO CONFLICT
+ * =================== */
$.fn.typeahead.noConflict = function () {
$.fn.typeahead = old
@@ -2311,8 +2287,8 @@
}
- /* TYPEAHEAD DATA-API
- * ================== */
+ /* TYPEAHEAD DATA-API
+ * ================== */
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
var $this = $(this)
From 2f790267f7125914fb95465b2fa101d0e9c135fa Mon Sep 17 00:00:00 2001
From: liuninge <749416752@qq.com>
Date: Wed, 20 May 2015 10:33:09 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dmodal=20show=E7=9A=84?=
=?UTF-8?q?=E6=97=B6=E5=80=99=20=E9=87=8D=E5=A4=8D=E7=BB=91=E5=AE=9Ascroll?=
=?UTF-8?q?=20resize=E4=BA=8B=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/js/bootstrap.js | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/src/js/bootstrap.js b/src/js/bootstrap.js
index 288aede..6cc2a11 100755
--- a/src/js/bootstrap.js
+++ b/src/js/bootstrap.js
@@ -96,6 +96,8 @@
this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
+ // edit by @liuning-geek
+ this.isPushSetPosQueue = false;
}
Modal.prototype = {
@@ -135,9 +137,12 @@
// add by @sofish
// set margin to adjust the window
this.setPos(that.$element);
- $(window).bind('scroll resize', function(){
- that.setPos(that.$element);
- });
+
+ // edit by @liuning-geek
+ if (!that.isPushSetPosQueue) {
+ that.isPushSetPosQueue = true;
+ pushSetPosQueue(function() { that.setPos(that.$element); });
+ }
if(data) data['setPos'] = this.setPos;
@@ -192,10 +197,28 @@
}
+ /* MODAL PRIVATE PROPERTY
+ * ===================== */
+
+ // add by @liuning-geek
+ var setPosQueue = [];
/* MODAL PRIVATE METHODS
* ===================== */
+ // add by @liuning-geek
+ function pushSetPosQueue(func) {
+ // If this is the first time a push in the window binding events
+ if (setPosQueue.length === 0) {
+ $(window).bind('scroll resize', function(){
+ for (var i = 0, len = setPosQueue.length; i < len; i++)
+ setPosQueue[i]();
+ });
+ }
+
+ setPosQueue.push(func);
+ }
+
function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {