@everymatrix/general-news-notification 1.85.17 → 1.85.18

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.
@@ -86,6 +86,8 @@ function setClientStyling(stylingContainer, clientStyling) {
86
86
  * @param {string} clientStylingUrl The URL of the style content
87
87
  */
88
88
  function setClientStylingURL(stylingContainer, clientStylingUrl) {
89
+ if (!stylingContainer || !clientStylingUrl) return;
90
+
89
91
  const url = new URL(clientStylingUrl);
90
92
 
91
93
  fetch(url.href)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const generalNewsNotification = require('./general-news-notification-9fe115ad.js');
5
+ const generalNewsNotification = require('./general-news-notification-bc5ce711.js');
6
6
  require('./index-1feedc36.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const generalNewsNotification = require('./general-news-notification-9fe115ad.js');
5
+ const generalNewsNotification = require('./general-news-notification-bc5ce711.js');
6
6
  require('./index-1feedc36.js');
7
7
 
8
8
 
@@ -84,6 +84,8 @@ function setClientStyling(stylingContainer, clientStyling) {
84
84
  * @param {string} clientStylingUrl The URL of the style content
85
85
  */
86
86
  function setClientStylingURL(stylingContainer, clientStylingUrl) {
87
+ if (!stylingContainer || !clientStylingUrl) return;
88
+
87
89
  const url = new URL(clientStylingUrl);
88
90
 
89
91
  fetch(url.href)
@@ -1,2 +1,2 @@
1
- export { G as general_news_notification } from './general-news-notification-ddb349a7.js';
1
+ export { G as general_news_notification } from './general-news-notification-f5dbd04a.js';
2
2
  import './index-4a2a97f1.js';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { G as GeneralNewsNotification } from './general-news-notification-ddb349a7.js';
1
+ export { G as GeneralNewsNotification } from './general-news-notification-f5dbd04a.js';
2
2
  import './index-4a2a97f1.js';
@@ -0,0 +1 @@
1
+ import{r as t,h as i}from"./index-4a2a97f1.js";const e=()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"iPad"===t||"iPhone"===t?"ios":"mtWeb"},n={en:{loading:"Is Loading ..."}},o=t=>new Promise((i=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((i=>{n[i]||(n[i]={});for(let e in t[i])n[i][e]=t[i][e]})),i(!0)}))}));function s(t,i){if(t){const e=document.createElement("style");e.innerHTML=i,t.appendChild(e)}}function a(t,i){if(!t||!i)return;const e=new URL(i);fetch(e.href).then((t=>t.text())).then((i=>{const e=document.createElement("style");e.innerHTML=i,t&&t.appendChild(e)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}const r=class{constructor(i){t(this,i),this.getNotificationMessage=()=>{this.isLoading=!0;try{let t=new URL(`${this.cmsEndpoint}/${this.language}/header-notification`);t.searchParams.append("device",e()),t.searchParams.append("platform",e()),fetch(t.href).then((t=>{if(200===t.status)return t.json();throw new Error("HTTP status "+t.status)})).then((t=>{this.message=t.message})).catch((t=>{console.error(t)})).finally((()=>this.isLoading=!1))}catch(t){console.error("Error fetching message:",t)}},this.toggleMinimize=()=>{this.isMinimized=!this.isMinimized,window.postMessage({type:"NewsWidgetResize",status:"minimized"},window.location.href)},this.closeNotification=()=>{this.isClosed=!0,window.postMessage({type:"NewsWidgetResize",status:"closed"},window.location.href)},this.cmsEndpoint=void 0,this.language=void 0,this.animationType="static",this.speed=30,this.canMinimize=!1,this.canClose=!1,this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.translationUrl="",this.message=void 0,this.isMinimized=!1,this.isClosed=!1,this.isLoading=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.language&&this.getNotificationMessage()}handleClientStylingChange(t,i){t!=i&&s(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(t,i){t!=i&&this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)}handleNewTranslations(){this.isLoading=!0,o(this.translationUrl).then((()=>{this.isLoading=!1}))}async componentWillLoad(){this.translationUrl.length>2&&await o(this.translationUrl)}componentDidLoad(){window.postMessage({type:"NewsWidgetResize",status:"loaded"},window.location.href),this.stylingContainer&&(null!=window.emMessageBus?function(t,i){if(window.emMessageBus){const e=document.createElement("style");window.emMessageBus.subscribe(i,(i=>{e.innerHTML=i,t&&t.appendChild(e)}))}}(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&s(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}connectedCallback(){this.cmsEndpoint&&this.language&&this.getNotificationMessage()}render(){if(this.isClosed)return null;const t=`${this.speed}s`;return i("div",{ref:t=>this.stylingContainer=t},this.canMinimize&&i("button",{class:"ToggleButton",onClick:this.toggleMinimize},i("span",{class:this.isMinimized?"TriangleActive":"TriangleInactive"},i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"6.835",viewBox:"0 0 14 6.835"},i("path",{id:"arrow",d:"M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z",transform:"translate(-274.511 -441.088)"})))),i("div",{class:{NotificationWrapper:!0,Minimized:this.isMinimized}},i("div",{class:{SlidingBar:!0,Minimized:this.isMinimized,ScrollLeft:"scroll-left"===this.animationType,ScrollRight:"scroll-right"===this.animationType,VisibleButtons:this.canMinimize||!0===this.canClose}},i("div",{class:"Message",style:{animationDuration:t}},this.isLoading?((t,i)=>{let e=n[void 0!==i&&i in n?i:"en"].loading;return e})(0,this.language):this.message)),this.canClose&&i("div",{class:"CloseButton"},i("button",{onClick:this.closeNotification},"X"))))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"],translationUrl:["handleNewTranslations"]}}};r.style=":host{display:block}.NotificationWrapper{background:var(--emw--header-color-background, var(--emw--color-background, #000000));color:var(--emw--color-white, #FFFFFF);position:sticky;width:100%;text-align:center;overflow:hidden;display:flex;justify-content:flex-end;align-items:center;border-bottom:6px solid var(--emw--color-primary, #22B04E);max-height:40px}.SlidingBar{transition:all 0.3s ease-in-out;width:100%}.Message{will-change:transform;margin:0 auto;padding:10px;width:90%}.ScrollLeft .Message{white-space:nowrap;animation:scroll-left 10s linear infinite;width:100%}.ScrollRight .Message{white-space:nowrap;animation:scroll-right 10s linear infinite;width:100%}.VisibleButtons .Message{display:flex}@keyframes scroll-left{from{transform:translateX(100%)}to{transform:translateX(-100%)}}@keyframes scroll-right{from{transform:translateX(-100%)}to{transform:translateX(100%)}}.SlidingBar:hover .Message{animation-play-state:paused}.CloseButton{padding-left:10px;background-color:var(--emw--header-color-background, var(--emw--color-background, #000000));display:flex;gap:10px}.ToggleButton{position:absolute;left:0}.ToggleButton .TriangleActive,.ToggleButton .TriangleInactive{display:block;transition:all 0.2s}.ToggleButton .TriangleActive{transform:scale(1.1) rotateX(180deg) translateY(3px);fill:var(--emw--color-primary, #52d004);margin-top:8px}.ToggleButton svg{fill:var(--emw--header-color-background, var(--emw--color-background, #000000));width:16px;transform:rotate(180deg)}.CloseButton{right:10px}button{background-color:var(--emw--color-primary, #22B04E);color:var(--emw--header-color-background, var(--emw--color-background, #000000));border:none;width:40px;height:40px;cursor:pointer}.NotificationWrapper.Minimized{visibility:hidden}";export{r as G}
@@ -1 +1 @@
1
- export{G as general_news_notification}from"./general-news-notification-ddb349a7.js";import"./index-4a2a97f1.js";
1
+ export{G as general_news_notification}from"./general-news-notification-f5dbd04a.js";import"./index-4a2a97f1.js";
@@ -1 +1 @@
1
- export{G as GeneralNewsNotification}from"./general-news-notification-ddb349a7.js";import"./index-4a2a97f1.js";
1
+ export{G as GeneralNewsNotification}from"./general-news-notification-f5dbd04a.js";import"./index-4a2a97f1.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/general-news-notification",
3
- "version": "1.85.17",
3
+ "version": "1.85.18",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1 +0,0 @@
1
- import{r as t,h as i}from"./index-4a2a97f1.js";const e=()=>{const t=(()=>{let t=window.navigator.userAgent;return t.toLowerCase().match(/android/i)?"Android":t.toLowerCase().match(/iphone/i)?"iPhone":t.toLowerCase().match(/ipad|ipod/i)?"iPad":"PC"})();if(t)return"PC"===t?"dk":"iPad"===t||"iPhone"===t?"ios":"mtWeb"},o={en:{loading:"Is Loading ..."}},n=t=>new Promise((i=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((i=>{o[i]||(o[i]={});for(let e in t[i])o[i][e]=t[i][e]})),i(!0)}))}));function s(t,i){if(t){const e=document.createElement("style");e.innerHTML=i,t.appendChild(e)}}function a(t,i){const e=new URL(i);fetch(e.href).then((t=>t.text())).then((i=>{const e=document.createElement("style");e.innerHTML=i,t&&t.appendChild(e)})).catch((t=>{console.error("There was an error while trying to load client styling from URL",t)}))}const r=class{constructor(i){t(this,i),this.getNotificationMessage=()=>{this.isLoading=!0;try{let t=new URL(`${this.cmsEndpoint}/${this.language}/header-notification`);t.searchParams.append("device",e()),t.searchParams.append("platform",e()),fetch(t.href).then((t=>{if(200===t.status)return t.json();throw new Error("HTTP status "+t.status)})).then((t=>{this.message=t.message})).catch((t=>{console.error(t)})).finally((()=>this.isLoading=!1))}catch(t){console.error("Error fetching message:",t)}},this.toggleMinimize=()=>{this.isMinimized=!this.isMinimized,window.postMessage({type:"NewsWidgetResize",status:"minimized"},window.location.href)},this.closeNotification=()=>{this.isClosed=!0,window.postMessage({type:"NewsWidgetResize",status:"closed"},window.location.href)},this.cmsEndpoint=void 0,this.language=void 0,this.animationType="static",this.speed=30,this.canMinimize=!1,this.canClose=!1,this.mbSource=void 0,this.clientStyling="",this.clientStylingUrl="",this.translationUrl="",this.message=void 0,this.isMinimized=!1,this.isClosed=!1,this.isLoading=!0}watchEndpoint(t,i){t&&t!=i&&this.cmsEndpoint&&this.language&&this.getNotificationMessage()}handleClientStylingChange(t,i){t!=i&&s(this.stylingContainer,this.clientStyling)}handleClientStylingChangeURL(t,i){t!=i&&this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)}handleNewTranslations(){this.isLoading=!0,n(this.translationUrl).then((()=>{this.isLoading=!1}))}async componentWillLoad(){this.translationUrl.length>2&&await n(this.translationUrl)}componentDidLoad(){window.postMessage({type:"NewsWidgetResize",status:"loaded"},window.location.href),this.stylingContainer&&(null!=window.emMessageBus?function(t,i){if(window.emMessageBus){const e=document.createElement("style");window.emMessageBus.subscribe(i,(i=>{e.innerHTML=i,t&&t.appendChild(e)}))}}(this.stylingContainer,`${this.mbSource}.Style`):(this.clientStyling&&s(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&a(this.stylingContainer,this.clientStylingUrl)))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}connectedCallback(){this.cmsEndpoint&&this.language&&this.getNotificationMessage()}render(){if(this.isClosed)return null;const t=`${this.speed}s`;return i("div",{ref:t=>this.stylingContainer=t},this.canMinimize&&i("button",{class:"ToggleButton",onClick:this.toggleMinimize},i("span",{class:this.isMinimized?"TriangleActive":"TriangleInactive"},i("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"6.835",viewBox:"0 0 14 6.835"},i("path",{id:"arrow",d:"M281.541,447.921a.488.488,0,0,0,.295-.122l6.5-5.851a.488.488,0,1,0-.65-.726l-6.176,5.556-6.176-5.556h0a.488.488,0,1,0-.65.726l6.5,5.851a.488.488,0,0,0,.355.122Z",transform:"translate(-274.511 -441.088)"})))),i("div",{class:{NotificationWrapper:!0,Minimized:this.isMinimized}},i("div",{class:{SlidingBar:!0,Minimized:this.isMinimized,ScrollLeft:"scroll-left"===this.animationType,ScrollRight:"scroll-right"===this.animationType,VisibleButtons:this.canMinimize||!0===this.canClose}},i("div",{class:"Message",style:{animationDuration:t}},this.isLoading?((t,i)=>{let e=o[void 0!==i&&i in o?i:"en"].loading;return e})(0,this.language):this.message)),this.canClose&&i("div",{class:"CloseButton"},i("button",{onClick:this.closeNotification},"X"))))}static get watchers(){return{cmsEndpoint:["watchEndpoint"],language:["watchEndpoint"],clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingChangeURL"],translationUrl:["handleNewTranslations"]}}};r.style=":host{display:block}.NotificationWrapper{background:var(--emw--header-color-background, var(--emw--color-background, #000000));color:var(--emw--color-white, #FFFFFF);position:sticky;width:100%;text-align:center;overflow:hidden;display:flex;justify-content:flex-end;align-items:center;border-bottom:6px solid var(--emw--color-primary, #22B04E);max-height:40px}.SlidingBar{transition:all 0.3s ease-in-out;width:100%}.Message{will-change:transform;margin:0 auto;padding:10px;width:90%}.ScrollLeft .Message{white-space:nowrap;animation:scroll-left 10s linear infinite;width:100%}.ScrollRight .Message{white-space:nowrap;animation:scroll-right 10s linear infinite;width:100%}.VisibleButtons .Message{display:flex}@keyframes scroll-left{from{transform:translateX(100%)}to{transform:translateX(-100%)}}@keyframes scroll-right{from{transform:translateX(-100%)}to{transform:translateX(100%)}}.SlidingBar:hover .Message{animation-play-state:paused}.CloseButton{padding-left:10px;background-color:var(--emw--header-color-background, var(--emw--color-background, #000000));display:flex;gap:10px}.ToggleButton{position:absolute;left:0}.ToggleButton .TriangleActive,.ToggleButton .TriangleInactive{display:block;transition:all 0.2s}.ToggleButton .TriangleActive{transform:scale(1.1) rotateX(180deg) translateY(3px);fill:var(--emw--color-primary, #52d004);margin-top:8px}.ToggleButton svg{fill:var(--emw--header-color-background, var(--emw--color-background, #000000));width:16px;transform:rotate(180deg)}.CloseButton{right:10px}button{background-color:var(--emw--color-primary, #22B04E);color:var(--emw--header-color-background, var(--emw--color-background, #000000));border:none;width:40px;height:40px;cursor:pointer}.NotificationWrapper.Minimized{visibility:hidden}";export{r as G}