Skip to content

Commit

Permalink
refactor: remove not used code
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanalhattami committed Apr 19, 2024
1 parent 903d930 commit 397a876
Showing 1 changed file with 0 additions and 43 deletions.
43 changes: 0 additions & 43 deletions resources/views/components/context-menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,6 @@
])>
{{ $action }}
</span>
@elseif($action instanceof \AymanAlhattami\FilamentContextMenu\ContentMenuItem)
<a href="{{ $action->getUrl() }}" target="{{ $action->getTarget() }}" @click="contextMenuOpen=false" @class([
"flex gap-x-1 select-none group justify-between rounded px-2 py-1.5 hover:bg-neutral-100 outline-none data-[disabled]:opacity-50 data-[disabled]:pointer-events-none dark:hover:bg-white/5",
'mt-1' => !$loop->first,
])>
<span class="flex gap-x-1">
@if(filled($action->getIcon()))
<span class="flex h-5 w-5 items-center justify-center">
<x-filament::icon
:icon="$action->getIcon()"
class="h-5 w-5 ml-auto text-xs tracking-widest text-neutral-400"/>
</span>
@endif
<span class="font-semibold hover:underline group-hover/link:underline group-focus-visible/link:underline text-sm text-gray-700 dark:text-gray-200">{{ $action->getTitle() }}</span>
</span>
</a>
@elseif($action instanceof \AymanAlhattami\FilamentContextMenu\ContentMenuDivider)
<div @class([
"flex h-px my-1 -mx-1 bg-gray-100 dark:bg-white/5",
Expand All @@ -35,32 +19,27 @@ class="h-5 w-5 ml-auto text-xs tracking-widest text-neutral-400"/>

<script>
document.addEventListener('DOMContentLoaded', function() {
var contextMenuOpen = false;
var contextMenu = document.getElementById('contextMenu');
var contextMenuTrigger = document.getElementsByClassName('fi-main')[0];
contextMenuTrigger.addEventListener('contextmenu', function(event) {
contextMenuOpen = true;
event.preventDefault();
contextMenu.style.opacity = '0';
contextMenu.style.display = 'block'; // Show the context menu
setTimeout(function() {
calculateContextMenuPosition(event);
calculateSubMenuPosition(event);
contextMenu.style.opacity = '1';
}, 0); // Similar to $nextTick
});
document.addEventListener('click', function(event) {
if (!contextMenu.contains(event.target)) {
contextMenuOpen = false;
contextMenu.style.display = 'none'; // Hide the context menu
}
});
window.addEventListener('resize', function(event) {
contextMenuOpen = false;
contextMenu.style.display = 'none';
});
Expand All @@ -76,28 +55,6 @@ function calculateContextMenuPosition(clickEvent) {
contextMenu.style.top = top + 'px';
contextMenu.style.left = left + 'px';
}
function calculateSubMenuPosition(clickEvent) {
var submenus = document.querySelectorAll('[data-submenu]');
var contextMenuWidth = contextMenu.offsetWidth;
submenus.forEach(function(submenu) {
if(window.innerWidth < (clickEvent.clientX + contextMenuWidth + submenu.offsetWidth)){
submenu.classList.add('left-0', '-translate-x-full');
submenu.classList.remove('right-0', 'translate-x-full');
} else {
submenu.classList.remove('left-0', '-translate-x-full');
submenu.classList.add('right-0', 'translate-x-full');
}
if(window.innerHeight < (submenu.previousElementSibling.getBoundingClientRect().top + submenu.offsetHeight)){
let heightDifference = (window.innerHeight - submenu.previousElementSibling.getBoundingClientRect().top) - submenu.offsetHeight;
submenu.style.top = heightDifference + 'px';
} else {
submenu.style.top = '';
}
});
}
});
</script>
@endif

0 comments on commit 397a876

Please sign in to comment.