PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.3.75
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.3.75
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / scripts / entries / feedback.ts

feedback.ts in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.3.75, at scripts/entries/feedback.ts

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import $ from 'jquery';
2 import Raven from '../lib/Raven';
3 import { domElements } from '../constants/selectors';
4 import ThickBoxModal from '../feedback/ThickBoxModal';
5 import { submitFeedbackForm } from '../feedback/feedbackFormApi';
6 import {
7 getOrCreateBackgroundApp,
8 initBackgroundApp,
9 } from '../utils/backgroundAppUtils';
10 import { ProxyMessages } from '../iframe/integratedMessages';
11
12 let embedder: any;
13
14 function deactivatePlugin() {
15 const href = $(domElements.deactivatePluginButton).attr('href');
16 if (href) {
17 window.location.href = href;
18 }
19 }
20
21 function setLoadingState() {
22 $(domElements.deactivateFeedbackSubmit).addClass('loading');
23 }
24
25 function submitAndDeactivate(e: Event) {
26 e.preventDefault();
27 setLoadingState();
28 const feedback = $(domElements.deactivateFeedbackForm)
29 .serializeArray()
30 .find(field => field.name === 'feedback');
31
32 submitFeedbackForm(domElements.deactivateFeedbackForm)
33 .then(() => {
34 if (feedback && embedder) {
35 embedder.postMessage({
36 key: ProxyMessages.TrackPluginDeactivation,
37 payload: {
38 type: feedback.value.trim().replace(/[\s']+/g, '_'),
39 },
40 });
41 }
42 })
43 .catch((err: Error) => {
44 Raven.captureException(err);
45 })
46 .finally(() => {
47 deactivatePlugin();
48 });
49 }
50
51 function init() {
52 embedder = getOrCreateBackgroundApp();
53 // eslint-disable-next-line no-new
54 new ThickBoxModal(
55 domElements.deactivatePluginButton,
56 'leadin-feedback-container',
57 'leadin-feedback-window',
58 'leadin-feedback-content'
59 );
60
61 $(domElements.deactivateFeedbackForm)
62 .off('submit')
63 .on('submit', submitAndDeactivate);
64 $(domElements.deactivateFeedbackSkip)
65 .off('click')
66 .on('click', deactivatePlugin);
67 }
68
69 initBackgroundApp(init);
70