jam-cloud/web/app/assets/javascripts/react-components/Broadcast.js.jsx.coffee

45 lines
1.2 KiB
CoffeeScript
Raw Permalink Normal View History

context = window
broadcastActions = window.JK.Actions.Broadcast;
rest = window.JK.Rest();
Broadcast = React.createClass({
displayName: 'Broadcast Notification'
handleNavigate: (e) ->
href = $(e.currentTarget).attr('href')
if href.indexOf('http') == 0
e.preventDefault()
window.JK.popExternalLink(href)
broadcastActions.hide.trigger()
notNow: (e) ->
e.preventDefault();
rest.quietBroadcastNotification({broadcast_id: this.props.notification.id})
broadcastActions.hide.trigger()
createMarkup: () ->
{__html: this.props.notification.message};
render: () ->
`<div className="broadcast-notification">
<div className="message" dangerouslySetInnerHTML={this.createMarkup()}/>
<div className="actions">
<div className="actionsAligner">
<a className="button-orange" onClick={this.handleNavigate}
href={this.props.notification.button_url}>{this.props.notification.button_label}</a>
<br/>
<a className="not-now" href="#" onClick={this.notNow}>not now, thanks</a>
</div>
</div>
</div>`
})
context.JK.Components.Broadcast = Broadcast
context.Broadcast = Broadcast