1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924 |
- 'use strict';
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- define(['jquery', 'underscore', '../../lib/@waca/dashboard-common/dist/utils/EventChainLocal', '../../apiHelpers/SlotAPIHelper', './VisSelectionInfo', './VisTooltipInfo', '../../util/DashboardFormatter', '../interactions/lassoSelect/LassoController', '../../features/content/visualizationGesture/api/VisualizationGestureAPI', '../../lib/@waca/dashboard-common/dist/core/APIFactory'], function ($, _, EventChainLocal, SlotAPIHelper, VisSelectionInfo, VisTooltipInfo, Formatter, LassoController, VisualizationGestureAPI, APIFactory) {
- 'use strict';
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- var VisEventHandler = function () {
- function VisEventHandler(options) {
- _classCallCheck(this, VisEventHandler);
- this._init(options);
- }
- VisEventHandler.prototype._init = function _init(options) {
- this._oTimerOut = null;
- this._lastSelected = null;
- this._lastHighlighted = null;
- this._lastImpliedSelection = [];
- this.dashboard = options.dashboard;
- this.logger = options.logger;
- this._target = options.target;
- this._targetElement = this._target.getTargetElement();
- this._ownerWidget = options.ownerWidget;
- this.content = this._ownerWidget.content;
- this.state = this.content.getFeature('state');
- this.visualization = this.content.getFeature('Visualization');
- this._visAPI = options.visAPI;
- this._visController = this.content.getFeature('InteractivityController.deprecated');
- this._selector = this.content.getFeature('DataPointSelections');
- this._transaction = options.transaction;
- this._visActionHelper = this._visController ? this._visController.getActionHelper() : null;
-
- var panAndZoomEvents = [{
- 'key': 'mousedown',
- 'callback': this.onMouseDown.bind(this)
- }, {
- 'key': 'mouseup',
- 'callback': this.onMouseUp.bind(this)
- }, {
- 'key': 'mousewheel wheel',
- 'callback': this.onMouseWheel.bind(this)
- }, {
- 'key': 'touchstart',
- 'callback': this.onClickTapPanStart.bind(this)
- }, {
- 'key': 'touchend',
- 'callback': this.onPanEnd.bind(this)
- }, {
- 'key': 'touchmove',
- 'callback': this.onPanMove.bind(this)
- }, {
- 'key': 'transformstart',
- 'callback': this.onPinchStart.bind(this),
- 'hammer': true
- }, {
- 'key': 'transform',
- 'callback': this.onPinch.bind(this),
- 'hammer': true
- }, {
- 'key': 'transformend',
- 'callback': this.onPinchEnd.bind(this),
- 'hammer': true
- }];
- var hoverEvents = [{
- 'key': 'mousemove touchmove',
- 'callback': this.onHover.bind(this)
- }, {
- 'key': 'mouseleave touchend',
- 'callback': this.onMouseLeave.bind(this)
- }];
- var clickEvents = [{
- 'key': 'contextmenu',
- 'callback': this.onClick.bind(this)
- }, {
- 'key': 'clicktap',
- 'callback': this.onClickTapPanStart.bind(this),
- 'data': { allowPropagationDefaultAction: true }
- }, {
- 'key': 'hold',
- 'callback': this.onHold.bind(this),
- 'hammer': true
- }];
- var keyEvents = [{
- 'key': 'keydown',
- 'callback': this.onKeyDown.bind(this)
- }];
- this._visControlEvents = [];
- var interactivitySettings = this._visAPI.getInteractivitySettings();
- if (!interactivitySettings.isClickDisabled) {
- this._visControlEvents.push.apply(this._visControlEvents, clickEvents);
- this._visControlEvents.push.apply(this._visControlEvents, keyEvents);
- }
- if (!interactivitySettings.isPanAndZoomDisabled) {
- this._visControlEvents.push.apply(this._visControlEvents, panAndZoomEvents);
- }
- if (!interactivitySettings.isHoverDisabled) {
- this._visControlEvents.push.apply(this._visControlEvents, hoverEvents);
- }
- this.serializeInteractivity = !!interactivitySettings.serialize;
- this._edgeSelection = !!options.edgeSelection;
- this._registerEvents();
- this.lassoCtrl = new LassoController({
- targetElement: this._targetElement,
- cordinateResolver: this._resolveCoordinates,
- isDragging: this._isDragging.bind(this),
- dashboard: this.dashboard
- });
-
-
- if (this._ownerWidget.contentFeatureLoader) {
-
- this._ownerWidget.contentFeatureLoader.registerFeature(this._ownerWidget.id, 'VisualizationGesture', this);
- }
- };
- VisEventHandler.prototype.getAPI = function getAPI() {
- if (!this.api) {
- this.api = APIFactory.createAPI(this, [VisualizationGestureAPI]);
- }
- return this.api;
- };
-
- VisEventHandler.prototype.isReadyToInteract = function isReadyToInteract() {
- if (this.serializeInteractivity) {
- return this.state.getStatus() === this.state.STATUS.RENDERED;
- }
-
- return true;
- };
-
- VisEventHandler.prototype.restoreState = function restoreState() {
- if (this._target.canRestore()) {
- this._target.restore(this._visAPI.getPropertyValue('interactivityState'));
- }
- };
-
- VisEventHandler.prototype.remove = function remove() {
- var _this = this;
- $(document).off('mouseup', this._onMouseUpHandler);
- $(document).off('touchend', this._onTouchEndHandler);
-
- if (this._targetElement) {
- this._visControlEvents.forEach(function (eventInfo) {
- if (eventInfo.hammer) {
- _this._targetElement.hammer().off(eventInfo.key, eventInfo.callback);
- } else {
- _this._targetElement.off(eventInfo.key, null, eventInfo.callback);
- }
- });
- }
-
- if (this._target) {
- this._target.remove();
- this._target = null;
- }
- this._lastHoverEvent = null;
- this._tooltipItems = null;
- this._lastHighlighted = null;
- this.content = null;
- if (this.lassoCtrl) {
- this._endLassoSelection();
- this.lassoCtrl.remove();
- this.lassoCtrl = null;
- }
- };
-
- VisEventHandler.prototype._registerEvents = function _registerEvents() {
- var _this2 = this;
- this._onMouseUpHandler = this._onDocumentMouseUp.bind(this);
- $(document).on('mouseup', this._onMouseUpHandler);
- this._onTouchEndHandler = this._onDocumentTouchEnd.bind(this);
- $(document).on('touchend', this._onTouchEndHandler);
- if (this._targetElement) {
- this._visControlEvents.forEach(function (eventInfo) {
- if (eventInfo.hammer) {
- _this2._targetElement.hammer(eventInfo.hammerOption).on(eventInfo.key, eventInfo.callback);
- } else {
- if (eventInfo.data) {
- _this2._targetElement.on(eventInfo.key, null, eventInfo.data, eventInfo.callback);
- } else {
- _this2._targetElement.on(eventInfo.key, null, eventInfo.callback);
- }
- }
- });
- }
- };
-
- VisEventHandler.prototype.onHover = function onHover(event) {
- if (!event.clientX) {
- this._resolveCoordinates(event);
- }
-
- if (this._isDragging(event) && !this.lassoCtrl.isLassoMode()) {
- if (this._target.canZoom() && this._target.pan) {
- this._target.pan(event);
- }
-
-
- this._skipSelection = true;
- } else {
- this._skipSelection = !this.isReadyToInteract();
- this._skipHoverover = this._skipSelection;
- }
- var items = this._target && this._target.getEventTargets ? this._target.getEventTargets(event) : [];
- if (this._stopHoverover) {
-
- if (this._targetElement) {
- if (items && items.length > 0) {
- this._targetElement.addClass('cursor-pointer');
- } else {
- this._targetElement.removeClass('cursor-pointer');
- }
- }
- return;
- }
-
- if (this._mouseDown) {
- this._clearHoverTimer();
- this._visActionHelper.hideToolbarActions();
- }
- this._handleImpliedSelections(items, event.ctrlKey || event.metaKey, false);
- this._handleHighlights(items);
- this._handleTooltips(event, items);
- this._triggerWidgetEvent('visevent:onmove', event, this._target, items, { mouseDown: this._mouseDown, onHold: this._onHold });
- };
-
- VisEventHandler.prototype.onMouseLeave = function onMouseLeave(event) {
- if (!event.clientX) {
- this._resolveCoordinates(event);
- }
- var items = this._target && this._target.getEventTargets ? this._target.getEventTargets(event) : [];
- this._lastHoverEvent = event;
- this._tooltipItems = items;
- if (this._tooltipItems && this._tooltipItems.length > 0) {
- this._clearHoverTimer();
- } else if (this._lastTooltip) {
- this._lastTooltip = null;
- this._clearHoverTimer();
- this._oTimerOut = setTimeout(this._handleMouseleaveTimeout.bind(this), 500);
- }
- };
- VisEventHandler.prototype._handleMouseleaveTimeout = function _handleMouseleaveTimeout() {
- if (!this._stopHoverover) {
- this._visActionHelper.hideToolbarActions();
- }
- };
-
- VisEventHandler.prototype.onClickTap = function onClickTap(event) {
- return event && event.type === 'tap' ? this.onTap(event) : this.onClick(event);
- };
-
- VisEventHandler.prototype.onClick = function onClick(event) {
- if (this._skipSelection) {
- this.setEventLocalProperty(event, 'preventDefaultContextBar', true);
- } else {
- var _getOnClickData2 = this._getOnClickData(event),
- shouldHandle = _getOnClickData2.shouldHandle,
- items = _getOnClickData2.items,
- isMultiSelect = _getOnClickData2.isMultiSelect;
- if (shouldHandle) {
- if (items) {
- if (items.length > 0) {
- this._handleSelections(event, items, { isMultiSelect: isMultiSelect });
- event.preventDefault();
- this.setEventLocalProperty(event, 'preventDefaultContextBar', true);
- } else {
-
- this._clearHoverTimer();
- this._clearAll(event);
- }
- }
- }
- }
- };
-
- VisEventHandler.prototype.onKeyDown = function onKeyDown(event) {
- if (this._target) {
- var result = this._target.processKeyDown(event);
- if (result) {
- var items = this._target.getEventTargets(event);
- if (items && items.length > 0) {
- this._handleSelections(event, items, { forceRightClick: true });
- event.preventDefault();
- this.setEventLocalProperty(event, 'preventDefaultContextBar', true);
- }
- }
- }
- };
-
- VisEventHandler.prototype._getOnClickData = function _getOnClickData(event) {
- var items = this._target && this._target.getEventTargets ? this._target.getEventTargets(event) : [];
- var isRightClick = event.type === 'contextmenu';
- var ignoreCase = !isRightClick && this.lassoCtrl.isLassoMode();
- var isMultiSelect = !ignoreCase && items && items.length > 1;
- return { shouldHandle: !ignoreCase, items: items, isMultiSelect: isMultiSelect };
- };
-
- VisEventHandler.prototype.onTap = function onTap(event) {
- this._resolveCoordinates(event);
- if (this._skipSelection) {
- this.setEventLocalProperty(event, 'preventDefaultContextBar', true);
- } else {
- var items = this._target && this._target.getEventTargets ? this._target.getEventTargets(event) : [];
- if (items) {
- if (items.length > 0) {
- var bSelected = this._isItemsSelected(items);
- var bHighlighted = this._isItemsHighlighed(items);
- this.setEventLocalProperty(event, 'preventDefaultContextBar', true);
-
-
- if (bSelected || bHighlighted) {
-
- this._handleSelections(event, items, { forceCtrlClick: true });
- } else {
- this._handleHighlights(items);
-
- this._handleTooltips(event, items, true);
- }
- } else {
- this._clearAll(event);
- }
- }
- }
- };
-
- VisEventHandler.prototype.onHold = function onHold(event) {
- this._resolveCoordinates(event);
- var isMultiSelect = false;
- this._onHold = true;
- var items = void 0;
- if (this.lassoCtrl.isLassoMode()) {
- items = this._target && this._target.getTargetsByCords ? this._target.getTargetsByCords(this.lassoCtrl.getCoordinates(), false) : [];
- isMultiSelect = true;
- } else {
- items = this._target && this._target.getEventTargets ? this._target.getEventTargets(event) : [];
- }
-
- this._handleSelections(event, items, { forceRightClick: true, isMultiSelect: isMultiSelect });
- };
-
- VisEventHandler.prototype._storeInteractivityState = function _storeInteractivityState(state) {
-
- this._ownerWidget.updateVisProperties({
- id: 'interactivityState',
- value: state
- }, {
- silent: true
- });
- };
-
- VisEventHandler.prototype.onMouseWheel = function onMouseWheel(event) {
- if (this._target.canZoom() && this._target.zoom) {
- this._target.zoomStart(event);
- this._target.zoom(event);
- var state = this._target.zoomEnd(event);
- if (state) {
- this._storeInteractivityState(state);
- }
- event.preventDefault();
- }
- };
-
- VisEventHandler.prototype.onPinchStart = function onPinchStart(event) {
- if (this._target.canZoom() && this._target.zoom) {
- this._resolveCoordinates(event);
-
-
- this._target.panEnd(event);
- this._target.zoomStart(event);
- }
- };
-
- VisEventHandler.prototype.onPinch = function onPinch(event) {
- if (this._target.canZoom() && this._target.zoom) {
- this._resolveCoordinates(event);
- this._target.zoom(event);
-
- (event.gesture || event.originalEvent || event).preventDefault();
- }
- };
-
- VisEventHandler.prototype.onPinchEnd = function onPinchEnd(event) {
- if (this._target.canZoom() && this._target.zoom) {
- this._resolveCoordinates(event);
- var state = this._target.zoomEnd(event);
- if (state) {
- this._storeInteractivityState(state);
- }
- }
- };
-
- VisEventHandler.prototype.onClickTapPanStart = function onClickTapPanStart(event) {
-
- return event.type === 'touchstart' ? this.onPanStart(event) : this.onClickTap(event);
- };
-
- VisEventHandler.prototype.onPanStart = function onPanStart(event) {
- if (this._canPan(event)) {
- this._resolveCoordinates(event);
- this._target.panStart(event);
-
- }
- };
-
- VisEventHandler.prototype.onPanEnd = function onPanEnd(event) {
- this._resolveCoordinates(event);
- var state = this._target.panEnd(event);
- if (state) {
- this._storeInteractivityState(state);
- }
-
- };
-
- VisEventHandler.prototype.onPanMove = function onPanMove(event) {
- var originalEvent = event.gesture || event.originalEvent || event;
- var isZoom = originalEvent.touches && event.originalEvent.touches.length === 2;
- if (this._canPan(event)) {
- this._resolveCoordinates(event);
- this._target.pan(event);
-
- originalEvent.preventDefault();
- } else if (isZoom) {
-
-
-
- originalEvent.preventDefault();
- }
- };
-
- VisEventHandler.prototype.onMouseDown = function onMouseDown(event) {
- var _getOnClickData3 = this._getOnClickData(event),
- shouldHandle = _getOnClickData3.shouldHandle,
- items = _getOnClickData3.items;
- if (shouldHandle && !!items && items.length > 0) {
-
-
- this.setEventLocalProperty(event, 'preventWidgetDeselect', true);
- }
- this._skipSelection = false;
- this._mouseDown = {
- X: event.pageX,
- Y: event.pageY
- };
- if (!this.lassoCtrl.isLassoMode() && this._target.canZoom && this._target.canZoom() && this._target.panStart) {
- this._target.panStart(event);
- }
- };
-
- VisEventHandler.prototype.onMouseUp = function onMouseUp(event) {
- if (this._target.canZoom && this._target.canZoom() && this._target.panEnd) {
- var state = this._target.panEnd(event);
- if (state) {
- this._storeInteractivityState(state);
- }
- }
- };
- VisEventHandler.prototype.getEdgeSelection = function getEdgeSelection() {
- return this._edgeSelection;
- };
-
- VisEventHandler.prototype._onDocumentMouseUp = function _onDocumentMouseUp() {
- this._mouseDown = false;
- };
-
- VisEventHandler.prototype._onDocumentTouchEnd = function _onDocumentTouchEnd() {
- if (this._onHold) {
- this._onHold = false;
- }
- };
-
- VisEventHandler.prototype._canPan = function _canPan(event) {
- return this._target.canZoom && this._target.canZoom() && event.originalEvent.touches.length === 1 && !this.lassoCtrl.isLassoMode();
- };
-
- VisEventHandler.prototype._resolveCoordinates = function _resolveCoordinates(event) {
- var touches = null;
- if (event.targetTouches) {
- touches = event.targetTouches;
- } else if (event.originalEvent && event.originalEvent.targetTouches) {
- touches = event.originalEvent.targetTouches;
- } else if (event.gesture) {
- touches = event.gesture.touches;
- }
- var isTouch = touches && touches.length;
- if (isTouch) {
- var coords = touches && touches.length ? touches[0] : null;
-
- if (coords && coords.clientX !== undefined) {
- event.isTouch = true;
- event.clientX = coords.clientX;
- event.clientY = coords.clientY;
- event.pageX = coords.pageX;
- event.pageY = coords.pageY;
- }
- } else {
- if (event.gesture && event.gesture.center) {
- event.clientX = event.clientX || event.gesture.center.clientX;
- event.clientY = event.clientY || event.gesture.center.clientY;
- event.pageX = event.pageX || event.gesture.center.pageX;
- event.pageY = event.pageY || event.gesture.center.pageY;
- } else if (event.originalEvent) {
- event.clientX = event.clientX || event.originalEvent.clientX || event.originalEvent.pageX;
- event.clientY = event.clientY || event.originalEvent.clientY || event.originalEvent.pageY;
- event.pageX = event.pageX || event.originalEvent.pageX;
- event.pageY = event.pageY || event.originalEvent.pageY;
- }
- }
- };
-
- VisEventHandler.prototype._getBoundsInfoFromEvent = function _getBoundsInfoFromEvent(event) {
- return {
- top: event.clientY,
- height: 1,
- left: event.clientX - 10,
- width: 20,
- parent: document.body
- };
- };
-
- VisEventHandler.prototype.setEventLocalProperty = function setEventLocalProperty(event, name, value) {
- var eventChainLocal = new EventChainLocal(event);
- eventChainLocal.setProperty(name, value);
- };
-
- VisEventHandler.prototype._isDragging = function _isDragging(event) {
- if (event.type === 'touchmove' && this.lassoCtrl.isLassoMode()) {
- return event.originalEvent.touches.length === 1;
- }
- return this._mouseDown && (Math.abs(this._mouseDown.X - event.pageX) > 5 || Math.abs(this._mouseDown.Y - event.pageY) > 5);
- };
-
- VisEventHandler.prototype._clearHoverTimer = function _clearHoverTimer() {
- if (this._oTimerOut !== null) {
- clearTimeout(this._oTimerOut);
- this._oTimerOut = null;
- }
- };
-
- VisEventHandler.prototype._clearLastHighlight = function _clearLastHighlight() {
- if (this._lastHighlighted) {
-
- this._clearDecorations(this._lastHighlighted, 'highlight');
- }
- this._lastHighlighted = undefined;
- this._skipHoverover = false;
- };
-
- VisEventHandler.prototype._clearDecorations = function _clearDecorations(items, name) {
- if (this._target && this._target.decorateTarget) {
- this._target.decorateTarget(items, name, false);
- }
- };
-
- VisEventHandler.prototype._compareItems = function _compareItems(items1, items2) {
- var keys1 = _.pluck(items1, 'key');
- var keys2 = _.pluck(items2, 'key');
- return _.difference(keys1, keys2).length === 0 && _.difference(keys2, keys1).length === 0;
- };
-
- VisEventHandler.prototype._isItemsHighlighed = function _isItemsHighlighed(items) {
- return this._compareItems(this._lastHighlighted, items);
- };
-
- VisEventHandler.prototype._isItemsImpliedSelected = function _isItemsImpliedSelected(items) {
- return _.find(this._lastImpliedSelection, function (impliedSelection) {
- return impliedSelection === items;
- });
- };
-
- VisEventHandler.prototype._handleTooltips = function _handleTooltips(event, items, forceTooltips) {
- var _this3 = this;
- var prevTooltip = this._lastTooltip ? this._lastTooltip : [];
- this._lastHoverEvent = event;
- this._tooltipItems = items;
- if (this._tooltipItems && this._tooltipItems.length > 0) {
-
- this._targetElement.addClass('cursor-pointer');
- if (!this._compareItems(prevTooltip, this._tooltipItems)) {
- this._clearHoverTimer();
- this._oTimerOut = setTimeout(function () {
- _this3._clearHoverTimer();
- var itemExist = _this3._tooltipItems && _this3._tooltipItems.length > 0;
- var allowHover = !_this3._stopHoverover && !_this3._skipHoverover;
- var force = forceTooltips;
- if (itemExist && (allowHover || force)) {
- var aSelectionInfo = _this3._getDataPayload(_this3._tooltipItems, VisTooltipInfo);
- if (aSelectionInfo) {
- var infoShown = _this3._showSelectionInfo(aSelectionInfo, _this3._lastHoverEvent, false, true, _this3._drillOnly, false, {
- isHover: true
- });
- if (infoShown) {
- _this3._lastTooltip = _this3._tooltipItems;
- }
- _this3._lastHoverEvent = null;
- _this3._tooltipItems = null;
- }
- }
- }, 500);
- }
- } else {
- this._targetElement.removeClass('cursor-pointer');
- if (this._lastTooltip) {
- this._lastTooltip = null;
- this._clearHoverTimer();
- this._oTimerOut = setTimeout(function () {
- _this3._clearHoverTimer();
- if (!_this3._stopHoverover) {
- _this3._visActionHelper.hideToolbarActions();
- }
- }, 500);
- }
- }
- };
-
- VisEventHandler.prototype._handleHighlights = function _handleHighlights(items, bAppend) {
- var prevHighlight = this._lastHighlighted ? this._lastHighlighted : [];
- if (bAppend) {
- var nonSelected = _.filter(this._lastHighlighted, function (obj) {
- return obj.source && obj.source.getDecoration && !obj.source.getDecoration('selected');
- });
- items.push.apply(items, nonSelected);
- }
- if (items && items.length > 0) {
- if (!this._isItemsHighlighed(items)) {
- if (this._target && this._target.decorateTarget) {
-
- this._clearLastHighlight();
- if (this._target.decorateTarget(items, 'highlight')) {
-
- this._lastHighlighted = items;
- }
- }
- }
- } else if (prevHighlight.length > 0) {
-
- this._clearLastHighlight();
- }
-
- if (!this._compareItems(prevHighlight, this._lastHighlighted) && this._target.completeDecorations) {
- this._target.completeDecorations();
- }
- };
-
- VisEventHandler.prototype._handleSelections = function _handleSelections(event, items, options) {
- var bCtrlClick = options.forceCtrlClick || event.ctrlKey || event.metaKey;
- var bRightClick = options.forceRightClick || event.type === 'contextmenu';
- this._skipHoverover = false;
- var resolved = null;
- if (bRightClick) {
-
- this._skipHoverover = true;
-
- var oNewSelection = this._getDataPayload(items, VisTooltipInfo);
- resolved = this._resolveItems(items);
- if (resolved.length > 0) {
- var _options = items[0].selectionContext ? {
- slots: items[0].selectionContext.slots,
- mapIndex: items[0].selectionContext.mapIndex,
- actions: items[0].selectionContext.actions
- } : {};
- _options.area = items[0].area;
- _options.isAreaSelected = items[0].isAreaSelected;
- var includeApplyFilter = void 0,
- noFilters = void 0,
- noDrillthrough = void 0;
- if (items[0].onlyGlobalActions) {
-
- includeApplyFilter = false;
- noFilters = true;
- noDrillthrough = true;
- } else {
- includeApplyFilter = bRightClick;
- noFilters = false;
- noDrillthrough = false;
- }
- this._showSelectionInfo(oNewSelection, event, includeApplyFilter, noFilters, undefined, noDrillthrough, _options);
- this._triggerWidgetEvent('visevent:select', event, this._target, items, { selectionInfo: oNewSelection, append: bCtrlClick, lasso: options.isMultiSelect });
- this._handleHighlights(items, bCtrlClick);
- return this._select(resolved, true, bCtrlClick, true, items[0].isEdgeSelect, options.isMultiSelect);
- } else {
-
- this._titleActions(event, items);
- }
- } else {
- resolved = this._resolveItems(items);
- this._handleHighlights(items);
- if (resolved.length > 0) {
- var isSelected = this._isSelected(resolved, items[0].isEdgeSelect);
-
-
- var doSelect = !isSelected;
- var doAppend = bCtrlClick || this.lassoCtrl.isLassoMode() && isSelected;
- var oSelectionInfo = this._getDataPayload(items);
- this._triggerWidgetEvent('visevent:select', event, this._target, items, { selectionInfo: oSelectionInfo, append: doAppend, lasso: options.isMultiSelect });
- return this._select(resolved, doSelect, doAppend, false, items[0].isEdgeSelect, options.isMultiSelect);
- } else if (items && items.length >= 1) {
- var type = items[0].type;
- switch (type) {
- case 'customdata':
- return this._handleCustomDataSelections(items, event);
- case 'itemclass':
- return this._handleImpliedSelections(items, bCtrlClick, true);
- case 'summary':
- return this._handleImpliedSelections(items, bCtrlClick, true);
- default:
- break;
- }
- }
- }
- };
- VisEventHandler.prototype._isSelectionsWithCustomData = function _isSelectionsWithCustomData(itemsArray) {
- var aResult = _.filter(itemsArray, function (item) {
- return item.type !== 'customdata';
- });
- return itemsArray.length > 0 && (!aResult || aResult.length === 0);
- };
-
- VisEventHandler.prototype._handleImpliedSelections = function _handleImpliedSelections(items, isMultiSelect, apply) {
- var prevImpliedSelection = this._lastImpliedSelection ? this._lastImpliedSelection : [];
- if (apply && items && items.length > 0) {
- if (!this._isItemsImpliedSelected(items)) {
-
- this._lastImpliedSelection.push(items);
- this._target.decorateTarget(items, 'implied_selection', apply, isMultiSelect);
- }
- } else if (prevImpliedSelection.length > 0 && !isMultiSelect) {
-
- this._lastImpliedSelection = [];
- this._clearDecorations(items, 'implied_selection');
- }
- };
- VisEventHandler.prototype._handleCustomDataSelections = function _handleCustomDataSelections(items, event) {
- this._triggerWidgetEvent('visevent:customdataselection', event, this._target, items);
- if (this._target && this._target.applyCustomDataSelection) {
- var currentSelectedIds = _.pluck(this._visAPI.getDecoratedCustomData('selected'), 'id');
- this._target.applyCustomDataSelection(_.filter(items, function (item) {
- return !_.contains(currentSelectedIds, item.key);
- }));
- }
- };
-
- VisEventHandler.prototype._resolveItems = function _resolveItems(items) {
- var _this4 = this;
- var resolved = [];
-
- _.each(items, function (item) {
- if (item.type === 'datapoint') {
- resolved = resolved.concat(_this4._resolveDataPointItem(item));
- } else if (item.type === 'item') {
- resolved = resolved.concat(_this4._resolveEdgeItem(item));
- }
- });
- return resolved;
- };
-
- VisEventHandler.prototype._processDataPointSelection = function _processDataPointSelection(selections, item) {
- var _this5 = this;
- var slots = this._getMappedSlotListByItem(item);
- _.each(item.values, function (rowdata, valueIndex) {
- var slot = item.slotAPIs ? item.slotAPIs[valueIndex] : slots[valueIndex];
- if (slot) {
- var valueSpans = 0;
- _.each(rowdata, function (value, itemInSlotIndex) {
- if (value === null) {
- value = Formatter.format(null);
- }
- var slotDataItem = _this5._getSlotDataItem(slot, item, itemInSlotIndex + valueSpans);
- if (value.span) {
-
-
- valueSpans += value.span - 1;
- }
- if (slotDataItem && ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object' || !SlotAPIHelper.isMultiMeasuresSeriesOrValueDataItem(slotDataItem))) {
- selections.addSelection(slot, slotDataItem, value, item.isEdgeSelect);
- }
- });
- }
- });
- };
- VisEventHandler.prototype._resolveDataPointItem = function _resolveDataPointItem(item) {
- var slots = this._getMappedSlotListByItem(item);
- var resolved = [];
- _.each(item.values, function (value, valueIndex) {
- var slot = item.slotAPIs ? item.slotAPIs[valueIndex] : slots[valueIndex];
- if (slot) {
- var dataItems = slot.getDataItemList();
- _.each(value, function (v, itemInSlotIndex) {
- var dataItem = dataItems[itemInSlotIndex];
- if (dataItem && dataItem.getType() === 'attribute' && !SlotAPIHelper.isMultiMeasuresSeriesOrValueDataItem(dataItem)) {
- resolved.push({
- dataItemId: dataItem.getId(),
- itemId: dataItem.getColumnId(),
- tupleItem: v
- });
- }
- });
- }
- });
- return [resolved];
- };
-
- VisEventHandler.prototype._resolveEdgeItem = function _resolveEdgeItem(item) {
- var slots = this._getMappedSlotListByItem(item);
- var resolved = [];
-
- _.each(item.values, function (value, valueIndex) {
- var slot = slots[valueIndex];
- if (slot) {
- var dataItems = slot.getDataItemList();
- _.each(value, function (v, itemIndex) {
- var dataItem = dataItems[itemIndex];
- if (!SlotAPIHelper.isMultiMeasuresSeriesOrValueDataItem(dataItem) && dataItem.getType() === 'attribute') {
- resolved.push({
- dataItemId: dataItem.getId(),
- itemId: dataItem.getColumnId(),
- tupleItem: v
- });
- }
- });
- }
- });
- return resolved;
- };
-
- VisEventHandler.prototype._processEdgeSelection = function _processEdgeSelection(selections, item) {
- var _this6 = this;
- var slots = this._getMappedSlotListByItem(item);
- if (item.values) {
- _.each(item.values, function (value, valueIndex, values) {
- if (value) {
- for (var i = 0; i < value.length; i++) {
- if (typeof value[i] !== 'undefined') {
- var slot = slots[valueIndex];
-
- var slotDataItem = void 0;
- if (slot.getDefinition().getProperty('multiMeasure') && slot.getDataItemList().length > 0) {
- (function () {
-
-
- var dataset = slot.getDefinition().getDatasetIdList()[0];
- var multiMeasuresSeriesSlot = _.find(slots, function (slot) {
- return SlotAPIHelper.isMultiMeasuresSeriesSlot(slot) && slot.getDefinition().getDatasetIdList()[0] === dataset;
- });
- if (!multiMeasuresSeriesSlot) {
- multiMeasuresSeriesSlot = SlotAPIHelper.getMultiMeasureSeriesSlot(_this6.visualization, dataset);
- }
- var multiMeasuresSlotIndex = _.indexOf(_.map(slots, function (slot) {
- return slot.getId();
- }), multiMeasuresSeriesSlot.getId());
- var multiMeasuresDataItemIndex = _.indexOf(_.map(multiMeasuresSeriesSlot.getDataItemList(), function (dataItemApi) {
- return dataItemApi.getColumnId();
- }), SlotAPIHelper.MULTI_MEASURES_SERIES);
- if (multiMeasuresSlotIndex >= 0 && multiMeasuresDataItemIndex >= 0 && values[multiMeasuresSlotIndex] && values[multiMeasuresSlotIndex][multiMeasuresDataItemIndex] && values[multiMeasuresSlotIndex][multiMeasuresDataItemIndex].u) {
- var dataItemUId = values[multiMeasuresSlotIndex][multiMeasuresDataItemIndex].u;
- slotDataItem = _.find(slot.getDataItemList(), function (dataItem) {
- return dataItem.getId() === dataItemUId;
- });
-
-
- }
- })();
- }
- if (slotDataItem === undefined) {
- slotDataItem = slot.getDataItemList()[i];
- }
- if (slotDataItem) {
- selections.addSelection(slot, slotDataItem, value[i], item.isEdgeSelect);
- }
- }
- }
- }
- });
- }
- };
-
- VisEventHandler.prototype._processCustomDataSelection = function _processCustomDataSelection(selections, item) {
- if (this._target && this._target.getCustomDataSelections && selections.addCustomSelection) {
- var customSelections = this._target.getCustomDataSelections(item);
- _.each(customSelections, function (s) {
- return selections.addCustomSelection((typeof s === 'undefined' ? 'undefined' : _typeof(s)) === 'object' ? s.label : s, (typeof s === 'undefined' ? 'undefined' : _typeof(s)) === 'object' ? s.value : undefined);
- });
- }
- };
-
- VisEventHandler.prototype._processDecorationTooltips = function _processDecorationTooltips(selections, items) {
- try {
-
- if (items && items.length === 1) {
- if (this._target && this._target.getDecoration && selections.addCustomSelection) {
- var tooltip = this._target.getDecoration(items[0], VisEventHandler.DECORATIONS.TOOLTIP);
- if (tooltip && typeof tooltip === 'string') {
- selections.addCustomSelection(tooltip);
- } else if (tooltip && Array.isArray(tooltip)) {
-
- tooltip.forEach(function (tip) {
- if (Array.isArray(tip) && tip.length === 2) {
- selections.addCustomSelection(tip[0], tip[1]);
- }
- });
- }
- }
- }
- } catch (e) {
- this.logger.error(e);
- }
- };
-
- VisEventHandler.prototype._getSlotDataItem = function _getSlotDataItem(slot, item, index) {
- var dataItemList = slot.getDataItemList();
-
- if (SlotAPIHelper.isMultiMeasuresValueSlot(slot)) {
- var slots = this._getMappedSlotListByItem(item);
- var slotIndex = void 0,
- dataItemIndex = void 0;
-
- _.find(slots, function (slot, index) {
- if (SlotAPIHelper.isMultiMeasuresSeriesSlot(slot)) {
- slotIndex = index;
- return true;
- }
- return false;
- });
-
- if (slotIndex) {
- _.find(slots[slotIndex].getDataItemList(), function (dataItem, index) {
- if (SlotAPIHelper.isMultiMeasuresSeriesOrValueDataItem(dataItem)) {
- dataItemIndex = index;
- return true;
- }
- return false;
- });
- var multiMeasuresSeries = item.values[slotIndex][dataItemIndex];
- var measureId = multiMeasuresSeries.u;
-
- return _.find(slot.getDataItemList(), function (dataItem) {
- return dataItem.getId() === measureId;
- });
- } else {
- return slot.getDataItemList()[index];
- }
- } else {
- return dataItemList[index];
- }
- };
-
- VisEventHandler.prototype._isSelected = function _isSelected(resolvedItems, isEdgeSelect) {
- var payload = this._getSelectionPayload(resolvedItems, false, isEdgeSelect);
- return this._selector.isSelected(payload, this._edgeSelection || isEdgeSelect);
- };
-
- VisEventHandler.prototype._isCustomDataItems = function _isCustomDataItems(items) {
- return _.chain(items).pluck('type').contains('customdata').value();
- };
- VisEventHandler.prototype._isCustomDataSelected = function _isCustomDataSelected(items) {
- var currentSelectionIds = _.pluck(this._visAPI.getDecoratedCustomData('selected'), 'id');
-
- if (currentSelectionIds.length > 0) {
- var customItemIds = _.chain(items).pluck('values').flatten().pluck('payload').pluck('id').value();
- if (customItemIds.length > 0) {
- return _.intersection(currentSelectionIds, customItemIds).length === customItemIds.length;
- }
- }
- return false;
- };
-
- VisEventHandler.prototype._isItemsSelected = function _isItemsSelected(items) {
- var isSelected = false;
- if (this._isCustomDataItems(items)) {
- isSelected = this._isCustomDataSelected(items);
- } else {
- var resolved = this._resolveItems(items);
- isSelected = resolved.length > 0 ? this._isSelected(resolved, items[0].isEdgeSelect) : false;
- }
- return isSelected;
- };
-
- VisEventHandler.prototype._select = function _select(resolved, doSelect, append, pending, isEdgeSelect, multiTuple) {
- var transactionToken = this._transaction.startTransaction();
- var selections = pending ? this.content.getFeature('DataPointSelections.pending') : this.content.getFeature('DataPointSelections');
- var payload = this._getSelectionPayload(resolved, multiTuple, isEdgeSelect);
- if (!append) {
- selections.clearAll(transactionToken);
- }
- if (doSelect) {
- selections.select(payload, transactionToken);
- } else {
- selections.deselect(payload, transactionToken);
- }
- this._transaction.endTransaction(transactionToken);
- };
- VisEventHandler.prototype._getSelectionPayload = function _getSelectionPayload(selections, multiTuple) {
- var edgeSelect = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
- if (multiTuple) {
- if (edgeSelect) {
- return _.map(_.flatten(selections), function (s) {
- return {
- categories: [{
- dataItemId: s.dataItemId,
- columnId: s.itemId,
- label: s.tupleItem && s.tupleItem.d,
- parentId: s.tupleItem && s.tupleItem.p && s.tupleItem.p.u,
- value: s.tupleItem && s.tupleItem.u
- }],
- edgeSelect: edgeSelect
- };
- });
- } else {
- return _.map(selections, function (datapoint) {
- return {
- categories: _.map(datapoint, function (s) {
- return {
- dataItemId: s.dataItemId,
- columnId: s.itemId,
- label: s.tupleItem && s.tupleItem.d,
- parentId: s.tupleItem && s.tupleItem.p && s.tupleItem.p.u,
- value: s.tupleItem && s.tupleItem.u
- };
- }),
- edgeSelect: edgeSelect
- };
- });
- }
- } else {
- return [{
- categories: _.chain(selections).flatten().map(function (s) {
- return {
- dataItemId: s.dataItemId,
- columnId: s.itemId,
- label: s.tupleItem && s.tupleItem.d,
- parentId: s.tupleItem && s.tupleItem.p && s.tupleItem.p.u,
- value: s.tupleItem && s.tupleItem.u
- };
- }).value(),
- edgeSelect: edgeSelect
- }];
- }
- };
-
- VisEventHandler.prototype.reduceItems = function reduceItems(resolved) {
- var selection = {
- itemIds: [],
- tuple: []
- };
- resolved.reduce(function (accumulator, item) {
- var _itemsId = void 0;
- var _tuple = void 0;
- if (Array.isArray(item)) {
-
- _itemsId = _.map(item, function (o) {
- return o.itemId;
- });
- _tuple = _.map(item, function (o) {
- if (_.isUndefined(o.tupleItem && o.tupleItem.u)) {
- return { u: o.tupleItem, d: o.tupleItem };
- }
- return o.tupleItem;
- });
- } else {
-
- _itemsId = [item.itemId];
- _tuple = item.tupleItem;
- }
- accumulator.itemIds = _.uniq(accumulator.itemIds.concat(_itemsId));
- accumulator.tuple.push(Array.isArray(_tuple) ? _.uniq(_tuple, false, function (t) {
- return t && t.u || t;
- }) : _tuple);
- return accumulator;
- }, selection);
- return selection;
- };
-
- VisEventHandler.prototype._titleActions = function _titleActions(event, items) {
- var _this7 = this;
- var aSlots = [];
- var itemsArea = items && items[0] ? items[0].area : undefined;
- if (items && items.length) {
- for (var i = 0; i < items.length; i++) {
- var item = items[i];
- if (item.type !== 'customdata') {
- (function () {
- var slots = _this7.visualization.getSlots().getMappedSlotList();
- item.values.forEach(function (value, index) {
- if (!aSlots.find(function (slot) {
- return slot.getId() === slots[index].getId();
- })) {
- aSlots.push(slots[index]);
- }
- });
- })();
- }
- }
- var mapIndex = items[0].selectionContext ? items[0].selectionContext.mapIndex : undefined;
- var actions = items[0].selectionContext && items[0].selectionContext.actions || [];
-
- this.setEventLocalProperty(event, 'preventDefaultContextBar', true);
- this._visActionHelper.showTitleActions(aSlots, { 'bounds': this._getBoundsInfoFromEvent(event) }, null,
- mapIndex, itemsArea, actions);
- }
- };
-
- VisEventHandler.prototype._clearAll = function _clearAll(event) {
- var _this8 = this;
- this._triggerWidgetEvent('visevent:clearselection', event);
-
- return this.content.getFeature('DataPointSelections').clearAll().then(function () {
- return _this8.content.getFeature('DataPointSelections.pending').clearAll();
- }).then(function () {
-
- return _this8.clearCustomDataSelection();
- });
- };
- VisEventHandler.prototype.clearCustomDataSelection = function clearCustomDataSelection(options) {
- this._target.applyCustomDataSelection([], options);
- };
-
- VisEventHandler.prototype._getDataPayload = function _getDataPayload(items, InfoClass) {
- var _this9 = this;
- var VisInfoClass = InfoClass || VisSelectionInfo;
- var selections = new VisInfoClass();
- _.each(items, function (item, itemIdx) {
- switch (item.type) {
- case 'datapoint':
- return _this9._processDataPointSelection(selections, item);
- case 'item':
- return _this9._processEdgeSelection(selections, item, itemIdx);
- case 'customdata':
- return _this9._processCustomDataSelection(selections, item);
- default:
- return;
- }
- });
- this._processDecorationTooltips(selections, items);
- return selections;
- };
-
- VisEventHandler.prototype._showSelectionInfo = function _showSelectionInfo(oSelectionObj, event, includeApplyFilter, noFilters, drillOnly, noDrillthrough, options) {
- var infoShown = false;
- if (oSelectionObj && oSelectionObj.getCategorySelections()) {
- this._visActionHelper.showDataPointActions(oSelectionObj, {
-
- 'bounds': this._getBoundsInfoFromEvent(event),
- 'targetNode': event.currentTarget
- }, includeApplyFilter, noFilters, drillOnly, noDrillthrough, options);
- infoShown = true;
- this.setEventLocalProperty(event, 'preventDefaultContextBar', true);
- }
- return infoShown;
- };
-
- VisEventHandler.prototype.setLassoSelectState = function setLassoSelectState(state) {
- var viewId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : LassoController.DEFAULT_VIEW_ID;
- if (this.lassoCtrl.getCurrentViewId() && this.lassoCtrl.getCurrentViewId() !== viewId) {
- this._endLassoSelection();
- state = true;
- }
- return this.toggleLassoSelect(state, viewId);
- };
-
- VisEventHandler.prototype.toggleLassoSelect = function toggleLassoSelect(state, viewId) {
- var enabled = arguments.length === 0 ? !this.lassoCtrl.isLassoMode() : !!state;
- if (this.lassoCtrl.isLassoMode() !== enabled) {
- if (enabled) {
- this.lassoCtrl.activateLassoMode(true, viewId);
- this.lassoCtrl.on('lassoSelect:done', this._handleLassoSelection, this);
- this.lassoCtrl.on('lassoSelect:cordsChange', this._handleLassoCordChange, this);
- this.lassoCtrl.on('lassoSelect:cancel', this._endLassoSelection, this);
- } else {
- this._endLassoSelection();
- }
- }
- return enabled;
- };
- VisEventHandler.prototype.getLassoViewId = function getLassoViewId() {
- return this.lassoCtrl.getCurrentViewId();
- };
- VisEventHandler.prototype._handleLassoSelection = function _handleLassoSelection(payload) {
- try {
- var items = [];
- if (!_.isUndefined(payload.radius)) {
- items = this._target && this._target.getEventTargets ? this._target.getEventTargets(payload.event, payload.radius) : [];
- } else {
- items = this._target && this._target.getTargetsByCords ? this._target.getTargetsByCords(payload.cords, false) : [];
- }
- if (items) {
- var options = {
- isMultiSelect: true
- };
-
-
-
- if (payload.event.type === 'touchend') {
- options.forceCtrlClick = true;
- }
- this._handleHighlights(items);
- this._handleSelections(payload.event, items, options);
- }
- } catch (e) {
- this.logger.error(e);
- }
- };
- VisEventHandler.prototype._handleLassoCordChange = function _handleLassoCordChange(payload) {
- try {
- var items = [];
- if (!_.isUndefined(payload.radius)) {
- items = this._target && this._target.getEventTargets ? this._target.getEventTargets(payload.event, payload.radius) : [];
- } else {
- items = this._target && this._target.getTargetsByCords ? this._target.getTargetsByCords(payload.cords, false) : [];
- }
- if (items) {
- this._handleHighlights(items);
- }
- } catch (e) {
- this.logger.error(e);
- }
- };
- VisEventHandler.prototype._endLassoSelection = function _endLassoSelection() {
- this.lassoCtrl.off('lassoSelect:done', this._handleLassoSelection, this);
- this.lassoCtrl.off('lassoSelect:cordsChange', this._handleLassoCordChange, this);
- this.lassoCtrl.off('lassoSelect:cancel', this._endLassoSelection, this);
- this.lassoCtrl.activateLassoMode(false);
- };
- VisEventHandler.prototype.isLassoSelectActive = function isLassoSelectActive() {
- return this.lassoCtrl.isLassoMode();
- };
-
- VisEventHandler.prototype.getLassoSelectState = function getLassoSelectState() {
- return this.isLassoSelectActive();
- };
-
-
- VisEventHandler.prototype._triggerWidgetEvent = function _triggerWidgetEvent(name, event, target, items, additionalPayloadItems) {
- var payload = {
- sender: this._widgetApi,
- event: event,
- target: target,
- items: items
- };
- _.each(additionalPayloadItems, function (additionalPayloadItems, key) {
- payload[key] = additionalPayloadItems;
- });
- this._ownerWidget.trigger(name, payload);
- };
-
- VisEventHandler.prototype.setPopoverClosed = function setPopoverClosed(payload) {
- this._isHoverFlyoutShowing = false;
- if (!payload || !payload.isHover) {
- this._stopHoverover = false;
- }
- };
-
- VisEventHandler.prototype.setPopoverOpened = function setPopoverOpened(payload) {
- if (!payload || !payload.isHover) {
- this._stopHoverover = true;
- if (payload && payload.isWidgetOdt) {
- this._stopHoverover = false;
- }
- }
- };
- VisEventHandler.prototype._getMappedSlotListByItem = function _getMappedSlotListByItem(item) {
- if (item && item.datasetId) {
- return SlotAPIHelper.getMappedSlotListByDataset(this.visualization, item.datasetId);
- } else {
- return this.visualization.getSlots().getMappedSlotList();
- }
- };
- return VisEventHandler;
- }();
-
- VisEventHandler.DECORATIONS = {
- HIGHLIGHT: 'highlight',
- SELECT: 'select',
- TOOLTIP: 'tooltip'
- };
- return VisEventHandler;
- });
|