|
@@ -3,17 +3,23 @@ var React = require('react'),
|
|
|
BootstrapButton = require('./BootstrapButton.js');
|
|
BootstrapButton = require('./BootstrapButton.js');
|
|
|
|
|
|
|
|
var BootstrapModal = React.createClass({
|
|
var BootstrapModal = React.createClass({
|
|
|
- componentDidMount: function() {
|
|
|
|
|
- $(ReactDOM.findDOMNode(this)).modal({backdrop: 'static', keyboard: false, show: false});
|
|
|
|
|
|
|
+ componentDidMount: function () {
|
|
|
|
|
+ var that = this;
|
|
|
|
|
+
|
|
|
|
|
+ $(this.refs.main).modal({ backdrop: 'static', keyboard: false, show: false });
|
|
|
|
|
+
|
|
|
|
|
+ $(this.refs.main).on('shown.bs.modal', function () {
|
|
|
|
|
+ if (that.focusElement) $(that.focusElement).focus();
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
componentWillUnmount: function() {
|
|
componentWillUnmount: function() {
|
|
|
- $(ReactDOM.findDOMNode(this)).off('hidden', this.handleHidden);
|
|
|
|
|
|
|
+ $(this.refs.main).off('hidden', this.handleHidden);
|
|
|
},
|
|
},
|
|
|
close: function() {
|
|
close: function() {
|
|
|
- $(ReactDOM.findDOMNode(this)).modal('hide');
|
|
|
|
|
|
|
+ $(this.refs.main).modal('hide');
|
|
|
},
|
|
},
|
|
|
open: function() {
|
|
open: function() {
|
|
|
- $(ReactDOM.findDOMNode(this)).modal('show');
|
|
|
|
|
|
|
+ $(this.refs.main).modal('show');
|
|
|
},
|
|
},
|
|
|
render: function() {
|
|
render: function() {
|
|
|
var confirmButton = null;
|
|
var confirmButton = null;
|
|
@@ -28,6 +34,7 @@ var BootstrapModal = React.createClass({
|
|
|
</BootstrapButton>
|
|
</BootstrapButton>
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (this.props.cancel) {
|
|
if (this.props.cancel) {
|
|
|
cancelButton = (
|
|
cancelButton = (
|
|
|
<BootstrapButton onClick={this.handleCancel}>
|
|
<BootstrapButton onClick={this.handleCancel}>
|
|
@@ -37,22 +44,26 @@ var BootstrapModal = React.createClass({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <div className="modal fade">
|
|
|
|
|
- <div className="modal-header">
|
|
|
|
|
- <button
|
|
|
|
|
- type="button"
|
|
|
|
|
- className="close"
|
|
|
|
|
- onClick={this.handleCancel}
|
|
|
|
|
- dangerouslySetInnerHTML={{__html: '×'}}
|
|
|
|
|
- />
|
|
|
|
|
- <h3>{this.props.title}</h3>
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="modal-body">
|
|
|
|
|
- {this.props.children}
|
|
|
|
|
- </div>
|
|
|
|
|
- <div className="modal-footer">
|
|
|
|
|
- {cancelButton}
|
|
|
|
|
- {confirmButton}
|
|
|
|
|
|
|
+ <div ref="main" className="modal fade">
|
|
|
|
|
+ <div className="modal-dialog">
|
|
|
|
|
+ <div className="modal-content">
|
|
|
|
|
+ <div className="modal-header">
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ className="close"
|
|
|
|
|
+ onClick={this.handleCancel}
|
|
|
|
|
+ dangerouslySetInnerHTML={{__html: '×'}}
|
|
|
|
|
+ />
|
|
|
|
|
+ <h4>{this.props.title}</h4>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="modal-body">
|
|
|
|
|
+ {this.props.children}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="modal-footer">
|
|
|
|
|
+ {cancelButton}
|
|
|
|
|
+ {confirmButton}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|
|
@@ -66,6 +77,9 @@ var BootstrapModal = React.createClass({
|
|
|
if (this.props.onConfirm) {
|
|
if (this.props.onConfirm) {
|
|
|
this.props.onConfirm();
|
|
this.props.onConfirm();
|
|
|
}
|
|
}
|
|
|
|
|
+ },
|
|
|
|
|
+ setFocusElement: function (element) {
|
|
|
|
|
+ this.focusElement = element;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|