@osovitny/anatoly 3.19.47 → 3.19.49

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.
@@ -21,9 +21,8 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
21
21
  import Swal from 'sweetalert2';
22
22
  import * as i1$5 from 'ngx-toastr';
23
23
  import { ToastrModule } from 'ngx-toastr';
24
- import * as i2 from '@angular/cdk/layout';
25
- import { Breakpoints } from '@angular/cdk/layout';
26
24
  import * as i1$6 from '@angular/cdk/platform';
25
+ import * as i2 from '@angular/cdk/layout';
27
26
  import * as i1$7 from '@angular/platform-browser';
28
27
  import * as i2$1 from '@angular/forms';
29
28
  import { FormControl, Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
@@ -3497,24 +3496,29 @@ class BrowserService {
3497
3496
  constructor(platform, breakpointObserver) {
3498
3497
  this.platform = platform;
3499
3498
  this.breakpointObserver = breakpointObserver;
3500
- // Breakpoint status flags
3501
- this.isMobileScreen = false;
3502
- this.isTabletScreen = false;
3503
- // Reactive update stream
3499
+ /*
3500
+ private isMobileScreen = false;
3501
+ private isTabletScreen = false;
3502
+ */
3503
+ //updated
3504
3504
  this._updated = new BehaviorSubject(null);
3505
3505
  this.updated$ = this._updated.asObservable();
3506
3506
  this.init();
3507
3507
  }
3508
3508
  init() {
3509
- // Listen to Angular CDK breakpoints for screen size changes
3509
+ /*
3510
3510
  this.breakpointObserver
3511
- .observe([Breakpoints.Handset, Breakpoints.Tablet])
3512
- .subscribe(result => {
3511
+ .observe([Breakpoints.Handset, Breakpoints.Tablet])
3512
+ .subscribe(result => {
3513
3513
  const breakpoints = result.breakpoints;
3514
+
3514
3515
  this.isMobileScreen = breakpoints[Breakpoints.Handset] || false;
3515
3516
  this.isTabletScreen = breakpoints[Breakpoints.Tablet] || false;
3517
+
3516
3518
  this.fireUpdated();
3517
- });
3519
+ });
3520
+ */
3521
+ this.fireUpdated();
3518
3522
  }
3519
3523
  fireUpdated() {
3520
3524
  this._updated.next(null);
@@ -3597,11 +3601,11 @@ class BrowserService {
3597
3601
  @osovitny/anatoly
3598
3602
 
3599
3603
  Authors:
3600
- Vadim Osovitny vadim.osovitny@osovitny.com
3601
- Anatoly Osovitny anatoly.osovitny@osovitny.com
3604
+ Vadim Osovitny vadim.osovitny@osovitny.com
3605
+ Anatoly Osovitny anatoly.osovitny@osovitny.com
3602
3606
 
3603
3607
  Created:
3604
- 29 Nov 2020
3608
+ 29 Nov 2020
3605
3609
 
3606
3610
  Copyright (c) 2016-2025 Osovitny Inc. All rights reserved.
3607
3611
  </file>
@@ -3612,25 +3616,72 @@ class DigitalMarketingService {
3612
3616
  this.title = title;
3613
3617
  this.meta = meta;
3614
3618
  this.dom = dom;
3619
+ this.existingMetaTags = new Map();
3615
3620
  }
3616
3621
  updateTitle(title) {
3617
3622
  this.title.setTitle(title);
3618
3623
  }
3619
3624
  updateDescription(desc) {
3620
- this.meta.updateTag({ name: 'description', content: desc });
3625
+ if (desc) {
3626
+ this.meta.updateTag({ name: 'description', content: desc });
3627
+ }
3628
+ else {
3629
+ this.meta.removeTag('name="description"');
3630
+ }
3621
3631
  }
3622
3632
  updateKeywords(keywords) {
3623
- this.meta.updateTag({ name: 'keywords', content: keywords });
3633
+ if (keywords) {
3634
+ this.meta.updateTag({ name: 'keywords', content: keywords });
3635
+ }
3636
+ else {
3637
+ this.meta.removeTag('name="keywords"');
3638
+ }
3624
3639
  }
3625
- updateMetaTags(meta) {
3626
- meta.forEach(m => this.meta.updateTag(m));
3640
+ updateMetaTags(metaDefinitions) {
3641
+ this.removePreviousMetaTags();
3642
+ if (metaDefinitions && metaDefinitions.length > 0) {
3643
+ metaDefinitions.forEach(metaDef => {
3644
+ const tag = this.meta.updateTag(metaDef);
3645
+ if (tag) {
3646
+ const key = this.getMetaTagKey(metaDef);
3647
+ this.existingMetaTags.set(key, tag);
3648
+ }
3649
+ });
3650
+ }
3651
+ }
3652
+ removePreviousMetaTags() {
3653
+ this.existingMetaTags.forEach((tag, key) => {
3654
+ if (tag && tag.parentNode) {
3655
+ tag.parentNode.removeChild(tag);
3656
+ }
3657
+ });
3658
+ this.existingMetaTags.clear();
3659
+ }
3660
+ getMetaTagKey(metaDef) {
3661
+ if (metaDef.name) {
3662
+ return `name:${metaDef.name}`;
3663
+ }
3664
+ else if (metaDef.property) {
3665
+ return `property:${metaDef.property}`;
3666
+ }
3667
+ else if (metaDef.httpEquiv) {
3668
+ return `httpEquiv:${metaDef.httpEquiv}`;
3669
+ }
3670
+ return Math.random().toString(); // fallback
3627
3671
  }
3628
3672
  setCanonicalUrl(url) {
3629
3673
  const canUrl = url === undefined ? this.dom.URL : url;
3674
+ const head = this.dom.getElementsByTagName('head')[0];
3675
+ const existingLinks = this.dom.querySelectorAll('link[rel="canonical"]');
3676
+ existingLinks.forEach((link) => {
3677
+ if (link.parentNode) {
3678
+ link.parentNode.removeChild(link);
3679
+ }
3680
+ });
3630
3681
  const link = this.dom.createElement('link');
3631
3682
  link.setAttribute('rel', 'canonical');
3632
- this.dom.head.appendChild(link);
3633
3683
  link.setAttribute('href', canUrl);
3684
+ head.appendChild(link);
3634
3685
  }
3635
3686
  updateCanonicalUrl(url) {
3636
3687
  const canUrl = url === undefined ? this.dom.URL : url;
@@ -3643,6 +3694,38 @@ class DigitalMarketingService {
3643
3694
  link.setAttribute('rel', 'canonical');
3644
3695
  link.setAttribute('href', canUrl);
3645
3696
  }
3697
+ updateOpenGraphTags(ogTags) {
3698
+ const metaTags = [];
3699
+ if (ogTags.title) {
3700
+ metaTags.push({ property: 'og:title', content: ogTags.title });
3701
+ metaTags.push({ name: 'twitter:title', content: ogTags.title });
3702
+ }
3703
+ if (ogTags.description) {
3704
+ metaTags.push({ property: 'og:description', content: ogTags.description });
3705
+ metaTags.push({ name: 'twitter:description', content: ogTags.description });
3706
+ }
3707
+ if (ogTags.image) {
3708
+ metaTags.push({ property: 'og:image', content: ogTags.image });
3709
+ metaTags.push({ name: 'twitter:image', content: ogTags.image });
3710
+ }
3711
+ if (ogTags.url) {
3712
+ metaTags.push({ property: 'og:url', content: ogTags.url });
3713
+ }
3714
+ metaTags.push({ name: 'twitter:card', content: 'summary_large_image' });
3715
+ this.updateMetaTags(metaTags);
3716
+ }
3717
+ clearAllMetaTags() {
3718
+ this.removePreviousMetaTags();
3719
+ this.meta.removeTag('name="description"');
3720
+ this.meta.removeTag('name="keywords"');
3721
+ const metaTagsToRemove = [
3722
+ 'property="og:title"', 'property="og:description"', 'property="og:image"', 'property="og:url"',
3723
+ 'name="twitter:title"', 'name="twitter:description"', 'name="twitter:image"', 'name="twitter:card"'
3724
+ ];
3725
+ metaTagsToRemove.forEach(selector => {
3726
+ this.meta.removeTag(selector);
3727
+ });
3728
+ }
3646
3729
  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
3730
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: DigitalMarketingService, factory: DigitalMarketingService.ɵfac, providedIn: 'root' }); }
3648
3731
  }