sharethis-angular
Version:
ShareThis Share Buttons for Angular apps/sites. Empower your online audience to share and amplify your content on social networks such as Facebook, WhatsApp, Linkedin, Twitter and many more. Includes four types of share buttons - Inline Share Buttons, Sti
247 lines (237 loc) • 10.4 kB
JavaScript
import * as i0 from '@angular/core';
import { Component, Input, ViewChild, NgModule } from '@angular/core';
function load (component, product) {
// load config
let config = component.config || { enabled: true };
config = JSON.parse(JSON.stringify(config));
// load buttons
const _onShareThisLoaded = window.onShareThisLoaded;
let onload = () => {
if (!onload.complete) {
if (!config.id) {
const id = 'sharethis-' + Date.now();
config.id = id;
}
if (component.buttons) {
component.buttons.id = config.id;
window.__sharethis__.load(product, config);
}
if (_onShareThisLoaded) {
_onShareThisLoaded();
}
onload.complete = true;
}
};
window.onShareThisLoaded = onload;
// load sharethis.js
if (document.getElementById('sharethis-js')) {
if (window.__sharethis__) {
window.onShareThisLoaded();
}
}
else {
const script = document.createElement('script');
script.setAttribute('id', 'sharethis-js');
const params = {
property: config.property || '',
product: product,
source: 'angularjs',
};
const query = Object.entries(params)
.map(([key, value]) => key + '=' + value)
.join('&');
script.src = 'https://platform-api.sharethis.com/js/sharethis.js?' + query;
script.async = true;
document.body.appendChild(script);
}
}
const DEFAULT_CONFIG$3 = {
alignment: 'left',
color: 'social',
enabled: true,
font_size: 16,
hide_desktop: false,
labels: 'counts',
language: 'en',
min_count: 0,
padding: 12,
radius: 4,
show_total: true,
show_mobile: true,
show_toggle: true,
size: 48,
top: 160,
};
class StickyShareButtonsComponent {
constructor(rd) {
this.rd = rd;
}
ngOnInit() { }
ngAfterViewInit() {
load({
config: { ...DEFAULT_CONFIG$3, ...this.config },
buttons: this.buttons.nativeElement,
}, 'sticky-share-buttons');
}
}
StickyShareButtonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: StickyShareButtonsComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
StickyShareButtonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.5", type: StickyShareButtonsComponent, selector: "st-sticky-share-buttons", inputs: { config: "config" }, viewQueries: [{ propertyName: "buttons", first: true, predicate: ["buttons"], descendants: true }], ngImport: i0, template: '<div #buttons> </div>', isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: StickyShareButtonsComponent, decorators: [{
type: Component,
args: [{
selector: 'st-sticky-share-buttons',
template: '<div #buttons> </div>',
}]
}], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { config: [{
type: Input
}], buttons: [{
type: ViewChild,
args: ['buttons']
}] } });
const DEFAULT_CONFIG$2 = {
alignment: 'center',
color: 'social',
enabled: true,
font_size: 16,
labels: 'cta',
language: 'en',
padding: 12,
radius: 4,
size: 40,
show_total: true,
};
class InlineShareButtonsComponent {
constructor(rd) {
this.rd = rd;
}
ngOnInit() { }
ngAfterViewInit() {
load({
config: { ...DEFAULT_CONFIG$2, ...this.config },
buttons: this.buttons.nativeElement,
}, 'inline-share-buttons');
}
}
InlineShareButtonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: InlineShareButtonsComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
InlineShareButtonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.5", type: InlineShareButtonsComponent, selector: "st-inline-share-buttons", inputs: { config: "config" }, viewQueries: [{ propertyName: "buttons", first: true, predicate: ["buttons"], descendants: true }], ngImport: i0, template: '<div #buttons> </div>', isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: InlineShareButtonsComponent, decorators: [{
type: Component,
args: [{
selector: 'st-inline-share-buttons',
template: '<div #buttons> </div>',
}]
}], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { config: [{
type: Input
}], buttons: [{
type: ViewChild,
args: ['buttons']
}] } });
const DEFAULT_CONFIG$1 = {
action: 'Follow us',
action_enabled: true,
action_pos: 'center',
alignment: 'center',
color: 'social',
enabled: true,
padding: 12,
radius: 4,
size: 40,
spacing: 8,
};
class InlineFollowButtonsComponent {
constructor(rd) {
this.rd = rd;
}
ngOnInit() { }
ngAfterViewInit() {
load({
config: { ...DEFAULT_CONFIG$1, ...this.config },
buttons: this.buttons.nativeElement,
}, 'inline-follow-buttons');
}
}
InlineFollowButtonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: InlineFollowButtonsComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
InlineFollowButtonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.5", type: InlineFollowButtonsComponent, selector: "st-inline-follow-buttons", inputs: { config: "config" }, viewQueries: [{ propertyName: "buttons", first: true, predicate: ["buttons"], descendants: true }], ngImport: i0, template: '<div #buttons> </div>', isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: InlineFollowButtonsComponent, decorators: [{
type: Component,
args: [{
selector: 'st-inline-follow-buttons',
template: '<div #buttons> </div>',
}]
}], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { config: [{
type: Input
}], buttons: [{
type: ViewChild,
args: ['buttons']
}] } });
const DEFAULT_CONFIG = {
alignment: 'center',
enabled: true,
language: 'en',
min_count: 0,
padding: 12,
size: 40,
};
class InlineReactionButtonsComponent {
constructor(rd) {
this.rd = rd;
}
ngOnInit() { }
ngAfterViewInit() {
load({
config: { ...DEFAULT_CONFIG, ...this.config },
buttons: this.buttons.nativeElement,
}, 'inline-reaction-buttons');
}
}
InlineReactionButtonsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: InlineReactionButtonsComponent, deps: [{ token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Component });
InlineReactionButtonsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.5", type: InlineReactionButtonsComponent, selector: "st-inline-reaction-buttons", inputs: { config: "config" }, viewQueries: [{ propertyName: "buttons", first: true, predicate: ["buttons"], descendants: true }], ngImport: i0, template: '<div #buttons> </div>', isInline: true });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: InlineReactionButtonsComponent, decorators: [{
type: Component,
args: [{
selector: 'st-inline-reaction-buttons',
template: '<div #buttons> </div>',
}]
}], ctorParameters: function () { return [{ type: i0.Renderer2 }]; }, propDecorators: { config: [{
type: Input
}], buttons: [{
type: ViewChild,
args: ['buttons']
}] } });
class SharethisAngularModule {
}
SharethisAngularModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: SharethisAngularModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
SharethisAngularModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.5", ngImport: i0, type: SharethisAngularModule, declarations: [StickyShareButtonsComponent,
InlineShareButtonsComponent,
InlineFollowButtonsComponent,
InlineReactionButtonsComponent], exports: [StickyShareButtonsComponent,
InlineShareButtonsComponent,
InlineFollowButtonsComponent,
InlineReactionButtonsComponent] });
SharethisAngularModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: SharethisAngularModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.5", ngImport: i0, type: SharethisAngularModule, decorators: [{
type: NgModule,
args: [{
declarations: [
StickyShareButtonsComponent,
InlineShareButtonsComponent,
InlineFollowButtonsComponent,
InlineReactionButtonsComponent,
],
imports: [],
exports: [
StickyShareButtonsComponent,
InlineShareButtonsComponent,
InlineFollowButtonsComponent,
InlineReactionButtonsComponent,
],
}]
}] });
/*
* Public API Surface of sharethis-angular
*/
/**
* Generated bundle index. Do not edit.
*/
export { InlineFollowButtonsComponent, InlineReactionButtonsComponent, InlineShareButtonsComponent, SharethisAngularModule, StickyShareButtonsComponent };
//# sourceMappingURL=sharethis-angular.mjs.map