cytoscape-edge-bend-editing
Advanced tools
Comparing version 1.1.1 to 1.1.2
{ | ||
"name": "cytoscape-edge-bend-editing", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "A Cytoscape.js extension enables editing edge bend points", | ||
@@ -5,0 +5,0 @@ "main": "cytoscape-edge-bend-editing.js", |
@@ -6,5 +6,3 @@ var bendPointUtilities = { | ||
// initilize bend points based on bendPositionsFcn | ||
initBendPoints: function(bendPositionsFcn) { | ||
var edges = cy.edges(); | ||
initBendPoints: function(bendPositionsFcn, edges) { | ||
for (var i = 0; i < edges.length; i++) { | ||
@@ -11,0 +9,0 @@ var edge = edges[i]; |
@@ -12,3 +12,3 @@ ;(function($$, $){ 'use strict'; | ||
var options = { | ||
var defaults = { | ||
// this function specifies the poitions of bend points | ||
@@ -30,12 +30,18 @@ bendPositionsFunction: function(ele) { | ||
function setOptions(from) { | ||
var tempOpts = {}; | ||
for (var key in options) | ||
tempOpts[key] = options[key]; | ||
var options; | ||
// Merge default options with the ones coming from parameter | ||
function extend(defaults, options) { | ||
var obj = {}; | ||
for (var key in from) | ||
if (tempOpts.hasOwnProperty(key)) | ||
tempOpts[key] = from[key]; | ||
return tempOpts; | ||
} | ||
for (var i in defaults) { | ||
obj[i] = defaults[i]; | ||
} | ||
for (var i in options) { | ||
obj[i] = options[i]; | ||
} | ||
return obj; | ||
}; | ||
@@ -45,4 +51,11 @@ cytoscape( 'core', 'edgeBendEditing', function(opts){ | ||
if(cy.contextMenus == null) { | ||
var exceptionStr = "To use cytoscape.js-edge-bend-editing extension you must include cytoscape.js-context-menus extension" | ||
+ "\n" + "Please see 'https://github.com/iVis-at-Bilkent/cytoscape.js-context-menus'"; | ||
throw exceptionStr; | ||
} | ||
// merge the options with default ones | ||
options = setOptions(opts); | ||
options = extend(defaults, opts); | ||
@@ -62,8 +75,8 @@ // define edgebendediting-hasbendpoints css class | ||
// init bend positions | ||
bendPointUtilities.initBendPoints(options.bendPositionsFunction); | ||
bendPointUtilities.initBendPoints(options.bendPositionsFunction, cy.edges()); | ||
if(options.enabled) | ||
$(cy.container()).cytoscapeEdgeBendEditing(options); | ||
$(cy.container()).cytoscapeEdgeBendEditing(options, cy); | ||
else | ||
$(cy.container()).cytoscapeEdgeBendEditing("unbind"); | ||
$(cy.container()).cytoscapeEdgeBendEditing("unbind", cy); | ||
@@ -70,0 +83,0 @@ |
@@ -1,2 +0,2 @@ | ||
module.exports = function () { | ||
module.exports = function (cy) { | ||
if (cy.undoRedo == null) | ||
@@ -3,0 +3,0 @@ return; |
@@ -5,3 +5,3 @@ var debounce = require('./debounce'); | ||
module.exports = function (params) { | ||
module.exports = function (params, cy) { | ||
var fn = params; | ||
@@ -15,3 +15,3 @@ | ||
// register undo redo functions | ||
registerUndoRedoFunctions(); | ||
registerUndoRedoFunctions(cy); | ||
@@ -21,3 +21,2 @@ var self = this; | ||
var $container = $(this); | ||
// var cy; | ||
var $canvas = $('<canvas></canvas>'); | ||
@@ -63,9 +62,2 @@ | ||
if(cy.contextMenus == null) { | ||
var exceptionStr = "To use cytoscape.js-edge-bend-editing extension you must include cytoscape.js-context-menus extension" | ||
+ "\n" + "Please see 'https://github.com/iVis-at-Bilkent/cytoscape.js-context-menus'"; | ||
throw exceptionStr; | ||
} | ||
var menuItems = [ | ||
@@ -188,3 +180,2 @@ { | ||
function renderBendShapes(edge) { | ||
var cy = edge.cy(); | ||
@@ -294,3 +285,2 @@ if(!edge.hasClass('edgebendediting-hasbendpoints')) { | ||
$container.cytoscape(function (e) { | ||
cy = this; | ||
clearDraws(true); | ||
@@ -297,0 +287,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
170883
2734