Enhance fb sharing
parent
c2d927788a
commit
875ae030f7
|
|
@ -1,7 +1,8 @@
|
||||||
import { BibleVerseService } from './../../services/bible-verse.service';
|
import { BibleVerseService } from './../../services/bible-verse.service';
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, Inject } from '@angular/core';
|
||||||
import { MatDialogConfig, MatDialog } from '@angular/material';
|
import { MatDialogConfig, MatDialog } from '@angular/material';
|
||||||
import { SharePopupComponent } from '../popups/share-popup/share-popup.component';
|
import { SharePopupComponent } from '../popups/share-popup/share-popup.component';
|
||||||
|
import { DOCUMENT } from '@angular/platform-browser';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'image-component',
|
selector: 'image-component',
|
||||||
|
|
@ -12,7 +13,7 @@ export class ImageComponent implements OnInit {
|
||||||
|
|
||||||
public shareUrl: string;
|
public shareUrl: string;
|
||||||
|
|
||||||
constructor(private dialog: MatDialog) { }
|
constructor(private dialog: MatDialog, @Inject(DOCUMENT) private document) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// this.bibleVerseService.randomVerse().subscribe(
|
// this.bibleVerseService.randomVerse().subscribe(
|
||||||
|
|
@ -23,8 +24,20 @@ export class ImageComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public share() {
|
public share() {
|
||||||
|
let port = this.document.location.port ? ":"+this.document.location.port : "";
|
||||||
|
let baseUrl = this.document.location.protocol +'//'+ this.document.location.hostname + port
|
||||||
let opts = new MatDialogConfig;
|
let opts = new MatDialogConfig;
|
||||||
opts.data = { relativeUrl: '/covid', title: 'Coronavirus Anxiety', description: 'Ecouragement in uncertain times' };
|
opts.data = {
|
||||||
|
prefix: 'o',
|
||||||
|
otherData: {
|
||||||
|
imageUrl: baseUrl + '/static/media/images/covid_fb_share.jpg',
|
||||||
|
imageWidth: 750,
|
||||||
|
imageHeight: 404,
|
||||||
|
title: 'Coronavirus Anxiety?',
|
||||||
|
description: 'The cure for coronavirus anxiety',
|
||||||
|
url: baseUrl + '/covid'
|
||||||
|
}
|
||||||
|
};
|
||||||
let dialog = this.dialog.open(SharePopupComponent, opts);
|
let dialog = this.dialog.open(SharePopupComponent, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,11 @@ export class SharePopupComponent implements OnInit {
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
let port = this.document.location.port ? ":"+this.document.location.port : "";
|
let port = this.document.location.port ? ":"+this.document.location.port : "";
|
||||||
this.shareUrl = this.document.location.protocol +'//'+ this.document.location.hostname + port + this.shareBaseUrl + data.prefix + this.id;
|
this.shareUrl = this.document.location.protocol +'//'+ this.document.location.hostname + port + this.shareBaseUrl + data.prefix + this.id;
|
||||||
if (this.data.relativeUrl) {
|
if (this.data.prefix === 'o') {
|
||||||
this.shareUrl = this.document.location.protocol + '//' + this.document.location.hostname + port + this.data.relativeUrl;
|
const shareData = encodeURIComponent(JSON.stringify(this.data.otherData));
|
||||||
|
console.log(shareData);
|
||||||
|
this.shareUrl = this.document.location.protocol + '//' + this.document.location.hostname + port + this.shareBaseUrl + data.prefix + shareData;
|
||||||
|
console.log(this.shareUrl);
|
||||||
}
|
}
|
||||||
this.facebookIframeUrl = this.urlPartA + this.shareUrl + this.urlPartB;
|
this.facebookIframeUrl = this.urlPartA + this.shareUrl + this.urlPartB;
|
||||||
this.twitterUrl = this.twitterPartA + data.title + " - " + data.description + "&url=" + this.shareUrl;
|
this.twitterUrl = this.twitterPartA + data.title + " - " + data.description + "&url=" + this.shareUrl;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue