JavaScript contextmenu

Adding icons to the javascript contextmenu.

Context menu with icons

NOTE: The property id is mandatory in the element


<html>
<script src="https://bossanova.uk/jsuites/v3/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v3/jsuites.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<div id='container' style='border:1px solid gray;width:400px;height:300px;'></div>

<div id='contextmenu'></div>

<script>
var contextMenu = jSuites.contextmenu(document.getElementById('contextmenu'), {
    items:[
        {
            title:'Copy',
            icon: 'content_copy',
            shortcut:'Ctrl + C',
            onclick:function() {
                alert('Copy');
            }
        },
        {
            title:'Cut',
            icon: 'content_cut',
            shortcut:'Ctrl + X',
            onclick:function() {
                alert('Cut');
            }
        },
        {
            title:'Paste',
            icon: 'content_paste',
            shortcut:'Ctrl + V',
            onclick:function() {
                alert('Pate');
            }
        },
        {
            type:'line'
        },
        {
            title:'Visit jexcel website',
            icon: 'link',
            onclick:function() {
                window.open('https://bossanova.uk/jexcel/v3/examples');
            }
        },
        {
            title:'About',
            onclick:function() {
                alert('jSuites v3')
            }
        },
    ],
    onclick:function() {
        contextMenu.close(false);
    }
});

document.getElementById('container').addEventListener("contextmenu", function(e) {
    contextMenu.open(e);
    e.preventDefault();
});
</script>
</html>