'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /** *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Dashboard *| (C) Copyright IBM Corp. 2018, 2019 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define(['underscore', './AbstractTupleLocator'], function (_, AbstractTupleLocator) { var SelectorTupleLocator = function (_AbstractTupleLocator) { _inherits(SelectorTupleLocator, _AbstractTupleLocator); /** * A tuple locator which tries points based on elements found by a CSS * selector. This is not the most robust approach, use it only as needed. */ function SelectorTupleLocator(_ref) { var $el = _ref.$el, selector = _ref.selector, viprWidget = _ref.viprWidget; _classCallCheck(this, SelectorTupleLocator); var _this = _possibleConstructorReturn(this, _AbstractTupleLocator.call(this)); _this.$el = $el; _this.selector = selector; _this.viprWidget = viprWidget; return _this; } SelectorTupleLocator.prototype.findTupleVisualInfo = function findTupleVisualInfo(filter, _ref2) { var _this2 = this; var includeInfo = _ref2.includeInfo, includePoints = _ref2.includePoints; //Query selector to get elements, and thus candidate points var matches = this.$el.find(this.selector).toArray().map(function (e) { return _this2._getPoint(e); }).map(function (point) { return _this2._getItemsAtCenterOfElement(point).map(function (item) { //Get info from item var info = _this2._getValueInfoFromItem(item); //Filter items according to specified filter if (_this2._itemSatisfiesFilter({ item: item, filter: filter })) { var result = {}; if (includeInfo) { result.info = info; } if (includePoints) { result.point = point; } return result; } }).filter(function (result) { return !!result; }); }); return _.flatten(matches); }; SelectorTupleLocator.prototype._getPoint = function _getPoint(e) { var _e$getBoundingClientR = e.getBoundingClientRect(), left = _e$getBoundingClientR.left, top = _e$getBoundingClientR.top, width = _e$getBoundingClientR.width, height = _e$getBoundingClientR.height; return { selectedNode: e, left: left, top: top, xOffset: width / 2, yOffset: height / 2 }; }; SelectorTupleLocator.prototype._getItemsAtCenterOfElement = function _getItemsAtCenterOfElement(_ref3) { var left = _ref3.left, top = _ref3.top, xOffset = _ref3.xOffset, yOffset = _ref3.yOffset; var coord = this.viprWidget.getVisCoordinate(left + xOffset, top + yOffset); return this.viprWidget.getItemsAtPoint(coord); }; return SelectorTupleLocator; }(AbstractTupleLocator); return SelectorTupleLocator; }); //# sourceMappingURL=SelectorTupleLocator.js.map