diff options
author | Mark Otto <otto@github.com> | 2013-02-06 10:42:54 +0400 |
---|---|---|
committer | Mark Otto <otto@github.com> | 2013-02-06 10:42:54 +0400 |
commit | 421f9f67c44d4b7c971b42808687ae7b71c99151 (patch) | |
tree | 4aa1c698f535d8ae8f7aae7a4b6d396bc86906a4 /docs/assets/js/bootstrap.js | |
parent | 6d21d8600739fe16e8993a11f82a4727065ca78a (diff) | |
parent | 3b56227553f40cc567e161c68c64f1e315fd5241 (diff) |
Merge branch '2.3.0-wip' into 3.0.0-wip
Conflicts:
docs/assets/css/bootstrap-responsive.css
docs/assets/js/bootstrap-popover.js
docs/assets/js/bootstrap.js
docs/css.html
docs/templates/pages/base-css.mustache
js/bootstrap-popover.js
less/mixins.less
less/tooltip.less
Diffstat (limited to 'docs/assets/js/bootstrap.js')
-rw-r--r-- | docs/assets/js/bootstrap.js | 81 |
1 files changed, 65 insertions, 16 deletions
diff --git a/docs/assets/js/bootstrap.js b/docs/assets/js/bootstrap.js index f0a03ee823..16d8d66c28 100644 --- a/docs/assets/js/bootstrap.js +++ b/docs/assets/js/bootstrap.js @@ -300,6 +300,7 @@ cycle: function (e) { 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)) @@ -538,7 +539,7 @@ , hide: function () { var dimension - if (this.transitioning) return + if (this.transitioning || !this.$element.hasClass('in')) return dimension = this.dimension() this.reset(this.$element[dimension]()) this.transition('removeClass', $.Event('hide'), 'hidden') @@ -788,13 +789,14 @@ * =================================== */ $(document) - .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) - .on('click.dropdown.data-api touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) - .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() }) - .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) - .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) + .on('click.dropdown.data-api', clearMenus) + .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) + .on('.dropdown-menu', function (e) { e.stopPropagation() }) + .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle) + .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) -}(window.jQuery);/* ========================================================= +}(window.jQuery); +/* ========================================================= * bootstrap-modal.js v3.0.0 * http://twitter.github.com/bootstrap/javascript.html#modals * ========================================================= @@ -1107,7 +1109,7 @@ } , getOptions: function (options) { - options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data()) + options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options) if (options.delay && typeof options.delay == 'number') { options.delay = { @@ -1192,15 +1194,58 @@ break } - $tip - .offset(tp) - .addClass(placement) - .addClass('in') - + this.applyPlacement(tp, placement) this.$element.trigger('shown') } } + , applyPlacement: function(offset, placement){ + var $tip = this.tip() + , width = $tip[0].offsetWidth + , height = $tip[0].offsetHeight + , actualWidth + , actualHeight + , delta + , replace + + $tip + .offset(offset) + .addClass(placement) + .addClass('in') + + actualWidth = $tip[0].offsetWidth + actualHeight = $tip[0].offsetHeight + + if (placement == 'top' && actualHeight != height) { + offset.top = offset.top + height - actualHeight + replace = true + } + + if (placement == 'bottom' || placement == 'top') { + delta = 0 + + if (offset.left < 0){ + 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') + } else { + this.replaceArrow(actualHeight - height, actualHeight, 'top') + } + + if (replace) $tip.offset(offset) + } + + , replaceArrow: function(delta, dimension, position){ + this + .arrow() + .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') + } + , setContent: function () { var $tip = this.tip() , title = this.getTitle() @@ -1252,7 +1297,7 @@ , getPosition: function () { var el = this.$element[0] - return $.extend({}, el.getBoundingClientRect ? el.getBoundingClientRect() : { + return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { width: el.offsetWidth , height: el.offsetHeight }, this.$element.offset()) @@ -1273,6 +1318,10 @@ return this.$tip = this.$tip || $(this.options.template) } + , arrow: function(){ + return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") + } + , validate: function () { if (!this.$element[0].parentNode) { this.hide() @@ -1404,8 +1453,8 @@ , $e = this.$element , o = this.options - content = $e.attr('data-content') - || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content) + content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content) + || $e.attr('data-content') return content } |