frame.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @author oldj
  3. * @blog http://oldj.net
  4. */
  5. 'use strict';
  6. import React from 'react';
  7. import './frame.less';
  8. export default class MyFrame extends React.Component {
  9. constructor(props) {
  10. super(props);
  11. }
  12. componentDidMount() {
  13. SH_event.on('esc', () => {
  14. this.onCancel();
  15. });
  16. }
  17. onOK() {
  18. this.props.onOK();
  19. }
  20. onCancel() {
  21. this.props.onCancel();
  22. }
  23. renderFootButtons() {
  24. let html = [];
  25. html.push(
  26. <div
  27. className="button btn-cancel"
  28. key="btn-cancel"
  29. onClick={this.onCancel.bind(this)}
  30. >
  31. {this.props.cancel_title || SH_Agent.lang.cancel}
  32. </div>
  33. );
  34. html.push(
  35. <div
  36. className="button btn-ok btn-default"
  37. key="btn-ok"
  38. onClick={this.onOK.bind(this)}
  39. >
  40. {this.props.ok_title || SH_Agent.lang.ok}
  41. </div>
  42. );
  43. return html;
  44. }
  45. render() {
  46. if (!this.props.show) {
  47. return null;
  48. }
  49. return (
  50. <div className="frame" ref="frame">
  51. <div className="overlay"></div>
  52. <div className="prompt">
  53. <div className="head">{this.props.head}</div>
  54. <div className="body">{this.props.body}</div>
  55. <div className="foot">{this.renderFootButtons()}</div>
  56. </div>
  57. </div>
  58. );
  59. }
  60. }