@odilo/core
Version:
Share buttons components for Angular and Ionic.
1,592 lines (1,566 loc) • 66.3 kB
JavaScript
import { DOCUMENT } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { Meta } from '@angular/platform-browser';
import { Platform, PlatformModule } from '@angular/cdk/platform';
import { BehaviorSubject, Subscription } from 'rxjs';
import { map } from 'rxjs/operators';
import { __spread, __extends, __read } from 'tslib';
import { InjectionToken, Inject, Injectable, Optional, NgModule, Directive, Input, Output, HostBinding, HostListener, EventEmitter, ElementRef, Renderer2, ChangeDetectorRef, Pipe, defineInjectable, inject } from '@angular/core';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var SHARE_BUTTONS_CONFIG = new InjectionToken('shareButtonsConfig');
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var ShareButtonBase = /** @class */ (function () {
function ShareButtonBase(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
this._props = _props;
this._url = _url;
this._http = _http;
this._platform = _platform;
this._document = _document;
this._windowSize = _windowSize;
this._disableButtonClick = _disableButtonClick;
this._logger = _logger;
this._self = this;
/**
* If share button supports share count
*/
this.supportShareCount = false;
}
Object.defineProperty(ShareButtonBase.prototype, "text", {
/** Share button label */
get: /**
* Share button label
* @return {?}
*/
function () {
return this._props.text;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ShareButtonBase.prototype, "ariaLabel", {
/** Share button aria-label attribute */
get: /**
* Share button aria-label attribute
* @return {?}
*/
function () {
return this._props.ariaLabel;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ShareButtonBase.prototype, "color", {
/** Share button color */
get: /**
* Share button color
* @return {?}
*/
function () {
return this._props.color;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ShareButtonBase.prototype, "icon", {
/** Share button icon (FontAwesome) */
get: /**
* Share button icon (FontAwesome)
* @return {?}
*/
function () {
return this._props.icon;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ShareButtonBase.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ShareButtonBase.prototype, "android", {
get: /**
* @return {?}
*/
function () {
return this.desktop;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ShareButtonBase.prototype, "ios", {
get: /**
* @return {?}
*/
function () {
return this.desktop;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ShareButtonBase.prototype, "sharerUrl", {
get: /**
* @return {?}
*/
function () {
if (this._platform.IOS)
return this.ios;
if (this._platform.ANDROID)
return this.android;
return this.desktop;
},
enumerable: true,
configurable: true
});
/**
* Opens share window
*/
/**
* Opens share window
* @param {?} metaTags
* @return {?}
*/
ShareButtonBase.prototype.click = /**
* Opens share window
* @param {?} metaTags
* @return {?}
*/
function (metaTags) {
return this._open(this._serializeMetaTags(metaTags));
};
/** Get share count of a URL */
/**
* Get share count of a URL
* @param {?} url
* @return {?}
*/
ShareButtonBase.prototype.shareCount = /**
* Get share count of a URL
* @param {?} url
* @return {?}
*/
function (url) {
return undefined;
};
/**
* @protected
* @param {?} metaTags
* @return {?}
*/
ShareButtonBase.prototype._serializeMetaTags = /**
* @protected
* @param {?} metaTags
* @return {?}
*/
function (metaTags) {
return Object.entries(this._supportedMetaTags)
.map((/**
* @param {?} __0
* @return {?}
*/
function (_a) {
var _b = __read(_a, 2), key = _b[0], value = _b[1];
return metaTags[key] ? value + "=" + encodeURIComponent(metaTags[key]) : '';
}))
.join('&');
};
/**
* @protected
* @param {?} serializedMetaTags
* @return {?}
*/
ShareButtonBase.prototype._open = /**
* @protected
* @param {?} serializedMetaTags
* @return {?}
*/
function (serializedMetaTags) {
var _this = this;
return new Promise((/**
* @param {?} resolve
* @return {?}
*/
function (resolve) {
// Avoid SSR error
if (_this.sharerUrl && _this._platform.isBrowser) {
/** @type {?} */
var finalUrl = _this.sharerUrl + serializedMetaTags;
// Debug mode, log sharer link
_this._logger(finalUrl);
/** @type {?} */
var popUp_1 = _this._document.defaultView.open(finalUrl, 'newwindow', _this._windowSize);
// Resolve when share dialog is closed
if (popUp_1) {
/** @type {?} */
var pollTimer_1 = _this._document.defaultView.setInterval((/**
* @return {?}
*/
function () {
if (popUp_1.closed) {
_this._document.defaultView.clearInterval(pollTimer_1);
resolve();
}
}), 200);
}
}
else {
console.warn(_this.text + " button is not compatible on this Platform");
}
}));
};
return ShareButtonBase;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var FacebookButton = /** @class */ (function (_super) {
__extends(FacebookButton, _super);
function FacebookButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this.supportShareCount = true;
_this._supportedMetaTags = {
url: 'u'
};
return _this;
}
Object.defineProperty(FacebookButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://www.facebook.com/sharer/sharer.php?";
},
enumerable: true,
configurable: true
});
/**
* @param {?} url
* @return {?}
*/
FacebookButton.prototype.shareCount = /**
* @param {?} url
* @return {?}
*/
function (url) {
return this._http.get("https://graph.facebook.com?id=" + url).pipe(map((/**
* @param {?} res
* @return {?}
*/
function (res) { return +res.share.share_count; })));
};
return FacebookButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TwitterButton = /** @class */ (function (_super) {
__extends(TwitterButton, _super);
function TwitterButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url',
description: 'text',
tags: 'hashtags',
via: 'via'
};
return _this;
}
Object.defineProperty(TwitterButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://twitter.com/intent/tweet?";
},
enumerable: true,
configurable: true
});
return TwitterButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var LinkedinButton = /** @class */ (function (_super) {
__extends(LinkedinButton, _super);
function LinkedinButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url',
title: 'title',
description: 'summary'
};
return _this;
}
Object.defineProperty(LinkedinButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "http://www.linkedin.com/shareArticle?";
},
enumerable: true,
configurable: true
});
return LinkedinButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var GooglePlusButton = /** @class */ (function (_super) {
__extends(GooglePlusButton, _super);
function GooglePlusButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url'
};
return _this;
}
Object.defineProperty(GooglePlusButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://plus.google.com/share?";
},
enumerable: true,
configurable: true
});
return GooglePlusButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TumblrButton = /** @class */ (function (_super) {
__extends(TumblrButton, _super);
function TumblrButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this.supportShareCount = true;
_this._supportedMetaTags = {
url: 'canonicalUrl',
description: 'caption',
tags: 'tags'
};
return _this;
}
Object.defineProperty(TumblrButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "http://tumblr.com/widgets/share/tool?";
},
enumerable: true,
configurable: true
});
/**
* @param {?} url
* @return {?}
*/
TumblrButton.prototype.shareCount = /**
* @param {?} url
* @return {?}
*/
function (url) {
return this._http.jsonp("https://api.tumblr.com/v2/share/stats?url=" + url, 'callback').pipe(map((/**
* @param {?} res
* @return {?}
*/
function (res) { return +res.response.note_count; })));
};
return TumblrButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var PinterestButton = /** @class */ (function (_super) {
__extends(PinterestButton, _super);
function PinterestButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this.supportShareCount = true;
_this._supportedMetaTags = {
url: 'url',
description: 'description',
image: 'media'
};
return _this;
}
Object.defineProperty(PinterestButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://pinterest.com/pin/create/button/?";
},
enumerable: true,
configurable: true
});
/**
* @param {?} metaTags
* @return {?}
*/
PinterestButton.prototype.click = /**
* @param {?} metaTags
* @return {?}
*/
function (metaTags) {
// Check if image parameter is defined
if (metaTags.image) {
return this._open(this._serializeMetaTags(metaTags));
}
console.warn('Pinterest button: image parameter is required!');
};
/**
* @param {?} url
* @return {?}
*/
PinterestButton.prototype.shareCount = /**
* @param {?} url
* @return {?}
*/
function (url) {
return this._http.get("https://api.pinterest.com/v1/urls/count.json?url=" + url, { responseType: 'text' }).pipe(map((/**
* @param {?} text
* @return {?}
*/
function (text) { return JSON.parse(text.replace(/^receiveCount\((.*)\)/, '$1')); })), map((/**
* @param {?} res
* @return {?}
*/
function (res) { return +res.count; })));
};
return PinterestButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var RedditButton = /** @class */ (function (_super) {
__extends(RedditButton, _super);
function RedditButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url',
title: 'title'
};
return _this;
}
Object.defineProperty(RedditButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "http://www.reddit.com/submit?";
},
enumerable: true,
configurable: true
});
return RedditButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var VkButton = /** @class */ (function (_super) {
__extends(VkButton, _super);
function VkButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url'
};
return _this;
}
Object.defineProperty(VkButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "http://vk.com/share.php?";
},
enumerable: true,
configurable: true
});
return VkButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var TelegramButton = /** @class */ (function (_super) {
__extends(TelegramButton, _super);
function TelegramButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url',
description: 'text'
};
return _this;
}
Object.defineProperty(TelegramButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return 'https://t.me/share/url?';
},
enumerable: true,
configurable: true
});
return TelegramButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MessengerButton = /** @class */ (function (_super) {
__extends(MessengerButton, _super);
function MessengerButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'link'
};
return _this;
}
Object.defineProperty(MessengerButton.prototype, "android", {
get: /**
* @return {?}
*/
function () {
return 'fb-messenger://share/?';
},
enumerable: true,
configurable: true
});
Object.defineProperty(MessengerButton.prototype, "ios", {
get: /**
* @return {?}
*/
function () {
return 'fb-messenger://share/?';
},
enumerable: true,
configurable: true
});
return MessengerButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var WhatsappButton = /** @class */ (function (_super) {
__extends(WhatsappButton, _super);
function WhatsappButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
description: 'text'
};
return _this;
}
Object.defineProperty(WhatsappButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://wa.me/?";
},
enumerable: true,
configurable: true
});
Object.defineProperty(WhatsappButton.prototype, "android", {
get: /**
* @return {?}
*/
function () {
return "whatsapp://send?";
},
enumerable: true,
configurable: true
});
Object.defineProperty(WhatsappButton.prototype, "ios", {
get: /**
* @return {?}
*/
function () {
return "https://api.whatsapp.com/send?";
},
enumerable: true,
configurable: true
});
/**
* @param {?} metaTags
* @return {?}
*/
WhatsappButton.prototype.click = /**
* @param {?} metaTags
* @return {?}
*/
function (metaTags) {
// Add the URL to message body
metaTags.description = metaTags.description ? metaTags.description + "\r\n" + this._url() : this._url();
/** @type {?} */
var serializedMetaTags = this._serializeMetaTags(metaTags);
return this._open(serializedMetaTags);
};
return WhatsappButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var XingButton = /** @class */ (function (_super) {
__extends(XingButton, _super);
function XingButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url'
};
return _this;
}
Object.defineProperty(XingButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://www.xing.com/app/user?op=share&";
},
enumerable: true,
configurable: true
});
return XingButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var SmsButton = /** @class */ (function (_super) {
__extends(SmsButton, _super);
function SmsButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
description: 'body'
};
return _this;
}
Object.defineProperty(SmsButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "sms:?";
},
enumerable: true,
configurable: true
});
Object.defineProperty(SmsButton.prototype, "android", {
get: /**
* @return {?}
*/
function () {
return "sms:?";
},
enumerable: true,
configurable: true
});
Object.defineProperty(SmsButton.prototype, "ios", {
get: /**
* @return {?}
*/
function () {
return 'sms:&';
},
enumerable: true,
configurable: true
});
/**
* @param {?} metaTags
* @return {?}
*/
SmsButton.prototype.click = /**
* @param {?} metaTags
* @return {?}
*/
function (metaTags) {
// Add the URL to message body
metaTags.description = metaTags.description ? metaTags.description + "\r\n" + this._url() : this._url();
/** @type {?} */
var serializedMetaTags = this._serializeMetaTags(metaTags);
return this._open(serializedMetaTags);
};
return SmsButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var EmailButton = /** @class */ (function (_super) {
__extends(EmailButton, _super);
function EmailButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
title: 'subject',
description: 'body'
};
return _this;
}
Object.defineProperty(EmailButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "mailto:?";
},
enumerable: true,
configurable: true
});
/**
* @param {?} metaTags
* @return {?}
*/
EmailButton.prototype.click = /**
* @param {?} metaTags
* @return {?}
*/
function (metaTags) {
// Add URL to message body
metaTags.description = metaTags.description ? metaTags.description + "\r\n" + this._url() : this._url();
/** @type {?} */
var serializedMetaTags = this._serializeMetaTags(metaTags);
return this._open(serializedMetaTags);
};
return EmailButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var PrintButton = /** @class */ (function (_super) {
__extends(PrintButton, _super);
function PrintButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
return _this;
}
/**
* @return {?}
*/
PrintButton.prototype.click = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise((/**
* @param {?} resolve
* @return {?}
*/
function (resolve) {
_this._document.defaultView.print();
resolve();
}));
};
return PrintButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var CopyButton = /** @class */ (function (_super) {
__extends(CopyButton, _super);
function CopyButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
return _this;
}
Object.defineProperty(CopyButton.prototype, "text", {
get: /**
* @return {?}
*/
function () {
return this._disable ? this._props.extra.successLabel : this._props.text;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CopyButton.prototype, "icon", {
get: /**
* @return {?}
*/
function () {
return this._disable ? this._props.extra.successIcon : this._props.icon;
},
enumerable: true,
configurable: true
});
/**
* @private
* @return {?}
*/
CopyButton.prototype._disableButton = /**
* @private
* @return {?}
*/
function () {
// Disable pointer for tiny delay
this._disable = true;
this._disableButtonClick(true);
};
/**
* @private
* @return {?}
*/
CopyButton.prototype._resetButton = /**
* @private
* @return {?}
*/
function () {
this._disable = false;
this._disableButtonClick(false);
};
/**
* @return {?}
*/
CopyButton.prototype.click = /**
* @return {?}
*/
function () {
var _this = this;
return new Promise((/**
* @param {?} resolve
* @return {?}
*/
function (resolve) {
try {
/** @type {?} */
var textArea = (/** @type {?} */ (_this._document.createElement('textarea')));
textArea.value = decodeURIComponent(_this._url());
_this._document.body.appendChild(textArea);
// highlight TextArea to copy the sharing link
if (_this._platform.IOS) {
/** @type {?} */
var range = _this._document.createRange();
range.selectNodeContents(textArea);
/** @type {?} */
var selection = _this._document.defaultView.getSelection();
selection.removeAllRanges();
selection.addRange(range);
textArea.readOnly = true;
textArea.setSelectionRange(0, 999999);
}
else {
textArea.select();
}
_this._document.execCommand('copy');
_this._document.body.removeChild(textArea);
_this._disableButton();
}
catch (e) {
console.warn('Copy link failed!', e.message);
}
finally {
setTimeout((/**
* @return {?}
*/
function () { return _this._resetButton(); }), 2000);
resolve();
}
}));
};
return CopyButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var MixButton = /** @class */ (function (_super) {
__extends(MixButton, _super);
function MixButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url'
};
return _this;
}
Object.defineProperty(MixButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://mix.com/add?";
},
enumerable: true,
configurable: true
});
return MixButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var LineButton = /** @class */ (function (_super) {
__extends(LineButton, _super);
function LineButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url'
};
return _this;
}
Object.defineProperty(LineButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return "https://social-plugins.line.me/lineit/share?";
},
enumerable: true,
configurable: true
});
return LineButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var QqButton = /** @class */ (function (_super) {
__extends(QqButton, _super);
function QqButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url',
title: 'title',
description: 'desc'
};
return _this;
}
Object.defineProperty(QqButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return 'https://connect.qq.com/widget/shareqq/index.html?';
},
enumerable: true,
configurable: true
});
return QqButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var WeiboButton = /** @class */ (function (_super) {
__extends(WeiboButton, _super);
function WeiboButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'url',
description: 'title'
};
return _this;
}
Object.defineProperty(WeiboButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return 'http://service.weibo.com/share/share.php?';
},
enumerable: true,
configurable: true
});
return WeiboButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var WeChatButton = /** @class */ (function (_super) {
__extends(WeChatButton, _super);
function WeChatButton(_props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) {
var _this = _super.call(this, _props, _url, _http, _platform, _document, _windowSize, _disableButtonClick, _logger) || this;
_this._props = _props;
_this._url = _url;
_this._http = _http;
_this._platform = _platform;
_this._document = _document;
_this._windowSize = _windowSize;
_this._disableButtonClick = _disableButtonClick;
_this._logger = _logger;
_this._supportedMetaTags = {
url: 'data'
};
return _this;
}
Object.defineProperty(WeChatButton.prototype, "desktop", {
get: /**
* @return {?}
*/
function () {
return 'https://api.qrserver.com/v1/create-qr-code/?';
},
enumerable: true,
configurable: true
});
return WeChatButton;
}(ShareButtonBase));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* Default share buttons properties
* @type {?}
*/
var SHARE_BUTTONS = {
facebook: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new FacebookButton(a, b, c, d, e, f, g, h); }),
text: 'Facebook',
icon: ['fab', 'facebook-f'],
color: '#4267B2',
ariaLabel: 'Share on Facebook'
},
twitter: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new TwitterButton(a, b, c, d, e, f, g, h); }),
text: 'Twitter',
icon: ['fab', 'twitter'],
color: '#00acee',
ariaLabel: 'Share on Twitter'
},
linkedin: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new LinkedinButton(a, b, c, d, e, f, g, h); }),
text: 'LinkedIn',
icon: ['fab', 'linkedin-in'],
color: '#006fa6',
ariaLabel: 'Share on LinkedIn'
},
google: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new GooglePlusButton(a, b, c, d, e, f, g, h); }),
text: 'Google+',
icon: ['fab', 'google-plus-g'],
color: '#DB4437',
ariaLabel: 'Share on Google plus'
},
pinterest: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new PinterestButton(a, b, c, d, e, f, g, h); }),
text: 'Pinterest',
icon: ['fab', 'pinterest-p'],
color: '#BD091D',
ariaLabel: 'Share on Pinterest'
},
reddit: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new RedditButton(a, b, c, d, e, f, g, h); }),
text: 'Reddit',
icon: ['fab', 'reddit-alien'],
color: '#FF4006',
ariaLabel: 'Share on Reddit'
},
tumblr: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new TumblrButton(a, b, c, d, e, f, g, h); }),
text: 'Tumblr',
icon: ['fab', 'tumblr'],
color: '#36465D',
ariaLabel: 'Share on Tumblr'
},
mix: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new MixButton(a, b, c, d, e, f, g, h); }),
text: 'Mix',
icon: ['fab', 'mix'],
color: '#ff8226',
ariaLabel: 'Share on Mix'
},
vk: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new VkButton(a, b, c, d, e, f, g, h); }),
text: 'VKontakte',
icon: ['fab', 'vk'],
color: '#4C75A3',
ariaLabel: 'Share on VKontakte'
},
telegram: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new TelegramButton(a, b, c, d, e, f, g, h); }),
text: 'Telegram',
icon: ['fab', 'telegram-plane'],
color: '#0088cc',
ariaLabel: 'Share on Telegram'
},
messenger: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new MessengerButton(a, b, c, d, e, f, g, h); }),
text: 'Messenger',
icon: ['fab', 'facebook-messenger'],
color: '#0080FF',
ariaLabel: 'Share on Messenger'
},
whatsapp: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new WhatsappButton(a, b, c, d, e, f, g, h); }),
text: 'WhatsApp',
icon: ['fab', 'whatsapp'],
color: '#25D366',
ariaLabel: 'Share on WhatsApp'
},
xing: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new XingButton(a, b, c, d, e, f, g, h); }),
text: 'Xing',
icon: ['fab', 'xing'],
color: '#006567',
ariaLabel: 'Share on Xing'
},
line: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new LineButton(a, b, c, d, e, f, g, h); }),
text: 'Line',
icon: ['fab', 'line'],
color: '#00b900',
ariaLabel: 'Share on Line'
},
sms: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new SmsButton(a, b, c, d, e, f, g, h); }),
text: 'SMS',
icon: 'comment-alt',
color: '#20c16c',
ariaLabel: 'Share link via SMS'
},
email: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new EmailButton(a, b, c, d, e, f, g, h); }),
text: 'Email',
icon: 'envelope',
color: '#FF961C',
ariaLabel: 'Share link via email'
},
print: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new PrintButton(a, b, c, d, e, f, g, h); }),
text: 'Print',
icon: 'print',
color: '#765AA2',
ariaLabel: 'Print page'
},
copy: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new CopyButton(a, b, c, d, e, f, g, h); }),
text: 'Copy link',
icon: 'link',
color: '#607D8B',
ariaLabel: 'Copy link',
extra: {
successLabel: 'Copied',
successIcon: 'check'
}
},
qq: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new QqButton(a, b, c, d, e, f, g, h); }),
text: 'QQ',
icon: ['fab', 'qq'],
color: '#000',
ariaLabel: 'Share on QQ'
},
weibo: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h
* @return {?}
*/
function (a, b, c, d, e, f, g, h) { return new WeiboButton(a, b, c, d, e, f, g, h); }),
text: 'Weibo',
icon: ['fab', 'weibo'],
color: '#000',
ariaLabel: 'Share on Weibo'
},
wechat: {
create: (/**
* @param {?} a
* @param {?} b
* @param {?} c
* @param {?} d
* @param {?} e
* @param {?} f
* @param {?} g
* @param {?} h