aumera-on-screen-widget 0.0.24 → 0.0.25
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/df-btn.js +108 -3
- package/package.json +1 -1
package/df-btn.js
CHANGED
|
@@ -394,6 +394,43 @@
|
|
|
394
394
|
box-shadow: 0 1px 3px 0 rgba(60,64,67,0.302), 0 4px 8px 3px rgba(60,64,67,0.149)
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
+
.df-hidden {
|
|
398
|
+
display: none !important;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.df-dismiss-btn {
|
|
402
|
+
position: absolute;
|
|
403
|
+
top: -6px;
|
|
404
|
+
${config.position === "left" ? "left: -6px;" : "right: -6px;"}
|
|
405
|
+
width: 20px;
|
|
406
|
+
height: 20px;
|
|
407
|
+
border-radius: 50%;
|
|
408
|
+
background: rgba(0, 0, 0, 0.7);
|
|
409
|
+
color: #ffffff;
|
|
410
|
+
display: flex;
|
|
411
|
+
align-items: center;
|
|
412
|
+
justify-content: center;
|
|
413
|
+
cursor: pointer;
|
|
414
|
+
opacity: 0;
|
|
415
|
+
pointer-events: none;
|
|
416
|
+
transition: opacity 0.2s ease, background 0.2s ease;
|
|
417
|
+
z-index: 10002;
|
|
418
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.25);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.df-dismiss-btn:hover {
|
|
422
|
+
background: rgba(0, 0, 0, 0.9);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.df-btn.df-closed:hover .df-dismiss-btn {
|
|
426
|
+
opacity: 1;
|
|
427
|
+
pointer-events: auto;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.df-btn:not(.df-closed) .df-dismiss-btn {
|
|
431
|
+
display: none;
|
|
432
|
+
}
|
|
433
|
+
|
|
397
434
|
.df-btn:not(.df-closed){
|
|
398
435
|
border-radius: 16px;
|
|
399
436
|
overflow: hidden;
|
|
@@ -527,6 +564,12 @@
|
|
|
527
564
|
.df-btn:not(.df-closed) > .df-btn-header > .df-btn-text:before {
|
|
528
565
|
display: none;
|
|
529
566
|
}
|
|
567
|
+
|
|
568
|
+
/* Mobile: dismiss badge always visible on the closed pill (no hover on touch) */
|
|
569
|
+
.df-btn.df-closed .df-dismiss-btn {
|
|
570
|
+
opacity: 1;
|
|
571
|
+
pointer-events: auto;
|
|
572
|
+
}
|
|
530
573
|
}
|
|
531
574
|
|
|
532
575
|
${
|
|
@@ -679,6 +722,11 @@
|
|
|
679
722
|
// Create button HTML
|
|
680
723
|
const buttonHTML = `
|
|
681
724
|
<button class="df-btn df-closed" onclick="dfToggle()">
|
|
725
|
+
<div class="df-dismiss-btn" onclick="dismissWidget(event)" aria-label="Hide chat widget" title="Hide">
|
|
726
|
+
<svg width="10" height="10" viewBox="0 0 16 16" fill="currentColor">
|
|
727
|
+
<path d="M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"/>
|
|
728
|
+
</svg>
|
|
729
|
+
</div>
|
|
682
730
|
${
|
|
683
731
|
config.showNotification
|
|
684
732
|
? `<div class="df-notification">
|
|
@@ -750,7 +798,59 @@
|
|
|
750
798
|
|
|
751
799
|
window.dismissNotification = dismissNotification;
|
|
752
800
|
|
|
801
|
+
// Widget dismiss (hide entire pill for a fixed window)
|
|
802
|
+
const WIDGET_DISMISSED_UNTIL_KEY = `osw-widget-dismissed-until-${config.orgId}`;
|
|
803
|
+
const DISMISS_DURATION_MS = 2 * 60 * 1000;
|
|
804
|
+
let widgetRevealTimer = null;
|
|
805
|
+
|
|
806
|
+
function getDismissedUntil() {
|
|
807
|
+
try {
|
|
808
|
+
return parseInt(localStorage.getItem(WIDGET_DISMISSED_UNTIL_KEY), 10) || 0;
|
|
809
|
+
} catch (e) {
|
|
810
|
+
return 0;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
function isWidgetDismissed() {
|
|
815
|
+
return Date.now() < getDismissedUntil();
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function scheduleWidgetReveal() {
|
|
819
|
+
const remaining = getDismissedUntil() - Date.now();
|
|
820
|
+
if (remaining <= 0) return;
|
|
821
|
+
if (widgetRevealTimer) clearTimeout(widgetRevealTimer);
|
|
822
|
+
widgetRevealTimer = setTimeout(() => {
|
|
823
|
+
widgetRevealTimer = null;
|
|
824
|
+
if (isWidgetDismissed()) return;
|
|
825
|
+
const b = document.querySelector(".df-btn");
|
|
826
|
+
if (b) b.classList.remove("df-hidden");
|
|
827
|
+
if (window.innerWidth > 768) startInactivityTimer();
|
|
828
|
+
}, remaining);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
function dismissWidget(event) {
|
|
832
|
+
event.stopPropagation();
|
|
833
|
+
event.preventDefault();
|
|
834
|
+
try {
|
|
835
|
+
localStorage.setItem(
|
|
836
|
+
WIDGET_DISMISSED_UNTIL_KEY,
|
|
837
|
+
String(Date.now() + DISMISS_DURATION_MS),
|
|
838
|
+
);
|
|
839
|
+
} catch (e) {
|
|
840
|
+
console.warn("[OSW Widget] Could not persist dismiss state:", e);
|
|
841
|
+
}
|
|
842
|
+
const btn = document.querySelector(".df-btn");
|
|
843
|
+
if (btn) btn.classList.add("df-hidden");
|
|
844
|
+
const notif = document.querySelector(".df-notification");
|
|
845
|
+
if (notif) notif.classList.remove("show");
|
|
846
|
+
clearInactivityAndShake();
|
|
847
|
+
scheduleWidgetReveal();
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
window.dismissWidget = dismissWidget;
|
|
851
|
+
|
|
753
852
|
const startInactivityTimer = () => {
|
|
853
|
+
if (isWidgetDismissed()) return;
|
|
754
854
|
// Don't start timer if notification was dismissed
|
|
755
855
|
if (isNotificationDismissed()) {
|
|
756
856
|
return;
|
|
@@ -1178,9 +1278,14 @@
|
|
|
1178
1278
|
// If open, do nothing (let header buttons handle maximize/minimize/close)
|
|
1179
1279
|
});
|
|
1180
1280
|
|
|
1181
|
-
//
|
|
1182
|
-
|
|
1183
|
-
|
|
1281
|
+
// Honor any active "dismiss for 2 minutes" state from a previous page load
|
|
1282
|
+
if (isWidgetDismissed()) {
|
|
1283
|
+
const initBtn = document.querySelector(".df-btn");
|
|
1284
|
+
if (initBtn) initBtn.classList.add("df-hidden");
|
|
1285
|
+
scheduleWidgetReveal();
|
|
1286
|
+
} else if (!isMobile) {
|
|
1287
|
+
// Start the inactivity timer when the page loads (button is initially closed)
|
|
1288
|
+
// But not on mobile since it starts open
|
|
1184
1289
|
startInactivityTimer();
|
|
1185
1290
|
}
|
|
1186
1291
|
|