header-ui
Version:
Header UI
116 lines (98 loc) • 4.55 kB
JSX
import React from 'react'
import {
Card,
CardHeader,
CardContent
} from '@material-ui/core'
class CloudEvent extends React.Component {
constructor() {
super()
this.state = {
}
}
copyToClipboard(element) {
const range = document.createRange();
const selection = window.getSelection();
// Clear selection from any previous data.
selection.removeAllRanges();
// Make the range select the entire content of the contentHolder paragraph.
range.selectNodeContents(document.querySelector(element));
// Add that range to the selection.
selection.addRange(range);
// Copy the selection to clipboard.
document.execCommand('copy');
// Clear selection if you want to.
selection.removeAllRanges();
}
handleExpandChange = (expanded) => {
this.setState({ expanded: expanded });
};
handleToggle = (event, toggle) => {
this.setState({ expanded: toggle });
};
handleExpand = () => {
this.setState({ expanded: true });
};
handleReduce = () => {
this.setState({ expanded: false });
};
render() {
return (
<div>
<div className="method">
<a id="CloudEvent-track" name="CloudObject-constructor" className="section-anchor" />
<Card style={{marginBottom:16}}>
<CardHeader
title="Track an Event"
style={{backgroundColor:"#f4f4f4", padding:"10px 16px"}}
/>
<CardContent>
<div className="method-example" id="api-summary-example">
<span className="pull-right flag fa fa-clipboard" title="Copy.." onClick={this.copyToClipboard.bind(this, "#pre_track")}>
</span>
<pre id="pre_track">
<span className="code-red">{`var`}</span>{` eventObj = `}<span className="code-red">{`new`}</span>{` CB.CloudEvent.track("`}<span className="code-yellow">{`Signup`}</span>{`",{`
}<span className="code-yellow">{`
username: thisObj.username,
email: thisObj.email`}</span>{`},{
success: `}<span className="code-red">{`function`}</span>{`(eventObj) {
//Gets Event Object
},
error: `}<span className="code-red">{`function`}</span>{`(err) {
//error in geting Event Object
}});`
}
</pre>
</div>{/* method-example */}
</CardContent>
<CardHeader title="CloudEvent( name, data, [type], [callback] )" subheaderTypographyProps={{ style: { fontSize: '12px !important' } }} subheader="Track Down an Event" />
<CardContent>
<div className="method-description">
<div className="method-list">
<h6>Argument</h6>
<dl className="argument-list">
<dt>name</dt>
<dd className>string <span>The name of the event you want to track.</span></dd>
<div className="clearfix" />
<dt>data</dt>
<dd className> Object <span>The information you want to send to the event.</span></dd>
<div className="clearfix" />
<dt>type</dt>
<dd className> [optional]Object <span></span></dd>
<div className="clearfix" />
<dt>type</dt>
<dd className> [optional]callback <span>The callback actions you want to perform.</span></dd>
<div className="clearfix" />
</dl>
<h6>Returns</h6>
<p>Void</p>
</div>
</div>
</CardContent>
</Card>
</div>
</div>
);
}
}
export default CloudEvent;