Skip to content
Permalink
08f3f79145
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
/** @jsx React.DOM */
var React = require("react/addons");
var {update} = React.addons;
function noop () {}
var ToastMessageSpec = {
displayName: "ToastMessage",
getDefaultProps () {
var iconClassNames = {
error: "toast-error",
info: "toast-info",
success: "toast-success",
warning: "toast-warning"
};
return {
className: "toast",
iconClassNames: iconClassNames,
titleClassName: "toast-title",
messageClassName: "toast-message",
tapToDismiss: true,
closeButton: false
};
},
handleOnClick (event) {
var {props} = this;
props.handleOnClick(event);
if (props.tapToDismiss) {
this.hideToast(true);
}
},
_handle_close_button_click (event) {
event.stopPropagation();
this.hideToast(true);
},
_handle_remove () {
var {props} = this;
props.handleRemove(props.key);
},
_render_close_button (props) {
return props.closeButton ? (
<button className="toast-close-button" role="button"
onClick={this._handle_close_button_click}>&times;</button>
) : false;
},
_render_title_element (props) {
return props.title ? (
<div className={props.titleClassName}>
{props.title}
</div>
) : false;
},
_render_message_element (props) {
return props.message ? (
<div className={props.messageClassName}>
{props.message}
</div>
) : false;
},
render () {
var cx = React.addons.classSet;
var {props} = this;
var iconClassName = props.iconClassName || props.iconClassNames[props.type];
var toastClass = {};
toastClass[props.className] = true;
toastClass[iconClassName] = true;
return (
<div className={cx(toastClass)} style={props.style || {}}
onClick={this.handleOnClick}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}>
{this._render_close_button(props)}
{this._render_title_element(props)}
{this._render_message_element(props)}
</div>
);
}
};
var jQuery = React.createClass(update(ToastMessageSpec, {
displayName: { $set: "ToastMessage.jQuery" },
mixins: { $set: [require("./jQueryMixin")] }
}));
/*
* assign default noop functions
*/
ToastMessageSpec.handleMouseEnter = noop;
ToastMessageSpec.handleMouseLeave = noop;
ToastMessageSpec.hideToast = noop;
var ToastMessage = module.exports = React.createClass(ToastMessageSpec);
ToastMessage.jQuery = jQuery;