react-line-social
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -43,17 +43,10 @@ 'use strict'; | ||
value: function componentDidMount() { | ||
if (!_utils2.default.getScript()) { | ||
var script = document.createElement('script'); | ||
script.id = 'recaptcha'; | ||
script.src = 'https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js'; | ||
script.type = 'text/javascript'; | ||
script.async = true; | ||
script.defer = true; | ||
script.onerror = function (error) { | ||
throw error; | ||
}; | ||
document.body.appendChild(script); | ||
_utils2.default.setScript(script); | ||
} | ||
this.componentDidUpdate(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
_utils2.default.loadButtons(); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -60,0 +53,0 @@ value: function render() { |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.Like = exports.Friend = exports.Share = undefined; | ||
exports.loadButtons = exports.Like = exports.Friend = exports.Share = undefined; | ||
@@ -21,2 +21,4 @@ var _share = require('./share'); | ||
var _utils = require('./utils'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,2 +28,3 @@ | ||
exports.Friend = _friend2.default; | ||
exports.Like = _like2.default; | ||
exports.Like = _like2.default; | ||
exports.loadButtons = _utils.loadButtons; |
@@ -43,17 +43,10 @@ 'use strict'; | ||
value: function componentDidMount() { | ||
if (!_utils2.default.getScript()) { | ||
var script = document.createElement('script'); | ||
script.id = 'recaptcha'; | ||
script.src = 'https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js'; | ||
script.type = 'text/javascript'; | ||
script.async = true; | ||
script.defer = true; | ||
script.onerror = function (error) { | ||
throw error; | ||
}; | ||
document.body.appendChild(script); | ||
_utils2.default.setScript(script); | ||
} | ||
this.componentDidUpdate(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
_utils2.default.loadButtons(); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -72,3 +65,3 @@ value: function render() { | ||
'data-type': 'like', | ||
'data-url': location.href | ||
'data-url': url || location.href | ||
}, share && { 'data-share': 'true' }, lineid && { 'data-lineid': lineid })); | ||
@@ -84,3 +77,4 @@ } | ||
share: _propTypes2.default.bool, | ||
lineid: _propTypes2.default.string | ||
lineid: _propTypes2.default.string, | ||
url: _propTypes2.default.string | ||
}; | ||
@@ -87,0 +81,0 @@ |
@@ -41,20 +41,10 @@ 'use strict'; | ||
value: function componentDidMount() { | ||
if (!_utils2.default.getScript()) { | ||
var script = document.createElement('script'); | ||
script.id = 'recaptcha'; | ||
script.src = 'https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js'; | ||
script.type = 'text/javascript'; | ||
script.async = true; | ||
script.defer = true; | ||
script.onerror = function (error) { | ||
throw error; | ||
}; | ||
script.onload = function () { | ||
window.LineIt.loadButton(); | ||
}; | ||
document.body.appendChild(script); | ||
_utils2.default.setScript(script); | ||
} | ||
this.componentDidUpdate(); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
_utils2.default.loadButtons(); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -71,3 +61,3 @@ value: function render() { | ||
'data-type': 'share-a', | ||
'data-url': location.href }); | ||
'data-url': url || location.href }); | ||
} | ||
@@ -80,3 +70,4 @@ }]); | ||
Share.propTypes = { | ||
locale: _propTypes2.default.oneOf(['en', 'ja', 'zh-TW', 'th', 'id']) | ||
locale: _propTypes2.default.oneOf(['en', 'ja', 'zh-TW', 'th', 'id']), | ||
url: _propTypes2.default.string | ||
}; | ||
@@ -83,0 +74,0 @@ |
@@ -6,3 +6,7 @@ 'use strict'; | ||
}); | ||
var lineScript = void 0; | ||
var scriptLoaded = false; | ||
var scriptInjected = false; | ||
var loadButton = function loadButton() { | ||
window.LineIt && window.LineIt.loadButton(); | ||
}; | ||
@@ -13,9 +17,23 @@ var Utils = { | ||
}, | ||
setScript: function setScript(script) { | ||
if (!lineScript) { | ||
lineScript = script; | ||
loadButtons: function loadButtons() { | ||
if (scriptInjected) { | ||
if (scriptLoaded) { | ||
loadButton(); | ||
} | ||
} else { | ||
var script = document.createElement('script'); | ||
script.src = 'https://d.line-scdn.net/r/web/social-plugin/js/thirdparty/loader.min.js'; | ||
script.type = 'text/javascript'; | ||
script.async = true; | ||
script.defer = true; | ||
script.onerror = function (error) { | ||
throw error; | ||
}; | ||
script.onload = function () { | ||
scriptLoaded = true; | ||
loadButton(); | ||
}; | ||
document.body.appendChild(script); | ||
scriptInjected = true; | ||
} | ||
}, | ||
getScript: function getScript() { | ||
return lineScript; | ||
} | ||
@@ -22,0 +40,0 @@ }; |
{ | ||
"name": "react-line-social", | ||
"author": "szchenghuang <szchenghuang@gmail.com>", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Line Social Plugins in React", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -18,2 +18,7 @@ # react-line-social # | ||
// Or cherry-pick import. | ||
import Share from 'react-line-social/share'; | ||
import Friend from 'react-line-social/friend'; | ||
import Like from 'react-line-social/like'; | ||
<Share /> | ||
@@ -31,2 +36,5 @@ | ||
## Configuration ## | ||
`Share` and `Like` components accept an optional `url` prop. When `url` is absent, `window.location.href` will be referenced. | ||
## License ## | ||
@@ -33,0 +41,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43
15827
233