mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 16:57:14 -06:00
33 lines
660 B
JavaScript
33 lines
660 B
JavaScript
define([
|
|
'lodash-src'
|
|
],
|
|
function () {
|
|
'use strict';
|
|
|
|
var _ = window._;
|
|
|
|
/*
|
|
Mixins :)
|
|
*/
|
|
_.mixin({
|
|
move: function (array, fromIndex, toIndex) {
|
|
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
|
|
return array;
|
|
},
|
|
// If variable is value, then return alt. If variable is anything else, return value;
|
|
toggle: function (variable, value, alt) {
|
|
return variable === value ? alt : value;
|
|
},
|
|
toggleInOut: function(array,value) {
|
|
if(_.includes(array,value)) {
|
|
array = _.without(array,value);
|
|
} else {
|
|
array.push(value);
|
|
}
|
|
return array;
|
|
}
|
|
});
|
|
|
|
return _;
|
|
});
|