react-disqus-comments
Version:
React Disqus thread component
1 lines • 8.96 kB
Source Map (JSON)
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 6dd401c0d5706a509d89","webpack:///./index.js","webpack:///./lib/disqus-thread.js","webpack:///external \"React\""],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;ACtCA,yC;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,IAAG;;AAEH;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAK;;AAEL;AACA;AACA;AACA;;AAEA;AACA;AACA,qB;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,QAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA,IAAG;;AAEH;AACA;AACA;AACA,kBAAiB,mBAAmB;AACpC;AACA;AACA;AACA,oBAAmB,uCAAuC;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,YAAW;AACX;AACA,qBAAoB,wBAAwB;AAC5C;AACA;AACA;AACA;AACA;AACA;AACA,EAAC;;;;;;;ACnLD,gD","file":"./dist/react-disqus-thread.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"React\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"React\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ReactDisqusThread\"] = factory(require(\"React\"));\n\telse\n\t\troot[\"ReactDisqusThread\"] = factory(root[\"React\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 6dd401c0d5706a509d89\n **/","module.exports = require('./lib/disqus-thread');\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./index.js\n ** module id = 0\n ** module chunks = 0\n **/","var React = require('react');\nvar DOM = React.DOM;\nvar DISQUS_CONFIG = [\n 'shortname', 'identifier', 'title', 'url', 'category_id', 'onNewComment'\n];\nvar __disqusAdded = false;\n\nfunction copyProps(context, props, prefix) {\n if (typeof prefix === 'undefined') {\n prefix = '';\n }\n\n Object.keys(props).forEach(function(prop) {\n context[prefix + prop] = props[prop];\n });\n\n if (typeof props.onNewComment === 'function') {\n context[prefix + 'config'] = function () {\n this.callbacks.onNewComment = [\n function (comment) {\n props.onNewComment(comment);\n }\n ];\n };\n }\n}\n\nmodule.exports = React.createClass({\n displayName: 'DisqusThread',\n\n propTypes: {\n /**\n * `shortname` tells the Disqus service your forum's shortname,\n * which is the unique identifier for your website as registered\n * on Disqus. If undefined , the Disqus embed will not load.\n */\n shortname: React.PropTypes.string.isRequired,\n\n /**\n * `identifier` tells the Disqus service how to identify the\n * current page. When the Disqus embed is loaded, the identifier\n * is used to look up the correct thread. If disqus_identifier\n * is undefined, the page's URL will be used. The URL can be\n * unreliable, such as when renaming an article slug or changing\n * domains, so we recommend using your own unique way of\n * identifying a thread.\n */\n identifier: React.PropTypes.string,\n\n /**\n * `title` tells the Disqus service the title of the current page.\n * This is used when creating the thread on Disqus for the first time.\n * If undefined, Disqus will use the <title> attribute of the page.\n * If that attribute could not be used, Disqus will use the URL of the page.\n */\n title: React.PropTypes.string,\n\n /**\n * `url` tells the Disqus service the URL of the current page.\n * If undefined, Disqus will take the window.location.href.\n * This URL is used to look up or create a thread if disqus_identifier\n * is undefined. In addition, this URL is always saved when a thread is\n * being created so that Disqus knows what page a thread belongs to.\n */\n url: React.PropTypes.string,\n\n /**\n * `category_id` tells the Disqus service the category to be used for\n * the current page. This is used when creating the thread on Disqus\n * for the first time.\n */\n category_id: React.PropTypes.string,\n\n /**\n * `onNewComment` function accepts one parameter `comment` which is a \n * JavaScript object with comment `id` and `text`. This allows you to track\n * user comments and replies and run a script after a comment is posted.\n */\n onNewComment: React.PropTypes.func\n },\n\n getDefaultProps: function () {\n return {\n shortname: null,\n identifier: null,\n title: null,\n url: null,\n category_id: null,\n onNewComment: null\n };\n },\n\n addDisqusScript: function () {\n if (__disqusAdded) {\n return;\n }\n\n var child = this.disqus = document.createElement('script');\n var parent = document.getElementsByTagName('head')[0] ||\n document.getElementsByTagName('body')[0];\n\n child.async = true;\n child.type = 'text/javascript';\n child.src = '//' + this.props.shortname + '.disqus.com/embed.js';\n\n parent.appendChild(child);\n __disqusAdded = true;\n },\n\n loadDisqus: function() {\n var props = {};\n\n // Extract Disqus props that were supplied to this component\n DISQUS_CONFIG.forEach(function(prop) {\n if (!!this.props[prop]) {\n props[prop] = this.props[prop];\n }\n }, this);\n\n // Always set URL\n if (!props.url || !props.url.length) {\n props.url = window.location.href;\n }\n\n // If Disqus has already been added, reset it\n if (typeof DISQUS !== 'undefined') {\n DISQUS.reset({ \n reload: true,\n config: function() {\n copyProps(this.page, props);\n\n // Disqus needs hashbang URL, see https://help.disqus.com/customer/portal/articles/472107\n this.page.url = this.page.url.replace(/#/, '') + '#!newthread';\n }\n });\n }\n // Otherwise add Disqus to the page\n else {\n copyProps(window, props, 'disqus_');\n this.addDisqusScript();\n }\n },\n\n componentDidMount: function () {\n this.loadDisqus();\n },\n\n componentDidUpdate: function () {\n this.loadDisqus();\n },\n\n shouldComponentUpdate: function(newProps) {\n return (newProps.id !== this.props.id || newProps.url !== this.props.url);\n },\n\n render: function () {\n return (\n DOM.div(this.props,\n DOM.div({id:\"disqus_thread\"}),\n DOM.noscript(null,\n DOM.span(null,\n 'Please enable JavaScript to view the ',\n DOM.a({href:\"http://disqus.com/?ref_noscript\"},\n 'comments powered by Disqus.'\n )\n )\n ),\n DOM.a({\n href:\"http://disqus.com\",\n className:\"dsq-brlink\"\n },\n 'blog comments powered by ',\n DOM.span({className:\"logo-disqus\"},\n 'Disqus'\n )\n )\n )\n );\n }\n});\n\n\n\n/*****************\n ** WEBPACK FOOTER\n ** ./lib/disqus-thread.js\n ** module id = 1\n ** module chunks = 0\n **/","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n/*****************\n ** WEBPACK FOOTER\n ** external \"React\"\n ** module id = 2\n ** module chunks = 0\n **/"],"sourceRoot":""}