ldx-widgets
Version:
widgets
61 lines (50 loc) • 1.54 kB
JavaScript
(function() {
var Dialogue, React, assign;
assign = require('lodash/assign');
React = require('react');
Dialogue = React.createFactory(require('../components/dialogue'));
/*
Can be applied to a top level component with a full screen container div in order to add methpds for displaying
a dialougue sheet, with messages and alerts
To Use:
- call @dialogueBox() at the appropriate spot within the component DOM tree within the render method
- call @showDialogue(options) to show (see widgets/dialogue_wrapper for available options)
- manually close a dialogue with @closeDialogue()
*/
module.exports = {
getInitialState: function() {
return {
__showDialogue: false
};
},
showDialogue: function(options) {
var base;
if (typeof (base = this.props).toggleNavFreeze === "function") {
base.toggleNavFreeze();
}
this.__dialogueProps = assign(options, {
key: 'dialogue',
cancelCallback: this.closeDialogue
});
return this.setState({
__showDialogue: true
});
},
closeDialogue: function() {
var base;
if (typeof (base = this.props).toggleNavFreeze === "function") {
base.toggleNavFreeze();
}
return this.setState({
__showDialogue: false
});
},
dialogueBox: function() {
if (this.state.__showDialogue) {
return Dialogue(this.__dialogueProps);
} else {
return null;
}
}
};
}).call(this);