@osovitny/anatoly 3.19.46 → 3.19.48

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.
@@ -356,9 +356,9 @@ class AppContextService extends ApiServiceBase {
356
356
  //userUpdated
357
357
  this._userUpdated = new BehaviorSubject(null);
358
358
  this.userUpdated$ = this._userUpdated.asObservable();
359
- //jsonFilesLoaded
360
- this._jsonFilesLoaded = new BehaviorSubject(null);
361
- this.jsonFilesLoaded$ = this._jsonFilesLoaded.asObservable();
359
+ //standardJsonFilesLoaded
360
+ this._standardJsonFilesLoaded = new BehaviorSubject(null);
361
+ this.standardJsonFilesLoaded$ = this._standardJsonFilesLoaded.asObservable();
362
362
  this.baseUrl = `${ApiUrl}/appContext`;
363
363
  }
364
364
  //fires
@@ -371,8 +371,8 @@ class AppContextService extends ApiServiceBase {
371
371
  fireUserUpdated() {
372
372
  this._userUpdated.next(null);
373
373
  }
374
- fireJsonFilesLoaded() {
375
- this._jsonFilesLoaded.next(null);
374
+ fireStandardJsonFilesLoaded() {
375
+ this._standardJsonFilesLoaded.next(null);
376
376
  }
377
377
  //API
378
378
  getCountriesJsonFile() {
@@ -477,7 +477,7 @@ class AppContextService extends ApiServiceBase {
477
477
  let stopwatch = new Stopwatch("@osovitny/anatoly. AppContextService: loading standard json files");
478
478
  stopwatch.start();
479
479
  return tasks$.pipe(tap(() => {
480
- this.fireJsonFilesLoaded();
480
+ this.fireStandardJsonFilesLoaded();
481
481
  //Logging
482
482
  stopwatch.stop();
483
483
  stopwatch.printElapsedAsMilliseconds();
@@ -3597,11 +3597,11 @@ class BrowserService {
3597
3597
  @osovitny/anatoly
3598
3598
 
3599
3599
  Authors:
3600
- Vadim Osovitny vadim.osovitny@osovitny.com
3601
- Anatoly Osovitny anatoly.osovitny@osovitny.com
3600
+ Vadim Osovitny vadim.osovitny@osovitny.com
3601
+ Anatoly Osovitny anatoly.osovitny@osovitny.com
3602
3602
 
3603
3603
  Created:
3604
- 29 Nov 2020
3604
+ 29 Nov 2020
3605
3605
 
3606
3606
  Copyright (c) 2016-2025 Osovitny Inc. All rights reserved.
3607
3607
  </file>
@@ -3612,25 +3612,72 @@ class DigitalMarketingService {
3612
3612
  this.title = title;
3613
3613
  this.meta = meta;
3614
3614
  this.dom = dom;
3615
+ this.existingMetaTags = new Map();
3615
3616
  }
3616
3617
  updateTitle(title) {
3617
3618
  this.title.setTitle(title);
3618
3619
  }
3619
3620
  updateDescription(desc) {
3620
- this.meta.updateTag({ name: 'description', content: desc });
3621
+ if (desc) {
3622
+ this.meta.updateTag({ name: 'description', content: desc });
3623
+ }
3624
+ else {
3625
+ this.meta.removeTag('name="description"');
3626
+ }
3621
3627
  }
3622
3628
  updateKeywords(keywords) {
3623
- this.meta.updateTag({ name: 'keywords', content: keywords });
3629
+ if (keywords) {
3630
+ this.meta.updateTag({ name: 'keywords', content: keywords });
3631
+ }
3632
+ else {
3633
+ this.meta.removeTag('name="keywords"');
3634
+ }
3624
3635
  }
3625
- updateMetaTags(meta) {
3626
- meta.forEach(m => this.meta.updateTag(m));
3636
+ updateMetaTags(metaDefinitions) {
3637
+ this.removePreviousMetaTags();
3638
+ if (metaDefinitions && metaDefinitions.length > 0) {
3639
+ metaDefinitions.forEach(metaDef => {
3640
+ const tag = this.meta.updateTag(metaDef);
3641
+ if (tag) {
3642
+ const key = this.getMetaTagKey(metaDef);
3643
+ this.existingMetaTags.set(key, tag);
3644
+ }
3645
+ });
3646
+ }
3647
+ }
3648
+ removePreviousMetaTags() {
3649
+ this.existingMetaTags.forEach((tag, key) => {
3650
+ if (tag && tag.parentNode) {
3651
+ tag.parentNode.removeChild(tag);
3652
+ }
3653
+ });
3654
+ this.existingMetaTags.clear();
3655
+ }
3656
+ getMetaTagKey(metaDef) {
3657
+ if (metaDef.name) {
3658
+ return `name:${metaDef.name}`;
3659
+ }
3660
+ else if (metaDef.property) {
3661
+ return `property:${metaDef.property}`;
3662
+ }
3663
+ else if (metaDef.httpEquiv) {
3664
+ return `httpEquiv:${metaDef.httpEquiv}`;
3665
+ }
3666
+ return Math.random().toString(); // fallback
3627
3667
  }
3628
3668
  setCanonicalUrl(url) {
3629
3669
  const canUrl = url === undefined ? this.dom.URL : url;
3670
+ const head = this.dom.getElementsByTagName('head')[0];
3671
+ const existingLinks = this.dom.querySelectorAll('link[rel="canonical"]');
3672
+ existingLinks.forEach((link) => {
3673
+ if (link.parentNode) {
3674
+ link.parentNode.removeChild(link);
3675
+ }
3676
+ });
3630
3677
  const link = this.dom.createElement('link');
3631
3678
  link.setAttribute('rel', 'canonical');
3632
- this.dom.head.appendChild(link);
3633
3679
  link.setAttribute('href', canUrl);
3680
+ head.appendChild(link);
3634
3681
  }
3635
3682
  updateCanonicalUrl(url) {
3636
3683
  const canUrl = url === undefined ? this.dom.URL : url;
@@ -3643,6 +3690,38 @@ class DigitalMarketingService {
3643
3690
  link.setAttribute('rel', 'canonical');
3644
3691
  link.setAttribute('href', canUrl);
3645
3692
  }
3693
+ updateOpenGraphTags(ogTags) {
3694
+ const metaTags = [];
3695
+ if (ogTags.title) {
3696
+ metaTags.push({ property: 'og:title', content: ogTags.title });
3697
+ metaTags.push({ name: 'twitter:title', content: ogTags.title });
3698
+ }
3699
+ if (ogTags.description) {
3700
+ metaTags.push({ property: 'og:description', content: ogTags.description });
3701
+ metaTags.push({ name: 'twitter:description', content: ogTags.description });
3702
+ }
3703
+ if (ogTags.image) {
3704
+ metaTags.push({ property: 'og:image', content: ogTags.image });
3705
+ metaTags.push({ name: 'twitter:image', content: ogTags.image });
3706
+ }
3707
+ if (ogTags.url) {
3708
+ metaTags.push({ property: 'og:url', content: ogTags.url });
3709
+ }
3710
+ metaTags.push({ name: 'twitter:card', content: 'summary_large_image' });
3711
+ this.updateMetaTags(metaTags);
3712
+ }
3713
+ clearAllMetaTags() {
3714
+ this.removePreviousMetaTags();
3715
+ this.meta.removeTag('name="description"');
3716
+ this.meta.removeTag('name="keywords"');
3717
+ const metaTagsToRemove = [
3718
+ 'property="og:title"', 'property="og:description"', 'property="og:image"', 'property="og:url"',
3719
+ 'name="twitter:title"', 'name="twitter:description"', 'name="twitter:image"', 'name="twitter:card"'
3720
+ ];
3721
+ metaTagsToRemove.forEach(selector => {
3722
+ this.meta.removeTag(selector);
3723
+ });
3724
+ }
3646
3725
  static { this.ɵfac = function DigitalMarketingService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || DigitalMarketingService)(i0.ɵɵinject(i1$7.Title), i0.ɵɵinject(i1$7.Meta), i0.ɵɵinject(DOCUMENT)); }; }
3647
3726
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DigitalMarketingService, factory: DigitalMarketingService.ɵfac, providedIn: 'root' }); }
3648
3727
  }
@@ -7210,7 +7289,7 @@ class CountryDropdownlist extends EditComponentBase {
7210
7289
  this.setValues();
7211
7290
  }
7212
7291
  setValues() {
7213
- this.appContext.jsonFilesLoaded$.subscribe({
7292
+ this.appContext.standardJsonFilesLoaded$.subscribe({
7214
7293
  next: () => {
7215
7294
  this.items = Utils.sortArray(this.appContext.countries);
7216
7295
  }
@@ -7279,7 +7358,7 @@ class LanguageDropdownlist extends EditComponentBase {
7279
7358
  this.appContext = appContext;
7280
7359
  }
7281
7360
  ngOnInit() {
7282
- this.appContext.jsonFilesLoaded$.subscribe({
7361
+ this.appContext.standardJsonFilesLoaded$.subscribe({
7283
7362
  next: () => {
7284
7363
  this.items = Utils.sortArray(this.appContext.languages);
7285
7364
  }
@@ -7688,7 +7767,7 @@ class TimezoneDropdownlist extends EditComponentBase {
7688
7767
  this.setValues();
7689
7768
  }
7690
7769
  setValues() {
7691
- this.appContext.jsonFilesLoaded$.subscribe({
7770
+ this.appContext.standardJsonFilesLoaded$.subscribe({
7692
7771
  next: () => {
7693
7772
  this.items = Utils.sortArray(this.appContext.timezones);
7694
7773
  }
@@ -9737,7 +9816,7 @@ class AddressComponent extends EditComponentBase {
9737
9816
  this.title = 'Address';
9738
9817
  }
9739
9818
  ngOnInit() {
9740
- this.appContext.jsonFilesLoaded$.subscribe({
9819
+ this.appContext.standardJsonFilesLoaded$.subscribe({
9741
9820
  next: () => {
9742
9821
  this.countryData = Utils.sortArray(this.appContext.countries);
9743
9822
  this.usStateData = Utils.sortArray(this.appContext.usStates);