|
@@ -34,6 +34,9 @@
|
|
|
var _physics = new Physics();
|
|
|
// var _stage = new createjs.Stage('corpus-map');
|
|
|
var _nodes = [];
|
|
|
+ var _articles_nodes = [];
|
|
|
+ var _no_articles_nodes = [];
|
|
|
+ var _nodes_by_entries = {};
|
|
|
// var _particules = [];
|
|
|
// var _base_radius = 3; // nodes radius (real radius, not diametre)
|
|
|
var _p_velocity_factor = 0.5;
|
|
@@ -42,6 +45,7 @@
|
|
|
var _node_opened_id = -1;
|
|
|
var _$entrees_block = $('#block-edlpentreesblock');
|
|
|
var _$entrees_block_termlinks = $('a.term-link', _$entrees_block);
|
|
|
+ var _$articles_link;
|
|
|
var _node_pop_up;
|
|
|
// Colors depend on edlp_vars loaded by edlptheme
|
|
|
// console.log('Corpus : edlp_vars', edlp_vars);
|
|
@@ -116,6 +120,7 @@
|
|
|
// console.log('first node', data.nodes[0]);
|
|
|
// buildParticles(data.nodes);
|
|
|
initNodePopup();
|
|
|
+ initArtilesLink();
|
|
|
buildNodes(data.nodes);
|
|
|
initEvents();
|
|
|
startAnime();
|
|
@@ -128,11 +133,16 @@
|
|
|
// /_/ |_/\____/\__,_/\___/____/
|
|
|
function buildNodes(nodes){
|
|
|
console.log("buildNodes", nodes);
|
|
|
- var x,y,d;
|
|
|
+ var d;
|
|
|
for (var i in nodes) {
|
|
|
d = i < 1 ? true : false;
|
|
|
- _nodes.push(new Node(i,nodes[i],d));
|
|
|
+ // _nodes.push(new Node(i,nodes[i],d));
|
|
|
+ new Node(i,nodes[i],d);
|
|
|
}
|
|
|
+ console.log('_nodes',_nodes);
|
|
|
+ console.log('_articles_nodes',_articles_nodes);
|
|
|
+ console.log('_no_articles_nodes',_no_articles_nodes);
|
|
|
+ console.log('_nodes_by_entries', _nodes_by_entries);
|
|
|
};
|
|
|
|
|
|
function Node(i,node,d){
|
|
@@ -140,6 +150,22 @@
|
|
|
for(key in node)
|
|
|
this[key] = node[key];
|
|
|
|
|
|
+ // record the node in different lists
|
|
|
+ _nodes.push(this);
|
|
|
+
|
|
|
+ if(this.has_article == 1){
|
|
|
+ _articles_nodes.push(this);
|
|
|
+ }else{
|
|
|
+ _no_articles_nodes.push(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (var j = 0; j < this.entrees.length; j++) {
|
|
|
+ if(typeof _nodes_by_entries[this.entrees[j]] == 'undefined')
|
|
|
+ _nodes_by_entries[this.entrees[j]] = [];
|
|
|
+
|
|
|
+ _nodes_by_entries[this.entrees[j]].push(this);
|
|
|
+ }
|
|
|
+
|
|
|
this.debug = d;
|
|
|
this.mass = 8;
|
|
|
this.velocity_threshold = 0.01;
|
|
@@ -160,6 +186,7 @@
|
|
|
|
|
|
this.hover = false;
|
|
|
this.opened = false;
|
|
|
+ this.faded = false;
|
|
|
|
|
|
// prototypes
|
|
|
if (typeof Node.initialized == "undefined") {
|
|
@@ -267,6 +294,16 @@
|
|
|
this.opened = false;
|
|
|
};
|
|
|
|
|
|
+ Node.prototype.fade = function(){
|
|
|
+ this.faded = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ Node.prototype.unFade = function(){
|
|
|
+ this.faded = false;
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Node.prototype.draw = function(){
|
|
|
// carre plein
|
|
|
// clouleur aléatoire ds les entrees
|
|
@@ -277,8 +314,9 @@
|
|
|
// actif entouré de rouge
|
|
|
|
|
|
_ctx.beginPath();
|
|
|
- _ctx.fillStyle = !this.p.resting() ? edlp_vars[this.e_color] : 'rgb(0, 0, 0)';
|
|
|
- // _ctx.fillStyle = edlp_vars[this.e_color];
|
|
|
+ // _ctx.fillStyle = !this.p.resting() ? edlp_vars[this.e_color] : 'rgb(0, 0, 0)';
|
|
|
+ _ctx.globalAlpha = this.faded ? 0.1 : 1;
|
|
|
+ _ctx.fillStyle = edlp_vars[this.e_color];
|
|
|
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
|
|
|
|
|
|
if(this.opened){
|
|
@@ -286,7 +324,7 @@
|
|
|
_ctx.strokeStyle = 'rgb(255,0,0)';
|
|
|
_ctx.strokeRect(this.x - this.r-3,this.y - this.r-3,this.r*2+6,this.r*2+6);
|
|
|
}
|
|
|
-
|
|
|
+ _ctx.globalAlpha = 1;
|
|
|
_ctx.closePath();
|
|
|
};
|
|
|
|
|
@@ -360,6 +398,7 @@
|
|
|
_node_opened_id = id;
|
|
|
_nodes[id].open();
|
|
|
}
|
|
|
+
|
|
|
function closeNode(){
|
|
|
if(_node_opened_id != -1){
|
|
|
_nodes[_node_opened_id].close();
|
|
@@ -367,6 +406,55 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // _ _ _ _
|
|
|
+ // /_\ _ _| |_(_)__| |___ ___
|
|
|
+ // / _ \| '_| _| / _| / -_|_-<
|
|
|
+ // /_/ \_\_| \__|_\__|_\___/__/
|
|
|
+ function initArtilesLink(){
|
|
|
+ // add "articles link to blockentrees"
|
|
|
+ _$articles_link = $('<a>')
|
|
|
+ .html('Articles')
|
|
|
+ .attr("href", "#articles")
|
|
|
+ .addClass('articles-link')
|
|
|
+ .on('click', onCLickedOnArticles);
|
|
|
+
|
|
|
+ $('.item-list ul',_$entrees_block).append(
|
|
|
+ $('<li>').append(
|
|
|
+ $('<span class="oblique-wrapper">').append(_$articles_link)
|
|
|
+ )
|
|
|
+ );
|
|
|
+ };
|
|
|
+
|
|
|
+ function onCLickedOnArticles(e){
|
|
|
+ e.preventDefault();
|
|
|
+ $(this).toggleClass('is-active');
|
|
|
+ if($(this).is('.is-active')){
|
|
|
+ filterArticles();
|
|
|
+ }else{
|
|
|
+ resetArticlesFilter();
|
|
|
+ }
|
|
|
+ // _$canvas.trigger({
|
|
|
+ // 'type':'corpus-cliqued-on-articles'
|
|
|
+ // });
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+
|
|
|
+ function filterArticles(){
|
|
|
+ console.log('filterArticles');
|
|
|
+ for (var i = 0; i < _no_articles_nodes.length; i++) {
|
|
|
+ _no_articles_nodes[i].fade();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ function resetArticlesFilter(){
|
|
|
+ console.log('resetArticlesFilter');
|
|
|
+ for (var i = 0; i < _no_articles_nodes.length; i++) {
|
|
|
+ _no_articles_nodes[i].unFade();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
// ______ __
|
|
|
// / ____/ _____ ____ / /______
|
|
|
// / __/ | | / / _ \/ __ \/ __/ ___/
|
|
@@ -422,8 +510,6 @@
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
// _ _ _ ___ _ _
|
|
|
// | \| |___ __| |___| _ \___ _ __| | | |_ __
|
|
|
// | .` / _ \/ _` / -_) _/ _ \ '_ \ |_| | '_ \
|