var Preact = require('preact'), h = require('preact').h, createClass = require('preact-compat').createClass, SupportedPlatforms = require('./supportedplatforms.jsx'), classNames = require('classnames'), ZeroClipboard = require('../js/lib/ZeroClipboard.js'); var Plugin = createClass({ shouldComponentUpdate: function(nextProps, nextState) { return this.props.plugin !== nextProps.plugin; }, setClipboardText: function() { if(this.props.plugin && this.props.flashEnabled) { var client = new ZeroClipboard(document.getElementById("copy-" + this.props.plugin.name)); var copyText = "cordova plugin add " + this.props.plugin.name; client.off(); client.on("copy", function(event) { event.clipboardData.setData("text/plain", copyText); }); } }, copyTextWithoutFlash: function() { if(!this.props.flashEnabled) { var range = document.createRange(); range.selectNode(this.getDOMNode().getElementsByClassName("cordova-add-command")[0]); var select = window.getSelection(); select.removeAllRanges(); select.addRange(range); try { document.execCommand("copy"); } catch(e) { // Silently fail for now } select.removeAllRanges(); } }, render: function() { if(!this.props.plugin) { // Empty card with loading wheel return (
{downloadCount} downloads last month
; } if(this.props.plugin) { copyIcon = (v{this.props.plugin.version} by {this.props.plugin.author}
{this.props.plugin.description}
{license}
{downloadField}Last updated {this.props.plugin.modified} days ago