Skip to content

Commit

Permalink
Use a filter function instead of string concatonation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rashid Khan committed Mar 1, 2016
1 parent 8992535 commit a7074da
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
7 changes: 0 additions & 7 deletions src/ui/public/utils/escape_attr.js

This file was deleted.

3 changes: 1 addition & 2 deletions src/ui/public/vislib/lib/dispatch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import d3 from 'd3';
import _ from 'lodash';
import $ from 'jquery';
import escapeAttr from 'ui/utils/escape_attr';
import SimpleEmitter from 'ui/utils/SimpleEmitter';
import VislibComponentsTooltipProvider from 'ui/vislib/components/Tooltip';
export default function DispatchClass(Private) {
Expand Down Expand Up @@ -231,7 +230,7 @@ export default function DispatchClass(Private) {
Dispatch.prototype.highlightLegend = function (element) {
var label = this.getAttribute('data-label');
if (!label) return;
$('[data-label]', element.parentNode).not('[data-label="' + escapeAttr(label) + '"]').css('opacity', 0.5);
$('[data-label]', element.parentNode).not(function (els, el) { return $(el).data('label') !== label;}).css('opacity', 0.5);

This comment has been minimized.

Copy link
@repocho

repocho Mar 5, 2016

Contributor

@rashidkpc You have inverted the functionality. Double not (not-filter and not label).
Then the hovered element is fade-out instead of other elements.
I'm going to revert this functionality to the original behavior in this PR #6346, but keeping the function for filtering.

};

/**
Expand Down
3 changes: 1 addition & 2 deletions src/ui/public/visualize/visualize_legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import _ from 'lodash';
import html from 'ui/visualize/visualize_legend.html';
import $ from 'jquery';
import d3 from 'd3';
import escapeAttr from 'ui/utils/escape_attr';
import findByParam from 'ui/utils/find_by_param';
import VislibLibDataProvider from 'ui/vislib/lib/data';
import VislibComponentsColorColorProvider from 'ui/vislib/components/color/color';
Expand Down Expand Up @@ -31,7 +30,7 @@ uiModules.get('kibana')
});

$scope.highlightSeries = function (label) {
$('[data-label]', $elem.siblings()).not('[data-label="' + escapeAttr(label) + '"]').css('opacity', 0.5);
$('[data-label]', $elem.siblings()).not(function (els, el) { return $(el).data('label') !== label;}).css('opacity', 0.5);
};

$scope.unhighlightSeries = function () {
Expand Down

0 comments on commit a7074da

Please sign in to comment.