UNPKG

@mornya/react-social-libs

Version:

The project of React.js Social Share and Widget modules.

49 lines (48 loc) 2.17 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { BaseShareComponent } from '../utils/BaseShareComponent'; var Email = (function (_super) { __extends(Email, _super); function Email() { return _super !== null && _super.apply(this, arguments) || this; } Email.prototype.onInit = function () { this.initialize('Email', { title: function (OG) { var _a; return (_a = OG.title) !== null && _a !== void 0 ? _a : ''; }, message: function (_OG) { return ''; }, }); }; Email.prototype.onMount = function (_extra) { this.setApiStep(); }; Email.prototype.onShare = function (extra, OG) { var _this = this; var _a, _b, _c; var options = { subject: (_b = (_a = extra.title) === null || _a === void 0 ? void 0 : _a.call(extra, OG)) !== null && _b !== void 0 ? _b : '', body: ((_c = extra.message) === null || _c === void 0 ? void 0 : _c.call(extra, OG)) || "".concat(OG.description).concat(this.getHashtag(extra.hashtags, '\n')) + '\n\n' + OG.url, }; var anchor = document.createElement('a'); anchor.href = this.mapToParam(Email.LINK_URL, options); anchor.target = '_blank'; anchor.click(); setTimeout(function () { return _this.onComplete(true, null); }, 1000); }; Email.LINK_URL = 'mailto:'; return Email; }(BaseShareComponent)); export default Email;