Skip to content

Commit

Permalink
11008 primera versión funcionamiento botones compartir
Browse files Browse the repository at this point in the history
  • Loading branch information
178Pelado committed Dec 17, 2024
1 parent 6f08149 commit 3d1c457
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@ <h4 class="modal-title">Compartir</h4>

<!-- Botones de redes sociales con iconos de Font Awesome -->
<div class="social-buttons">
<button class="social-icon-button">
<!-- Botón de ResearchGate -->
<a class="social-icon-button" [href]="researchGateLink" target="_blank">
<i class="fa-brands fa-researchgate icon-size"></i>
</button>
<button class="social-icon-button">
</a>
<!-- Botón de Mendeley -->
<a class="social-icon-button" [href]="mendeleyLink" target="_blank">
<i class="fa-brands fa-mendeley icon-size"></i>
</button>
<button class="social-icon-button">
</a>
<!-- Botón de WhatsApp -->
<a class="social-icon-button" [href]="whatsappLink" target="_blank">
<i class="fa-brands fa-whatsapp icon-size"></i>
</button>
<button class="social-icon-button">
</a>
<!-- Botón de LinkedIn -->
<a class="social-icon-button" [href]="linkedinLink" target="_blank">
<i class="fa-brands fa-linkedin icon-size"></i>
</button>
<button class="social-icon-button">
</a>
<!-- Botón de X (Twitter) -->
<a class="social-icon-button" [href]="xLink" target="_blank">
<i class="fa-brands fa-x-twitter icon-size"></i>
</button>
</a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CommonModule } from '@angular/common';
import { Component, ViewChild, ElementRef, Input } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { HostWindowService } from 'src/app/shared/host-window.service';
import { Observable } from 'rxjs';

@Component({
selector: 'sedici-share-buttons',
Expand All @@ -13,9 +15,14 @@ export class SediciShareButtonsComponent {

@ViewChild('elementContentToCopy') elementContentToCopy: ElementRef;
@Input() link: string;
@Input() title: string;
@Input() type: string;
isMobile$: Observable<boolean>;
copySuccess: boolean = false;

constructor(public activeModal: NgbActiveModal) {}
constructor(public activeModal: NgbActiveModal, private windowService: HostWindowService) {
this.isMobile$ = this.windowService.isMobile();
}

copyToClipboard(element: HTMLInputElement) {
navigator.clipboard.writeText(element.value).then(() => {
Expand All @@ -26,6 +33,37 @@ export class SediciShareButtonsComponent {
});
}

get researchGateLink(): string {
const subject = `${this.type} compartido desde sedici.unlp.edu.ar`;
const text = `¡Hola! Quiero compartir este/a ${this.type} desde el repositorio SEDICI (sedici.unlp.edu.ar).\n${this.title}\n${this.link}`;
return `https://www.researchgate.net/messages?ocmd=1&messageModalSubject=${encodeURIComponent(subject)}&messageModalText=${encodeURIComponent(text)}`;
}

get mendeleyLink(): string {
return `https://www.mendeley.com/import/?url=${encodeURIComponent(this.link)}`;
}

get whatsappLink(): string {
let baseURL = '';
this.isMobile$.subscribe(isMobile => {
if (isMobile) {
baseURL = 'https://api.whatsapp.com/send';
} else {
baseURL = 'https://web.whatsapp.com/send';
}
});
const message = `¡Hola! Quiero compartir este/a ${this.type} desde el repositorio SEDICI (sedici.unlp.edu.ar).\n${this.title}\n${this.link}`;
return `${baseURL}?text=${encodeURIComponent(message)}`;
}

get linkedinLink(): string {
return `https://www.linkedin.com/shareArticle?mini=true&url=${encodeURIComponent(this.link)}&title=${encodeURIComponent(this.title)}`;
}

get xLink(): string {
return `https://x.com/share?text=${encodeURIComponent(this.title)}&url=${encodeURIComponent(this.link)}&via=sedici_unlp`;
}

close() {
this.activeModal.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export class UntypedItemComponent extends BaseComponent {
centered: true, // Centra el modal
});
modalRef.componentInstance.link = this.object.firstMetadataValue('dc.identifier.uri');
modalRef.componentInstance.title = this.object.firstMetadataValue('dc.title');
modalRef.componentInstance.type = this.object.firstMetadataValue('sedici.subtype') || this.object.firstMetadataValue('dc.type');
}

get hasMetadata(): boolean {
Expand Down

0 comments on commit 3d1c457

Please sign in to comment.