diff options
author | Gleb Mazovetskiy <glebm@google.com> | 2015-04-27 11:59:39 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glebm@google.com> | 2015-04-27 11:59:39 +0300 |
commit | f95e617f9d165c85a7d9fe658f56b53c5b756dcb (patch) | |
tree | 1a5b728c2153985adf4d60ef4c9bed7d8ee847d6 /assets/javascripts/bootstrap.js | |
parent | 4d879df2cb2dd4ef6dc72478a1a389d5f60a45f6 (diff) |
rake convert
Diffstat (limited to 'assets/javascripts/bootstrap.js')
-rw-r--r-- | assets/javascripts/bootstrap.js | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/assets/javascripts/bootstrap.js b/assets/javascripts/bootstrap.js index 1c88b71e..d2e117e0 100644 --- a/assets/javascripts/bootstrap.js +++ b/assets/javascripts/bootstrap.js @@ -229,8 +229,8 @@ if (typeof jQuery === 'undefined') { if ($parent.length) { var $input = this.$element.find('input') if ($input.prop('type') == 'radio') { - if ($input.prop('checked') && this.$element.hasClass('active')) changed = false - else $parent.find('.active').removeClass('active') + if ($input.prop('checked')) changed = false + if (!$input.prop('checked') || !this.$element.hasClass('active')) $parent.find('.active').removeClass('active') } if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') } else { @@ -280,7 +280,7 @@ if (typeof jQuery === 'undefined') { var $btn = $(e.target) if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') Plugin.call($btn, 'toggle') - e.preventDefault() + if (!$(e.target).is('input[type="radio"]')) e.preventDefault() }) .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type)) @@ -774,7 +774,10 @@ if (typeof jQuery === 'undefined') { if (!isActive) { if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { // if mobile we use a backdrop because click events don't delegate - $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) + $(document.createElement('div')) + .addClass('dropdown-backdrop') + .insertAfter($(this)) + .on('click', clearMenus) } var relatedTarget = { relatedTarget: this } @@ -836,6 +839,8 @@ if (typeof jQuery === 'undefined') { if (!$parent.hasClass('open')) return + if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return + $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget)) if (e.isDefaultPrevented()) return @@ -895,8 +900,7 @@ if (typeof jQuery === 'undefined') { .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle) .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown) - .on('keydown.bs.dropdown.data-api', '[role="menu"]', Dropdown.prototype.keydown) - .on('keydown.bs.dropdown.data-api', '[role="listbox"]', Dropdown.prototype.keydown) + .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown) }(jQuery); @@ -992,9 +996,7 @@ if (typeof jQuery === 'undefined') { that.$element[0].offsetWidth // force reflow } - that.$element - .addClass('in') - .attr('aria-hidden', false) + that.$element.addClass('in') that.enforceFocus() @@ -1028,7 +1030,6 @@ if (typeof jQuery === 'undefined') { this.$element .removeClass('in') - .attr('aria-hidden', true) .off('click.dismiss.bs.modal') .off('mouseup.dismiss.bs.modal') @@ -1092,7 +1093,8 @@ if (typeof jQuery === 'undefined') { if (this.isShown && this.options.backdrop) { var doAnimate = $.support.transition && animate - this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') + this.$backdrop = $(document.createElement('div')) + .addClass('modal-backdrop ' + animate) .appendTo(this.$body) this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { @@ -1292,7 +1294,7 @@ if (typeof jQuery === 'undefined') { this.type = type this.$element = $(element) this.options = this.getOptions(options) - this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport) + this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport)) if (this.$element[0] instanceof document.constructor && !this.options.selector) { throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!') @@ -1427,6 +1429,7 @@ if (typeof jQuery === 'undefined') { .data('bs.' + this.type, this) this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) + this.$element.trigger('inserted.bs.' + this.type) var pos = this.getPosition() var actualWidth = $tip[0].offsetWidth @@ -1619,7 +1622,7 @@ if (typeof jQuery === 'undefined') { var rightEdgeOffset = pos.left + viewportPadding + actualWidth if (leftEdgeOffset < viewportDimensions.left) { // left overflow delta.left = viewportDimensions.left - leftEdgeOffset - } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow + } else if (rightEdgeOffset > viewportDimensions.right) { // right overflow delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset } } @@ -1645,7 +1648,13 @@ if (typeof jQuery === 'undefined') { } Tooltip.prototype.tip = function () { - return (this.$tip = this.$tip || $(this.options.template)) + if (!this.$tip) { + this.$tip = $(this.options.template) + if (this.$tip.length != 1) { + throw new Error(this.type + ' `template` option must consist of exactly 1 top-level element!') + } + } + return this.$tip } Tooltip.prototype.arrow = function () { @@ -1682,6 +1691,12 @@ if (typeof jQuery === 'undefined') { clearTimeout(this.timeout) this.hide(function () { that.$element.off('.' + that.type).removeData('bs.' + that.type) + if (that.$tip) { + that.$tip.detach() + } + that.$tip = null + that.$arrow = null + that.$viewport = null }) } |