Move script for cytoscape to be common
This commit is contained in:
parent
8337614c4c
commit
6cbf05c57c
40
_includes/cytoscape.html
Normal file
40
_includes/cytoscape.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
<script>
|
||||
var cy = cytoscape({
|
||||
container: document.getElementById('cy'),
|
||||
elements: $.getJSON("{{ site.baseurl }}/public/data/channelslist.json"),
|
||||
style: [
|
||||
{
|
||||
selector: 'node',
|
||||
style: {
|
||||
'label': 'data(label)',
|
||||
'text-valign': 'center',
|
||||
'background-color': 'data(color)',
|
||||
'width': 'data(size)',
|
||||
'height': 'data(size)',
|
||||
'color': 'white',
|
||||
'text-outline-width': 2,
|
||||
'text-outline-color': '#888'
|
||||
}
|
||||
},
|
||||
{
|
||||
selector: 'edge',
|
||||
style: {
|
||||
'line-color': 'data(color)'
|
||||
}
|
||||
}],
|
||||
layout: {
|
||||
name: 'cose',
|
||||
nodeDimensionsIncludeLabels: true,
|
||||
nodeOverlap: 50
|
||||
}
|
||||
});
|
||||
|
||||
cy.on('tap', 'node', function () {
|
||||
try { // your browser may block popups
|
||||
window.open(this.data('href'));
|
||||
} catch (e) { // fall back on url change
|
||||
window.location.href = this.data('href');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
@ -23,3 +23,6 @@
|
|||
|
||||
<!-- disqus comments -->
|
||||
{% if page.comments %}{% include disqus_comments.html %}{% endif %}
|
||||
|
||||
<!-- js.cytoscape -->
|
||||
{% if page.cytoscape %}{% include cytoscape.html %}{% endif %}
|
|
@ -10,5 +10,7 @@ Credits: {{ site.url }}/disclosure
|
|||
|
||||
<body>
|
||||
{{ content }}
|
||||
|
||||
{% include scripts.html %}
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
|
@ -12,43 +12,4 @@ style: "#cy { width: 100%; height: 100%; position: fixed; }"
|
|||
---
|
||||
La molette de la souris sert à de/zoomer
|
||||
<div id="cy"></div>
|
||||
<script>
|
||||
var cy = cytoscape({
|
||||
container: document.getElementById('cy'),
|
||||
elements: $.getJSON("{{ site.baseurl }}/public/data/channelslist.json"),
|
||||
style: [
|
||||
{
|
||||
selector: 'node',
|
||||
style: {
|
||||
'label': 'data(label)',
|
||||
'text-valign': 'center',
|
||||
'background-color': 'data(color)',
|
||||
'width': 'data(size)',
|
||||
'height': 'data(size)',
|
||||
'color': 'white',
|
||||
'text-outline-width': 2,
|
||||
'text-outline-color': '#888'
|
||||
}
|
||||
},
|
||||
{
|
||||
selector: 'edge',
|
||||
style: {
|
||||
'line-color': 'data(color)'
|
||||
}
|
||||
}],
|
||||
layout: {
|
||||
name: 'cose',
|
||||
nodeDimensionsIncludeLabels: true,
|
||||
nodeOverlap: 50
|
||||
}
|
||||
});
|
||||
|
||||
cy.on('tap', 'node', function () {
|
||||
try { // your browser may block popups
|
||||
window.open(this.data('href'));
|
||||
} catch (e) { // fall back on url change
|
||||
window.location.href = this.data('href');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue