Security: Fixes javascript security warnings in old vendored libs (#50382)

This commit is contained in:
Torkel Ödegaard 2022-06-08 13:55:08 +02:00 committed by GitHub
parent 58a783c0e4
commit 74608d6480
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3500 additions and 3493 deletions

View File

@ -18,7 +18,7 @@
* ========================================================== */ * ========================================================== */
!function ($) { !function($) {
"use strict"; // jshint ;_; "use strict"; // jshint ;_;
@ -26,22 +26,22 @@
/* CSS TRANSITION SUPPORT (http://www.modernizr.com/) /* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
* ======================================================= */ * ======================================================= */
$(function () { $(function() {
$.support.transition = (function () { $.support.transition = (function() {
var transitionEnd = (function () { var transitionEnd = (function() {
var el = document.createElement('bootstrap') var el = document.createElement('bootstrap')
, transEndEventNames = { , transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd' 'WebkitTransition': 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend' , 'MozTransition': 'transitionend'
, 'OTransition' : 'oTransitionEnd otransitionend' , 'OTransition': 'oTransitionEnd otransitionend'
, 'transition' : 'transitionend' , 'transition': 'transitionend'
} }
, name , name
for (name in transEndEventNames){ for (name in transEndEventNames) {
if (el.style[name] !== undefined) { if (el.style[name] !== undefined) {
return transEndEventNames[name] return transEndEventNames[name]
} }
@ -77,11 +77,11 @@
* ========================================================== */ * ========================================================== */
!function ($) { !function($) {
"use strict"; // jshint ;_; "use strict"; // jshint ;_;
/* ============================================================ /* ============================================================
* bootstrap-dropdown.js v2.3.2 * bootstrap-dropdown.js v2.3.2
* http://getbootstrap.com/2.3.2/javascript.html#dropdowns * http://getbootstrap.com/2.3.2/javascript.html#dropdowns
* ============================================================ * ============================================================
@ -105,9 +105,9 @@
* ========================= */ * ========================= */
var toggle = '[data-toggle=dropdown]' var toggle = '[data-toggle=dropdown]'
, Dropdown = function (element) { , Dropdown = function(element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle) var $el = $(element).on('click.dropdown.data-api', this.toggle)
$('html').on('click.dropdown.data-api', function () { $('html').on('click.dropdown.data-api', function() {
$el.parent().removeClass('open') $el.parent().removeClass('open')
}) })
} }
@ -116,7 +116,7 @@
constructor: Dropdown constructor: Dropdown
, toggle: function (e) { , toggle: function(e) {
var $this = $(this) var $this = $(this)
, $parent , $parent
, isActive , isActive
@ -142,7 +142,7 @@
return false return false
} }
, keydown: function (e) { , keydown: function(e) {
var $this var $this
, $items , $items
, $active , $active
@ -187,7 +187,7 @@
function clearMenus() { function clearMenus() {
$('.dropdown-backdrop').remove() $('.dropdown-backdrop').remove()
$(toggle).each(function () { $(toggle).each(function() {
getParent($(this)).removeClass('open') getParent($(this)).removeClass('open')
}) })
} }
@ -202,7 +202,7 @@
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
} }
$parent = selector && $(selector) $parent = selector && $.find(selector)
if (!$parent || !$parent.length) $parent = $this.parent() if (!$parent || !$parent.length) $parent = $this.parent()
@ -215,8 +215,8 @@
var old = $.fn.dropdown var old = $.fn.dropdown
$.fn.dropdown = function (option) { $.fn.dropdown = function(option) {
return this.each(function () { return this.each(function() {
var $this = $(this) var $this = $(this)
, data = $this.data('dropdown') , data = $this.data('dropdown')
if (!data) $this.data('dropdown', (data = new Dropdown(this))) if (!data) $this.data('dropdown', (data = new Dropdown(this)))
@ -230,7 +230,7 @@
/* DROPDOWN NO CONFLICT /* DROPDOWN NO CONFLICT
* ==================== */ * ==================== */
$.fn.dropdown.noConflict = function () { $.fn.dropdown.noConflict = function() {
$.fn.dropdown = old $.fn.dropdown = old
return this return this
} }
@ -241,9 +241,9 @@
$(document) $(document)
.on('click.dropdown.data-api', clearMenus) .on('click.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.dropdown.data-api', '.dropdown form', function(e) { e.stopPropagation() })
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle) .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) .on('keydown.dropdown.data-api', toggle + ', [role=menu]', Dropdown.prototype.keydown)
}(window.jQuery); }(window.jQuery);
/* ========================================================= /* =========================================================
@ -266,7 +266,7 @@
* ========================================================= */ * ========================================================= */
!function ($) { !function($) {
"use strict"; // jshint ;_; "use strict"; // jshint ;_;
@ -274,7 +274,7 @@
/* MODAL CLASS DEFINITION /* MODAL CLASS DEFINITION
* ====================== */ * ====================== */
var Modal = function (element, options) { var Modal = function(element, options) {
this.options = options this.options = options
this.$element = $(element) this.$element = $(element)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
@ -285,11 +285,11 @@
constructor: Modal constructor: Modal
, toggle: function () { , toggle: function() {
return this[!this.isShown ? 'show' : 'hide']() return this[!this.isShown ? 'show' : 'hide']()
} }
, show: function () { , show: function() {
var that = this var that = this
, e = $.Event('show') , e = $.Event('show')
@ -301,7 +301,7 @@
this.escape() this.escape()
this.backdrop(function () { this.backdrop(function() {
var transition = $.support.transition && that.$element.hasClass('fade') var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) { if (!that.$element.parent().length) {
@ -321,13 +321,13 @@
that.enforceFocus() that.enforceFocus()
transition ? transition ?
that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : that.$element.one($.support.transition.end, function() { that.$element.focus().trigger('shown') }) :
that.$element.focus().trigger('shown') that.$element.focus().trigger('shown')
}) })
} }
, hide: function (e) { , hide: function(e) {
e && e.preventDefault() e && e.preventDefault()
var that = this var that = this
@ -353,19 +353,19 @@
this.hideModal() this.hideModal()
} }
, enforceFocus: function () { , enforceFocus: function() {
var that = this var that = this
$(document).on('focusin.modal', function (e) { $(document).on('focusin.modal', function(e) {
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
that.$element.focus() that.$element.focus()
} }
}) })
} }
, escape: function () { , escape: function() {
var that = this var that = this
if (this.isShown && this.options.keyboard) { if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.modal', function ( e ) { this.$element.on('keyup.dismiss.modal', function(e) {
e.which == 27 && that.hide() e.which == 27 && that.hide()
}) })
} else if (!this.isShown) { } else if (!this.isShown) {
@ -373,34 +373,34 @@
} }
} }
, hideWithTransition: function () { , hideWithTransition: function() {
var that = this var that = this
, timeout = setTimeout(function () { , timeout = setTimeout(function() {
that.$element.off($.support.transition.end) that.$element.off($.support.transition.end)
that.hideModal() that.hideModal()
}, 500) }, 500)
this.$element.one($.support.transition.end, function () { this.$element.one($.support.transition.end, function() {
clearTimeout(timeout) clearTimeout(timeout)
that.hideModal() that.hideModal()
}) })
} }
, hideModal: function () { , hideModal: function() {
var that = this var that = this
this.$element.hide() this.$element.hide()
this.backdrop(function () { this.backdrop(function() {
that.removeBackdrop() that.removeBackdrop()
that.$element.trigger('hidden') that.$element.trigger('hidden')
}) })
} }
, removeBackdrop: function () { , removeBackdrop: function() {
this.$backdrop && this.$backdrop.remove() this.$backdrop && this.$backdrop.remove()
this.$backdrop = null this.$backdrop = null
} }
, backdrop: function (callback) { , backdrop: function(callback) {
var that = this var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : '' , animate = this.$element.hasClass('fade') ? 'fade' : ''
@ -429,7 +429,7 @@
} else if (!this.isShown && this.$backdrop) { } else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in') this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')? $.support.transition && this.$element.hasClass('fade') ?
this.$backdrop.one($.support.transition.end, callback) : this.$backdrop.one($.support.transition.end, callback) :
callback() callback()
@ -445,8 +445,8 @@
var old = $.fn.modal var old = $.fn.modal
$.fn.modal = function (option) { $.fn.modal = function(option) {
return this.each(function () { return this.each(function() {
var $this = $(this) var $this = $(this)
, data = $this.data('modal') , data = $this.data('modal')
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option) , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
@ -468,7 +468,7 @@
/* MODAL NO CONFLICT /* MODAL NO CONFLICT
* ================= */ * ================= */
$.fn.modal.noConflict = function () { $.fn.modal.noConflict = function() {
$.fn.modal = old $.fn.modal = old
return this return this
} }
@ -477,17 +477,17 @@
/* MODAL DATA-API /* MODAL DATA-API
* ============== */ * ============== */
$(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { $(document).on('click.modal.data-api', '[data-toggle="modal"]', function(e) {
var $this = $(this) var $this = $(this)
, href = $this.attr('href') , href = $this.attr('href')
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 , $target = $.find($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data()) , option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault() e.preventDefault()
$target $target
.modal(option) .modal(option)
.one('hide', function () { .one('hide', function() {
$this.focus() $this.focus()
}) })
}) })
@ -514,7 +514,7 @@
* ========================================================== */ * ========================================================== */
!function ($) { !function($) {
"use strict"; // jshint ;_; "use strict"; // jshint ;_;
@ -522,7 +522,7 @@
/* TOOLTIP PUBLIC CLASS DEFINITION /* TOOLTIP PUBLIC CLASS DEFINITION
* =============================== */ * =============================== */
var Tooltip = function (element, options) { var Tooltip = function(element, options) {
this.init('tooltip', element, options) this.init('tooltip', element, options)
} }
@ -530,7 +530,7 @@
constructor: Tooltip constructor: Tooltip
, init: function (type, element, options) { , init: function(type, element, options) {
var eventIn var eventIn
, eventOut , eventOut
, triggers , triggers
@ -561,7 +561,7 @@
this.fixTitle() this.fixTitle()
} }
, getOptions: function (options) { , getOptions: function(options) {
options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options) options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') { if (options.delay && typeof options.delay == 'number') {
@ -574,12 +574,12 @@
return options return options
} }
, enter: function (e) { , enter: function(e) {
var defaults = $.fn[this.type].defaults var defaults = $.fn[this.type].defaults
, options = {} , options = {}
, self , self
this._options && $.each(this._options, function (key, value) { this._options && $.each(this._options, function(key, value) {
if (defaults[key] != value) options[key] = value if (defaults[key] != value) options[key] = value
}, this) }, this)
@ -594,7 +594,7 @@
}, self.options.delay.show) }, self.options.delay.show)
} }
, leave: function (e) { , leave: function(e) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type) var self = $(e.currentTarget)[this.type](this._options).data(this.type)
if (this.timeout) clearTimeout(this.timeout) if (this.timeout) clearTimeout(this.timeout)
@ -606,7 +606,7 @@
}, self.options.delay.hide) }, self.options.delay.hide)
} }
, show: function () { , show: function() {
var $tip var $tip
, pos , pos
, actualWidth , actualWidth
@ -633,7 +633,11 @@
.detach() .detach()
.css({ top: 0, left: 0, display: 'block' }) .css({ top: 0, left: 0, display: 'block' })
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) if (this.options.container) {
$tip.appendTo($.find(this.options.container));
} else {
$tip.insertAfter(this.$element)
}
pos = this.getPosition() pos = this.getPosition()
@ -642,48 +646,48 @@
switch (placement) { switch (placement) {
case 'bottom': case 'bottom':
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2} tp = { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 }
break break
case 'top': case 'top':
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2} tp = { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 }
break break
case 'left': case 'left':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth} tp = { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth }
break break
case 'right': case 'right':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width} tp = { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
break break
// extend placements (top) // extend placements (top)
case 'topLeft': case 'topLeft':
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .10)}; tp = { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .10) };
break; break;
case 'topRight': case 'topRight':
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .90)}; tp = { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - (actualWidth * .90) };
break; break;
// extend placements (right) // extend placements (right)
case 'rightTop': case 'rightTop':
tp = {top: pos.top + pos.height / 2 - (actualHeight *.10), left: pos.left + pos.width}; tp = { top: pos.top + pos.height / 2 - (actualHeight * .10), left: pos.left + pos.width };
break; break;
case 'rightBottom': case 'rightBottom':
tp = {top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left + pos.width}; tp = { top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left + pos.width };
break; break;
// extend placements (bottom) // extend placements (bottom)
case 'bottomLeft': case 'bottomLeft':
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .10)}; tp = { top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .10) };
break; break;
case 'bottomRight': case 'bottomRight':
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .90)}; tp = { top: pos.top + pos.height, left: pos.left + pos.width / 2 - (actualWidth * .90) };
break; break;
// extend placements (left) // extend placements (left)
case 'leftTop': case 'leftTop':
tp = {top: pos.top + pos.height / 2 - (actualHeight *.10), left: pos.left - actualWidth}; tp = { top: pos.top + pos.height / 2 - (actualHeight * .10), left: pos.left - actualWidth };
break; break;
case 'leftBottom': case 'leftBottom':
tp = {top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left - actualWidth}; tp = { top: pos.top + pos.height / 2 - (actualHeight * .90), left: pos.left - actualWidth };
break; break;
@ -694,7 +698,7 @@
} }
} }
, applyPlacement: function(offset, placement){ , applyPlacement: function(offset, placement) {
var $tip = this.tip() var $tip = this.tip()
, width = $tip[0].offsetWidth , width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight , height = $tip[0].offsetHeight
@ -719,7 +723,7 @@
if (placement == 'bottom' || placement == 'top') { if (placement == 'bottom' || placement == 'top') {
delta = 0 delta = 0
if (offset.left < 0){ if (offset.left < 0) {
delta = offset.left * -2 delta = offset.left * -2
offset.left = 0 offset.left = 0
$tip.offset(offset) $tip.offset(offset)
@ -735,21 +739,22 @@
if (replace) $tip.offset(offset) if (replace) $tip.offset(offset)
} }
, replaceArrow: function(delta, dimension, position){ , replaceArrow: function(delta, dimension, position) {
this this
.arrow() .arrow()
.css(position, delta ? (50 * (1 - delta / dimension) + "%") : '') .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
} }
, setContent: function () { , setContent: function() {
var $tip = this.tip() var $tip = this.tip()
, title = this.getTitle() , title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) //$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
$tip.find('.tooltip-inner').text(title)
$tip.removeClass('fade in top bottom left right') $tip.removeClass('fade in top bottom left right')
} }
, hide: function () { , hide: function() {
var that = this var that = this
, $tip = this.tip() , $tip = this.tip()
, e = $.Event('hide') , e = $.Event('hide')
@ -760,11 +765,11 @@
$tip.removeClass('in') $tip.removeClass('in')
function removeWithAnimation() { function removeWithAnimation() {
var timeout = setTimeout(function () { var timeout = setTimeout(function() {
$tip.off($.support.transition.end).detach() $tip.off($.support.transition.end).detach()
}, 500) }, 500)
$tip.one($.support.transition.end, function () { $tip.one($.support.transition.end, function() {
clearTimeout(timeout) clearTimeout(timeout)
$tip.detach() $tip.detach()
}) })
@ -779,18 +784,18 @@
return this return this
} }
, fixTitle: function () { , fixTitle: function() {
var $e = this.$element var $e = this.$element
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '') $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
} }
} }
, hasContent: function () { , hasContent: function() {
return this.getTitle() return this.getTitle()
} }
, getPosition: function () { , getPosition: function() {
var el = this.$element[0] var el = this.$element[0]
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
width: el.offsetWidth width: el.offsetWidth
@ -798,7 +803,7 @@
}, this.$element.offset()) }, this.$element.offset())
} }
, getTitle: function () { , getTitle: function() {
var title var title
, $e = this.$element , $e = this.$element
, o = this.options , o = this.options
@ -809,15 +814,15 @@
return title return title
} }
, tip: function () { , tip: function() {
return this.$tip = this.$tip || $(this.options.template) return this.$tip = this.$tip || $(this.options.template)
} }
, arrow: function(){ , arrow: function() {
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
} }
, validate: function () { , validate: function() {
if (!this.$element[0].parentNode) { if (!this.$element[0].parentNode) {
this.hide() this.hide()
this.$element = null this.$element = null
@ -825,24 +830,24 @@
} }
} }
, enable: function () { , enable: function() {
this.enabled = true this.enabled = true
} }
, disable: function () { , disable: function() {
this.enabled = false this.enabled = false
} }
, toggleEnabled: function () { , toggleEnabled: function() {
this.enabled = !this.enabled this.enabled = !this.enabled
} }
, toggle: function (e) { , toggle: function(e) {
var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
self.tip().hasClass('in') ? self.hide() : self.show() self.tip().hasClass('in') ? self.hide() : self.show()
} }
, destroy: function () { , destroy: function() {
this.hide().$element.off('.' + this.type).removeData(this.type) this.hide().$element.off('.' + this.type).removeData(this.type)
} }
@ -854,8 +859,8 @@
var old = $.fn.tooltip var old = $.fn.tooltip
$.fn.tooltip = function ( option ) { $.fn.tooltip = function(option) {
return this.each(function () { return this.each(function() {
var $this = $(this) var $this = $(this)
, data = $this.data('tooltip') , data = $this.data('tooltip')
, options = typeof option == 'object' && option , options = typeof option == 'object' && option
@ -882,7 +887,7 @@
/* TOOLTIP NO CONFLICT /* TOOLTIP NO CONFLICT
* =================== */ * =================== */
$.fn.tooltip.noConflict = function () { $.fn.tooltip.noConflict = function() {
$.fn.tooltip = old $.fn.tooltip = old
return this return this
} }
@ -909,7 +914,7 @@
* ======================================================== */ * ======================================================== */
!function ($) { !function($) {
"use strict"; // jshint ;_; "use strict"; // jshint ;_;
@ -917,7 +922,7 @@
/* TAB CLASS DEFINITION /* TAB CLASS DEFINITION
* ==================== */ * ==================== */
var Tab = function (element) { var Tab = function(element) {
this.element = $(element) this.element = $(element)
} }
@ -925,7 +930,7 @@
constructor: Tab constructor: Tab
, show: function () { , show: function() {
var $this = this.element var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)') , $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target') , selector = $this.attr('data-target')
@ -938,7 +943,7 @@
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
} }
if ( $this.parent('li').hasClass('active') ) return if ($this.parent('li').hasClass('active')) return
previous = $ul.find('.active:last a')[0] previous = $ul.find('.active:last a')[0]
@ -950,10 +955,10 @@
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
$target = $(selector) $target = $.find(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: 'shown'
, relatedTarget: previous , relatedTarget: previous
@ -961,7 +966,7 @@
}) })
} }
, activate: function ( element, container, callback) { , activate: function(element, container, callback) {
var $active = container.find('> .active') var $active = container.find('> .active')
, transition = callback , transition = callback
&& $.support.transition && $.support.transition
@ -982,7 +987,7 @@
element.removeClass('fade') element.removeClass('fade')
} }
if ( element.parent('.dropdown-menu') ) { if (element.parent('.dropdown-menu')) {
element.closest('li.dropdown').addClass('active') element.closest('li.dropdown').addClass('active')
} }
@ -1003,8 +1008,8 @@
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') , data = $this.data('tab')
if (!data) $this.data('tab', (data = new Tab(this))) if (!data) $this.data('tab', (data = new Tab(this)))
@ -1018,7 +1023,7 @@
/* TAB NO CONFLICT /* TAB NO CONFLICT
* =============== */ * =============== */
$.fn.tab.noConflict = function () { $.fn.tab.noConflict = function() {
$.fn.tab = old $.fn.tab = old
return this return this
} }
@ -1027,7 +1032,7 @@
/* 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).tab('show') $(this).tab('show')
}) })
@ -1052,7 +1057,7 @@
* ============================================================ */ * ============================================================ */
!function($){ !function($) {
"use strict"; // jshint ;_; "use strict"; // jshint ;_;
@ -1060,7 +1065,7 @@
/* TYPEAHEAD PUBLIC CLASS DEFINITION /* TYPEAHEAD PUBLIC CLASS DEFINITION
* ================================= */ * ================================= */
var Typeahead = function (element, options) { var Typeahead = function(element, options) {
this.$element = $(element) this.$element = $(element)
this.options = $.extend({}, $.fn.typeahead.defaults, options) this.options = $.extend({}, $.fn.typeahead.defaults, options)
this.matcher = this.options.matcher || this.matcher this.matcher = this.options.matcher || this.matcher
@ -1077,7 +1082,7 @@
constructor: Typeahead constructor: Typeahead
, select: function () { , select: function() {
// CHANGE (rashidkpc) If nothing is selected, use existing value // CHANGE (rashidkpc) If nothing is selected, use existing value
var val = this.$menu.find('.active').attr('data-value') || this.$element.val(); var val = this.$menu.find('.active').attr('data-value') || this.$element.val();
this.$element this.$element
@ -1086,11 +1091,11 @@
return this.hide() return this.hide()
} }
, updater: function (item) { , updater: function(item) {
return item return item
} }
, show: function () { , show: function() {
var pos = $.extend({}, this.$element.position(), { var pos = $.extend({}, this.$element.position(), {
height: this.$element[0].offsetHeight height: this.$element[0].offsetHeight
}) })
@ -1107,13 +1112,13 @@
return this return this
} }
, hide: function () { , hide: function() {
this.$menu.hide() this.$menu.hide()
this.shown = false this.shown = false
return this return this
} }
, lookup: function (event) { , lookup: function(event) {
var items var items
this.query = this.$element.val() this.query = this.$element.val()
@ -1127,10 +1132,10 @@
return items ? this.process(items) : this return items ? this.process(items) : this
} }
, process: function (items) { , process: function(items) {
var that = this var that = this
items = $.grep(items, function (item) { items = $.grep(items, function(item) {
return that.matcher(item) return that.matcher(item)
}) })
@ -1143,11 +1148,11 @@
return this.render(items.slice(0, this.options.items)).show() return this.render(items.slice(0, this.options.items)).show()
} }
, matcher: function (item) { , matcher: function(item) {
return ~item.toLowerCase().indexOf(this.query.toLowerCase()) return ~item.toLowerCase().indexOf(this.query.toLowerCase())
} }
, sorter: function (items) { , sorter: function(items) {
var beginswith = [] var beginswith = []
, caseSensitive = [] , caseSensitive = []
, caseInsensitive = [] , caseInsensitive = []
@ -1162,20 +1167,20 @@
return beginswith.concat(caseSensitive, caseInsensitive) return beginswith.concat(caseSensitive, caseInsensitive)
} }
, highlighter: function (item) { , highlighter: function(item) {
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&') var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
if (!query) { if (!query) {
return item; return item;
} }
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) { return item.replace(new RegExp('(' + query + ')', 'ig'), function($1, match) {
return '<strong>' + match + '</strong>' return '<strong>' + match + '</strong>'
}); });
} }
, render: function (items) { , render: function(items) {
var that = this var that = this
items = $(items).map(function (i, item) { items = $(items).map(function(i, item) {
i = $(that.options.item).attr('data-value', item) i = $(that.options.item).attr('data-value', item)
i.find('a').html(that.highlighter(item)) i.find('a').html(that.highlighter(item))
return i[0] return i[0]
@ -1187,7 +1192,7 @@
return this return this
} }
, next: function (event) { , next: function(event) {
var active = this.$menu.find('.active').removeClass('active') var active = this.$menu.find('.active').removeClass('active')
, next = active.next() , next = active.next()
@ -1198,7 +1203,7 @@
next.addClass('active') next.addClass('active')
} }
, prev: function (event) { , prev: function(event) {
var active = this.$menu.find('.active').removeClass('active') var active = this.$menu.find('.active').removeClass('active')
, prev = active.prev() , prev = active.prev()
@ -1209,7 +1214,7 @@
prev.addClass('active') prev.addClass('active')
} }
, listen: function () { , listen: function() {
this.$element this.$element
.on('focus', $.proxy(this.focus, this)) .on('focus', $.proxy(this.focus, this))
.on('blur', $.proxy(this.blur, this)) .on('blur', $.proxy(this.blur, this))
@ -1226,7 +1231,7 @@
.on('mouseleave', 'li', $.proxy(this.mouseleave, this)) .on('mouseleave', 'li', $.proxy(this.mouseleave, this))
}, },
destroy: function () { destroy: function() {
this.$element.off().removeData('typeahead'); this.$element.off().removeData('typeahead');
this.$menu.off(); this.$menu.off();
} }
@ -1240,7 +1245,7 @@
return isSupported return isSupported
} }
, move: function (e) { , move: function(e) {
if (!this.shown) return if (!this.shown) return
// grafana change, shift+left parenthesis // grafana change, shift+left parenthesis
@ -1248,7 +1253,7 @@
return; return;
} }
switch(e.keyCode) { switch (e.keyCode) {
case 9: // tab case 9: // tab
case 13: // enter case 13: // enter
case 27: // escape case 27: // escape
@ -1269,18 +1274,18 @@
e.stopPropagation() e.stopPropagation()
} }
, keydown: function (e) { , keydown: function(e) {
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27,57]) this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40, 38, 9, 13, 27, 57])
this.move(e) this.move(e)
} }
, keypress: function (e) { , keypress: function(e) {
if (this.suppressKeyPressRepeat) return if (this.suppressKeyPressRepeat) return
this.move(e) this.move(e)
} }
, keyup: function (e) { , keyup: function(e) {
switch(e.keyCode) { switch (e.keyCode) {
case 40: // down arrow case 40: // down arrow
case 38: // up arrow case 38: // up arrow
case 16: // shift case 16: // shift
@ -1303,7 +1308,7 @@
this.lookup(); this.lookup();
} }
if(e.keyCode === 13 && typeof this.$menu.find('.active').attr('data-value') === 'undefined') { if (e.keyCode === 13 && typeof this.$menu.find('.active').attr('data-value') === 'undefined') {
// CHANGE (rashidkpc). Enter was hit, nothing was selected from typeahead, submit form // CHANGE (rashidkpc). Enter was hit, nothing was selected from typeahead, submit form
this.$element.submit(); this.$element.submit();
} else { } else {
@ -1313,29 +1318,29 @@
} }
, focus: function (e) { , focus: function(e) {
this.focused = true this.focused = true
} }
, blur: function (e) { , blur: function(e) {
this.focused = false this.focused = false
if (!this.mousedover && this.shown) this.hide() if (!this.mousedover && this.shown) this.hide()
} }
, click: function (e) { , click: function(e) {
e.stopPropagation() e.stopPropagation()
e.preventDefault() e.preventDefault()
this.select() this.select()
this.$element.focus() this.$element.focus()
} }
, mouseenter: function (e) { , mouseenter: function(e) {
this.mousedover = true this.mousedover = true
this.$menu.find('.active').removeClass('active') this.$menu.find('.active').removeClass('active')
$(e.currentTarget).addClass('active') $(e.currentTarget).addClass('active')
} }
, mouseleave: function (e) { , mouseleave: function(e) {
this.mousedover = false this.mousedover = false
if (!this.focused && this.shown) this.hide() if (!this.focused && this.shown) this.hide()
} }
@ -1348,8 +1353,8 @@
var old = $.fn.typeahead var old = $.fn.typeahead
$.fn.typeahead = function (option) { $.fn.typeahead = function(option) {
return this.each(function () { return this.each(function() {
var $this = $(this) var $this = $(this)
, data = $this.data('typeahead') , data = $this.data('typeahead')
, options = typeof option == 'object' && option , options = typeof option == 'object' && option
@ -1372,7 +1377,7 @@
/* TYPEAHEAD NO CONFLICT /* TYPEAHEAD NO CONFLICT
* =================== */ * =================== */
$.fn.typeahead.noConflict = function () { $.fn.typeahead.noConflict = function() {
$.fn.typeahead = old $.fn.typeahead = old
return this return this
} }
@ -1381,7 +1386,7 @@
/* TYPEAHEAD DATA-API /* TYPEAHEAD DATA-API
* ================== */ * ================== */
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) { $(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function(e) {
var $this = $(this) var $this = $(this)
if ($this.data('typeahead')) return if ($this.data('typeahead')) return
$this.typeahead($this.data()) $this.typeahead($this.data())
@ -1408,7 +1413,7 @@
* ========================================================== */ * ========================================================== */
!function ($) { !function($) {
"use strict"; // jshint ;_; "use strict"; // jshint ;_;
@ -1416,16 +1421,16 @@
/* AFFIX CLASS DEFINITION /* AFFIX CLASS DEFINITION
* ====================== */ * ====================== */
var Affix = function (element, options) { var Affix = function(element, options) {
this.options = $.extend({}, $.fn.affix.defaults, options) this.options = $.extend({}, $.fn.affix.defaults, options)
this.$window = $(window) this.$window = $(window)
.on('scroll.affix.data-api', $.proxy(this.checkPosition, this)) .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
.on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this)) .on('click.affix.data-api', $.proxy(function() { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
this.$element = $(element) this.$element = $(element)
this.checkPosition() this.checkPosition()
} }
Affix.prototype.checkPosition = function () { Affix.prototype.checkPosition = function() {
if (!this.$element.is(':visible')) return if (!this.$element.is(':visible')) return
var scrollHeight = $(document).height() var scrollHeight = $(document).height()
@ -1460,8 +1465,8 @@
var old = $.fn.affix var old = $.fn.affix
$.fn.affix = function (option) { $.fn.affix = function(option) {
return this.each(function () { return this.each(function() {
var $this = $(this) var $this = $(this)
, data = $this.data('affix') , data = $this.data('affix')
, options = typeof option == 'object' && option , options = typeof option == 'object' && option
@ -1480,7 +1485,7 @@
/* AFFIX NO CONFLICT /* AFFIX NO CONFLICT
* ================= */ * ================= */
$.fn.affix.noConflict = function () { $.fn.affix.noConflict = function() {
$.fn.affix = old $.fn.affix = old
return this return this
} }
@ -1489,8 +1494,8 @@
/* AFFIX DATA-API /* AFFIX DATA-API
* ============== */ * ============== */
$(window).on('load', function () { $(window).on('load', function() {
$('[data-spy="affix"]').each(function () { $('[data-spy="affix"]').each(function() {
var $spy = $(this) var $spy = $(this)
, data = $spy.data() , data = $spy.data()

View File

@ -29,7 +29,7 @@ Licensed under the MIT license.
* V. 1.1: Fix error handling so e.g. parsing an empty string does * V. 1.1: Fix error handling so e.g. parsing an empty string does
* produce a color rather than just crashing. * produce a color rather than just crashing.
*/ */
(function($){$.color={};$.color.make=function(r,g,b,a){var o={};o.r=r||0;o.g=g||0;o.b=b||0;o.a=a!=null?a:1;o.add=function(c,d){for(var i=0;i<c.length;++i)o[c.charAt(i)]+=d;return o.normalize()};o.scale=function(c,f){for(var i=0;i<c.length;++i)o[c.charAt(i)]*=f;return o.normalize()};o.toString=function(){if(o.a>=1){return"rgb("+[o.r,o.g,o.b].join(",")+")"}else{return"rgba("+[o.r,o.g,o.b,o.a].join(",")+")"}};o.normalize=function(){function clamp(min,value,max){return value<min?min:value>max?max:value}o.r=clamp(0,parseInt(o.r),255);o.g=clamp(0,parseInt(o.g),255);o.b=clamp(0,parseInt(o.b),255);o.a=clamp(0,o.a,1);return o};o.clone=function(){return $.color.make(o.r,o.b,o.g,o.a)};return o.normalize()};$.color.extract=function(elem,css){var c;do{c=elem.css(css).toLowerCase();if(c!=""&&c!="transparent")break;elem=elem.parent()}while(elem.length&&!$.nodeName(elem.get(0),"body"));if(c=="rgba(0, 0, 0, 0)")c="transparent";return $.color.parse(c)};$.color.parse=function(str){var res,m=$.color.make;if(res=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10));if(res=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10),parseFloat(res[4]));if(res=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55);if(res=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55,parseFloat(res[4]));if(res=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))return m(parseInt(res[1],16),parseInt(res[2],16),parseInt(res[3],16));if(res=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))return m(parseInt(res[1]+res[1],16),parseInt(res[2]+res[2],16),parseInt(res[3]+res[3],16));var name=$.trim(str).toLowerCase();if(name=="transparent")return m(255,255,255,0);else{res=lookupColors[name]||[0,0,0];return m(res[0],res[1],res[2])}};var lookupColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery); (function($) { $.color = {}; $.color.make = function(r, g, b, a) { var o = {}; o.r = r || 0; o.g = g || 0; o.b = b || 0; o.a = a != null ? a : 1; o.add = function(c, d) { for (var i = 0; i < c.length; ++i)o[c.charAt(i)] += d; return o.normalize() }; o.scale = function(c, f) { for (var i = 0; i < c.length; ++i)o[c.charAt(i)] *= f; return o.normalize() }; o.toString = function() { if (o.a >= 1) { return "rgb(" + [o.r, o.g, o.b].join(",") + ")" } else { return "rgba(" + [o.r, o.g, o.b, o.a].join(",") + ")" } }; o.normalize = function() { function clamp(min, value, max) { return value < min ? min : value > max ? max : value } o.r = clamp(0, parseInt(o.r), 255); o.g = clamp(0, parseInt(o.g), 255); o.b = clamp(0, parseInt(o.b), 255); o.a = clamp(0, o.a, 1); return o }; o.clone = function() { return $.color.make(o.r, o.b, o.g, o.a) }; return o.normalize() }; $.color.extract = function(elem, css) { var c; do { c = elem.css(css).toLowerCase(); if (c != "" && c != "transparent") break; elem = elem.parent() } while (elem.length && !$.nodeName(elem.get(0), "body")); if (c == "rgba(0, 0, 0, 0)") c = "transparent"; return $.color.parse(c) }; $.color.parse = function(str) { var res, m = $.color.make; if (res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str)) return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10)); if (res = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str)) return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4])); if (res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str)) return m(parseFloat(res[1]) * 2.55, parseFloat(res[2]) * 2.55, parseFloat(res[3]) * 2.55); if (res = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str)) return m(parseFloat(res[1]) * 2.55, parseFloat(res[2]) * 2.55, parseFloat(res[3]) * 2.55, parseFloat(res[4])); if (res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str)) return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16)); if (res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str)) return m(parseInt(res[1] + res[1], 16), parseInt(res[2] + res[2], 16), parseInt(res[3] + res[3], 16)); var name = $.trim(str).toLowerCase(); if (name == "transparent") return m(255, 255, 255, 0); else { res = lookupColors[name] || [0, 0, 0]; return m(res[0], res[1], res[2]) } }; var lookupColors = { aqua: [0, 255, 255], azure: [240, 255, 255], beige: [245, 245, 220], black: [0, 0, 0], blue: [0, 0, 255], brown: [165, 42, 42], cyan: [0, 255, 255], darkblue: [0, 0, 139], darkcyan: [0, 139, 139], darkgrey: [169, 169, 169], darkgreen: [0, 100, 0], darkkhaki: [189, 183, 107], darkmagenta: [139, 0, 139], darkolivegreen: [85, 107, 47], darkorange: [255, 140, 0], darkorchid: [153, 50, 204], darkred: [139, 0, 0], darksalmon: [233, 150, 122], darkviolet: [148, 0, 211], fuchsia: [255, 0, 255], gold: [255, 215, 0], green: [0, 128, 0], indigo: [75, 0, 130], khaki: [240, 230, 140], lightblue: [173, 216, 230], lightcyan: [224, 255, 255], lightgreen: [144, 238, 144], lightgrey: [211, 211, 211], lightpink: [255, 182, 193], lightyellow: [255, 255, 224], lime: [0, 255, 0], magenta: [255, 0, 255], maroon: [128, 0, 0], navy: [0, 0, 128], olive: [128, 128, 0], orange: [255, 165, 0], pink: [255, 192, 203], purple: [128, 0, 128], violet: [128, 0, 128], red: [255, 0, 0], silver: [192, 192, 192], white: [255, 255, 255], yellow: [255, 255, 0] } })(jQuery);
// the actual Flot code // the actual Flot code
(function($) { (function($) {
@ -48,7 +48,7 @@ Licensed under the MIT license.
$.fn.detach = function() { $.fn.detach = function() {
return this.each(function() { return this.each(function() {
if (this.parentNode) { if (this.parentNode) {
this.parentNode.removeChild( this ); this.parentNode.removeChild(this);
} }
}); });
}; };
@ -616,7 +616,7 @@ Licensed under the MIT license.
mouseActiveRadius: 10 // how far the mouse can be away to activate an item mouseActiveRadius: 10 // how far the mouse can be away to activate an item
}, },
interaction: { interaction: {
redrawOverlayInterval: 1000/60 // time between updates, -1 means in same flow redrawOverlayInterval: 1000 / 60 // time between updates, -1 means in same flow
}, },
hooks: {} hooks: {}
}, },
@ -625,7 +625,7 @@ Licensed under the MIT license.
eventHolder = null, // jQuery object that events should be bound to eventHolder = null, // jQuery object that events should be bound to
ctx = null, octx = null, ctx = null, octx = null,
xaxes = [], yaxes = [], xaxes = [], yaxes = [],
plotOffset = { left: 0, right: 0, top: 0, bottom: 0}, plotOffset = { left: 0, right: 0, top: 0, bottom: 0 },
plotWidth = 0, plotHeight = 0, plotWidth = 0, plotHeight = 0,
hooks = { hooks = {
processOptions: [], processOptions: [],
@ -649,28 +649,28 @@ Licensed under the MIT license.
plot.getPlaceholder = function() { return placeholder; }; plot.getPlaceholder = function() { return placeholder; };
plot.getCanvas = function() { return surface.element; }; plot.getCanvas = function() { return surface.element; };
plot.getPlotOffset = function() { return plotOffset; }; plot.getPlotOffset = function() { return plotOffset; };
plot.width = function () { return plotWidth; }; plot.width = function() { return plotWidth; };
plot.height = function () { return plotHeight; }; plot.height = function() { return plotHeight; };
plot.offset = function () { plot.offset = function() {
var o = eventHolder.offset(); var o = eventHolder.offset();
o.left += plotOffset.left; o.left += plotOffset.left;
o.top += plotOffset.top; o.top += plotOffset.top;
return o; return o;
}; };
plot.getData = function () { return series; }; plot.getData = function() { return series; };
plot.getAxes = function () { plot.getAxes = function() {
var res = {}, i; var res = {}, i;
$.each(xaxes.concat(yaxes), function (_, axis) { $.each(xaxes.concat(yaxes), function(_, axis) {
if (axis) if (axis)
res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis; res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis;
}); });
return res; return res;
}; };
plot.getXAxes = function () { return xaxes; }; plot.getXAxes = function() { return xaxes; };
plot.getYAxes = function () { return yaxes; }; plot.getYAxes = function() { return yaxes; };
plot.c2p = canvasToAxisCoords; plot.c2p = canvasToAxisCoords;
plot.p2c = axisToCanvasCoords; plot.p2c = axisToCanvasCoords;
plot.getOptions = function () { return options; }; plot.getOptions = function() { return options; };
plot.highlight = highlight; plot.highlight = highlight;
plot.unhighlight = unhighlight; plot.unhighlight = unhighlight;
plot.triggerRedrawOverlay = triggerRedrawOverlay; plot.triggerRedrawOverlay = triggerRedrawOverlay;
@ -681,7 +681,7 @@ Licensed under the MIT license.
}; };
}; };
plot.shutdown = shutdown; plot.shutdown = shutdown;
plot.destroy = function () { plot.destroy = function() {
shutdown(); shutdown();
placeholder.removeData("plot").empty(); placeholder.removeData("plot").empty();
@ -698,7 +698,7 @@ Licensed under the MIT license.
highlights = []; highlights = [];
plot = null; plot = null;
}; };
plot.resize = function () { plot.resize = function() {
var width = placeholder.width(), var width = placeholder.width(),
height = placeholder.height(); height = placeholder.height();
surface.resize(width, height); surface.resize(width, height);
@ -923,7 +923,7 @@ Licensed under the MIT license.
function allAxes() { function allAxes() {
// return flat array without annoying null entries // return flat array without annoying null entries
return $.grep(xaxes.concat(yaxes), function (a) { return a; }); return $.grep(xaxes.concat(yaxes), function(a) { return a; });
} }
function canvasToAxisCoords(pos) { function canvasToAxisCoords(pos) {
@ -1102,7 +1102,7 @@ Licensed under the MIT license.
axis.datamax = max; axis.datamax = max;
} }
$.each(allAxes(), function (_, axis) { $.each(allAxes(), function(_, axis) {
// init axis // init axis
axis.datamin = topSentry; axis.datamin = topSentry;
axis.datamax = bottomSentry; axis.datamax = bottomSentry;
@ -1113,7 +1113,7 @@ Licensed under the MIT license.
s = series[i]; s = series[i];
s.datapoints = { points: [] }; s.datapoints = { points: [] };
executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]); executeHooks(hooks.processRawData, [s, s.data, s.datapoints]);
} }
// first pass: clean and copy data // first pass: clean and copy data
@ -1213,7 +1213,7 @@ Licensed under the MIT license.
points[k + 1] = points[k - ps + 1] || 0; points[k + 1] = points[k - ps + 1] || 0;
// if series has null values, let's give the last !null value a nice step // if series has null values, let's give the last !null value a nice step
if(nullify) if (nullify)
points[k] = p[0]; points[k] = p[0];
// we've added a point, better reflect that // we've added a point, better reflect that
@ -1239,7 +1239,7 @@ Licensed under the MIT license.
} }
} }
executeHooks(hooks.processDatapoints, [ s, s.datapoints]); executeHooks(hooks.processDatapoints, [s, s.datapoints]);
} }
// second pass: find datamax/datamin for auto-scaling // second pass: find datamax/datamin for auto-scaling
@ -1306,7 +1306,7 @@ Licensed under the MIT license.
updateAxis(s.yaxis, ymin, ymax); updateAxis(s.yaxis, ymin, ymax);
} }
$.each(allAxes(), function (_, axis) { $.each(allAxes(), function(_, axis) {
if (axis.datamin == topSentry) if (axis.datamin == topSentry)
axis.datamin = null; axis.datamin = null;
if (axis.datamax == bottomSentry) if (axis.datamax == bottomSentry)
@ -1401,14 +1401,14 @@ Licensed under the MIT license.
// data point to canvas coordinate // data point to canvas coordinate
if (t == identity) // slight optimization if (t == identity) // slight optimization
axis.p2c = function (p) { return (p - m) * s; }; axis.p2c = function(p) { return (p - m) * s; };
else else
axis.p2c = function (p) { return (t(p) - m) * s; }; axis.p2c = function(p) { return (t(p) - m) * s; };
// canvas coordinate to data point // canvas coordinate to data point
if (!it) if (!it)
axis.c2p = function (c) { return m + c / s; }; axis.c2p = function(c) { return m + c / s; };
else else
axis.c2p = function (c) { return it(m + c / s); }; axis.c2p = function(c) { return it(m + c / s); };
} }
function measureTickLabels(axis) { function measureTickLabels(axis) {
@ -1555,7 +1555,7 @@ Licensed under the MIT license.
if (minMargin == null) { if (minMargin == null) {
minMargin = 0; minMargin = 0;
for (i = 0; i < series.length; ++i) for (i = 0; i < series.length; ++i)
minMargin = Math.max(minMargin, 2 * (series[i].points.radius + series[i].points.lineWidth/2)); minMargin = Math.max(minMargin, 2 * (series[i].points.radius + series[i].points.lineWidth / 2));
} }
var margins = { var margins = {
@ -1568,7 +1568,7 @@ Licensed under the MIT license.
// check axis labels, note we don't check the actual // check axis labels, note we don't check the actual
// labels but instead use the overall width/height to not // labels but instead use the overall width/height to not
// jump as much around with replots // jump as much around with replots
$.each(allAxes(), function (_, axis) { $.each(allAxes(), function(_, axis) {
if (axis.reserveSpace && axis.ticks && axis.ticks.length) { if (axis.reserveSpace && axis.ticks && axis.ticks.length) {
if (axis.direction === "x") { if (axis.direction === "x") {
margins.left = Math.max(margins.left, axis.labelWidth / 2); margins.left = Math.max(margins.left, axis.labelWidth / 2);
@ -1601,7 +1601,7 @@ Licensed under the MIT license.
// If the grid is visible, add its border width to the offset // If the grid is visible, add its border width to the offset
for (var a in plotOffset) { for (var a in plotOffset) {
if(typeof(options.grid.borderWidth) == "object") { if (typeof (options.grid.borderWidth) == "object") {
plotOffset[a] += showGrid ? options.grid.borderWidth[a] : 0; plotOffset[a] += showGrid ? options.grid.borderWidth[a] : 0;
} }
else { else {
@ -1609,7 +1609,7 @@ Licensed under the MIT license.
} }
} }
$.each(axes, function (_, axis) { $.each(axes, function(_, axis) {
var axisOpts = axis.options; var axisOpts = axis.options;
axis.show = axisOpts.show == null ? axis.used : axisOpts.show; axis.show = axisOpts.show == null ? axis.used : axisOpts.show;
axis.reserveSpace = axisOpts.reserveSpace == null ? axis.show : axisOpts.reserveSpace; axis.reserveSpace = axisOpts.reserveSpace == null ? axis.show : axisOpts.reserveSpace;
@ -1620,13 +1620,13 @@ Licensed under the MIT license.
if (showGrid) { if (showGrid) {
var allocatedAxes = $.grep(axes, function (axis) { var allocatedAxes = $.grep(axes, function(axis) {
return axis.show || axis.reserveSpace; return axis.show || axis.reserveSpace;
}); });
var snaped = false; var snaped = false;
for (var i = 0; i < 2; i++) { for (var i = 0; i < 2; i++) {
$.each(allocatedAxes, function (_, axis) { $.each(allocatedAxes, function(_, axis) {
// make the ticks // make the ticks
setupTickGeneration(axis); setupTickGeneration(axis);
setTicks(axis); setTicks(axis);
@ -1653,7 +1653,7 @@ Licensed under the MIT license.
// might stick out // might stick out
adjustLayoutForThingsStickingOut(); adjustLayoutForThingsStickingOut();
$.each(allocatedAxes, function (_, axis) { $.each(allocatedAxes, function(_, axis) {
allocateAxisBoxSecondPhase(axis); allocateAxisBoxSecondPhase(axis);
}); });
} }
@ -1663,7 +1663,7 @@ Licensed under the MIT license.
plotHeight = surface.height - plotOffset.bottom - plotOffset.top; plotHeight = surface.height - plotOffset.bottom - plotOffset.top;
// now we got the proper plot dimensions, we can compute the scaling // now we got the proper plot dimensions, we can compute the scaling
$.each(axes, function (_, axis) { $.each(axes, function(_, axis) {
setTransformationHelpers(axis); setTransformationHelpers(axis);
}); });
@ -1795,7 +1795,7 @@ Licensed under the MIT license.
if (!axis.tickGenerator) { if (!axis.tickGenerator) {
axis.tickGenerator = function (axis) { axis.tickGenerator = function(axis) {
var ticks = [], var ticks = [],
start = floorInBase(axis.min, axis.tickSize), start = floorInBase(axis.min, axis.tickSize),
@ -1812,7 +1812,7 @@ Licensed under the MIT license.
return ticks; return ticks;
}; };
axis.tickFormatter = function (value, axis) { axis.tickFormatter = function(value, axis) {
var factor = axis.tickDecimals ? Math.pow(10, axis.tickDecimals) : 1; var factor = axis.tickDecimals ? Math.pow(10, axis.tickDecimals) : 1;
var formatted = "" + Math.round(value * factor) / factor; var formatted = "" + Math.round(value * factor) / factor;
@ -1833,7 +1833,7 @@ Licensed under the MIT license.
} }
if ($.isFunction(opts.tickFormatter)) if ($.isFunction(opts.tickFormatter))
axis.tickFormatter = function (v, axis) { return "" + opts.tickFormatter(v, axis); }; axis.tickFormatter = function(v, axis) { return "" + opts.tickFormatter(v, axis); };
if (opts.alignTicksWithAxis != null) { if (opts.alignTicksWithAxis != null) {
var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1]; var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1];
@ -1847,7 +1847,7 @@ Licensed under the MIT license.
axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]); axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]);
} }
axis.tickGenerator = function (axis) { axis.tickGenerator = function(axis) {
// copy ticks, scaled to this axis // copy ticks, scaled to this axis
var ticks = [], v, i; var ticks = [], v, i;
for (i = 0; i < otherAxis.ticks.length; ++i) { for (i = 0; i < otherAxis.ticks.length; ++i) {
@ -2185,20 +2185,20 @@ Licensed under the MIT license.
// If either borderWidth or borderColor is an object, then draw the border // If either borderWidth or borderColor is an object, then draw the border
// line by line instead of as one rectangle // line by line instead of as one rectangle
bc = options.grid.borderColor; bc = options.grid.borderColor;
if(typeof bw == "object" || typeof bc == "object") { if (typeof bw == "object" || typeof bc == "object") {
if (typeof bw !== "object") { if (typeof bw !== "object") {
bw = {top: bw, right: bw, bottom: bw, left: bw}; bw = { top: bw, right: bw, bottom: bw, left: bw };
} }
if (typeof bc !== "object") { if (typeof bc !== "object") {
bc = {top: bc, right: bc, bottom: bc, left: bc}; bc = { top: bc, right: bc, bottom: bc, left: bc };
} }
if (bw.top > 0) { if (bw.top > 0) {
ctx.strokeStyle = bc.top; ctx.strokeStyle = bc.top;
ctx.lineWidth = bw.top; ctx.lineWidth = bw.top;
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(0 - bw.left, 0 - bw.top/2); ctx.moveTo(0 - bw.left, 0 - bw.top / 2);
ctx.lineTo(plotWidth, 0 - bw.top/2); ctx.lineTo(plotWidth, 0 - bw.top / 2);
ctx.stroke(); ctx.stroke();
} }
@ -2224,15 +2224,15 @@ Licensed under the MIT license.
ctx.strokeStyle = bc.left; ctx.strokeStyle = bc.left;
ctx.lineWidth = bw.left; ctx.lineWidth = bw.left;
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(0 - bw.left/2, plotHeight + bw.bottom); ctx.moveTo(0 - bw.left / 2, plotHeight + bw.bottom);
ctx.lineTo(0- bw.left/2, 0); ctx.lineTo(0 - bw.left / 2, 0);
ctx.stroke(); ctx.stroke();
} }
} }
else { else {
ctx.lineWidth = bw; ctx.lineWidth = bw;
ctx.strokeStyle = options.grid.borderColor; ctx.strokeStyle = options.grid.borderColor;
ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw); ctx.strokeRect(-bw / 2, -bw / 2, plotWidth + bw, plotHeight + bw);
} }
} }
@ -2241,7 +2241,7 @@ Licensed under the MIT license.
function drawAxisLabels() { function drawAxisLabels() {
$.each(allAxes(), function (_, axis) { $.each(allAxes(), function(_, axis) {
var box = axis.box, var box = axis.box,
legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis", legacyStyles = axis.direction + "Axis " + axis.direction + axis.n + "Axis",
layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles, layer = "flot-" + axis.direction + "-axis flot-" + axis.direction + axis.n + "-axis " + legacyStyles,
@ -2319,7 +2319,7 @@ Licensed under the MIT license.
var olddatapoints = datapoints.points var olddatapoints = datapoints.points
datapoints.points = abandonedPoints; datapoints.points = abandonedPoints;
series.points.radius = series.lines.lineWidth/2; series.points.radius = series.lines.lineWidth / 2;
// plot the orphan points with a radius of lineWidth/2 // plot the orphan points with a radius of lineWidth/2
drawSeriesPoints(series); drawSeriesPoints(series);
// reset old info // reset old info
@ -2575,10 +2575,10 @@ Licensed under the MIT license.
ctx.lineWidth = sw; ctx.lineWidth = sw;
ctx.strokeStyle = "rgba(0,0,0,0.1)"; ctx.strokeStyle = "rgba(0,0,0,0.1)";
// position shadow at angle from the mid of line // position shadow at angle from the mid of line
var angle = Math.PI/18; var angle = Math.PI / 18;
plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis); plotLine(series.datapoints, Math.sin(angle) * (lw / 2 + sw / 2), Math.cos(angle) * (lw / 2 + sw / 2), series.xaxis, series.yaxis);
ctx.lineWidth = sw/2; ctx.lineWidth = sw / 2;
plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis); plotLine(series.datapoints, Math.sin(angle) * (lw / 2 + sw / 4), Math.cos(angle) * (lw / 2 + sw / 4), series.xaxis, series.yaxis);
} }
ctx.lineWidth = lw; ctx.lineWidth = lw;
@ -2633,7 +2633,7 @@ Licensed under the MIT license.
// Doing the conditional here allows the shadow setting to still be // Doing the conditional here allows the shadow setting to still be
// optional even with a lineWidth of 0. // optional even with a lineWidth of 0.
if( lw == 0 ) if (lw == 0)
lw = 0.0001; lw = 0.0001;
if (lw > 0 && sw > 0) { if (lw > 0 && sw > 0) {
@ -2641,11 +2641,11 @@ Licensed under the MIT license.
var w = sw / 2; var w = sw / 2;
ctx.lineWidth = w; ctx.lineWidth = w;
ctx.strokeStyle = "rgba(0,0,0,0.1)"; ctx.strokeStyle = "rgba(0,0,0,0.1)";
plotPoints(series.datapoints, radius, null, w + w/2, true, plotPoints(series.datapoints, radius, null, w + w / 2, true,
series.xaxis, series.yaxis, symbol); series.xaxis, series.yaxis, symbol);
ctx.strokeStyle = "rgba(0,0,0,0.2)"; ctx.strokeStyle = "rgba(0,0,0,0.2)";
plotPoints(series.datapoints, radius, null, w/2, true, plotPoints(series.datapoints, radius, null, w / 2, true,
series.xaxis, series.yaxis, symbol); series.xaxis, series.yaxis, symbol);
} }
@ -2793,7 +2793,7 @@ Licensed under the MIT license.
barLeft = -series.bars.barWidth / 2; barLeft = -series.bars.barWidth / 2;
} }
var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null; var fillStyleCallback = series.bars.fill ? function(bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null;
plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, fillStyleCallback, series.xaxis, series.yaxis); plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, fillStyleCallback, series.xaxis, series.yaxis);
ctx.restore(); ctx.restore();
} }
@ -2815,7 +2815,7 @@ Licensed under the MIT license.
function insertLegend() { function insertLegend() {
if (options.legend.container != null) { if (options.legend.container != null) {
$(options.legend.container).html(""); $.find(options.legend.container).html("");
} else { } else {
placeholder.find(".legend").remove(); placeholder.find(".legend").remove();
} }
@ -2901,7 +2901,7 @@ Licensed under the MIT license.
pos += 'right:' + (m[0] + plotOffset.right) + 'px;'; pos += 'right:' + (m[0] + plotOffset.right) + 'px;';
else if (p.charAt(1) == "w") else if (p.charAt(1) == "w")
pos += 'left:' + (m[0] + plotOffset.left) + 'px;'; pos += 'left:' + (m[0] + plotOffset.left) + 'px;';
var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos +';') + '</div>').appendTo(placeholder); var legend = $('<div class="legend">' + table.replace('style="', 'style="position:absolute;' + pos + ';') + '</div>').appendTo(placeholder);
if (options.legend.backgroundOpacity != 0.0) { if (options.legend.backgroundOpacity != 0.0) {
// put in the transparent background // put in the transparent background
// separately to avoid blended labels and // separately to avoid blended labels and
@ -2917,7 +2917,7 @@ Licensed under the MIT license.
c = c.toString(); c = c.toString();
} }
var div = legend.children(); var div = legend.children();
$('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity); $('<div style="position:absolute;width:' + div.width() + 'px;height:' + div.height() + 'px;' + pos + 'background-color:' + c + ';"> </div>').prependTo(legend).css('opacity', options.legend.backgroundOpacity);
} }
} }
} }
@ -3020,10 +3020,12 @@ Licensed under the MIT license.
j = item[1]; j = item[1];
ps = series[i].datapoints.pointsize; ps = series[i].datapoints.pointsize;
return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps), return {
datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps),
dataIndex: j, dataIndex: j,
series: series[i], series: series[i],
seriesIndex: i }; seriesIndex: i
};
} }
return null; return null;
@ -3032,13 +3034,13 @@ Licensed under the MIT license.
function onMouseMove(e) { function onMouseMove(e) {
if (options.grid.hoverable) if (options.grid.hoverable)
triggerClickHoverEvent("plothover", e, triggerClickHoverEvent("plothover", e,
function (s) { return s["hoverable"] != false; }); function(s) { return s["hoverable"] != false; });
} }
function onMouseLeave(e) { function onMouseLeave(e) {
if (options.grid.hoverable) if (options.grid.hoverable)
triggerClickHoverEvent("plothover", e, triggerClickHoverEvent("plothover", e,
function (s) { return false; }); function(s) { return false; });
} }
function onClick(e) { function onClick(e) {
@ -3046,7 +3048,7 @@ Licensed under the MIT license.
return; return;
} }
triggerClickHoverEvent("plotclick", e, function (s) { return s["clickable"] != false; }); triggerClickHoverEvent("plotclick", e, function(s) { return s["clickable"] != false; });
} }
// grafana addon - added to support mobile devices click in plot // grafana addon - added to support mobile devices click in plot
@ -3056,7 +3058,7 @@ Licensed under the MIT license.
} }
if (!eventHolder.is(e.target) && eventHolder.has(e.target).length === 0) { if (!eventHolder.is(e.target) && eventHolder.has(e.target).length === 0) {
triggerClickHoverEvent("plotleave", e, function (s) { false; }); triggerClickHoverEvent("plotleave", e, function(s) { false; });
return; return;
} }
@ -3125,7 +3127,7 @@ Licensed under the MIT license.
highlight(item.series, item.datapoint, eventname); highlight(item.series, item.datapoint, eventname);
} }
placeholder.trigger(eventname, [ pos, item ]); placeholder.trigger(eventname, [pos, item]);
} }
function triggerRedrawOverlay() { function triggerRedrawOverlay() {
@ -3257,7 +3259,7 @@ Licensed under the MIT license.
octx.strokeStyle = highlightColor; octx.strokeStyle = highlightColor;
drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth, drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth,
function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); function() { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth);
} }
function getColorOrGradient(spec, bottom, top, defaultColor) { function getColorOrGradient(spec, bottom, top, defaultColor) {