Skip to content
Permalink
Browse files

initial commit

  • Loading branch information...
d2fong committed Sep 5, 2017
0 parents commit 7f18c4e3c711f73c92d70b5d1818d3c02a85c469
Showing with 356 additions and 0 deletions.
  1. +3 −0 .babelrc
  2. +1 −0 .eslintignore
  3. +13 −0 .eslintrc
  4. +2 −0 .gitignore
  5. +2 −0 .npmignore
  6. +19 −0 LICENSE
  7. +79 −0 README.md
  8. +24 −0 bower.json
  9. +97 −0 demo.html
  10. +44 −0 package.json
  11. +9 −0 src/assign.js
  12. +7 −0 src/core/index.js
  13. +14 −0 src/index.js
  14. +7 −0 test/example.js
  15. +35 −0 webpack.config.js
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
@@ -0,0 +1 @@
node_modules/**/*
@@ -0,0 +1,13 @@
{
"env": {
"browser": true,
"commonjs": true,
"node": true,
"amd": true,
"es6": true
},
"extends": "eslint:recommended",
"rules": {
"semi": "error"
}
}
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
19 LICENSE
@@ -0,0 +1,19 @@
Copyright (c) Cytoscape

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,79 @@
cytoscape-popper
================================================================================


## Description

A Cytoscape.js extension for Popper.js


## Dependencies

* Cytoscape.js ^3.2.0
* <List your dependencies here please>


## Usage instructions

Download the library:
* via npm: `npm install cytoscape-popper`,
* via bower: `bower install cytoscape-popper`, or
* via direct download in the repository (probably from a tag).

Import the library as appropriate for your project:

ES import:

```js
import cytoscape from 'cytoscape';
import popper from 'cytoscape-popper';
cytoscape.use( popper );
```

CommonJS require:

```js
let cytoscape = require('cytoscape');
let popper = require('cytoscape-popper');
cytoscape.use( popper ); // register extension
```

AMD:

```js
require(['cytoscape', 'cytoscape-popper'], function( cytoscape, popper ){
popper( cytoscape ); // register extension
});
```

Plain HTML/JS has the extension registered for you automatically, because no `require()` is needed.


## API

TODO describe the API of the extension here.


## Build targets

* `npm run test` : Run Mocha tests in `./test`
* `npm run build` : Build `./src/**` into `cytoscape-popper.js`
* `npm run watch` : Automatically build on changes with live reloading (N.b. you must already have an HTTP server running)
* `npm run dev` : Automatically build on changes with live reloading with webpack dev server
* `npm run lint` : Run eslint on the source

N.b. all builds use babel, so modern ES features can be used in the `src`.


## Publishing instructions

This project is set up to automatically be published to npm and bower. To publish:

1. Build the extension : `npm run build`
1. Commit the build : `git commit -am "Build for release"`
1. Bump the version number and tag: `npm version major|minor|patch`
1. Push to origin: `git push && git push --tags`
1. Publish to npm: `npm publish .`
1. If publishing to bower for the first time, you'll need to run `bower register cytoscape-popper https://github.com/cytoscape&#x2F;cytoscape.js-popper.git`
@@ -0,0 +1,24 @@
{
"name": "cytoscape-popper",
"description": "A Cytoscape.js extension for Popper.js",
"main": "cytoscape-popper.js",
"dependencies": {
"cytoscape": "^3.2.0"
},
"repository": {
"type": "git",
"url": "https://github.com/cytoscape/cytoscape.js-popper.git"
},
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"keywords": [
"cytoscape",
"cytoscape-extension"
],
"license": "MIT"
}
@@ -0,0 +1,97 @@
<!DOCTYPE>

<html>

<head>
<title>cytoscape-popper.js demo</title>

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

<script src="https://unpkg.com/cytoscape/dist/cytoscape.min.js"></script>

<!-- for testing with local version of cytoscape.js -->
<!--<script src="../cytoscape.js/build/cytoscape.js"></script>-->

<script src="cytoscape-popper.js"></script>

<style>
body {
font-family: helvetica neue, helvetica, liberation sans, arial, sans-serif;
font-size: 14px;
}
#cy {
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
z-index: 999;
}
h1 {
opacity: 0.5;
font-size: 1em;
font-weight: bold;
}
</style>

<script>
document.addEventListener('DOMContentLoaded', function(){
var cy = window.cy = cytoscape({
container: document.getElementById('cy'),
style: [
{
selector: 'node',
style: {
'content': 'data(name)'
}
},
{
selector: 'edge',
style: {
'curve-style': 'bezier',
'target-arrow-shape': 'triangle'
}
}
],
elements: {
nodes: [
{ data: { id: 'j', name: 'Jerry' } },
{ data: { id: 'e', name: 'Elaine' } },
{ data: { id: 'k', name: 'Kramer' } },
{ data: { id: 'g', name: 'George' } }
],
edges: [
{ data: { source: 'j', target: 'e' } },
{ data: { source: 'j', target: 'k' } },
{ data: { source: 'j', target: 'g' } },
{ data: { source: 'e', target: 'j' } },
{ data: { source: 'e', target: 'k' } },
{ data: { source: 'k', target: 'j' } },
{ data: { source: 'k', target: 'e' } },
{ data: { source: 'k', target: 'g' } },
{ data: { source: 'g', target: 'j' } }
]
}
});
// demo your core ext
cy.popper( /* args... */ );
});
</script>
</head>

<body>
<h1>cytoscape-popper demo</h1>

<div id="cy"></div>

</body>

</html>
@@ -0,0 +1,44 @@
{
"name": "cytoscape-popper",
"version": "0.0.0",
"description": "A Cytoscape.js extension for Popper.js",
"main": "cytoscape-popper.js",
"author": "Cytoscape",
"scripts": {
"lint": "eslint src",
"build": "cross-env NODE_ENV=production webpack",
"build:min": "cross-env NODE_ENV=production MIN=true webpack",
"watch": "webpack --progress --watch",
"dev": "webpack-dev-server --open",
"test": "mocha"
},
"repository": {
"type": "git",
"url": "https://github.com/cytoscape/cytoscape.js-popper.git"
},
"keywords": [
"cytoscape",
"cytoscape-extension"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/cytoscape/cytoscape.js-popper/issues"
},
"homepage": "https://github.com/cytoscape/cytoscape.js-popper",
"devDependencies": {
"babel-core": "^6.24.1",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.5.1",
"camelcase": "^4.1.0",
"chai": "4.0.2",
"cross-env": "^5.0.0",
"eslint": "^3.9.1",
"mocha": "3.4.2",
"webpack": "^2.6.1",
"webpack-dev-server": "^2.4.5"
},
"peerDependencies": {
"cytoscape": "^3.2.0"
},
"dependencies": {}
}
@@ -0,0 +1,9 @@
// Simple, internal Object.assign() polyfill for options objects etc.

module.exports = Object.assign != null ? Object.assign.bind( Object ) : function( tgt, ...srcs ){
srcs.forEach( src => {
Object.keys( src ).forEach( k => tgt[k] = src[k] );
} );

return tgt;
};
@@ -0,0 +1,7 @@
module.exports = function(){
let cy = this;

// your extension impl...

return this; // chainability
};
@@ -0,0 +1,14 @@
const impl = require('./core');

// registers the extension on a cytoscape lib ref
let register = function( cytoscape ){
if( !cytoscape ){ return; } // can't register if cytoscape unspecified

cytoscape( 'core', 'popper', impl ); // register with cytoscape.js
};

if( typeof cytoscape !== 'undefined' ){ // expose to global cytoscape (i.e. window.cytoscape)
register( cytoscape );
}

module.exports = register;
@@ -0,0 +1,7 @@
const chai = require('chai');

describe('This', function(){
it('does that', function(){
expect( true ).to.be.true;
});
});
@@ -0,0 +1,35 @@
const path = require('path');
const pkg = require('./package.json');
const camelcase = require('camelcase');
const process = require('process');
const webpack = require('webpack');
const env = process.env;
const NODE_ENV = env.NODE_ENV;
const MIN = env.MIN;

let config = {
devtool: 'inline-source-map',
entry: './src/index.js',
output: {
path: path.join( __dirname ),
filename: pkg.name + '.js',
library: camelcase( pkg.name ),
libraryTarget: 'umd'
},
module: {
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }
]
},
externals: NODE_ENV === 'production' ? Object.keys( pkg.dependencies || {} ) : [],
plugins: MIN ? [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: false,
}
})
] : []
};

module.exports = config;

0 comments on commit 7f18c4e

Please sign in to comment.
You can’t perform that action at this time.