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.
 
  17 import React from 'react';
 
  19 import Icon from '../../../icons/Icon';
 
  20 import iconEdit from '../../../../../../../../res/ecomp/asdc/sequencer/sprites/icons/edit.svg';
 
  23  * A hover-over popup. It shows notes, but perhaps will be put to other uses.
 
  24  * @param props React properties.
 
  28 export default class Popup extends React.Component {
 
  30   // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
  33    * Construct react view.
 
  34    * @param props element properties (of which there are none).
 
  35    * @param context react context.
 
  37   constructor(props, context) {
 
  38     super(props, context);
 
  47   // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
  55     // Build CSS + styles to position and configure popup.
 
  57     let top = this.state.top;
 
  58     let left = this.state.left;
 
  60     const popupHeight = 200;
 
  61     const popupWidth = 320;
 
  63     let auxCssVertical = 'top';
 
  64     let auxCssHorizontal = 'left';
 
  66     if (this.state.top > (window.innerHeight - popupHeight)) {
 
  67       top -= (popupHeight + 50);
 
  68       auxCssVertical = 'bottom';
 
  71     if (this.state.left > (window.innerWidth - popupWidth)) {
 
  72       left -= (popupWidth - 80);
 
  73       auxCssHorizontal = 'right';
 
  76     const auxCss = `asdcs-diagram-popup-${auxCssVertical}${auxCssHorizontal}`;
 
  80       display: (this.state.visible ? 'block' : 'none'),
 
  85     let notes = this.state.notes || '';
 
  86     if (notes.length > 255) {
 
  87       notes = notes.substring(0, 255);
 
  88       notes = `${notes} ...`;
 
  92       <div className={`asdcs-diagram-popup ${auxCss}`} style={styles}>
 
  93         <div className="asdcs-diagram-popup-header">Notes</div>
 
  94         <div className="asdcs-diagram-popup-body">
 
  95           <div className="asdcs-icon-popup">
 
  96             <Icon glyph={iconEdit} />
 
  98           <div className="asdcs-diagram-notes">
 
  99             <div className="asdcs-diagram-note">
 
 104         <div className="asdcs-diagram-popup-footer"></div>