@@ -16,55 +16,18 @@ customElements.define(
1616 constructor ( ) {
1717 // Get parent class properties
1818 super ( ) ;
19- this . repositionPopover = this . repositionPopover . bind ( this ) ; // So this is available in the event listener.
2019
2120 // First step.
2221 this . formStep = this . querySelector (
2322 '#prpl-sending-email-form-step'
2423 ) ;
2524 }
2625
27- /**
28- * Repositions the popover relative to the target element.
29- * @private
30- */
31- repositionPopover ( ) {
32- const horizontalTarget = document . querySelector ( '.prpl-wrap' ) ;
33- const verticalTarget = document . querySelector (
34- '.prpl-widget-wrapper.prpl-suggested-tasks'
35- ) ;
36-
37- // Just in case.
38- if ( ! horizontalTarget || ! verticalTarget ) {
39- return ;
40- }
41-
42- const horizontalRect = horizontalTarget . getBoundingClientRect ( ) ;
43- const verticalRect = verticalTarget . getBoundingClientRect ( ) ;
44- const popoverId = this . getAttribute ( 'popover-id' ) ;
45- const popover = document . getElementById ( popoverId ) ;
46-
47- // Reset default popover styles.
48- popover . style . margin = '0' ;
49-
50- // Calculate target's center
51- const horizontalTargetCenter =
52- horizontalRect . left + horizontalRect . width / 2 ;
53-
54- // Apply the position.
55- popover . style . position = 'fixed' ;
56- popover . style . left = `${ horizontalTargetCenter } px` ;
57- popover . style . top = `${ Math . round (
58- Math . abs ( verticalRect . top )
59- ) } px`;
60- popover . style . transform = 'translateX(-50%)' ;
61- }
62-
6326 /**
6427 * Runs when the popover is added to the DOM.
6528 */
6629 popoverAddedToDOM ( ) {
67- window . addEventListener ( 'resize' , this . repositionPopover ) ;
30+ super . popoverAddedToDOM ( ) ;
6831
6932 // For the results step, add event listener to radio buttons.
7033 const nextButton = this . querySelector (
@@ -85,13 +48,6 @@ customElements.define(
8548 }
8649 }
8750
88- /**
89- * Runs when the popover is opening.
90- */
91- popoverOpening ( ) {
92- this . repositionPopover ( ) ;
93- }
94-
9551 /**
9652 * Hide all steps.
9753 */
0 commit comments