2021-07-16 11:41:58 -03:00
|
|
|
/*
|
2021-12-25 14:39:34 -08:00
|
|
|
* Copyright [2021] [wisemapping]
|
2021-07-16 11:41:58 -03:00
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2021-12-19 08:06:42 -08:00
|
|
|
import { $assert } from '@wisemapping/core-js';
|
2021-12-05 08:33:09 -08:00
|
|
|
import $ from 'jquery';
|
2021-12-14 17:54:11 -08:00
|
|
|
import { $msg } from '../Messages';
|
2021-12-02 00:41:56 +00:00
|
|
|
import FloatingTip from './FloatingTip';
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2021-12-03 16:11:17 -08:00
|
|
|
class LinkIconTooltip extends FloatingTip {
|
|
|
|
constructor(linkIcon) {
|
2021-10-04 17:05:34 -07:00
|
|
|
$assert(linkIcon, 'linkIcon can not be null');
|
2021-12-02 00:41:56 +00:00
|
|
|
const nativeElement = $(linkIcon.getImage().peer._native);
|
2021-12-03 16:11:17 -08:00
|
|
|
super(nativeElement, {
|
2021-10-04 17:05:34 -07:00
|
|
|
// Content can also be a function of the target element!
|
2021-12-29 18:11:10 +00:00
|
|
|
content() {
|
|
|
|
return LinkIconTooltip._buildContent(linkIcon);
|
|
|
|
},
|
2021-10-04 17:05:34 -07:00
|
|
|
html: true,
|
|
|
|
placement: 'bottom',
|
|
|
|
title: $msg('LINK'),
|
|
|
|
trigger: 'manual',
|
2021-12-29 18:11:10 +00:00
|
|
|
template: '<div id="linkPopover" class="popover" onmouseover="jQuery(this).mouseleave(function() {jQuery(this).fadeOut(200); });" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
|
|
|
|
destroyOnExit: true,
|
2021-10-04 17:05:34 -07:00
|
|
|
});
|
2021-12-03 16:11:17 -08:00
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2021-12-03 16:11:17 -08:00
|
|
|
static _buildContent(linkIcon) {
|
2021-12-29 18:11:10 +00:00
|
|
|
const url = linkIcon.getModel().getUrl();
|
2022-03-25 16:50:25 -03:00
|
|
|
const linkText = `${url}`;
|
2021-12-29 18:11:10 +00:00
|
|
|
|
2021-10-04 17:05:34 -07:00
|
|
|
const result = $('<div></div>').css({
|
|
|
|
padding: '5px',
|
|
|
|
width: '100%',
|
|
|
|
});
|
2021-12-29 18:11:10 +00:00
|
|
|
const link = $('<a id="linkPopoverAnchor"></a>').attr({
|
|
|
|
href: url,
|
2021-10-04 17:05:34 -07:00
|
|
|
alt: 'Open in new window ...',
|
|
|
|
target: '_blank',
|
|
|
|
});
|
2021-07-16 11:41:58 -03:00
|
|
|
|
2022-06-21 19:45:13 -07:00
|
|
|
link.append(linkText);
|
|
|
|
result.append(link);
|
|
|
|
|
2021-10-04 17:05:34 -07:00
|
|
|
return result;
|
2021-12-03 16:11:17 -08:00
|
|
|
}
|
|
|
|
}
|
2021-07-16 11:41:58 -03:00
|
|
|
|
|
|
|
export default LinkIconTooltip;
|