2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import React from 'react';
17 import ReactDOM from 'react-dom';
18 import BootstrapModal from 'react-bootstrap/lib/Modal.js';
22 export default class Modal extends React.Component {
24 static Header = BootstrapModal.Header;
26 static Title = BootstrapModal.Title;
28 static Footer = BootstrapModal.Footer;
30 static Body = class ModalBody extends React.Component {
33 let {children, ...props} = this.props;
35 <BootstrapModal.Body {...props}>
37 </BootstrapModal.Body>
42 let element = ReactDOM.findDOMNode(this);
43 element.addEventListener('click', event => {
44 if (event.target.tagName === 'A') {
45 event.preventDefault();
48 ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType =>
49 element.addEventListener(eventType, event => event.stopPropagation())
54 componentWillMount() {
55 this.modalId = `dox-ui-modal-${nextModalId++}`;
59 this.ensureRootClass();
62 componentDidUpdate() {
63 this.ensureRootClass();
67 let element = document.getElementById(this.modalId);
68 while(element && !element.hasAttribute('data-reactroot')) {
69 element = element.parentElement;
71 if (element && !element.classList.contains('dox-ui')) {
72 element.classList.add('dox-ui');
77 let {children, ...props} = this.props;
79 <BootstrapModal {...props} id={this.modalId}>