(function () { const el = document.createElement('div'); const style = document.createElement('style'); style.innerHTML = ` #vtjLink { position: absolute; right: 50px; bottom: 50px; width: 40px; height: 40px; border: none; z-index: 9999; cursor: pointer; border-radius: 50%; display: flex; justify-content: center; align-items: center; border: 1px solid #eee; background: #fff; box-shadow: 0 0 3px rgba(0,0,0,.1); } #vtjLink svg{ height: 20px; width: 20px; color: #333; } #vtjLink:hover { background: #ecf5ff; } #vtjLink:hover svg { color:#409eff; } .vtj-link-dragging { user-select: none; iframe { user-select: none; pointer-events: none; } } `; el.id = 'vtjLink'; el.innerHTML = ''; document.head.appendChild(style); document.body.appendChild(el); let dragging = false; let diffX; let diffY; let timer = null; let isDragged = false; let startPosition = null; const size = 50; const update = function (e) { if (dragging) { const x = Math.min( Math.max(0, e.clientX - diffX), window.innerWidth - size ); const y = Math.min( Math.max(0, e.clientY - diffX), window.innerHeight - size ); el.style.left = x + 'px'; el.style.top = y + 'px'; } }; el.addEventListener('mousedown', function (e) { const rect = el.getBoundingClientRect(); diffX = e.clientX - rect.left; diffY = e.clientY - rect.top; document.body.classList.add('vtj-link-dragging'); startPosition = { x: e.clientX, y: e.clientY }; isDragged = false; dragging = true; }); window.addEventListener('mouseup', function (e) { dragging = false; e.stopPropagation(); e.preventDefault(); document.body.classList.remove('vtj-link-dragging'); if ( startPosition && Math.abs(startPosition.x - e.clientX) < 10 && Math.abs(startPosition.y - e.clientY) < 10 ) { isDragged = false; } else { isDragged = true; } }); window.addEventListener('mousemove', function (e) { update(e); }); el.addEventListener('click', function (e) { if (!isDragged) { const section = window.location.hash.split('/'); const id = section.pop() || ''; const options = window.__VTJ_LINK__ || {}; let path = options.href || window.location.pathname + '@vtj/pro/#/'; if (id) { path += '?id=' + id; } window.open(path, 'VTJDesigner'); } }); })();