53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
import { MdDialogRef, MdSnackBar } from '@angular/material';
|
|
import { MD_DIALOG_DATA } from '@angular/material';
|
|
import { Component, OnInit, Inject } from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'app-share-popup',
|
|
templateUrl: './share-popup.component.html',
|
|
styleUrls: ['./share-popup.component.css']
|
|
})
|
|
export class SharePopupComponent implements OnInit {
|
|
//private urlPartA: string = "https://www.facebook.com/plugins/share_button.php?href=";
|
|
//private urlPartB: string = "&layout=button_count&size=large&mobile_iframe=true&width=106&height=28&appId";
|
|
private urlPartA: string = "https://www.facebook.com/sharer/sharer.php?kid_directed_site=0&u=";
|
|
private urlPartB: string = "&display=popup&ref=plugin&src=share_button";
|
|
private twitterPartA: string = "https://twitter.com/intent/tweet?text=";
|
|
private twitterPartB: string = "https://twitter.com/intent/tweet?text=ShareThis&url=http%3A%2F%2Fwww.sharethis.com%2F";
|
|
public twitterUrl: string;
|
|
private sermonId: string;
|
|
public facebookIframeUrl: string;
|
|
private shareBaseUrl: string = "https://ofbbutte.com/api/share/s";
|
|
public shareUrl: string;
|
|
|
|
constructor(@Inject(MD_DIALOG_DATA) public data: any, private mdDialogRef: MdDialogRef<SharePopupComponent>, private snackbar: MdSnackBar) {
|
|
this.sermonId = data.sermonId;
|
|
this.shareUrl = this.shareBaseUrl + this.sermonId;
|
|
this.facebookIframeUrl = this.urlPartA + this.shareUrl + this.urlPartB;
|
|
this.twitterUrl = this.twitterPartA + data.sermonTitle + " - " + data.sermonDescription + "&url=" + this.shareUrl;
|
|
}
|
|
|
|
ngOnInit() {
|
|
}
|
|
|
|
close(){
|
|
this.mdDialogRef.close();
|
|
}
|
|
|
|
copyLink(target){
|
|
console.log(target);
|
|
target.select();
|
|
try {
|
|
var successful = document.execCommand('copy');
|
|
var msg = successful ? 'successful' : 'unsuccessful';
|
|
console.log('Copying text command was ' + msg);
|
|
target.blur();
|
|
let s = this.snackbar.open("Link Copied","OK");
|
|
s.onAction().subscribe(()=>{ s.dismiss(); });
|
|
s.afterOpened().subscribe(()=>{ setTimeout(()=>{ s.dismiss(); },3000); });
|
|
} catch (err) {
|
|
console.log('Oops, unable to copy');
|
|
}
|
|
}
|
|
}
|