X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=static%2Ftopology3D%2Fjs%2Fd3-context-menu.js;fp=static%2Ftopology3D%2Fjs%2Fd3-context-menu.js;h=0000000000000000000000000000000000000000;hb=e6eb7437628e932ef823800b5a8380790a6b22d7;hp=6f770420e643900186a4011dcf04b86f9f0ccf2d;hpb=cb541fcbce8951ac488037253c80a10fd432d60b;p=osm%2FLW-UI.git diff --git a/static/topology3D/js/d3-context-menu.js b/static/topology3D/js/d3-context-menu.js deleted file mode 100644 index 6f77042..0000000 --- a/static/topology3D/js/d3-context-menu.js +++ /dev/null @@ -1,131 +0,0 @@ -(function (root, factory) { - if (typeof module === 'object' && module.exports) { - module.exports = function (d3) { - d3.contextMenu = factory(d3); - return d3.contextMenu; - }; - } else if (typeof define === 'function' && define.amd) { - try { - var d3 = require('d3'); - } catch (e) { - d3 = root.d3; - } - - d3.contextMenu = factory(d3); - define([], function () { - return d3.contextMenu; - }); - } else if (root.d3) { - root.d3.contextMenu = factory(root.d3); - } -}(this, - function (d3) { - return function (menu, opts) { - var openCallback, - closeCallback; - - if (typeof opts === 'function') { - openCallback = opts; - } else { - opts = opts || {}; - openCallback = opts.onOpen; - closeCallback = opts.onClose; - } - - // create the div element that will hold the context menu - d3.selectAll('.d3-context-menu').data([1]) - .enter() - .append('div') - .attr('class', 'd3-context-menu'); - - // close menu - d3.select('body').on('click.d3-context-menu', function () { - d3.select('.d3-context-menu').style('display', 'none'); - if (closeCallback) { - closeCallback(); - } - }); - - // this gets executed when a contextmenu event occurs - return function (data, index) { - var elm = this; - d3.selectAll('.d3-context-menu').html(''); - var list = d3.selectAll('.d3-context-menu') - .on('contextmenu', function (d) { - d3.select('.d3-context-menu').style('display', 'none'); - d3.event.preventDefault(); - d3.event.stopPropagation(); - }) - .append('ul'); - list.selectAll('li').data(typeof menu === 'function' ? menu(data) : menu).enter() - .filter(function (d) { - if(opts.type_object == 'node'){ - if (opts.edit_mode || opts.edit_mode == d.edit_mode ) { - if ((d.nodes == undefined || d.nodes.length == 0) || - (d.nodes != undefined && d.nodes.length > 0 && d.nodes.indexOf(data.info.type) > -1)) - return true - } - } - if(opts.type_object == 'link'){ - if (opts.edit_mode == d.edit_mode) { - - return true - } - } - return false; - }) - .append('li') - .attr('class', function (d) { - var ret = ''; - if (d.divider) { - ret += ' is-divider'; - } - if (d.disabled) { - ret += ' is-disabled'; - } - if (!d.action) { - ret += ' is-header'; - } - //if() - return ret; - }) - .html(function (d) { - if (d.divider) { - return '
'; - } - if (!d.title) { - console.error('No title attribute set. Check the spelling of your options.'); - } - return (typeof d.title === 'string') ? d.title : d.title(data); - }) - .on('click', function (d, i) { - if (d.disabled) return; // do nothing if disabled - if (!d.action) return; // headers have no "action" - d.action(elm, data, index); - d3.select('.d3-context-menu').style('display', 'none'); - - if (closeCallback) { - closeCallback(); - } - }); - - // the openCallback allows an action to fire before the menu is displayed - // an example usage would be closing a tooltip - if (openCallback) { - if (openCallback(data, index) === false) { - return; - } - } - - // display context menu - d3.select('.d3-context-menu') - .style('left', (d3.event.pageX - 2) + 'px') - .style('top', (d3.event.pageY - 2) + 'px') - .style('display', 'block'); - - d3.event.preventDefault(); - d3.event.stopPropagation(); - }; - }; - } -)); \ No newline at end of file