UNPKG

ldx-widgets

Version:

widgets

77 lines (64 loc) 2.04 kB
/* Confirm User Action Props NOTE: this widget is intended to be passed as the element prop to the pvr widget @props.onOkay callback to be executed when the user clicks the 'OK' button @props.confirmText - default 'Are you sure?' String to display to the user @props.confirmBtnLabel - default 'OK' String to display on the button that executes the callback @props.cancelBtnLabel - default 'Cancel' String to display on the button that dismisses the pvr w/ no action */ (function() { var ConfirmUserAction, React, button, div, ref; React = require('react'); ref = React.DOM, div = ref.div, button = ref.button; ConfirmUserAction = React.createClass({ displayName: 'ConfirmUserAction', propTypes: { close: React.PropTypes.func.isRequired, onOkay: React.PropTypes.func.isRequired }, getDefaultProps: function() { return { confirmText: 'Are you sure?', confirmBtnLabel: 'OK', cancelBtnLabel: 'Cancel' }; }, handleButtonClick: function(e) { if (e.target.value === 'okay') { return this.props.onOkay(); } else { return this.props.close(); } }, render: function() { var cancelBtnLabel, confirmBtnLabel, confirmText, ref1; ref1 = this.props, confirmText = ref1.confirmText, confirmBtnLabel = ref1.confirmBtnLabel, cancelBtnLabel = ref1.cancelBtnLabel; return div({ key: 'inner', className: 'inner confirm' }, [ div({ key: 'message', className: 'message' }, confirmText), button({ key: 'okay-btn', type: 'button', className: 'okay-btn', onClick: this.handleButtonClick, value: 'okay' }, confirmBtnLabel), button({ key: 'cancel-btn', type: 'button', className: 'cancel-btn', onClick: this.handleButtonClick, value: 'cancel' }, cancelBtnLabel) ]); } }); module.exports = ConfirmUserAction; }).call(this);