@mornya/react-social-libs
Version:
The project of React.js Social Share and Widget modules.
64 lines (63 loc) • 2.58 kB
JavaScript
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 SMS = (function (_super) {
__extends(SMS, _super);
function SMS() {
return _super !== null && _super.apply(this, arguments) || this;
}
SMS.prototype.onInit = function () {
this.initialize('SMS', {
message: function (_OG) { return ''; },
target: '',
});
};
SMS.prototype.onMount = function (_extra) {
this.setApiStep();
};
SMS.prototype.onShare = function (extra, OG) {
var _this = this;
var _a;
var text = ((_a = extra.message) === null || _a === void 0 ? void 0 : _a.call(extra, OG)) ||
OG.title + '\n\n' + "".concat(OG.description).concat(this.getHashtag(extra.hashtags, '\n')) + '\n\n' + OG.url;
var href;
if (this.deviceInfo.isMobile) {
if (this.deviceInfo.isAOS) {
href = this.mapToParam("".concat(SMS.LINK_URL.sms, "//"), { body: text });
}
else if (this.deviceInfo.isIOS) {
href = this.mapToParam("".concat(SMS.LINK_URL.sms).concat(extra.target), { '&body': text });
}
else {
href = this.mapToParam(SMS.LINK_URL.sms, { text: text });
}
}
else if (this.deviceInfo.OS.vendor === 'MAC') {
href = this.mapToParam("".concat(SMS.LINK_URL.iMessage).concat(extra.target), { '&body': text });
}
else {
href = this.mapToParam(SMS.LINK_URL.sms, { text: text });
}
window.location.href = href;
setTimeout(function () { return _this.onComplete(true, null); }, 1000);
};
SMS.LINK_URL = {
sms: 'sms:',
iMessage: 'imessage:',
};
return SMS;
}(BaseShareComponent));
export default SMS;