releasebird-javascript-sdk 1.0.76 → 1.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/RbirdFormManager.js
CHANGED
|
@@ -53,7 +53,8 @@ export class RbirdFormManager {
|
|
|
53
53
|
const state = sessionManager.getState();
|
|
54
54
|
|
|
55
55
|
const http = new XMLHttpRequest();
|
|
56
|
-
|
|
56
|
+
const url = `${API}/ewidget/forms/${formId}`;
|
|
57
|
+
http.open("GET", url);
|
|
57
58
|
http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
|
58
59
|
http.setRequestHeader("apiKey", this.apiKey);
|
|
59
60
|
|
|
@@ -552,6 +552,40 @@ export default class RbirdWebsiteWidget {
|
|
|
552
552
|
});
|
|
553
553
|
|
|
554
554
|
this.messageBubblesContainer.style.display = 'flex';
|
|
555
|
+
|
|
556
|
+
// Position bubbles so they don't overflow screen edges
|
|
557
|
+
this.positionMessageBubbles();
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Position message bubbles container to stay within viewport bounds
|
|
562
|
+
*/
|
|
563
|
+
positionMessageBubbles() {
|
|
564
|
+
if (!this.messageBubblesContainer || !this.websiteWidget) return;
|
|
565
|
+
|
|
566
|
+
const buttonRect = this.websiteWidget.getBoundingClientRect();
|
|
567
|
+
const containerWidth = 320; // max-width from CSS
|
|
568
|
+
const padding = 10; // minimum distance from screen edge
|
|
569
|
+
const gap = 20; // gap between button and bubbles
|
|
570
|
+
|
|
571
|
+
// Calculate vertical position (above the button)
|
|
572
|
+
const bottomFromViewport = window.innerHeight - buttonRect.top + gap;
|
|
573
|
+
this.messageBubblesContainer.style.bottom = `${bottomFromViewport}px`;
|
|
574
|
+
|
|
575
|
+
// Calculate horizontal position
|
|
576
|
+
// Try to center on the button first
|
|
577
|
+
let leftPosition = buttonRect.left + (buttonRect.width / 2) - (containerWidth / 2);
|
|
578
|
+
|
|
579
|
+
// Constrain to viewport bounds
|
|
580
|
+
const minLeft = padding;
|
|
581
|
+
const maxLeft = window.innerWidth - containerWidth - padding;
|
|
582
|
+
|
|
583
|
+
// Clamp the position
|
|
584
|
+
leftPosition = Math.max(minLeft, Math.min(leftPosition, maxLeft));
|
|
585
|
+
|
|
586
|
+
// Apply position
|
|
587
|
+
this.messageBubblesContainer.style.left = `${leftPosition}px`;
|
|
588
|
+
this.messageBubblesContainer.style.right = 'unset';
|
|
555
589
|
}
|
|
556
590
|
|
|
557
591
|
/**
|
|
@@ -809,25 +843,22 @@ export default class RbirdWebsiteWidget {
|
|
|
809
843
|
// Update badge position
|
|
810
844
|
if (this.countBadge) {
|
|
811
845
|
const buttonRect = this.websiteWidget.getBoundingClientRect();
|
|
812
|
-
this.countBadge.style.left = `${buttonRect.right -
|
|
846
|
+
this.countBadge.style.left = `${buttonRect.right - 10}px`;
|
|
813
847
|
this.countBadge.style.right = 'unset';
|
|
814
|
-
this.countBadge.style.bottom = `${window.innerHeight - buttonRect.top
|
|
848
|
+
this.countBadge.style.bottom = `${window.innerHeight - buttonRect.top - 5}px`;
|
|
815
849
|
}
|
|
816
850
|
|
|
817
851
|
// Update hide button position (top right of bubble)
|
|
818
852
|
if (this.hideWidgetButton) {
|
|
819
853
|
const buttonRect = this.websiteWidget.getBoundingClientRect();
|
|
820
|
-
this.hideWidgetButton.style.left = `${buttonRect.right -
|
|
854
|
+
this.hideWidgetButton.style.left = `${buttonRect.right - 10}px`;
|
|
821
855
|
this.hideWidgetButton.style.right = 'unset';
|
|
822
856
|
this.hideWidgetButton.style.bottom = `${window.innerHeight - buttonRect.top + 5}px`;
|
|
823
857
|
}
|
|
824
858
|
|
|
825
859
|
// Update message bubbles container position
|
|
826
860
|
if (this.messageBubblesContainer) {
|
|
827
|
-
|
|
828
|
-
this.messageBubblesContainer.style.left = `${buttonRect.left}px`;
|
|
829
|
-
this.messageBubblesContainer.style.right = 'unset';
|
|
830
|
-
this.messageBubblesContainer.style.bottom = `${window.innerHeight - buttonRect.top + 20}px`;
|
|
861
|
+
this.positionMessageBubbles();
|
|
831
862
|
}
|
|
832
863
|
}
|
|
833
864
|
|
|
@@ -895,23 +926,21 @@ export default class RbirdWebsiteWidget {
|
|
|
895
926
|
|
|
896
927
|
// Update badge position
|
|
897
928
|
if (this.countBadge) {
|
|
898
|
-
this.countBadge.style.left = `${buttonRect.right -
|
|
929
|
+
this.countBadge.style.left = `${buttonRect.right - 10}px`;
|
|
899
930
|
this.countBadge.style.right = 'unset';
|
|
900
|
-
this.countBadge.style.bottom = `${window.innerHeight - buttonRect.top
|
|
931
|
+
this.countBadge.style.bottom = `${window.innerHeight - buttonRect.top - 5}px`;
|
|
901
932
|
}
|
|
902
933
|
|
|
903
934
|
// Update hide button position (top right of bubble)
|
|
904
935
|
if (this.hideWidgetButton) {
|
|
905
|
-
this.hideWidgetButton.style.left = `${buttonRect.right -
|
|
936
|
+
this.hideWidgetButton.style.left = `${buttonRect.right - 10}px`;
|
|
906
937
|
this.hideWidgetButton.style.right = 'unset';
|
|
907
|
-
this.hideWidgetButton.style.bottom = `${window.innerHeight - buttonRect.top
|
|
938
|
+
this.hideWidgetButton.style.bottom = `${window.innerHeight - buttonRect.top - 5}px`;
|
|
908
939
|
}
|
|
909
940
|
|
|
910
941
|
// Update message bubbles container position
|
|
911
942
|
if (this.messageBubblesContainer) {
|
|
912
|
-
this.
|
|
913
|
-
this.messageBubblesContainer.style.right = 'unset';
|
|
914
|
-
this.messageBubblesContainer.style.bottom = `${window.innerHeight - buttonRect.top + 20}px`;
|
|
943
|
+
this.positionMessageBubbles();
|
|
915
944
|
}
|
|
916
945
|
}
|
|
917
946
|
|