UNPKG

@mornya/react-social-libs

Version:

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

47 lines (46 loc) 2.01 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'; import { openShareWindow } from '../utils/UI'; var Twitter = (function (_super) { __extends(Twitter, _super); function Twitter() { return _super !== null && _super.apply(this, arguments) || this; } Twitter.prototype.onInit = function () { this.initialize('Twitter', { message: function (OG) { return "[".concat(OG.title, "] ").concat(OG.description); }, hashtags: [], }); }; Twitter.prototype.onMount = function (_extra) { this.setApiStep(); }; Twitter.prototype.onShare = function (extra, OG) { var _this = this; var _a; openShareWindow(this.mapToParam(Twitter.LINK_URL, { text: (_a = extra.message) === null || _a === void 0 ? void 0 : _a.call(extra, OG), url: OG.url, hashtags: extra.hashtags, }), 'twitter', this.deviceInfo.isMobile ? [] : [550, 445]) .then(function () { return _this.onComplete(true, null); }) .catch(function (error) { return console.error(error); }); }; Twitter.LINK_URL = 'https://twitter.com/share'; return Twitter; }(BaseShareComponent)); export default Twitter;