UNPKG

@mornya/react-social-libs

Version:

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

1 lines 4.79 kB
var t,e,a=this&&this.__extends||(t=function(e,a){return(t=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,a){e.__proto__=a}:function(e,a){for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(e[t]=a[t])}))(e,a)},function(e,a){if("function"!=typeof a&&null!==a)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");function __(){this.constructor=e}t(e,a),e.prototype=null===a?Object.create(a):(__.prototype=a.prototype,new __)}),n=(Object.defineProperty(exports,"__esModule",{value:!0}),require("../utils/BaseShareComponent")),l=require("../utils/Loader"),n=(e=n.BaseShareComponent,a(KakaoTalk,e),KakaoTalk.prototype.onInit=function(){this.initialize("KakaoTalk",{appId:"",type:"",value:void 0,isInstallTalk:!0})},KakaoTalk.prototype.onMount=function(e){var a=this;(0,l.initKakaoSDK)(e.appId).then(function(){return a.setApiStep()}).catch(console.error)},KakaoTalk.prototype.onShare=function(e,a){var t;if(null!=(t=window.Kakao)&&t.isInitialized())switch(e.type){case"feed":this.sendFeed(e);break;case"list":this.sendList(e);break;case"location":this.sendLocation(e);break;case"commerce":this.sendCommerce(e);break;case"text":this.sendText(e);break;case"scrap":this.sendScrap(e);break;case"custom":this.sendCustom(e)}else console.error("Kakao SDK was not initialized.")},KakaoTalk.prototype.onUnmount=function(e){(0,l.destroyKakaoSDK)()},KakaoTalk.prototype.sendFeed=function(e){var t=this,a={objectType:"feed",content:e.value.content,social:e.value.social,installTalk:null==(a=e.isInstallTalk)||a,success:function(e){var a;null!=(a=window.Kakao)&&a.Share.cleanup(),t.onComplete(!0,e)},fail:function(){var e;null!=(e=window.Kakao)&&e.Share.cleanup(),t.onComplete(!1,null)}};e.value.buttonTitle?a.buttonTitle=e.value.buttonTitle:a.buttons=e.value.buttons,null!=(e=window.Kakao)&&e.Share.sendDefault(a)},KakaoTalk.prototype.sendList=function(e){var t=this,a={objectType:"list",headerTitle:e.value.headerTitle,headerLink:e.value.headerLink,contents:e.value.contents,installTalk:!!e.isInstallTalk,success:function(e){var a;null!=(a=window.Kakao)&&a.Share.cleanup(),t.onComplete(!0,e)},fail:function(){var e;null!=(e=window.Kakao)&&e.Share.cleanup(),t.onComplete(!1,null)}};e.value.headerImageUrl&&(a.headerImageUrl=e.value.headerImageUrl,a.headerImageWidth=e.value.headerImageWidth,a.headerImageHeight=e.value.headerImageHeight),e.value.buttonTitle?a.buttonTitle=e.value.buttonTitle:a.buttons=e.value.buttons,null!=(e=window.Kakao)&&e.Share.sendDefault(a)},KakaoTalk.prototype.sendLocation=function(e){var t=this,a={objectType:"location",content:e.value.content,address:e.value.address,addressTitle:e.value.addressTitle,social:e.value.social,installTalk:!!e.isInstallTalk,success:function(e){var a;null!=(a=window.Kakao)&&a.Share.cleanup(),t.onComplete(!0,e)},fail:function(){var e;null!=(e=window.Kakao)&&e.Share.cleanup(),t.onComplete(!1,null)}};e.value.buttonTitle?a.buttonTitle=e.value.buttonTitle:a.buttons=e.value.buttons,null!=(e=window.Kakao)&&e.Share.sendDefault(a)},KakaoTalk.prototype.sendCommerce=function(e){var t=this,a={objectType:"commerce",content:e.value.content,commerce:e.value.commerce,installTalk:!!e.isInstallTalk,success:function(e){var a;null!=(a=window.Kakao)&&a.Share.cleanup(),t.onComplete(!0,e)},fail:function(){var e;null!=(e=window.Kakao)&&e.Share.cleanup(),t.onComplete(!1,null)}};e.value.buttonTitle?a.buttonTitle=e.value.buttonTitle:a.buttons=e.value.buttons,null!=(e=window.Kakao)&&e.Share.sendDefault(a)},KakaoTalk.prototype.sendText=function(e){var t=this,a={objectType:"text",text:e.value.text,link:e.value.link,installTalk:!!e.isInstallTalk,success:function(e){var a;null!=(a=window.Kakao)&&a.Share.cleanup(),t.onComplete(!0,e)},fail:function(){var e;null!=(e=window.Kakao)&&e.Share.cleanup(),t.onComplete(!1,null)}};e.value.buttonTitle&&(a.buttonTitle=e.value.buttonTitle),null!=(e=window.Kakao)&&e.Share.sendDefault(a)},KakaoTalk.prototype.sendScrap=function(e){var a,t=this,e={requestUrl:e.value.requestUrl,templateId:e.value.templateId,templateArgs:e.value.templateArgs,installTalk:!!e.isInstallTalk,success:function(e){var a;null!=(a=window.Kakao)&&a.Share.cleanup(),t.onComplete(!0,e)},fail:function(){var e;null!=(e=window.Kakao)&&e.Share.cleanup(),t.onComplete(!1,null)}};null!=(a=window.Kakao)&&a.Share.sendScrap(e)},KakaoTalk.prototype.sendCustom=function(e){var a,t=this,e={templateId:e.value.templateId,templateArgs:e.value.templateArgs,installTalk:!!e.isInstallTalk,success:function(e){var a;null!=(a=window.Kakao)&&a.Share.cleanup(),t.onComplete(!0,e)},fail:function(){var e;null!=(e=window.Kakao)&&e.Share.cleanup(),t.onComplete(!1,null)}};null!=(a=window.Kakao)&&a.Share.sendCustom(e)},KakaoTalk);function KakaoTalk(){return null!==e&&e.apply(this,arguments)||this}exports.default=n;