Skip to content

Commit

Permalink
pass in raw DOM element, not jquery collection
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed May 19, 2017
1 parent 600ca38 commit 78bcc79
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/core_plugins/tile_map/public/maps_visualization.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'ui/vislib';
import 'plugins/kbn_vislib_vis_types/controls/vislib_basic_options';
import MapsVisTypeMapsRenderbotProvider from './maps_renderbot';
import $ from 'jquery';

export function MapsVisualizationProvider(Private) {

const MapsRenderbot = Private(MapsVisTypeMapsRenderbotProvider);

class MapsVisController {
constructor(el) {
this.el = el;
this.el = $(el);
}

render(vis, esResponse) {
Expand Down
6 changes: 4 additions & 2 deletions src/ui/public/vis/vis_types/angular_vis_type.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { VisTypeProvider } from 'ui/vis/vis_types';
import $ from 'jquery';


export function AngularVisTypeProvider(Private, $compile, $rootScope) {
const VisType = Private(VisTypeProvider);

class AngularVisController {
constructor(el) {
this.el = el;
constructor(domeElement) {
this.el = $(domeElement);
}

render(vis, esResponse) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/vis/vis_types/react_vis_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function ReactVisTypeProvider(Private) {

class ReactVisController {
constructor(el) {
this.el = el[0];
this.el = el;
}

render(vis, visData) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/vis/vis_types/vislib_vis_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function VislibVisTypeProvider(Private) {

class VislibVisController {
constructor(el) {
this.el = el[0];
this.el = el;
}

render(vis, esResponse) {
Expand Down
27 changes: 17 additions & 10 deletions src/ui/public/visualize/visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import visualizationTemplate from 'ui/visualize/visualization.html';
import 'angular-sanitize';




uiModules
.get('kibana/directive', ['ngSanitize'])
.directive('visualization', function (Notifier, SavedVis, indexPatterns, Private, config, $timeout) {
Expand All @@ -25,16 +27,11 @@ uiModules

$scope.showSpyPanel = $scope.vis && $scope.vis.showSpyPanel || false;

function getter(selector) {
return function () {
const $sel = $el.find(selector);
if ($sel.size()) return $sel;
};
}

const getVisEl = getter('.visualize-chart');
const getVisContainer = getter('.vis-container');
const getSpyContainer = getter('.visualize-spy-container');
//todo: lets make this a simple function call.
const getVisEl = jQueryGetter('.visualize-chart');
const getVisContainer = jQueryGetter('.vis-container');
const getSpyContainer = jQueryGetter('.visualize-spy-container');

// Show no results message when isZeroHits is true and it requires search
$scope.showNoResultsMessage = function () {
Expand Down Expand Up @@ -105,7 +102,9 @@ uiModules
});

const Visualization = $scope.vis.type.visualization;
const visualization = new Visualization(getVisEl());

//todo: make this not a jquery element
const visualization = new Visualization(getVisEl()[0]);

const renderFunction = _.debounce(() => {
visualization.render($scope.vis, $scope.visData)
Expand All @@ -125,6 +124,14 @@ uiModules
$scope.$on('$destroy', () => {
visualization.destroy();
});


function jQueryGetter(selector) {
return function () {
const $sel = $el.find(selector);
if ($sel.size()) return $sel;
};
}
}
};
});

0 comments on commit 78bcc79

Please sign in to comment.