client/js/main.js
changeset 648 e388117572d8
parent 647 eaaa1efce396
child 649 2b9c120dba55
equal deleted inserted replaced
647:eaaa1efce396 648:e388117572d8
   548         shortenText: function(_text, _maxlength) {
   548         shortenText: function(_text, _maxlength) {
   549             return (_text.length > _maxlength ? (_text.substr(0, _maxlength) + '…') : _text);
   549             return (_text.length > _maxlength ? (_text.substr(0, _maxlength) + '…') : _text);
   550         },
   550         },
   551         /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited
   551         /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited
   552          * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */
   552          * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */
   553         drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {
   553         drawEditBox: function(_options, _coords, _path, _xmargin, _selector, _renkan) {
   554             _selector.css({
   554             _selector.css({
   555                 width: (_options.tooltip_width - 2 * _options.tooltip_padding)
   555                 width: (_options.tooltip_width - 2 * _options.tooltip_padding)
   556             });
   556             });
       
   557             
       
   558             var rect = _selector[0].getBoundingClientRect();
       
   559             var container_rect = _renkan.$[0].getBoundingClientRect();
       
   560 
       
   561             if(rect.bottom > (container_rect.bottom - 2 * _options.tooltip_padding - 10)) {
       
   562                 _selector.css({
       
   563                     'overflow-x': 'hidden',
       
   564                     'overflow-y': 'scroll',
       
   565                     'max-height':(container_rect.bottom - 2 * _options.tooltip_padding - 10 - rect.top) + 'px'
       
   566                 });
       
   567             }
       
   568 
   557             var _height = _selector.outerHeight() + 2 * _options.tooltip_padding,
   569             var _height = _selector.outerHeight() + 2 * _options.tooltip_padding,
   558                 _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
   570                 _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
   559                 _left = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length),
   571                 _left = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length),
   560                 _right = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length + _options.tooltip_width),
   572                 _right = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length + _options.tooltip_width),
   561                 _top = _coords.y - _height / 2;
   573                 _top = _coords.y - _height / 2;
   573             _path.segments[2].point.y = _path.segments[3].point.y = _top;
   585             _path.segments[2].point.y = _path.segments[3].point.y = _top;
   574             _path.segments[4].point.y = _path.segments[5].point.y = _bottom;
   586             _path.segments[4].point.y = _path.segments[5].point.y = _bottom;
   575             _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;
   587             _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;
   576             _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;
   588             _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;
   577             _path.fillColor = new paper.Color(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0, _top], [0, _bottom]);
   589             _path.fillColor = new paper.Color(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0, _top], [0, _bottom]);
       
   590 
   578             _selector.css({
   591             _selector.css({
   579                 left: (_options.tooltip_padding + Math.min(_left, _right)),
   592                 left: (_options.tooltip_padding + Math.min(_left, _right)),
   580                 top: (_options.tooltip_padding + _top)
   593                 top: (_options.tooltip_padding + _top)
   581             });
   594             });
       
   595             
   582             return _path;
   596             return _path;
   583         },
   597         },
   584         // from http://stackoverflow.com/a/6444043
   598         // from http://stackoverflow.com/a/6444043
   585         increaseBrightness: function (hex, percent){
   599         increaseBrightness: function (hex, percent){
   586             // strip the leading # if it's there
   600             // strip the leading # if it's there