Skip to content

Commit

Permalink
Merge pull request #3348 from luki215/update-js-libs
Browse files Browse the repository at this point in the history
Update vulnerable js libs
  • Loading branch information
mshibuya authored Apr 4, 2021
2 parents 3b505fc + c7493e2 commit 036b2f5
Show file tree
Hide file tree
Showing 18 changed files with 1,101 additions and 10,462 deletions.
78 changes: 50 additions & 28 deletions app/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ========================================================================
* Bootstrap: affix.js v3.2.0
* http://getbootstrap.com/javascript/#affix
* Bootstrap: affix.js v3.4.1
* https://getbootstrap.com/docs/3.4/javascript/#affix
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */

Expand All @@ -16,19 +16,21 @@
var Affix = function (element, options) {
this.options = $.extend({}, Affix.DEFAULTS, options)

this.$target = $(this.options.target)
var target = this.options.target === Affix.DEFAULTS.target ? $(this.options.target) : $(document).find(this.options.target)

this.$target = target
.on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))

this.$element = $(element)
this.affixed =
this.unpin =
this.affixed = null
this.unpin = null
this.pinnedOffset = null

this.checkPosition()
}

Affix.VERSION = '3.2.0'
Affix.VERSION = '3.4.1'

Affix.RESET = 'affix affix-top affix-bottom'

Expand All @@ -37,6 +39,28 @@
target: window
}

Affix.prototype.getState = function (scrollHeight, height, offsetTop, offsetBottom) {
var scrollTop = this.$target.scrollTop()
var position = this.$element.offset()
var targetHeight = this.$target.height()

if (offsetTop != null && this.affixed == 'top') return scrollTop < offsetTop ? 'top' : false

if (this.affixed == 'bottom') {
if (offsetTop != null) return (scrollTop + this.unpin <= position.top) ? false : 'bottom'
return (scrollTop + targetHeight <= scrollHeight - offsetBottom) ? false : 'bottom'
}

var initializing = this.affixed == null
var colliderTop = initializing ? scrollTop : position.top
var colliderHeight = initializing ? targetHeight : height

if (offsetTop != null && scrollTop <= offsetTop) return 'top'
if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'

return false
}

Affix.prototype.getPinnedOffset = function () {
if (this.pinnedOffset) return this.pinnedOffset
this.$element.removeClass(Affix.RESET).addClass('affix')
Expand All @@ -52,42 +76,40 @@
Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return

var scrollHeight = $(document).height()
var scrollTop = this.$target.scrollTop()
var position = this.$element.offset()
var height = this.$element.height()
var offset = this.options.offset
var offsetTop = offset.top
var offsetBottom = offset.bottom
var scrollHeight = Math.max($(document).height(), $(document.body).height())

if (typeof offset != 'object') offsetBottom = offsetTop = offset
if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)

var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
var affix = this.getState(scrollHeight, height, offsetTop, offsetBottom)

if (this.affixed === affix) return
if (this.unpin != null) this.$element.css('top', '')
if (this.affixed != affix) {
if (this.unpin != null) this.$element.css('top', '')

var affixType = 'affix' + (affix ? '-' + affix : '')
var e = $.Event(affixType + '.bs.affix')
var affixType = 'affix' + (affix ? '-' + affix : '')
var e = $.Event(affixType + '.bs.affix')

this.$element.trigger(e)
this.$element.trigger(e)

if (e.isDefaultPrevented()) return
if (e.isDefaultPrevented()) return

this.affixed = affix
this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
this.affixed = affix
this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null

this.$element
.removeClass(Affix.RESET)
.addClass(affixType)
.trigger($.Event(affixType.replace('affix', 'affixed')))
this.$element
.removeClass(Affix.RESET)
.addClass(affixType)
.trigger(affixType.replace('affix', 'affixed') + '.bs.affix')
}

if (affix == 'bottom') {
this.$element.offset({
top: scrollHeight - this.$element.height() - offsetBottom
top: scrollHeight - height - offsetBottom
})
}
}
Expand Down Expand Up @@ -132,8 +154,8 @@

data.offset = data.offset || {}

if (data.offsetBottom) data.offset.bottom = data.offsetBottom
if (data.offsetTop) data.offset.top = data.offsetTop
if (data.offsetBottom != null) data.offset.bottom = data.offsetBottom
if (data.offsetTop != null) data.offset.top = data.offsetTop

Plugin.call($spy, data)
})
Expand Down
17 changes: 10 additions & 7 deletions app/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ========================================================================
* Bootstrap: alert.js v3.2.0
* http://getbootstrap.com/javascript/#alerts
* Bootstrap: alert.js v3.4.1
* https://getbootstrap.com/docs/3.4/javascript/#alerts
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */

Expand All @@ -18,7 +18,9 @@
$(el).on('click', dismiss, this.close)
}

Alert.VERSION = '3.2.0'
Alert.VERSION = '3.4.1'

Alert.TRANSITION_DURATION = 150

Alert.prototype.close = function (e) {
var $this = $(this)
Expand All @@ -29,12 +31,13 @@
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}

var $parent = $(selector)
selector = selector === '#' ? [] : selector
var $parent = $(document).find(selector)

if (e) e.preventDefault()

if (!$parent.length) {
$parent = $this.hasClass('alert') ? $this : $this.parent()
$parent = $this.closest('.alert')
}

$parent.trigger(e = $.Event('close.bs.alert'))
Expand All @@ -51,7 +54,7 @@
$.support.transition && $parent.hasClass('fade') ?
$parent
.one('bsTransitionEnd', removeElement)
.emulateTransitionEnd(150) :
.emulateTransitionEnd(Alert.TRANSITION_DURATION) :
removeElement()
}

Expand Down
55 changes: 35 additions & 20 deletions app/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ========================================================================
* Bootstrap: button.js v3.2.0
* http://getbootstrap.com/javascript/#buttons
* Bootstrap: button.js v3.4.1
* https://getbootstrap.com/docs/3.4/javascript/#buttons
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */

Expand All @@ -19,7 +19,7 @@
this.isLoading = false
}

Button.VERSION = '3.2.0'
Button.VERSION = '3.4.1'

Button.DEFAULTS = {
loadingText: 'loading...'
Expand All @@ -31,20 +31,20 @@
var val = $el.is('input') ? 'val' : 'html'
var data = $el.data()

state = state + 'Text'
state += 'Text'

if (data.resetText == null) $el.data('resetText', $el[val]())

$el[val](data[state] == null ? this.options[state] : data[state])

// push to event loop to allow forms to submit
setTimeout($.proxy(function () {
$el[val](data[state] == null ? this.options[state] : data[state])

if (state == 'loadingText') {
this.isLoading = true
$el.addClass(d).attr(d, d)
$el.addClass(d).attr(d, d).prop(d, true)
} else if (this.isLoading) {
this.isLoading = false
$el.removeClass(d).removeAttr(d)
$el.removeClass(d).removeAttr(d).prop(d, false)
}
}, this), 0)
}
Expand All @@ -56,13 +56,19 @@
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
$parent.find('.active').removeClass('active')
this.$element.addClass('active')
} else if ($input.prop('type') == 'checkbox') {
if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false
this.$element.toggleClass('active')
}
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
$input.prop('checked', this.$element.hasClass('active'))
if (changed) $input.trigger('change')
} else {
this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
this.$element.toggleClass('active')
}

if (changed) this.$element.toggleClass('active')
}


Expand Down Expand Up @@ -100,11 +106,20 @@
// BUTTON DATA-API
// ===============

$(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
Plugin.call($btn, 'toggle')
e.preventDefault()
})
$(document)
.on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
var $btn = $(e.target).closest('.btn')
Plugin.call($btn, 'toggle')
if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) {
// Prevent double click on radios, and the double selections (so cancellation) on checkboxes
e.preventDefault()
// The target component still receive the focus
if ($btn.is('input,button')) $btn.trigger('focus')
else $btn.find('input:visible,button:visible').first().trigger('focus')
}
})
.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))
})

}(jQuery);
Loading

0 comments on commit 036b2f5

Please sign in to comment.