PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.1.13
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.1.13
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 / feedback / ThickBoxModal.ts

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

51 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import $ from 'jquery';
2 import { domElements } from '../constants/selectors';
3
4 export default class ThickBoxModal {
5 openTriggerSelector: string;
6 inlineContentId: string;
7 windowCssClass: string;
8 contentCssClass: string;
9
10 constructor(
11 openTriggerSelector: string,
12 inlineContentId: string,
13 windowCssClass: string,
14 contentCssClass: string
15 ) {
16 this.openTriggerSelector = openTriggerSelector;
17 this.inlineContentId = inlineContentId;
18 this.windowCssClass = windowCssClass;
19 this.contentCssClass = contentCssClass;
20
21 $(openTriggerSelector).on('click', this.init.bind(this));
22 }
23
24 close() {
25 //@ts-expect-error global
26 window.tb_remove();
27 }
28
29 init(e: Event) {
30 //@ts-expect-error global
31 window.tb_show(
32 '',
33 `#TB_inline?inlineId=${this.inlineContentId}&modal=true`
34 );
35 // thickbox doesn't respect the width and height url parameters https://core.trac.wordpress.org/ticket/17249
36 // We override thickboxes css with !important in the css
37 $(domElements.thickboxModalWindow).addClass(this.windowCssClass);
38
39 // have to modify the css of the thickbox content container as well
40 $(domElements.thickboxModalContent).addClass(this.contentCssClass);
41
42 // we unbind previous handlers because a thickbox modal is a single global object.
43 // Everytime it is re-opened, it still has old handlers bound
44 $(domElements.thickboxModalClose)
45 .off('click')
46 .on('click', this.close);
47
48 e.preventDefault();
49 }
50 }
51