• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yext / answers-search-ui / 16886612290

11 Aug 2025 04:53PM UTC coverage: 61.442% (+0.001%) from 61.441%
16886612290

Pull #1952

github

mkouzel-yext
Update extracted translations

Ran `npm run extract-translations`
Pull Request #1952: Update click event listeners v1.15

1965 of 3348 branches covered (58.69%)

Branch coverage included in aggregate %.

4 of 10 new or added lines in 2 files covered. (40.0%)

43 existing lines in 2 files now uncovered.

3378 of 5348 relevant lines covered (63.16%)

26.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

1.89
/src/ui/components/ctas/ctacomponent.js
1
/* eslint-disable no-self-assign */
2
/** @module CTAComponent */
3

4
import Component from '../component';
5
import AnalyticsEvent from '../../../core/analytics/analyticsevent';
6
import DOM from '../../dom/dom';
7

8
class CTAConfig {
9
  constructor (config = {}) {
×
10
    Object.assign(this, config);
×
11

12
    /**
13
     * Label below the CTA icon
14
     * @type {string}
15
     */
16
    this.label = config.label;
×
17

18
    /**
19
     * CTA icon, maps to a set of icons.
20
     * @type {string}
21
     */
22
    this.icon = config.icon;
×
23

24
    /**
25
     * Url to custom icon, has priority over icon.
26
     * @type {string}
27
     */
28
    this.iconUrl = config.iconUrl;
×
29

30
    /**
31
     * Whether the DOM should include legacy class names
32
     * @type {boolean}
33
     */
34
    this.includeLegacyClasses = config.includeLegacyClasses || false;
×
35

36
    /**
37
     * Click through url for the icon and label
38
     * @type {string}
39
     */
40
    this.url = config.url;
×
41

42
    /**
43
     * Analytics event that should fire:
44
     * @type {string}
45
     */
46
    this.analyticsEventType = config.analytics || config.eventType || 'CTA_CLICK';
×
47

48
    /**
49
     * The target attribute for the CTA link.
50
     * @type {boolean}
51
     */
52
    this.target = config.target || '_blank';
×
53

54
    /**
55
     * The eventOptions needed for the event to fire, passed as a string or Object
56
     * from config.dataMappings || {}.
57
     * @type {Object}
58
     */
59
    if (typeof config.eventOptions === 'string') {
×
60
      this.eventOptions = JSON.parse(config.eventOptions);
×
61
    }
62
    this.eventOptions = this.eventOptions;
×
63

64
    /**
65
     * Additional css className modifiers for the cta
66
     * @type {string}
67
     */
68
    this._ctaModifiers = config._ctaModifiers;
×
69

70
    /**
71
     * Whether the cta is the only one in its CTACollectionComponent
72
     * @type {boolean}
73
     */
74
    this._isSolo = config._isSolo || false;
×
75
  }
76
}
77

78
export default class CTAComponent extends Component {
79
  constructor (config = {}, systemConfig = {}) {
×
80
    super(new CTAConfig(config), systemConfig);
×
81
  }
82

83
  onMount () {
84
    const el = DOM.query(this._container, '.js-yxt-CTA');
×
85
    if (el && this._config.eventOptions) {
×
NEW
86
      const handleClick = (e) => {
×
87
        if (e.button === 0 || e.button === 1) {
×
88
          this.reportAnalyticsEvent();
×
89
        }
90
      };
NEW
91
      DOM.on(el, 'click', e => {
×
NEW
92
        handleClick(e);
×
93
      });
NEW
94
      DOM.on(el, 'auxclick', e => {
×
NEW
95
        handleClick(e);
×
96
      });
97
    }
98
  }
99

100
  setState (data) {
101
    return super.setState({
×
102
      ...data,
103
      hasIcon: this._config.icon || this._config.iconUrl
×
104
    });
105
  }
106

107
  reportAnalyticsEvent () {
108
    const analyticsEvent = new AnalyticsEvent(this._config.analyticsEventType);
×
109
    analyticsEvent.addOptions(this._config.eventOptions);
×
110
    this.analyticsReporter.report(analyticsEvent);
×
111
  }
112

113
  static get type () {
114
    return 'CTA';
24✔
115
  }
116

117
  static defaultTemplateName (config) {
118
    return 'ctas/cta';
×
119
  }
120
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc