Socket
Socket
Sign inDemoInstall

cytoscape-expand-collapse

Package Overview
Dependencies
Maintainers
6
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cytoscape-expand-collapse - npm Package Compare versions

Comparing version 3.0.12 to 3.1.0

2

package.json
{
"name": "cytoscape-expand-collapse",
"version": "3.0.12",
"version": "3.1.0",
"description": "This extension provides an interface to expand-collapse nodes.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

var debounce = require('./debounce');
var elementUtilities;
module.exports = function (params, cy, api, $) {
var elementUtilities;
var fn = params;

@@ -6,0 +6,0 @@

@@ -12,23 +12,6 @@ ;

var expandCollapseUtilities;
var undoRedoUtilities = require('./undoRedoUtilities');
var cueUtilities = require("./cueUtilities");
var options = {
layoutBy: null, // for rearrange after expand/collapse. It's just layout options or whole layout function. Choose your side!
fisheye: true, // whether to perform fisheye view after expand/collapse you can specify a function too
animate: true, // whether to animate on drawing changes you can specify a function too
ready: function () { }, // callback when expand/collapse initialized
undoable: true, // and if undoRedoExtension exists,
cueEnabled: true, // Whether cues are enabled
expandCollapseCuePosition: 'top-left', // default cue position is top left you can specify a function per node too
expandCollapseCueSize: 12, // size of expand-collapse cue
expandCollapseCueLineSize: 8, // size of lines used for drawing plus-minus icons
expandCueImage: undefined, // image of expand icon if undefined draw regular expand cue
collapseCueImage: undefined, // image of collapse icon if undefined draw regular collapse cue
expandCollapseCueSensitivity: 1 // sensitivity of expand-collapse cues
};
function setOptions(from) {
function extendOptions(options, extendBy) {
var tempOpts = {};

@@ -38,5 +21,5 @@ for (var key in options)

for (var key in from)
for (var key in extendBy)
if (tempOpts.hasOwnProperty(key))
tempOpts[key] = from[key];
tempOpts[key] = extendBy[key];
return tempOpts;

@@ -55,3 +38,3 @@ }

// creates and returns the API instance for the extension
function createExtensionAPI(cy) {
function createExtensionAPI(cy, expandCollapseUtilities) {
var api = {}; // API to be returned

@@ -62,3 +45,3 @@ // set functions

api.setOptions = function(opts) {
options = opts;
setScratch(cy, 'options', options);
};

@@ -68,3 +51,3 @@

api.setOption = function (name, value) {
options[name] = value;
getScratch(cy, 'options')[name] = value;
};

@@ -77,3 +60,4 @@

var eles = this.collapsibleNodes(_eles);
var tempOptions = setOptions(opts);
var options = getScratch(cy, 'options');
var tempOptions = extendOptions(options, opts);
evalOptions(tempOptions);

@@ -87,3 +71,4 @@

var eles = this.collapsibleNodes(_eles);
var tempOptions = setOptions(opts);
var options = getScratch(cy, 'options');
var tempOptions = extendOptions(options, opts);
evalOptions(tempOptions);

@@ -97,3 +82,4 @@

var eles = this.expandableNodes(_eles);
var tempOptions = setOptions(opts);
var options = getScratch(cy, 'options');
var tempOptions = extendOptions(options, opts);
evalOptions(tempOptions);

@@ -107,3 +93,4 @@

var eles = this.expandableNodes(_eles);
var tempOptions = setOptions(opts);
var options = getScratch(cy, 'options');
var tempOptions = extendOptions(options, opts);
evalOptions(tempOptions);

@@ -119,3 +106,4 @@

api.collapseAll = function (opts) {
var tempOptions = setOptions(opts);
var options = getScratch(cy, 'options');
var tempOptions = extendOptions(options, opts);
evalOptions(tempOptions);

@@ -128,3 +116,4 @@

api.expandAll = function (opts) {
var tempOptions = setOptions(opts);
var options = getScratch(cy, 'options');
var tempOptions = extendOptions(options, opts);
evalOptions(tempOptions);

@@ -216,14 +205,48 @@

}
var api; // Define the api instance
// Get the whole scratchpad reserved for this extension (on an element or core) or get a single property of it
function getScratch (cyOrEle, name) {
if (cyOrEle.scratch('_cyExpandCollapse') === undefined) {
cyOrEle.scratch('_cyExpandCollapse', {});
}
var scratch = cyOrEle.scratch('_cyExpandCollapse');
var retVal = ( name === undefined ) ? scratch : scratch[name];
return retVal;
}
// Set a single property on scratchpad of an element or the core
function setScratch (cyOrEle, name, val) {
getScratch(cyOrEle)[name] = val;
}
// register the extension cy.expandCollapse()
cytoscape("core", "expandCollapse", function (opts) {
var cy = this;
var options = getScratch(cy, 'options') || {
layoutBy: null, // for rearrange after expand/collapse. It's just layout options or whole layout function. Choose your side!
fisheye: true, // whether to perform fisheye view after expand/collapse you can specify a function too
animate: true, // whether to animate on drawing changes you can specify a function too
ready: function () { }, // callback when expand/collapse initialized
undoable: true, // and if undoRedoExtension exists,
cueEnabled: true, // Whether cues are enabled
expandCollapseCuePosition: 'top-left', // default cue position is top left you can specify a function per node too
expandCollapseCueSize: 12, // size of expand-collapse cue
expandCollapseCueLineSize: 8, // size of lines used for drawing plus-minus icons
expandCueImage: undefined, // image of expand icon if undefined draw regular expand cue
collapseCueImage: undefined, // image of collapse icon if undefined draw regular collapse cue
expandCollapseCueSensitivity: 1 // sensitivity of expand-collapse cues
};
// If opts is not 'get' that is it is a real options object then initilize the extension
if (opts !== 'get') {
var cy = this;
options = setOptions(opts);
expandCollapseUtilities = require('./expandCollapseUtilities')(cy);
api = createExtensionAPI(cy); // creates and returns the API instance for the extension
options = extendOptions(options, opts);
var expandCollapseUtilities = require('./expandCollapseUtilities')(cy);
var api = createExtensionAPI(cy, expandCollapseUtilities); // creates and returns the API instance for the extension
setScratch(cy, 'api', api);
undoRedoUtilities(cy, api);

@@ -236,5 +259,7 @@

options.ready();
setScratch(cy, 'options', options);
}
return api; // Expose the API to the users
return getScratch(cy, 'api'); // Expose the API to the users
});

@@ -241,0 +266,0 @@ };

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc