Compare commits

...
24 Commits
Author SHA1 Message Date
bachir 56a2f0c21f mignified assets for prod 2018-04-21 10:28:09 +02:00
bachir f7e402320e rewrited the corpus map drawing without virtual canvas pre-rendering as it's blured 2018-04-21 10:27:02 +02:00
bachir 79071bf0cc improved checkcollision performance 2018-04-20 11:18:05 +02:00
bachir 6d40f860e4 more corpus optimizations 2018-04-19 22:48:51 +02:00
bachir fcb7677cfc pre rendering each node in owne virtual canvas, then just move this canvas into the main scene 2018-04-19 21:12:53 +02:00
bachir 86dcf68f62 corpus removed hardcoded _dpi value to 2 to window.devicePixelRatio 2018-04-19 18:25:19 +02:00
bachir eddb96cb2e trying to fix corpus map canvas resolution 2018-04-18 21:58:52 +02:00
bachir 2df8d15d91 fixed corpus map canvas resolution 2018-04-18 21:47:29 +02:00
bachir f515e7682a mignified assets for prod 2018-04-18 17:41:01 +02:00
bachir 6e56bf1799 fixed entrees menu : translation and order 2018-04-18 17:40:08 +02:00
bachir 613ea5fc02 fixed blured corpus map 2018-04-18 16:41:01 +02:00
bachir a9cd74b3fb bug fix 2018-04-18 11:42:11 +02:00
bachir bcd129a961 removed redondant events from piwik tracking : ajaxload and search 2018-04-18 11:40:15 +02:00
bachir 35eadafe3e improved piwik search tracking 2018-04-18 11:34:17 +02:00
bachir 74f4c09eb1 added piwik tracking for: ajax loading timing, site search 2018-04-18 11:24:28 +02:00
bachir 67ce55c047 updated events fields display 2018-04-18 10:44:38 +02:00
bachir ab9c1dcd4d mignified assets for prod 2018-04-18 10:30:33 +02:00
bachir f7225cdd01 added entree page tracking, added title to ajax response for tracking (production, agenda, search) 2018-04-18 10:29:46 +02:00
bachir 65d95036c0 added piwik tracking for RandomPlayer 2018-04-18 10:15:54 +02:00
bachir 1904ab1352 fix stupid bug 2018-04-18 10:05:48 +02:00
bachir 77065246fc forgot a debugger; 2018-04-18 10:04:07 +02:00
bachir b6168089a7 trying to fix adudio player bug, added audio play piwik tracking 2018-04-18 10:02:59 +02:00
bachir 249bc608b3 added better page tracking for piwik 2018-04-18 09:49:32 +02:00
bachir 9c61825a17 expanded assets for debug purpose 2018-04-18 09:31:03 +02:00
16 changed files with 397 additions and 158 deletions
@@ -79,7 +79,8 @@ class AgendaController extends ControllerBase {
});
$data = [
'rendered'=> $rendered
'rendered'=> $rendered,
'title'=>'Agenda',
];
// translations links
@@ -25,12 +25,15 @@ class EdlpAjaxController extends ControllerBase {
switch($this->entity_type){
case 'node':
$this->bundle = $this->entity->getType();
$this->title = $this->entity->getTitle();
break;
case 'taxonomy_term':
$this->bundle = $this->entity->bundle();
$this->title = $this->entity->getName();
break;
default:
$this->bundle = NULL;
$this->title = '';
}
}
}
@@ -160,10 +163,13 @@ class EdlpAjaxController extends ControllerBase {
return render($renderable);
});
$title = $this->title;
$title .= $this->viewmode != '' && $this->viewmode != 'default' ? ' | ' . $this->viewmode : '';
$data = [
'date' => time(),
'id' => $this->id,
'title' => $title,
'view_mode' => $this->viewmode,
'bundle' => $this->bundle,
'entity_type' => $this->entity_type,
@@ -1,43 +1,44 @@
(function($,Drupal,drupalSettings){EdlpCorpus=function(){var _activated=true;var _$body=$('body');var _$container=_$body;var _$canvas=$('<canvas id="corpus-map">').appendTo(_$container);var _canvas=_$canvas[0];var _ctx=_canvas.getContext('2d');var _canvas_props={'margin_top':75,'margin_right':0,'margin_bottom':65,'margin_left':0};var _physics=new Physics();var _nodes=[];var _articles_nodes=[];var _no_articles_nodes=[];var _articles_filter_on=false;var _nodes_by_entries={};var _nodes_by_nid={};var _nodes_Nid_Id={};var _nodes_centered=[];var _nodes_centered_attractions=[];var _playlist=[];var _p_velocity_factor=0.5;var _mouse_in=true;var _m_pos={x:0,y:0};var _node_hover_id=-1;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;var _settings=drupalSettings.edlp_corpus;var _ecolors=_settings.colors;var _attracter;function init(){initCanvas();if(_activated){loadCorpus();}else{_$canvas.addClass('de-activated');}};function initCanvas(){window.addEventListener('resize',onResizeCanvas,false);onResizeCanvas();};function onResizeCanvas(){_canvas.width=window.innerWidth;_canvas.height=window.innerHeight;for(var i=0;i<_nodes.length;i++){_nodes[i].onResizeCanvas();resizePhysics();}};function loadCorpus(){var ajax_path=_settings.load_corpus_ajax_url;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(function(data){onCorpusLoaded(data);}).fail(function(jqxhr,textStatus,error){onCorpusLoadError(jqxhr,textStatus,error);});};function onCorpusLoadError(jqxhr,textStatus,error){void 0;};function onCorpusLoaded(data){initPhysics();buildNodes(data.nodes);initArtilesLink();initNodePopup();initEvents();checkPreOpenedEntry();startAnime();};function initPhysics(){_attracter=_physics.makeParticle(1000);_attracter.fixed=true;resizePhysics();};function resizePhysics(){_attracter.position={x:_canvas.width/2,y:_canvas.height/2};};function buildNodes(nodes){var d;for(var i in nodes){d=i<1?true:false;new Node(i,nodes[i],d);_playlist.push({'id':i,'nid':nodes[i].nid,'audio_url':nodes[i].audio_url});}};function Node(i,node,d){this.id=i;for(key in node)
(function($,Drupal,drupalSettings){EdlpCorpus=function(){var _activated=true;var _$body=$('body');var _$container=_$body;var _$canvas=$('<canvas id="corpus-map">').appendTo(_$container);var _canvas=_$canvas[0];var _ctx=_canvas.getContext('2d');var _dpi=window.devicePixelRatio;var _scene_props={width:0,height:0,'margin_top':0,'margin_right':0,'margin_bottom':0,'margin_left':0};var _physics=new Physics();var _nodes=[];var _articles_nodes=[];var _no_articles_nodes=[];var _articles_filter_on=false;var _nodes_by_entries={};var _nodes_by_nid={};var _nodes_Nid_Id={};var _nodes_centered=[];var _nodes_centered_attractions=[];var _playlist=[];var _p_velocity_factor=0.5;var _mouse_in=true;var _m_pos={x:0,y:0};var _node_hover_id=-1;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;var _settings=drupalSettings.edlp_corpus;var _ecolors=_settings.colors;var _attracter;var check_parts_colid_frq=2;var check_parts_colid_tick=1;function init(){initCanvas();if(_activated){loadCorpus();}else{_$canvas.addClass('de-activated');}};function initCanvas(){window.addEventListener('resize',onResizeCanvas,false);onResizeCanvas();};function onResizeCanvas(){_scene_props.width=window.innerWidth;_scene_props.height=window.innerHeight;_canvas.style.width=_scene_props.width+'px';_canvas.style.height=_scene_props.height+'px';_canvas.width=_scene_props.width*_dpi;_canvas.height=_scene_props.height*_dpi;_ctx.scale(_dpi,_dpi);if(_nodes.length){for(var i=0;i<_nodes.length;i++){_nodes[i].onResizeCanvas();}
resizePhysics();}};function loadCorpus(){var ajax_path=_settings.load_corpus_ajax_url;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(function(data){onCorpusLoaded(data);}).fail(function(jqxhr,textStatus,error){onCorpusLoadError(jqxhr,textStatus,error);});};function onCorpusLoadError(jqxhr,textStatus,error){void 0;};function onCorpusLoaded(data){initPhysics();buildNodes(data.nodes);initArtilesLink();initNodePopup();initEvents();checkPreOpenedEntry();startAnime();};function initPhysics(){_attracter=_physics.makeParticle(1000);_attracter.fixed=true;resizePhysics();};function resizePhysics(){_attracter.position={x:_scene_props.width/2,y:_scene_props.height/2};};function buildNodes(nodes){var d;for(var i in nodes){d=i<1?true:false;new Node(i,nodes[i],d);_playlist.push({'id':i,'nid':nodes[i].nid,'audio_url':nodes[i].audio_url});}};function Node(i,node,d){this.id=i;for(key in node)
this[key]=node[key];_nodes.push(this);_nodes_by_nid[this.nid]=this;_nodes_Nid_Id[this.nid]=this.id;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=Math.max(1,this.entrees.length);this.velocity_threshold=0.01;switch(true){case this.entrees.length>3:this.r=8;break;case this.entrees.length>1&&this.entrees.length<=3:this.r=5;break;default:this.r=3;break;}
this.e_color='e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];this.hover=false;this.opened=false;this.faded=false;this.center=false;this.aside=false;this.scrambling=false;this.wall_bouncing_elasticity=0.75;if(typeof Node.initialized=="undefined"){Node.prototype.init=function(){this.calcWallLimits();this.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.ori_pos={x:this.x,y:this.y};this.initPhysics();};Node.prototype.initPhysics=function(){this.p=_physics.makeParticle(this.mass,this.x,this.y);this.p.velocity=new Physics.Vector((Math.random()-0.5)*_p_velocity_factor,(Math.random()-0.5)*_p_velocity_factor);this.ori_p=_physics.makeParticle(1000,this.ori_pos.x,this.ori_pos.y);this.ori_p.fixed=true;this.ori_p_attract=_physics.makeAttraction(this.ori_p,this.p,1000,_canvas.width*2);this.ori_p_attract.on=false;this.attract=_physics.makeAttraction(_attracter,this.p,1000,_canvas.width*2);this.attract.on=false;};Node.prototype.calcWallLimits=function(){this.wall_limits={top:_canvas_props.margin_top+this.r,right:_canvas.width-_canvas_props.margin_right-this.r,bottom:_canvas.height-_canvas_props.margin_bottom-this.r,left:_canvas_props.margin_left+this.r}};Node.prototype.onResizeCanvas=function(){this.calcWallLimits();this.shuffleOriP();};Node.prototype.shuffleOriP=function(){this.ori_pos.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.ori_pos.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.scramble();};Node.prototype.onUpdate=function(){if(this.hover||this.opened){this.p.fixed=true;}else{this.p.fixed=false;}
if(this.center)
this.limitEvolutionZone();if(!this.p.resting()){this.checkWallBouncing();this.updatePos();if(this.scrambling){this.checkOriPDist();}}
this.d=this.r*2;this.e_color='e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];this.canvas=document.createElement('canvas');this.canvas_ctx=this.canvas.getContext('2d');this.line_width=1;this.w=this.r*2+this.line_width*2;this.w_2=this.w/2;this.canvas.width=this.w;this.canvas.height=this.w;this.canvas_ctx.fillStyle='rgb(255,255,255)';this.canvas_ctx.lineWidth=this.line_width;this.wall_bouncing_elasticity=0.75;this.hover=false;this.opened=false;this.faded=false;this.center=false;this.aside=false;this.scrambling=false;if(typeof Node.initialized=="undefined"){Node.prototype.init=function(){this.calcWallLimits();this.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.ori_pos={x:this.x,y:this.y};this.initPhysics();};Node.prototype.initPhysics=function(){this.p=_physics.makeParticle(this.mass,this.x,this.y);this.p.velocity=new Physics.Vector((Math.random()-0.5)*_p_velocity_factor,(Math.random()-0.5)*_p_velocity_factor);this.ori_p=_physics.makeParticle(1000,this.ori_pos.x,this.ori_pos.y);this.ori_p.fixed=true;this.ori_p_attract=_physics.makeAttraction(this.ori_p,this.p,1000,_scene_props.width*2);this.ori_p_attract.on=false;this.attract=_physics.makeAttraction(_attracter,this.p,1000,_scene_props.width*2);this.attract.on=false;};Node.prototype.calcWallLimits=function(){this.wall_limits={top:_scene_props.margin_top+this.r,right:_scene_props.width-_scene_props.margin_right-this.r,bottom:_scene_props.height-_scene_props.margin_bottom-this.r,left:_scene_props.margin_left+this.r}};Node.prototype.onResizeCanvas=function(){this.calcWallLimits();this.shuffleOriP();};Node.prototype.shuffleOriP=function(){this.ori_pos.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.ori_pos.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.scramble();};Node.prototype.onUpdate=function(){if(this.hover||this.opened){this.p.fixed=true;}else{this.p.fixed=false;if(this.center)
this.limitEvolutionZone();this.checkWallBouncing();this.updatePos();if(this.scrambling){this.checkOriPDist();}}
if(_mouse_in&&!this.aside&&!this.faded)
this.checkMouse();this.draw();};Node.prototype.checkVelocityThreshold=function(){if(!this.centered||!this.aside){if(Math.abs(this.p.velocity.x)<this.velocity_threshold&&Math.abs(this.p.velocity.y)<this.velocity_threshold){this.p.velocity.multiplyScalar(0);}}};Node.prototype.checkWallBouncing=function(){switch(true){case this.x<this.wall_limits.left&&this.p.velocity.x<0:this.p.position.x=this.wall_limits.left;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.x>this.wall_limits.right&&this.p.velocity.x>0:this.p.position.x=this.wall_limits.right;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y<this.wall_limits.top&&this.p.velocity.y<0:this.p.position.y=this.wall_limits.top;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y>this.wall_limits.bottom&&this.p.velocity.y>0:this.p.position.y=this.wall_limits.bottom;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;}};Node.prototype.updatePos=function(){this.x=this.p.position.x;this.y=this.p.position.y;};Node.prototype.checkMouse=function(){if(_m_pos.x>this.x-this.r&&_m_pos.x<this.x+this.r&&_m_pos.y>this.y-this.r&&_m_pos.y<this.y+this.r){if(_node_hover_id==-1||_node_hover_id!==this.id){this.setHover();}}else{this.unsetHover();}};Node.prototype.setHover=function(){this.hover=true;_node_hover_id=this.id;_node_pop_up.setNode(this);};Node.prototype.unsetHover=function(){this.hover=false;if(_node_hover_id==this.id){_node_hover_id=-1;_node_pop_up.removeNode();}};Node.prototype.open=function(){this.opened=true;_node_opened_id=this.id;};Node.prototype.close=function(){this.opened=false;};Node.prototype.fade=function(){this.faded=true;};Node.prototype.unFade=function(){this.faded=false;};Node.prototype.setCenteredOnEntree=function(tid){this.e_color='e_col_'+tid;this.setCentered();};Node.prototype.setCentered=function(){this.center=true;this.stopScrambling();this.unsetAside();this.attract.on=true;}
this.checkMouse();this.redraw();};Node.prototype.checkVelocityThreshold=function(){if(!this.centered||!this.aside){if(Math.abs(this.p.velocity.x)<this.velocity_threshold&&Math.abs(this.p.velocity.y)<this.velocity_threshold){this.p.velocity.multiplyScalar(0);}}};Node.prototype.checkWallBouncing=function(){switch(true){case this.x<this.wall_limits.left&&this.p.velocity.x<0:this.p.position.x=this.wall_limits.left;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.x>this.wall_limits.right&&this.p.velocity.x>0:this.p.position.x=this.wall_limits.right;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y<this.wall_limits.top&&this.p.velocity.y<0:this.p.position.y=this.wall_limits.top;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y>this.wall_limits.bottom&&this.p.velocity.y>0:this.p.position.y=this.wall_limits.bottom;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;}};Node.prototype.updatePos=function(){this.x=this.p.position.x;this.y=this.p.position.y;};Node.prototype.checkMouse=function(){if(_m_pos.x>this.x-this.r&&_m_pos.x<this.x+this.r&&_m_pos.y>this.y-this.r&&_m_pos.y<this.y+this.r){if(_node_hover_id==-1||_node_hover_id!==this.id){this.setHover();}}else{this.unsetHover();}};Node.prototype.setHover=function(){this.hover=true;_node_hover_id=this.id;_node_pop_up.setNode(this);};Node.prototype.unsetHover=function(){this.hover=false;if(_node_hover_id==this.id){_node_hover_id=-1;_node_pop_up.removeNode();}};Node.prototype.open=function(){this.opened=true;_node_opened_id=this.id;};Node.prototype.close=function(){this.opened=false;};Node.prototype.fade=function(){this.faded=true;};Node.prototype.unFade=function(){this.faded=false;};Node.prototype.setCenteredOnEntree=function(tid){this.e_color='e_col_'+tid;this.setCentered();};Node.prototype.setCentered=function(){this.center=true;this.stopScrambling();this.unsetAside();this.attract.on=true;}
Node.prototype.unsetCentered=function(){this.center=false;this.attract.on=false;}
Node.prototype.limitEvolutionZone=function(){this.dist_to_attracter=this.p.distanceTo(_attracter);if(this.dist_to_attracter<_canvas.width/4){if(this.p.velocity.length()>0.4){this.p.velocity.multiplyScalar(0.995);}}
if(Math.abs(_attracter.position.x-this.x)>_canvas.width/3||Math.abs(_attracter.position.y-this.y)>_canvas.height/3){this.attract.on=true;}else{this.attract.on=false;}}
Node.prototype.setAside=function(){this.aside=true;this.stopScrambling();this.unsetCentered();this.ori_p.position.x=this.x<_canvas.width/2?this.wall_limits.left:this.wall_limits.right;this.ori_p_attract.on=true;this.wall_bouncing_elasticity=0.15;}
Node.prototype.limitEvolutionZone=function(){this.dist_to_attracter=this.p.distanceTo(_attracter);if(this.dist_to_attracter<_scene_props.width/4){if(this.p.velocity.length()>0.4){this.p.velocity.multiplyScalar(0.99);}}
if(Math.abs(_attracter.position.x-this.x)>_scene_props.width/4||Math.abs(_attracter.position.y-this.y)>_scene_props.height/4){this.attract.on=true;}else{this.attract.on=false;}}
Node.prototype.setAside=function(){this.aside=true;this.stopScrambling();this.unsetCentered();this.ori_p.position.x=this.x<_scene_props.width/2?this.wall_limits.left:this.wall_limits.right;this.ori_p_attract.on=true;this.wall_bouncing_elasticity=0.15;}
Node.prototype.unsetAside=function(){void 0;this.aside=false;this.ori_p_attract.on=false;this.ori_p.position.x=this.ori_pos.x;this.wall_bouncing_elasticity=0.75;}
Node.prototype.scramble=function(){this.scrambling=true;this.unsetCentered();this.unsetAside();this.ori_p.position.x=this.ori_pos.x;this.ori_p.position.y=this.ori_pos.y;this.ori_p_attract.on=true;}
Node.prototype.checkOriPDist=function(){if(this.p.distanceTo(this.ori_p)<50){this.stopScrambling();}};Node.prototype.stopScrambling=function(){this.scrambling=false;this.ori_p_attract.on=false;}
Node.prototype.draw=function(){_ctx.beginPath();_ctx.globalAlpha=this.faded?0.15:1;_ctx.lineWidth='2px';_ctx.fillStyle='rgb(255,255,255)';_ctx.fillRect(this.x-this.r,this.y-this.r,this.r*2,this.r*2);_ctx.strokeStyle=_ecolors[this.e_color];_ctx.strokeRect(this.x-this.r,this.y-this.r,this.r*2,this.r*2);if(this.opened){_ctx.fillStyle=_ecolors[this.e_color];_ctx.fillRect(this.x-this.r,this.y-this.r,this.r*2,this.r*2);}
_ctx.globalAlpha=1;_ctx.closePath();};Node.initialized=true;}
this.init();};function checkParticulesCollisions(){var na,nb,ma,mb,w,h,dx,dy,makeup,newVelX1,newVelY1,newVelX2,newVelY2;for(var n=0,l=_nodes.length;n<l;n++){na=_nodes[n];ma=na.p.mass;if(na.scrambling)continue;for(var q=n+1;q<l;q++){nb=_nodes[q];mb=nb.p.mass;if((na.center&&nb.aside)||(na.aside&&nb.center)||(na.aside&&nb.aside))
continue;if(na.center&&nb.center){if(Math.min(na.p.distanceTo(_attracter),nb.p.distanceTo(_attracter))>300){if(Math.random()>0.3)continue;}}
w=h=(na.r+nb.r);w=h+=4;dx=na.p.position.x-nb.p.position.x;dy=na.p.position.y-nb.p.position.y;if(Math.abs(dx)>w||Math.abs(dy)>h)continue;if(Math.abs(dx)<Math.abs(dy)){makeup=(h-Math.abs(dy))/2;if(dy>0){na.p.position.y+=makeup;nb.p.position.y-=makeup;}else{na.p.position.y-=makeup;nb.p.position.y+=makeup;}
newVelY1=(ma-mb)/(ma+mb)*na.p.velocity.y+2*mb/(ma+mb)*nb.p.velocity.y;newVelY2=(mb-ma)/(mb+ma)*nb.p.velocity.y+2*ma/(mb+ma)*na.p.velocity.y;na.p.velocity.y=newVelY1;nb.p.velocity.y=newVelY2;}else{makeup=(w-Math.abs(dx))/2;if(dx>0){na.p.position.x+=makeup;nb.p.position.x-=makeup;}else{na.p.position.x-=makeup;nb.p.position.x+=makeup;}
newVelX1=(ma-mb)/(ma+mb)*na.p.velocity.x+2*mb/(ma+mb)*nb.p.velocity.x;newVelX2=(mb-ma)/(mb+ma)*nb.p.velocity.x+2*ma/(mb+ma)*na.p.velocity.x;na.p.velocity.x=newVelX1;nb.p.velocity.x=newVelX2;}
Node.prototype.move=function(){_ctx.drawImage(this.canvas,this.x-this.w_2,this.y-this.w_2);};Node.prototype.redraw=function(){_ctx.beginPath();_ctx.fillStyle='rgb(255,255,255)';_ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);_ctx.globalAlpha=this.faded?0.15:1;if(this.opened){_ctx.fillStyle=_ecolors[this.e_color];_ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);}
_ctx.strokeStyle=_ecolors[this.e_color];_ctx.strokeRect(this.x-this.r,this.y-this.r,this.d,this.d);_ctx.closePath();};Node.initialized=true;}
this.init();};function checkParticulesCollisions(){if(check_parts_colid_tick<check_parts_colid_frq){check_parts_colid_tick++;return;}
check_parts_colid_tick=1;var na,nb,ma,mb,w,h,dx,dy,makeup,newVelX1,newVelY1,newVelX2,newVelY2,Smamb;for(var n=0,l=_nodes.length;n<l;n++){na=_nodes[n];if(na.scrambling||na.aside||na.center)continue;ma=na.p.mass;for(var q=n+1;q<l;q++){nb=_nodes[q];if(nb.aside)
continue;w=h=(na.r+nb.r);w=h+=4;dx=na.p.position.x-nb.p.position.x;if(Math.abs(dx)>w)continue;dy=na.p.position.y-nb.p.position.y;if(Math.abs(dy)>h)continue
mb=nb.p.mass;Smamb=ma+mb;if(Math.abs(dx)<Math.abs(dy)){makeup=(h-Math.abs(dy))/2;if(dy>0){na.p.position.y+=makeup;nb.p.position.y-=makeup;}else{na.p.position.y-=makeup;nb.p.position.y+=makeup;}
newVelY1=(ma-mb)/Smamb*na.p.velocity.y+2*mb/Smamb*nb.p.velocity.y;newVelY2=(mb-ma)/Smamb*nb.p.velocity.y+2*ma/Smamb*na.p.velocity.y;na.p.velocity.y=newVelY1;nb.p.velocity.y=newVelY2;}else{makeup=(w-Math.abs(dx))/2;if(dx>0){na.p.position.x+=makeup;nb.p.position.x-=makeup;}else{na.p.position.x-=makeup;nb.p.position.x+=makeup;}
newVelX1=(ma-mb)/Smamb*na.p.velocity.x+2*mb/Smamb*nb.p.velocity.x;newVelX2=(mb-ma)/Smamb*nb.p.velocity.x+2*ma/Smamb*na.p.velocity.x;na.p.velocity.x=newVelX1;nb.p.velocity.x=newVelX2;}
na.p.velocity.multiplyScalar(0.90);nb.p.velocity.multiplyScalar(0.90);}}};function openNodeByNid(nid){closeNode();if(typeof _nodes_Nid_Id[nid]!='undefined'){_node_opened_id=_nodes_Nid_Id[nid];_nodes[_nodes_Nid_Id[nid]].open();}}
function closeNode(){if(_node_opened_id!=-1){_nodes[_node_opened_id].close();_node_opened_id=-1;}}
function createNodesRepulsions(){purgeNodesRepulsions();for(var n=0;n<_nodes_centered.length;n++){for(var q=n+1;q<_nodes_centered.length;q++){_physics.makeAttraction(_nodes_centered[n].p,_nodes_centered[q].p,-0.4,10);}}};function purgeNodesRepulsions(){for(var a=_physics.attractions.length-1;a>=0;a--){if(Math.abs(_physics.attractions[a].constant)<1){_physics.attractions.splice(a,1);}else{break;}}};function updateRandomPlaylist(p){_$canvas.trigger({type:'update-random-playlist',playlist:p})};function toggleEntree(tid,bubbling){var $link=_$entrees_block_termlinks.filter('[tid="'+tid+'"]');var $li=$link.parents('li');var sys_path=$link.attr('data-drupal-link-system-path');var url=$link.attr('href');if(!$li.is('.opened')){_$entrees_block_termlinks.parents('li').removeClass('opened');$li.addClass('opened');$li.parents('.item-list').addClass('opened')
filterEntree(tid);if(bubbling){_$body.trigger({'type':'open_entree','tid':tid,'url':url,'sys_path':sys_path});}}else if(bubbling){$li.removeClass('opened');$li.parents('.item-list').removeClass('opened')
function createNodesRepulsions(){purgeNodesRepulsions();for(var n=0;n<_nodes_centered.length;n++){for(var q=n+1;q<_nodes_centered.length;q++){_physics.makeAttraction(_nodes_centered[n].p,_nodes_centered[q].p,-0.4,10);}}};function purgeNodesRepulsions(){for(var a=_physics.attractions.length-1;a>=0;a--){if(Math.abs(_physics.attractions[a].constant)<1){_physics.attractions.splice(a,1);}else{break;}}};function updateRandomPlaylist(p){_$canvas.trigger({type:'update-random-playlist',playlist:p})};function toggleEntree(tid,bubbling){var $link=_$entrees_block_termlinks.filter('[tid="'+tid+'"]');var $li=$link.parents('li');var sys_path=$link.attr('data-drupal-link-system-path');var url=$link.attr('href');var title=$link.text();if(!$li.is('.opened')){_$entrees_block_termlinks.parents('li').removeClass('opened');$li.addClass('opened');$li.parents('.item-list').addClass('opened')
filterEntree(tid);if(bubbling){_$body.trigger({'type':'open_entree','tid':tid,'url':url,'sys_path':sys_path,'title':title});}}else if(bubbling){$li.removeClass('opened');$li.parents('.item-list').removeClass('opened')
scrambleCollection();_$body.trigger({'type':'close_entree','tid':tid});}};function filterEntree(t){shutDownArticles();_nodes_centered=[];for(var n=0;n<_nodes.length;n++){if(_nodes[n].entrees.indexOf(t)==-1){_nodes[n].setAside();}else{_nodes[n].setCenteredOnEntree(t);_nodes_centered.push(_nodes[n]);}}
updateRandomPlaylist(_nodes_centered);createNodesRepulsions();};function highlightEntries(){_$entrees_block_termlinks.parents('li').removeClass('highlighted').parents('.item-list').removeClass('highlighted');var id=-1;if(_node_hover_id!=-1){id=_node_hover_id;}else if(_node_opened_id!=-1){id=_node_opened_id;}
var entree;if(id!=-1){for(var i=0;i<_nodes[id].entrees.length;i++){entree=_nodes[id].entrees[i];_$entrees_block_termlinks.filter(function(){return $(this).attr('tid')==entree;}).parents('li').addClass('highlighted').parents('.item-list').addClass('highlighted');}}};function filterSearchResults(nids){shutDownArticles();_nodes_centered=[];for(var n=0;n<_nodes.length;n++){if(nids.indexOf(_nodes[n].nid)==-1){_nodes[n].setAside();}else{_nodes[n].setCentered();_nodes_centered.push(_nodes[n]);}}
updateRandomPlaylist(_nodes_centered);createNodesRepulsions();};function scrambleCollection(){for(var i=0;i<_nodes.length;i++){_nodes[i].scramble();}
updateRandomPlaylist(_playlist);};function closeAllEntries(){_$entrees_block_termlinks.each(function(index,el){if($(this).parents('li').is('.opened')){$(this).trigger('click');return false;}});};function initArtilesLink(){_$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')){activateArticlesFilter();closeAllEntries();}else{deactivateArticlesFilter();}
return false;};function activateArticlesFilter(){_articles_filter_on=true;for(var i=0;i<_no_articles_nodes.length;i++){_no_articles_nodes[i].fade();}
updateRandomPlaylist(_articles_nodes);};function deactivateArticlesFilter(){_articles_filter_on=false;for(var i=0;i<_no_articles_nodes.length;i++){_no_articles_nodes[i].unFade();}
updateRandomPlaylist(_playlist);};function shutDownArticles(){if(_$articles_link.is('.is-active'))
updateRandomPlaylist(_articles_nodes);if(typeof _paq!=='undefined'){_paq.push(['trackEvent','Corpus Articles','on']);}};function deactivateArticlesFilter(){_articles_filter_on=false;for(var i=0;i<_no_articles_nodes.length;i++){_no_articles_nodes[i].unFade();}
updateRandomPlaylist(_playlist);if(typeof _paq!=='undefined'){_paq.push(['trackEvent','Corpus Articles','off']);}};function shutDownArticles(){if(_$articles_link.is('.is-active'))
_$articles_link.trigger('click');};function initEvents(){void 0;_$canvas.on('mousemove',function(event){event.preventDefault();_m_pos.x=event.originalEvent.clientX;_m_pos.y=event.originalEvent.clientY;}).on('mouseenter',function(event){_mouse_in=true;}).on('mouseout',function(event){_mouse_in=false;_node_pop_up.removeNode();}).on('click',function(event){if(event.target.tagName!="A"&&event.target.tagName!="INPUT"){event.preventDefault();if(_node_hover_id!=-1){var event={'type':'corpus-cliked-on-node','target_node':_nodes[_node_hover_id],'article':_articles_filter_on};_$canvas.trigger(event);}else{_$canvas.trigger('corpus-cliked-on-map');shutDownArticles();}}}).on('mouseover-audio-link',function(e){void 0;_nodes_by_nid[e.nid].setHover();}).on('mouseout-audio-link',function(e){void 0;_nodes_by_nid[e.nid].unsetHover();}).on('audio-node-opened',function(e){openNodeByNid(e.nid);}).on('audio-node-closed',function(e){closeNode();}).on('open-entree',function(e){toggleEntree(e.tid);}).on('close-all-entree',function(e){closeAllEntries();});_$entrees_block_termlinks.on('click',function(event){event.preventDefault();toggleEntree($(this).attr('tid'),true);return false;});_$body.on('chutier-action-done',function(e){_nodes_by_nid[e.target_id].chutier_action=e.new_action;}).on('search-results-loaded',function(e){filterSearchResults(e.results);}).on('search-closed',function(e){scrambleCollection();}).on('new-content-not-entree-ajax-loaded',function(e){if(_$entrees_block_termlinks.parents('li.opened').length){_$entrees_block_termlinks.parents('li').removeClass('opened').parents('.item-list').removeClass('opened');scrambleCollection();}});};function checkPreOpenedEntry(){_$entrees_block.find('li.entree').each(function(index,el){var $li=$(this);if($('a.is-active',$li).length){$li.addClass('opened').parents('.item-list').addClass('opened');filterEntree($li.attr('tid'));return false;}});};function initNodePopup(){_node_pop_up=new NodePopUp();};function NodePopUp(){this.visible=false;this.node;this.$dom=$('<div>').addClass('node-popup').attr('pos','top-right').appendTo('body');this.$content=$('<div>').addClass('inner').appendTo(this.$dom);if(typeof NodePopUp.initialized=="undefined"){NodePopUp.prototype.setNode=function(n){this.node=n;this.setPositioning();this.setContent();};NodePopUp.prototype.setPositioning=function(){switch(true){case this.node.x>this.node.wall_limits.right-350&&this.node.y<this.node.wall_limits.top+200:this.$dom.attr('pos','bottom-left');break;case this.node.x>this.node.wall_limits.right-350:this.$dom.attr('pos','top-left');break;case this.node.y<this.node.wall_limits.top+200:this.$dom.attr('pos','bottom-right');break;default:this.$dom.attr('pos','top-right');}};NodePopUp.prototype.setContent=function(){this.$content.html('');var $entrees=$('<div>').addClass('entrees');for(var i=0;i<this.node.entrees.length;i++){var tid=this.node.entrees[i];$entrees.append($('<span>').addClass('entree').attr('tid',tid));}
var $chutier_action=$('<span>').addClass('chutier-icon').attr('action',this.node.chutier_action);this.$content.append($entrees).append('<h2 class="title">'+this.node.title+'</h2>').append('<section class="description">'+this.node.description+'</section>').append($chutier_action);};NodePopUp.prototype.removeNode=function(){this.node=false;};NodePopUp.prototype.draw=function(){if(this.node){this.$dom.css({'display':"block",'left':this.node.x+"px",'top':this.node.y+"px",});}else{this.$dom.css({'display':"none",});}};NodePopUp.initialized=true;}}
function render(){_ctx.clearRect(0,0,_canvas.width,_canvas.height);checkParticulesCollisions();for(var i=0;i<_nodes.length;i++){_nodes[i].onUpdate();}
function render(){_ctx.clearRect(0,0,_scene_props.width,_scene_props.height);checkParticulesCollisions();for(var i=0;i<_nodes.length;i++){_nodes[i].onUpdate();}
_node_pop_up.draw();if(_node_hover_id!=-1){_canvas.style.cursor='pointer';}else{_canvas.style.cursor='auto';}
highlightEntries();};function startAnime(){_physics.onUpdate(render);_physics.play()
$('body').attr('corpus','map-ready').trigger({'type':'corpus-map-ready','playlist':_playlist});};init();}
@@ -24,11 +24,16 @@
var _$canvas = $('<canvas id="corpus-map">').appendTo(_$container);
var _canvas = _$canvas[0];
var _ctx = _canvas.getContext('2d');
var _canvas_props = {
var _dpi = window.devicePixelRatio;
var _scene_props = {
width:0,
height:0,
// 'margin_top':90, // with red border on head
'margin_top':75, // without red border on head
// 'margin_top':75, // without red border on head
'margin_top':0,
'margin_right':0,
'margin_bottom':65,
// 'margin_bottom':65,
'margin_bottom':0,
'margin_left':0
};
var _physics = new Physics();
@@ -68,6 +73,9 @@
// _scrambler_CL,
// _scrambler_CR;
var check_parts_colid_frq = 2;
var check_parts_colid_tick = 1;
// ____ _ __
// / _/___ (_) /______
// / // __ \/ / __/ ___/
@@ -92,10 +100,20 @@
onResizeCanvas();
};
function onResizeCanvas() {
_canvas.width = window.innerWidth;
_canvas.height = window.innerHeight;
for (var i = 0; i < _nodes.length; i++) {
_nodes[i].onResizeCanvas();
// _dpi = 2;
_scene_props.width = window.innerWidth;
_scene_props.height = window.innerHeight;
_canvas.style.width = _scene_props.width+'px';
_canvas.style.height = _scene_props.height+'px';
_canvas.width = _scene_props.width*_dpi;
_canvas.height = _scene_props.height*_dpi;
_ctx.scale(_dpi, _dpi);
if(_nodes.length){
for (var i = 0; i < _nodes.length; i++) {
_nodes[i].onResizeCanvas();
}
// move _attracter and _repulser to the center again
resizePhysics();
}
@@ -149,7 +167,7 @@
};
function resizePhysics(){
// attracters
_attracter.position = {x:_canvas.width/2, y:_canvas.height/2};
_attracter.position = {x:_scene_props.width/2, y:_scene_props.height/2};
};
// _ _ _
@@ -211,9 +229,24 @@
this.r = 3;//4;
break;
}
this.d = this.r*2;
this.e_color = 'e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];
// pre-rendering node virtual canvas
this.canvas = document.createElement('canvas');
this.canvas_ctx = this.canvas.getContext('2d');
this.line_width = 1;
this.w = this.r*2+this.line_width*2;
this.w_2 = this.w/2;
this.canvas.width = this.w;
this.canvas.height = this.w;
this.canvas_ctx.fillStyle = 'rgb(255,255,255)';
this.canvas_ctx.lineWidth = this.line_width;
this.wall_bouncing_elasticity = 0.75;
// node states
this.hover = false;
this.opened = false;
this.faded = false;
@@ -221,9 +254,6 @@
this.aside = false;
this.scrambling = false;
this.wall_bouncing_elasticity = 0.75;
// this.n_repulses = {};
// prototypes
if (typeof Node.initialized == "undefined") {
@@ -236,10 +266,43 @@
this.ori_pos = {x:this.x,y:this.y};
// TODO: don't forget to move ori_pos on window resize
//this.drawSprite();
this.initPhysics();
};
// Node.prototype.drawSprite = function(){
// _ctx.clearRect(0, 0, this.w, this.w);
//
// this.canvas_ctx.beginPath();
// // white background
// this.canvas_ctx.fillRect(0,0,this.w,this.w);
//
// this.canvas_ctx.globalAlpha = this.faded ? 0.15 : 1;
//
// if(this.opened){
// // carre plein
// // this.canvas_ctx.lineWidth = '1px';
// // this.canvas_ctx.strokeStyle = 'rgb(255,0,0)';
// // this.canvas_ctx.strokeRect(this.x - this.r-3,this.y - this.r-3,this.r*2+6,this.r*2+6);
// // ou carre contour
// this.canvas_ctx.save(); // save the normal context state (fill white)
// this.canvas_ctx.fillStyle = _ecolors[this.e_color];
// this.canvas_ctx.fillRect(this.line_width,this.line_width,this.d,this.d);
// this.canvas_ctx.restore(); // restore the normal context state (fill white)
// }
// // else{
// // // carre plein
// // // this.canvas_ctx.fillStyle = _ecolors[this.e_color];
// // // this.canvas_ctx.fillRect(this.x - this.r,this.y - this.r,this.d,this.d);
// // // ou carre contour
// // this.canvas_ctx.fillRect(this.line_width,this.line_width,this.d,this.d);
// // }
// this.canvas_ctx.strokeStyle = _ecolors[this.e_color];
// this.canvas_ctx.strokeRect(this.line_width,this.line_width,this.d,this.d);
// // this.canvas_ctx.globalAlpha = 1;
// this.canvas_ctx.closePath();
// };
Node.prototype.initPhysics = function(){
// particule
this.p = _physics.makeParticle(this.mass, this.x, this.y);
@@ -248,19 +311,19 @@
this.ori_p = _physics.makeParticle(1000, this.ori_pos.x, this.ori_pos.y);
this.ori_p.fixed = true;
// TODO: don't forget to move ori_p on window resize
this.ori_p_attract = _physics.makeAttraction(this.ori_p, this.p, 1000, _canvas.width*2);
this.ori_p_attract = _physics.makeAttraction(this.ori_p, this.p, 1000, _scene_props.width*2);
this.ori_p_attract.on = false;
// attracter
this.attract = _physics.makeAttraction(_attracter, this.p, 1000, _canvas.width*2);
this.attract = _physics.makeAttraction(_attracter, this.p, 1000, _scene_props.width*2);
this.attract.on = false;
};
Node.prototype.calcWallLimits = function(){
this.wall_limits = {
top: _canvas_props.margin_top +this.r,
right: _canvas.width -_canvas_props.margin_right -this.r,
bottom: _canvas.height -_canvas_props.margin_bottom -this.r,
left: _canvas_props.margin_left +this.r
top: _scene_props.margin_top +this.r,
right: _scene_props.width -_scene_props.margin_right -this.r,
bottom: _scene_props.height -_scene_props.margin_bottom -this.r,
left: _scene_props.margin_left +this.r
}
};
@@ -283,26 +346,25 @@
this.p.fixed = true;
}else{
this.p.fixed = false;
}
if(this.center)
if(this.center)
this.limitEvolutionZone();
if(!this.p.resting()){
// if(!this.p.resting()){
// this.checkVelocityThreshold();
this.checkWallBouncing();
this.updatePos();
if(this.scrambling){
this.checkOriPDist();
}
// }
}
if(_mouse_in && !this.aside && !this.faded)
this.checkMouse();
// if(this.debug)
// console.log("Node pos: ", {x:this.x, y:this.y});
this.draw();
// this.move();
this.redraw();
};
Node.prototype.checkVelocityThreshold = function(){
@@ -380,16 +442,20 @@
Node.prototype.open = function(){
this.opened = true;
_node_opened_id = this.id;
//this.drawSprite();
};
Node.prototype.close = function(){
this.opened = false;
//this.drawSprite();
};
Node.prototype.fade = function(){
this.faded = true;
//this.drawSprite();
};
Node.prototype.unFade = function(){
this.faded = false;
//this.drawSprite();
};
Node.prototype.setCenteredOnEntree = function(tid){
@@ -402,6 +468,7 @@
this.stopScrambling();
this.unsetAside();
this.attract.on = true;
//this.drawSprite();
}
Node.prototype.unsetCentered = function(){
this.center = false;
@@ -413,13 +480,13 @@
// if(this.id == 1)
// console.log('this.p.velocity', this.p.velocity);
this.dist_to_attracter = this.p.distanceTo(_attracter);
if( this.dist_to_attracter < _canvas.width/4){
if( this.dist_to_attracter < _scene_props.width/4){
if( this.p.velocity.length() > 0.4 ){
this.p.velocity.multiplyScalar(0.995);
this.p.velocity.multiplyScalar(0.99); // 0.995
}
}
if( Math.abs(_attracter.position.x - this.x) > _canvas.width/3
|| Math.abs(_attracter.position.y - this.y) > _canvas.height/3){
if( Math.abs(_attracter.position.x - this.x) > _scene_props.width/4
|| Math.abs(_attracter.position.y - this.y) > _scene_props.height/4){
this.attract.on = true;
}else{
this.attract.on = false;
@@ -431,7 +498,7 @@
// this.fade();
this.stopScrambling();
this.unsetCentered();
this.ori_p.position.x = this.x < _canvas.width /2 ? this.wall_limits.left : this.wall_limits.right;
this.ori_p.position.x = this.x < _scene_props.width /2 ? this.wall_limits.left : this.wall_limits.right;
this.ori_p_attract.on = true;
this.wall_bouncing_elasticity = 0.15;
}
@@ -468,26 +535,18 @@
// this.scramble_CL.on = false;
}
Node.prototype.draw = function(){
// carre plein
// clouleur aléatoire ds les entrees
// 3 tailles :
// - 1 entree : petit carre 5px
// - 2-3 entrees : moyen 7.5px
// - >3 entrees : grand 10px
// actif entouré de rouge
Node.prototype.move = function(){
// just draw the virtual node canvas into the main scene canvas at the right position
_ctx.drawImage(this.canvas, this.x-this.w_2, this.y-this.w_2);
};
Node.prototype.redraw = function(){
_ctx.beginPath();
_ctx.globalAlpha = this.faded ? 0.15 : 1;
// carre plein
// _ctx.fillStyle = _ecolors[this.e_color];
// _ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
// ou carre contour
_ctx.lineWidth = '2px';
// white background
_ctx.fillStyle = 'rgb(255,255,255)';
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
_ctx.strokeStyle = _ecolors[this.e_color];
_ctx.strokeRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
_ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);
_ctx.globalAlpha = this.faded ? 0.15 : 1;
if(this.opened){
// carre plein
@@ -495,10 +554,21 @@
// _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);
// ou carre contour
// _ctx.save(); // save the normal context state (fill white)
_ctx.fillStyle = _ecolors[this.e_color];
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
_ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);
// _ctx.restore(); // restore the normal context state (fill white)
}
_ctx.globalAlpha = 1;
// else{
// // carre plein
// // _ctx.fillStyle = _ecolors[this.e_color];
// // _ctx.fillRect(this.x - this.r,this.y - this.r,this.d,this.d);
// // ou carre contour
// _ctx.fillRect(this.line_width,this.line_width,this.d,this.d);
// }
_ctx.strokeStyle = _ecolors[this.e_color];
_ctx.strokeRect(this.x-this.r,this.y-this.r,this.d,this.d);
// _ctx.globalAlpha = 1;
_ctx.closePath();
};
@@ -507,53 +577,68 @@
this.init();
};
// TODO: we may convert a lot of computation into a web worker
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
function checkParticulesCollisions(){
// do not run particule collision every frames
if(check_parts_colid_tick < check_parts_colid_frq){
check_parts_colid_tick++;
return;
}
check_parts_colid_tick = 1;
// pre create vars to save memory;
var na,nb,
ma,mb,
w,h,dx,dy,
makeup,
newVelX1, newVelY1, newVelX2, newVelY2;
newVelX1, newVelY1, newVelX2, newVelY2,
Smamb;
// , angle;
// colisions between _particules
for (var n = 0, l = _nodes.length; n < l; n++) {
na = _nodes[n];
ma = na.p.mass;
// avoid colliding for centered nodes
// if(_nodes[n].center) continue;
// avoid colliding for scrambling nodes
if(na.scrambling) continue;
// avoid colliding for aside nodes
// avoid colliding for centered nodes
if(na.scrambling || na.aside || na.center) continue;
ma = na.p.mass;
for (var q = n+1; q < l; q++) {
nb = _nodes[q];
mb = nb.p.mass;
// avoid impact between center and aside particules
// if((na.center && nb.aside) || (na.aside && nb.center))
// and between aside particules
if((na.center && nb.aside) || (na.aside && nb.center) || (na.aside && nb.aside))
if(nb.aside)
continue;
// avoid impact between two centered particulses that comes to the center
if(na.center && nb.center){
if(Math.min(na.p.distanceTo(_attracter), nb.p.distanceTo(_attracter)) > 300){
if( Math.random()>0.3 ) continue;
}
}
// if(na.center && nb.center){
// if(Math.min(na.p.distanceTo(_attracter), nb.p.distanceTo(_attracter)) > 300){
// if( Math.random()>0.3 ) continue;
// }
// }
w = h = (na.r+nb.r);
// if(!na.aside && !nb.aside){
w = h += 4; // add a saftey zone around squares eccept for aside squares
// }
dx = na.p.position.x - nb.p.position.x;
dy = na.p.position.y - nb.p.position.y;
// if both dx and dy are inferior to w & h so squares are colliding (overlapping)
// if( Math.abs(dx) <= w && Math.abs(dy) <= h){ console.log('colliding'); }
// else not so skip
if( Math.abs(dx) > w || Math.abs(dy) > h) continue;
// if( Math.abs(dx) > w || Math.abs(dy) > h) continue;
dx = na.p.position.x - nb.p.position.x;
if( Math.abs(dx) > w ) continue;
dy = na.p.position.y - nb.p.position.y;
if(Math.abs(dy) > h) continue
mb = nb.p.mass;
Smamb = ma+mb;
if(Math.abs(dx) < Math.abs(dy)){ // vertical collision
makeup = (h - Math.abs(dy))/2;
if(dy > 0){ // a is upper than b
@@ -565,8 +650,8 @@
}
// bounce
// https://en.wikipedia.org/wiki/Elastic_collision#One-dimensional_Newtonian
newVelY1 = (ma-mb)/(ma+mb)*na.p.velocity.y+2*mb/(ma+mb)*nb.p.velocity.y;
newVelY2 = (mb-ma)/(mb+ma)*nb.p.velocity.y+2*ma/(mb+ma)*na.p.velocity.y;
newVelY1 = (ma-mb)/Smamb*na.p.velocity.y+2*mb/Smamb*nb.p.velocity.y;
newVelY2 = (mb-ma)/Smamb*nb.p.velocity.y+2*ma/Smamb*na.p.velocity.y;
na.p.velocity.y = newVelY1;
nb.p.velocity.y = newVelY2;
@@ -582,8 +667,8 @@
}
// bounce
// https://en.wikipedia.org/wiki/Elastic_collision#One-dimensional_Newtonian
newVelX1 = (ma-mb)/(ma+mb)*na.p.velocity.x+2*mb/(ma+mb)*nb.p.velocity.x;
newVelX2 = (mb-ma)/(mb+ma)*nb.p.velocity.x+2*ma/(mb+ma)*na.p.velocity.x;
newVelX1 = (ma-mb)/Smamb*na.p.velocity.x+2*mb/Smamb*nb.p.velocity.x;
newVelX2 = (mb-ma)/Smamb*nb.p.velocity.x+2*ma/Smamb*na.p.velocity.x;
na.p.velocity.x = newVelX1;
nb.p.velocity.x = newVelX2;
@@ -640,7 +725,6 @@
// console.log('_physics.attractions.length', _physics.attractions.length);
};
// ___ _ ___ _ _ _ _
// | _ \__ _ _ _ __| |___ _ __ | _ \ |__ _ _ _| (_)__| |_
// | / _` | ' \/ _` / _ \ ' \ | _/ / _` | || | | (_-< _|
@@ -662,13 +746,20 @@
var $li = $link.parents('li');
var sys_path = $link.attr('data-drupal-link-system-path');
var url = $link.attr('href');
var title = $link.text();
if(!$li.is('.opened')){
_$entrees_block_termlinks.parents('li').removeClass('opened');
$li.addClass('opened');
$li.parents('.item-list').addClass('opened')
filterEntree(tid);
if(bubbling){
_$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
_$body.trigger({
'type':'open_entree',
'tid':tid,
'url':url,
'sys_path':sys_path,
'title':title
});
}
// bubbling is true only when event is a real click on entree link
}else if(bubbling){
@@ -800,6 +891,10 @@
_no_articles_nodes[i].fade();
}
updateRandomPlaylist(_articles_nodes);
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'Corpus Articles', 'on']);
}
};
function deactivateArticlesFilter(){
//console.log('deactivateArticlesFilter');
@@ -808,6 +903,10 @@
_no_articles_nodes[i].unFade();
}
updateRandomPlaylist(_playlist);
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'Corpus Articles', 'off']);
}
};
function shutDownArticles(){
// shutdown articles if active
@@ -1030,7 +1129,7 @@
// | / -_) ' \/ _` / -_) '_|
// |_|_\___|_||_\__,_\___|_|
function render(){
_ctx.clearRect(0, 0, _canvas.width, _canvas.height);
_ctx.clearRect(0, 0, _scene_props.width, _scene_props.height);
checkParticulesCollisions();
@@ -8,6 +8,7 @@ namespace Drupal\edlp_corpus\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\taxonomy\Entity\Term;
use Drupal\workflow\Entity\WorkflowManager;
/**
@@ -24,26 +25,40 @@ class BlockEntrees extends BlockBase {
*/
public function build() {
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$query = \Drupal::entityQuery('taxonomy_term')
// ->sort('weight', 'DESC')
// ->sort('name', 'DESC')
->condition('vid', 'entrees');
$tids = $query->execute();
$terms = entity_load_multiple('taxonomy_term', $tids);
// dsm($terms);
foreach ($terms as $term) {
// dpm($term->toArray());
$tid = $term->id();
$name = $term->getName();
// $terms = entity_load_multiple('taxonomy_term', $tids);
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms);
$terms = Term::loadMultiple($tids);
$ordered_terms = [];
foreach ($terms as $term) {
// remove masqué
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
if($sid == 'generique_masque') continue;
// translate the term
$term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
$name = $term->getName();
$ordered_trans_terms[$name] = $term;
}
ksort($ordered_trans_terms);
// dsm($terms);
foreach ($ordered_trans_terms as $name => $term) {
$tid = $term->id();
$entree = array(
'tid'=>$tid
);
// term name
// term link
$url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
$url->setOptions(array(
'attributes' => array(
@@ -102,6 +102,7 @@ class ProductionsController extends ControllerBase {
$data = [
'rendered'=> $rendered,
'title'=> 'Productions',
// 'block' => array(
// 'rendered'=> \Drupal::service('renderer')->renderRoot($block_render),
// 'region'=> str_replace('_', '-', $block->getRegion()),
@@ -120,7 +121,7 @@ class ProductionsController extends ControllerBase {
'#set_active_class' => TRUE,
];
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
$data ['translations_links'] = $translations_rendered;
}
@@ -1,7 +1,4 @@
(function($,Drupal,drupalSettings){var settings=drupalSettings.edlp_search;var _$body=$('body');var _$container;var _$form;function init(){initEvents();initAjax();};function initEvents(){$('body').on('new-content-ajax-loaded',initAjax).on('edlp_search_search_form-col-closed',onSearchClosed);};function initAjax(){_$form=$('#edlp-search-form:not(.ajax-enabled)');if(!_$form.length)return false;_$form=$('#edlp-search-form:not(.ajax-enabled)').on('submit',onSubmitForm).addClass('ajax-enabled');_$container=_$form.parents('.row');if(!_$container.length){_$container=_$form.parent();}};function onSubmitForm(e){e.preventDefault();var args={};args.keys=$('input[type="search"]',this).val();args.entries=[];$('input[type="checkbox"]:checked','#edit-entries').each(function(index,el){args.entries.push($(this).val());});args.langues=$('input[name="language"]',this).val();args.genres=$('input[name="genres"]',this).val();loadResults(args);return false;};function loadResults(args){_$form.addClass('ajax-loading');_$body.addClass('ajax-loading');$('[theme="edlp_search_results"]',_$container).addClass('ajax-loading');var path=window.location.origin+drupalSettings.path.baseUrl+settings.results_ajax_url;$.getJSON(path,args).done(function(data){onResultsLoaded(data);}).fail(function(jqxhr,textStatus,error){onResultsLoadFail(jqxhr,textStatus,error);});};function onResultsLoaded(data){_$form.removeClass('ajax-loading');_$body.removeClass('ajax-loading');$prev_results=$('[theme="edlp_search_results"]',_$container);if($prev_results.length){$prev_results.replaceWith(data.rendered);}else{_$container.append(data.rendered);}
_$body.trigger({'type':'search-results-loaded','results':data.results_nids});if(typeof _paq!=='undefined'){var search_name='keys:'+data.keys
+';langues:'+data.langues
+';genres:'+data.genres
+';entries:'+data.entry_names.join(',');_paq.push(['trackEvent','AjaxSearch','Results',search_name,data.results_nids.length]);}};function onResultsLoadFail(jqxhr,textStatus,error){void 0;};function onSearchClosed(e){$('div[theme="edlp_search_results"]').remove();_$body.trigger({'type':'search-closed'});}
_$body.trigger({'type':'search-results-loaded','results':data.results_nids});if(typeof _paq!=='undefined'){var search_name=data.keys+';'+data.langues+';'+data.genres+';'+data.entry_names.join(',');_paq.push(['trackSiteSearch',search_name,'search',data.results_nids.length]);}};function onResultsLoadFail(jqxhr,textStatus,error){void 0;};function onSearchClosed(e){$('div[theme="edlp_search_results"]').remove();_$body.trigger({'type':'search-closed'});}
init();})(jQuery,Drupal,drupalSettings);
@@ -95,12 +95,18 @@
// piwik
if(typeof _paq !== 'undefined'){
// page tracking
// https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
// _paq.push(['setCustomUrl', state.url]);
// _paq.push(['setDocumentTitle', data.title]);
// _paq.push(['trackPageView']);
// trackEvent(category, action, [name], [value])
var search_name = 'keys:'+data.keys
+';langues:'+data.langues
+';genres:'+data.genres
+';entries:'+data.entry_names.join(',');
_paq.push(['trackEvent', 'AjaxSearch', 'Results', search_name, data.results_nids.length]);
var search_name = data.keys+';'+data.langues+';'+data.genres+';'+data.entry_names.join(',');
// _paq.push(['trackEvent', 'AjaxSearch', 'Results', search_name, data.results_nids.length]);
// piwik track searches
// trackSiteSearch(keyword, [category], [resultsCount])
_paq.push(['trackSiteSearch', search_name, 'search', data.results_nids.length]);
}
};
@@ -78,7 +78,8 @@ class EdlpSearchController extends ControllerBase {
$rendered = render($this->renderable);
$data = [
'rendered' => $rendered
'rendered' => $rendered,
'title' => 'Search',
];
// translations links
@@ -328,9 +329,9 @@ class EdlpSearchController extends ControllerBase {
}
// entries
$this->entry_names = [];
if (!empty($this->entries)){
$terms = entity_load_multiple('taxonomy_term', $this->entries);
$this->entry_names = [];
$entries_condition_group = $query->createConditionGroup();
foreach ($terms as $tid => $term) {
$entries_condition_group->addCondition('field_entrees', (int)$tid, "=");
@@ -1,8 +1,8 @@
(function($,Drupal,drupalSettings){EdlpTheme=function(){var _ajax_settings=drupalSettings.edlp_ajax;var _$body=$('body');var _corpus_ready=false;var _$corpus_canvas;var _$row=$('main[role="main"]>.layout-content>.row');var _$ajaxLinks;var _audioPlayer;var _randomPlayer;var _compoPlayer;function init(){void 0;_audioPlayer=new AudioPlayer();_compoPlayer=new CompoPlayer();initAjaxLinks();initHistory();if(!drupalSettings.path.isFront)
return;initEvents();};function initEvents(){_$body.on('corpus-map-ready',onCorpusMapReady).on('on-studio-chutier-updated',initAjaxLinks).on('studio-initialized',function(e){_compoPlayer.newCompo();}).on('studio-not-active',function(e){_compoPlayer.deactivate();}).on('on-studio-compo-updated',function(e){initAjaxLinks();_compoPlayer.refresh();}).on('on-studio-compo-opened',function(e){initAjaxLinks();_compoPlayer.newCompo();}).on('search-results-loaded',initAjaxLinks).on('open_entree',function(e){void 0;closeAllModals();_$body.removeClass();if(typeof e.url!='undefined'){var state=getSysPathState(e.sys_path);history.pushState(state,null,e.url);}}).on('close_entree',function(e){backToFrontPage();});}
(function($,Drupal,drupalSettings){EdlpTheme=function(){var _ajax_settings=drupalSettings.edlp_ajax;var _$body=$('body');var _corpus_ready=false;var _$corpus_canvas;var _$row=$('main[role="main"]>.layout-content>.row');var _$ajaxLinks;var _audioPlayer;var _randomPlayer;var _compoPlayer;var _ajax_timing={start:0,end:0};function init(){void 0;_audioPlayer=new AudioPlayer();_compoPlayer=new CompoPlayer();initAjaxLinks();initHistory();if(!drupalSettings.path.isFront)
return;initEvents();};function initEvents(){_$body.on('corpus-map-ready',onCorpusMapReady).on('on-studio-chutier-updated',initAjaxLinks).on('studio-initialized',function(e){_compoPlayer.newCompo();}).on('studio-not-active',function(e){_compoPlayer.deactivate();}).on('on-studio-compo-updated',function(e){initAjaxLinks();_compoPlayer.refresh();}).on('on-studio-compo-opened',function(e){initAjaxLinks();_compoPlayer.newCompo();}).on('search-results-loaded',initAjaxLinks).on('open_entree',function(e){void 0;closeAllModals();_$body.removeClass();if(typeof e.url!='undefined'){var state=getSysPathState(e.sys_path);history.pushState(state,null,e.url);if(typeof _paq!=='undefined'){_paq.push(['setCustomUrl',e.url]);_paq.push(['setDocumentTitle',e.title]);_paq.push(['trackPageView']);}}}).on('close_entree',function(e){backToFrontPage();});}
function initScrollbars(){};function getSysPathState(sys_path,view_mode){var state={'sys_path':sys_path,'ajax_path':sys_path};var node_match=state.ajax_path.match(/^\/?(node\/(\d+))$/i);void 0;var term_match=state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);void 0;if(node_match){state.ajax_path=_ajax_settings.entityjson_path+'/'+node_match[1];state.node_nid=node_match[2];if(view_mode){state.ajax_path+='/'+view_mode;state.view_mode=view_mode;}}else if(term_match){state.ajax_path=_ajax_settings.entityjson_path+'/'+term_match[1];state.ajax_path=state.ajax_path.replace(/taxonomy\/term/,'taxonomy_term');state.entree_tid=term_match[2];if(view_mode){state.ajax_path+='/'+view_mode;state.view_mode=view_mode;}else{state.ajax_path=null;}}else{state.ajax_path+='/ajax'}
return state;};function ajaxLoadContent(state){void 0;_$body.addClass('ajax-loading');var path=window.location.origin+Drupal.url(state.ajax_path);$.getJSON(path,{}).done(function(data){onAjaxLoaded(data,state);}).fail(function(jqxhr,textStatus,error){onAjaxLoadError(jqxhr,textStatus,error,state.sys_path);});};function onAjaxLoadError(jqxhr,textStatus,error,sys_path){void 0;$('.ajax-loading').removeClass('ajax-loading');_$body.removeClass('ajax-loading');};function onAjaxLoaded(data,state){void 0;if(data.entity_type=="node"&&data.bundle=="evenement"){if(_$row.find('.col.event').length){_$row.find('.col.event').replaceWith(data.rendered);}else if(_$row.find('.col.aside').length){_$row.find('.col.aside').replaceWith(data.rendered);}else{_$row.append(data.rendered);}}else{_$row.removeAttr('style').html(data.rendered);}
return state;};function ajaxLoadContent(state){void 0;_$body.addClass('ajax-loading');_ajax_timing.start=performance.now();var path=window.location.origin+Drupal.url(state.ajax_path);$.getJSON(path,{}).done(function(data){onAjaxLoaded(data,state);}).fail(function(jqxhr,textStatus,error){onAjaxLoadError(jqxhr,textStatus,error,state.sys_path);});};function onAjaxLoadError(jqxhr,textStatus,error,sys_path){void 0;$('.ajax-loading').removeClass('ajax-loading');_$body.removeClass('ajax-loading');};function onAjaxLoaded(data,state){void 0;if(data.entity_type=="node"&&data.bundle=="evenement"){if(_$row.find('.col.event').length){_$row.find('.col.event').replaceWith(data.rendered);}else if(_$row.find('.col.aside').length){_$row.find('.col.aside').replaceWith(data.rendered);}else{_$row.append(data.rendered);}}else{_$row.removeAttr('style').html(data.rendered);}
var body_classes=['path-'+state.sys_path.replace(/\//g,'-'),'entity-type-'+data.entity_type,'bundle-'+data.bundle,'view-mode-'+data.view_mode];_$body.removeClass().addClass(body_classes.join(' '));if(state.node_nid)
_$body.addClass('path-edlp-node');$('.ajax-loading').removeClass('ajax-loading');$('.ajax-link.is-active').removeClass('is-active');$('.is-active-trail').removeClass('is-active-trail');if(typeof state.selector!='undefined'){void 0;$('a[selector="'+state.selector+'"]').addClass('is-active');initAudioLinksInContent();}else{if(typeof state.view_mode!='undefined'){$('a[viewmode="'+state.view_mode+'"][data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');}else{$('a[data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');}
_$body.trigger({'type':'new-content-not-entree-ajax-loaded'});}
@@ -13,7 +13,7 @@ if(state.sys_path=="productions"){initProductions();}else{addCloseModalBtnToCols
if(data.entity_type=="node"&&data.bundle=="enregistrement"&&data.view_mode=="transcript"){initEnregistrementTranscript();}
if(typeof data.translations_links!='undefined'){void 0;var lang_code=drupalSettings.path.currentLanguage;var $links=$(data.translations_links);$links.find('li[hreflang="'+lang_code+'"]').addClass('is-active').find('a').addClass('is-active');if(state.view_mode){$links.find('a').each(function(i,e){var $a=$(this);$a.attr('href',$a.attr('href')+'#'+state.view_mode);});}
$('ul','.block.language-switcher-language-url').replaceWith($links);}
initAjaxLinks();_$body.trigger({'type':'new-content-ajax-loaded'});Drupal.attachBehaviors(_$row[0]);_$body.attr('booted','booted');_$body.removeClass('ajax-loading');if(state.url){history.pushState(state,null,state.url);if(typeof _paq!=='undefined'){_paq.push(['trackEvent','AjaxNav','loaded',state.url]);}}};function initAudioLinksInContent(){_$row.find('a.audio-link').on('mouseover',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseover-audio-link',nid:$(this).attr('nid')});}}).on('mouseout',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseout-audio-link',nid:$(this).attr('nid')});}});};function addCloseModalBtnToCols(){$('.col',_$row).each(function(index,el){if($('span.close-col-btn',this).length)
initAjaxLinks();_$body.trigger({'type':'new-content-ajax-loaded'});Drupal.attachBehaviors(_$row[0]);_$body.attr('booted','booted');_$body.removeClass('ajax-loading');if(state.url){history.pushState(state,null,state.url);if(typeof _paq!=='undefined'){_paq.push(['setCustomUrl',state.url]);_paq.push(['setDocumentTitle',data.title]);_ajax_timing.end=performance.now();_paq.push(['setGenerationTimeMs',_ajax_timing.end-_ajax_timing.start]);_paq.push(['trackPageView']);}}};function initAudioLinksInContent(){_$row.find('a.audio-link').on('mouseover',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseover-audio-link',nid:$(this).attr('nid')});}}).on('mouseout',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseout-audio-link',nid:$(this).attr('nid')});}});};function addCloseModalBtnToCols(){$('.col',_$row).each(function(index,el){if($('span.close-col-btn',this).length)
return true;$(this).children('.wrapper').prepend($('<span>').addClass('close-col-btn').on('click',onCloseModal));});};function onCloseModal(e){var $col=$(this).parents('.col');var theme=$col.attr('theme');if(theme!=''){_$body.trigger({'type':theme+'-col-closed'});}
$col.remove();if(!$('.col',_$row).length&&!_$body.is('.entity-type-node.bundle-page')&&!_$body.is('.entity-type-taxonomy_term.bundle-entrees')){backToFrontPage();}};function refreshAllBlocks(){var path=window.location.origin+Drupal.url(_ajax_settings.blocksjson_path);$.getJSON(path,{}).done(function(data){onAjaxBlockLoaded(data);}).fail(function(jqxhr,textStatus,error){onAjaxBlockLoadError(jqxhr,textStatus,error);});};function onAjaxBlockLoadError(jqxhr,textStatus,error){void 0;};function onAjaxBlockLoaded(data){void 0;for(var blockname in data.blocks){var block=data.blocks[blockname];void 0;$(block.id).replaceWith(block.rendered);}};function initHistory(){initFirstLoad();window.addEventListener('popstate',onHistoryPopState);};function initFirstLoad(){void 0;var edlp_origin=JSON.parse(window.localStorage.getItem('edlp_origin'));void 0;if(edlp_origin!=null&&edlp_origin.sys_path){var view_mode=edlp_origin.hash.replace('#','');var state=getSysPathState(edlp_origin.sys_path,view_mode);if(edlp_origin.entity_type=="taxonomy_term"&&edlp_origin.entity_bundle=="entrees"&&view_mode){state.selector='entree-'+view_mode+'-link-'+edlp_origin.entity_id;if(_corpus_ready){_$corpus_canvas.trigger({type:'open-entree',tid:edlp_origin.entity_id});}else{$('li.entree[tid="'+edlp_origin.entity_id+'"] a.term-link').addClass('is-active');}}
if(edlp_origin.audio_url){var node={nid:edlp_origin.entity_id,audio_url:edlp_origin.audio_url};_audioPlayer.openDocument(node,'history_first_load');if(view_mode==""){state.audio=true;state.node=node;_$body.attr('booted','booted');}else{ajaxLoadContent(state);}}
@@ -23,20 +23,21 @@ history.replaceState(state,null,edlp_origin.url+edlp_origin.hash);window.localSt
else if(e.state.audio){_audioPlayer.openDocument(e.state.node,'popstate',e.state.historic_index);}
else{if(e.state.entree_tid){openEntree(e.state.entree_tid);}
if(e.state.ajax_path){e.state.url=null;ajaxLoadContent(e.state);}}};function initAjaxLinks(){$('a.site-name','#block-edlptheme-branding').add('a','#block-mainnavigation').add('a','#block-footer.menu--footer').add('a','#block-productions').add('a','article.node:not(.node--type-enregistrement) h2.node-title').add('a','.productions-subtree').add('a','.productions-parent').addClass('ajax-link');_$ajaxLinks=$('.ajax-link:not(.ajax-enabled)').each(function(i,e){var $this=$(this);if($this.is('.ajax-enable'))return;if($this.attr('data-drupal-link-system-path')){$this.on('click',onClickAjaxLink).addClass('ajax-enable');}});};function onClickAjaxLink(e){e.preventDefault();var $link=$(this);if($link.is('.is-active'))
return false;if($link.is('.audio-link')){_audioPlayer.emmit('stop-shuffle').openDocument({nid:$link.attr('nid'),audio_url:$link.attr('audio_url')});return false;}
return false;if($link.is('.audio-link')){_audioPlayer.emmit('stop-shuffle').openDocument({nid:$link.attr('nid'),audio_url:$link.attr('audio_url'),title:$link.find('.field--name-title').html()});return false;}
var sys_path=$(this).attr('data-drupal-link-system-path');if(sys_path=='<front>'){backToFrontPage();return false;}
var view_mode=$link.attr('viewmode');var state=getSysPathState(sys_path,view_mode);state.url=$(this).attr('href');if(view_mode){state.url+="#"+view_mode;}
if($link.is('[selector]')){state.selector=$link.attr('selector');}
$link.addClass('ajax-loading');ajaxLoadContent(state);return false;};function onCorpusMapReady(e){_corpus_ready=true;_$corpus_canvas=$('canvas#corpus-map');_$corpus_canvas.on('corpus-cliked-on-map',function(e){backToFrontPage();}).on('corpus-cliked-on-node',function(e){_audioPlayer.emmit('stop-shuffle').setAutoOpenArticle(e.article).openDocument(e.target_node);});_randomPlayer=new RandomPlayer(e.playlist);_$body.attr('corpus-map','ready');}
function openEntree(tid){if(tid){closeAllModals();_$body.removeClass();if(_corpus_ready){_$corpus_canvas.trigger({type:'open-entree',tid:tid});}else{$('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');}}};function AudioPlayer(){var that=this;this.fid;this.audio=new Audio();this.audio_events=["loadedmetadata","canplay","playing","pause","timeupdate","ended","error"];this.$container=$('<div id="audio-player">');this.$btns=$('<div>').addClass('btns').appendTo(this.$container);this.$previous=$('<div>').addClass('previous').appendTo(this.$btns);this.$playpause=$('<div>').addClass('play-pause').appendTo(this.$btns);this.$next=$('<div>').addClass('next').appendTo(this.$btns);this.$timelinecont=$('<div>').addClass('time-line-container').appendTo(this.$container);this.$timeline=$('<div>').addClass('time-line').appendTo(this.$timelinecont);this.$loader=$('<div>').addClass('loader').appendTo(this.$timeline);this.$cursor=$('<div>').addClass('cursor').appendTo(this.$timeline);this.$time=$('<div>').addClass('time').appendTo(this.$container);this.$currentTime=$('<div>').addClass('current-time').html('00:00').appendTo(this.$time);this.$duration=$('<div>').addClass('duration').html('00:00').appendTo(this.$time);this.$fav=$('<div>').addClass('favoris').appendTo(this.$container);this.$cartel=$('<div>').addClass('cartel').appendTo(this.$container);this.hideTimer=false;this.hideTimeMS=10000;this.currentHistoricIndex=null;this.historic=[];this.shuffle_is_active=false;this.auto_open_article=false;this.event_handlers={'audio-open-document':[],'audio-play':[],'audio-pause':[],'audio-play-next':[],'audio-ended':[],'stop-shuffle':[]};this.init();};AudioPlayer.prototype={init(){this.$container.appendTo('header[role="banner"] .region-header');this.timeline_w=parseInt(this.$timeline.width());var fn='';for(var i=0;i<this.audio_events.length;i++){fn=this.audio_events[i];fn='on'+fn.charAt(0).toUpperCase()+fn.slice(1);this.audio.addEventListener(this.audio_events[i],this[fn].bind(this),true);}
this.$previous.on('click',this.playPrevious.bind(this));this.$playpause.on('click',this.togglePlayPause.bind(this));this.$next.on('click',this.playNext.bind(this));},openDocument(node,caller,historic_index){if(typeof node=='undefined'||typeof node.nid=='undefined'||typeof node.audio_url=='undfined'){void 0;return false;}
if(typeof caller=='undefined'||caller!='popstate'){this.historic.push(node);this.currentHistoricIndex=this.historic.length-1;if(caller!="history_first_load"){state={audio:true,node:node,historic_index:this.currentHistoricIndex,};history.pushState(state,null,node.document_url);}}else{this.currentHistoricIndex=historic_index;}
this.emmit('audio-open-document',{caller:caller});this.launch();},launch(){this.clearTimeOutToHide();this.setSRC(this.historic[this.currentHistoricIndex].audio_url);this.loadNode(this.historic[this.currentHistoricIndex].nid);try{_$corpus_canvas.trigger({'type':'audio-node-opened','nid':this.historic[this.currentHistoricIndex].nid});}catch(e){void 0;}
this.showHidePreviousBtn();this.showHideNextBtn();this.show();},setSRC(url){void 0;this.audio.src=url;},onLoadedmetadata(){var rem=parseInt(this.audio.duration,10),mins=Math.floor(rem/60,10),secs=rem-mins*60;this.$duration.html('<span>'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs+'</span>');this.updateLoadingBar();},updateLoadingBar(){this.$loader.css({'width':parseInt((100*this.audio.buffered.end(0)/this.audio.duration),10)+'%'});if(this.audio.buffered.end(0)<this.audio.duration){var that=this;window.requestAnimationFrame(that.updateLoadingBar.bind(that));}else{}},onCanplay(){this.play();},onError(){void 0;},play(){this.clearTimeOutToHide();this.audio.play();},playPrevious(){if(this.currentHistoricIndex>0){this.currentHistoricIndex-=1;this.launch();}},playNext(){if(this.currentHistoricIndex<this.historic.length-1){this.currentHistoricIndex+=1;this.launch();}else{this.emmit('audio-play-next');}},togglePlayPause(e){if(this.audio.paused){this.audio.play();}else{this.audio.pause();}},stop(){this.audio.pause();if(!(_$body.is('.path-node-'+this.historic[this.currentHistoricIndex].nid)&&(_$body.is('.view-mode-article')||_$body.is('.view-mode-transcript')))){this.timeOutToHide();}},onPlaying(){this.$btns.addClass('is-playing');this.emmit('audio-play');},onPause(){this.$btns.removeClass('is-playing');this.emmit('audio-pause');},onTimeupdate(){this.$cursor.css({'left':(this.audio.currentTime/this.audio.duration*this.timeline_w)+"px"});var rem=parseInt(this.audio.currentTime,10),mins=Math.floor(rem/60,10),secs=rem-mins*60;this.$currentTime.html('<span>'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs+'</span>');},onEnded(){void 0;this.emmit('audio-ended');this.stop();},loadNode(nid){this.$cartel.addClass('loading');var vm='player_cartel';var ajax_path=_ajax_settings.entityjson_path+'/node/'+nid+'/'+vm;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(this.onNodeLoaded.bind(this)).fail(this.onNodeLoadFail.bind(this));},onNodeLoaded(data){this.$cartel.html(data.rendered).removeClass('loading');_$body.trigger({'type':'new-audio-cartel-loaded'});initAjaxLinks();if(this.auto_open_article){this.$cartel.find('a.link-article').trigger('click');this.auto_open_article=false;}},onNodeLoadFail(jqxhr,textStatus,error){void 0;this.$cartel.removeClass('loading').html('');},setAutoOpenArticle(art){this.auto_open_article=art;return this;},show(){this.$container.addClass('visible');},showHidePreviousBtn(){if(this.historic.length>1&&this.currentHistoricIndex>0){this.$previous.addClass('is-active');}else{this.$previous.removeClass('is-active');}},showHideNextBtn(){if(this.currentHistoricIndex<this.historic.length-1||this.shuffle_is_active){this.$next.addClass('is-active');}else{this.$next.removeClass('is-active');}},timeOutToHide(){this.clearTimeOutToHide();this.hideTimer=setTimeout(this.hide.bind(this),this.hideTimeMS);},clearTimeOutToHide(){if(this.hideTimer){clearTimeout(this.hideTimer);this.hideTimer=false;}},hide(){this.$container.removeClass('visible');try{_$corpus_canvas.trigger('audio-node-closed');}catch(e){void 0;}},on(event_name,handler){if(typeof this.event_handlers[event_name]=='undefined'){void 0;}
function openEntree(tid){if(tid){closeAllModals();_$body.removeClass();if(_corpus_ready){_$corpus_canvas.trigger({type:'open-entree',tid:tid});}else{$('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');}}};function AudioPlayer(){var that=this;this.fid;this.audio=new Audio();this.audio_events=["loadedmetadata","canplay","playing","pause","timeupdate","ended","error"];this.$container=$('<div id="audio-player">');this.$btns=$('<div>').addClass('btns').appendTo(this.$container);this.$previous=$('<div>').addClass('previous').appendTo(this.$btns);this.$playpause=$('<div>').addClass('play-pause').appendTo(this.$btns);this.$next=$('<div>').addClass('next').appendTo(this.$btns);this.$timelinecont=$('<div>').addClass('time-line-container').appendTo(this.$container);this.$timeline=$('<div>').addClass('time-line').appendTo(this.$timelinecont);this.$loader=$('<div>').addClass('loader').appendTo(this.$timeline);this.$cursor=$('<div>').addClass('cursor').appendTo(this.$timeline);this.$time=$('<div>').addClass('time').appendTo(this.$container);this.$currentTime=$('<div>').addClass('current-time').html('00:00').appendTo(this.$time);this.$duration=$('<div>').addClass('duration').html('00:00').appendTo(this.$time);this.$fav=$('<div>').addClass('favoris').appendTo(this.$container);this.$cartel=$('<div>').addClass('cartel').appendTo(this.$container);this.hideTimer=false;this.hideTimeMS=10000;this.currentHistoricIndex=null;this.historic=[];this.shuffle_is_active=false;this.auto_open_article=false;this.event_handlers={'audio-open-document':[],'audio-play':[],'audio-pause':[],'audio-play-next':[],'audio-ended':[],'stop-shuffle':[]};this.init();};AudioPlayer.prototype={init(){this.$container_parent=$('header[role="banner"] .region-header');this.$container.appendTo(this.$container_parent);this.timeline_w=parseInt(this.$timeline.width());var fn='';for(var i=0;i<this.audio_events.length;i++){fn=this.audio_events[i];fn='on'+fn.charAt(0).toUpperCase()+fn.slice(1);this.audio.addEventListener(this.audio_events[i],this[fn].bind(this),true);}
this.$previous.on('click',this.playPrevious.bind(this));this.$playpause.on('click',this.togglePlayPause.bind(this));this.$next.on('click',this.playNext.bind(this));},openDocument(node,caller,historic_index){if(typeof node=='undefined'||typeof node.nid=='undefined'||typeof node.audio_url=='undfined'||typeof node.document_url=='undfined'){void 0;return false;}
if(typeof caller=='undefined'||caller!='popstate'){this.historic.push(node);this.currentHistoricIndex=this.historic.length-1;if(caller!="history_first_load"){var state={audio:true,node:{nid:node.nid,audio_url:node.audio_url,document_url:node.document_url,title:node.title||null,},historic_index:this.currentHistoricIndex,};history.pushState(state,null,node.document_url);}}else{this.currentHistoricIndex=historic_index;}
this.emmit('audio-open-document',{caller:caller});if(typeof _paq!=='undefined'){if(typeof node.title!='undefined'){_paq.push(['trackEvent','Audio','play',node.title]);}}
this.launch();},launch(){this.clearTimeOutToHide();this.setSRC(this.historic[this.currentHistoricIndex].audio_url);this.loadNode(this.historic[this.currentHistoricIndex].nid);try{_$corpus_canvas.trigger({'type':'audio-node-opened','nid':this.historic[this.currentHistoricIndex].nid});}catch(e){void 0;}
this.showHidePreviousBtn();this.showHideNextBtn();this.show();},setSRC(url){void 0;this.audio.src=url;},onLoadedmetadata(){var rem=parseInt(this.audio.duration,10),mins=Math.floor(rem/60,10),secs=rem-mins*60;this.$duration.html('<span>'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs+'</span>');this.updateLoadingBar();},updateLoadingBar(){if(this.audio.buffered.length>0){this.$loader.css({'width':parseInt((100*this.audio.buffered.end(0)/this.audio.duration),10)+'%'});if(this.audio.buffered.end(0)<this.audio.duration){var that=this;window.requestAnimationFrame(that.updateLoadingBar.bind(that));}else{}}},onCanplay(){this.play();},onError(){void 0;},play(){this.clearTimeOutToHide();this.audio.play();},playPrevious(){if(this.currentHistoricIndex>0){this.currentHistoricIndex-=1;this.launch();}},playNext(){if(this.currentHistoricIndex<this.historic.length-1){this.currentHistoricIndex+=1;this.launch();}else{this.emmit('audio-play-next');}},togglePlayPause(e){if(this.audio.paused){this.audio.play();}else{this.audio.pause();}},stop(){this.audio.pause();if(!(_$body.is('.path-node-'+this.historic[this.currentHistoricIndex].nid)&&(_$body.is('.view-mode-article')||_$body.is('.view-mode-transcript')))){this.timeOutToHide();}},onPlaying(){this.$btns.addClass('is-playing');this.emmit('audio-play');},onPause(){this.$btns.removeClass('is-playing');this.emmit('audio-pause');},onTimeupdate(){this.$cursor.css({'left':(this.audio.currentTime/this.audio.duration*this.timeline_w)+"px"});var rem=parseInt(this.audio.currentTime,10),mins=Math.floor(rem/60,10),secs=rem-mins*60;this.$currentTime.html('<span>'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs+'</span>');},onEnded(){void 0;this.emmit('audio-ended');this.stop();},loadNode(nid){this.$cartel.addClass('loading');var vm='player_cartel';var ajax_path=_ajax_settings.entityjson_path+'/node/'+nid+'/'+vm;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(this.onNodeLoaded.bind(this)).fail(this.onNodeLoadFail.bind(this));},onNodeLoaded(data){this.$cartel.html(data.rendered).removeClass('loading');_$body.trigger({'type':'new-audio-cartel-loaded'});initAjaxLinks();if(this.auto_open_article){this.$cartel.find('a.link-article').trigger('click');this.auto_open_article=false;}},onNodeLoadFail(jqxhr,textStatus,error){void 0;this.$cartel.removeClass('loading').html('');},setAutoOpenArticle(art){this.auto_open_article=art;return this;},show(){this.$container_parent.addClass('audio-player-visible');this.$container.addClass('visible');},showHidePreviousBtn(){if(this.historic.length>1&&this.currentHistoricIndex>0){this.$previous.addClass('is-active');}else{this.$previous.removeClass('is-active');}},showHideNextBtn(){if(this.currentHistoricIndex<this.historic.length-1||this.shuffle_is_active){this.$next.addClass('is-active');}else{this.$next.removeClass('is-active');}},timeOutToHide(){this.clearTimeOutToHide();this.hideTimer=setTimeout(this.hide.bind(this),this.hideTimeMS);},clearTimeOutToHide(){if(this.hideTimer){clearTimeout(this.hideTimer);this.hideTimer=false;}},hide(){this.$container_parent.removeClass('audio-player-visible');this.$container.removeClass('visible');try{_$corpus_canvas.trigger('audio-node-closed');}catch(e){void 0;}},on(event_name,handler){if(typeof this.event_handlers[event_name]=='undefined'){void 0;}
this.event_handlers[event_name].push(handler);return this;},emmit(event_name,args){var handler;var args=args||{};for(var i=this.event_handlers[event_name].length-1;i>=0;i--){handler=this.event_handlers[event_name][i];setTimeout(function(){handler(args);},0);}
return this;},}
function RandomPlayer(playlist){this.active=false;this.playlist=playlist;this.$btn=$('<a>').html('Shuffle').addClass('random-player-btn');this.init();};RandomPlayer.prototype={init(){$('<div>').addClass('block random-player').append(this.$btn).prependTo('.region-footer-right');this.$btn.on('click',this.toggleActive.bind(this));_audioPlayer.on('audio-ended',this.onAudioPlayerEnded.bind(this)).on('audio-play-next',this.onAudioPlayNext.bind(this)).on('stop-shuffle',this.stop.bind(this));_$corpus_canvas.on('update-random-playlist',this.updatePlaylist.bind(this));},updatePlaylist(e){this.playlist=e.playlist;this.shuffle();},shuffle(){var tempPLaylist=[];for(var i=this.playlist.length-1;i>=0;i--){tempPLaylist.push(this.playlist[i]);}
this.shuffledPlaylist=[];while(tempPLaylist.length>0){var r=Math.floor(Math.random()*tempPLaylist.length);this.shuffledPlaylist.push(tempPLaylist.splice(r,1)[0]);}},toggleActive(e){if(this.active){this.stop();}else{this.start();}},start(){this.active=_audioPlayer.shuffle_is_active=true;this.$btn.addClass('is-active');this.shuffle();this.next();},stop(){this.active=_audioPlayer.shuffle_is_active=false;this.$btn.removeClass('is-active');},next(){if(this.active&&this.shuffledPlaylist.length>0)
this.shuffledPlaylist=[];while(tempPLaylist.length>0){var r=Math.floor(Math.random()*tempPLaylist.length);this.shuffledPlaylist.push(tempPLaylist.splice(r,1)[0]);}},toggleActive(e){if(this.active){this.stop();}else{this.start();}},start(){this.active=_audioPlayer.shuffle_is_active=true;this.$btn.addClass('is-active');this.shuffle();this.next();if(typeof _paq!=='undefined'){_paq.push(['trackEvent','RandomPlayer','start']);}},stop(){this.active=_audioPlayer.shuffle_is_active=false;this.$btn.removeClass('is-active');if(typeof _paq!=='undefined'){_paq.push(['trackEvent','RandomPlayer','stop']);}},next(){if(this.active&&this.shuffledPlaylist.length>0)
_audioPlayer.openDocument(this.shuffledPlaylist.splice(0,1)[0]);},onAudioPlayNext(){this.next();},onAudioPlayerEnded(){this.next();}};function CompoPlayer(){this.active=false;this.playing=false;this.paused=false;this.playlist=[];this.current_index=0;this.$composer=null;this.$compo=null;this.$controls=null;this.init();};CompoPlayer.prototype={init(){_audioPlayer.on('audio-open-document',this.onAudioOpenDocument.bind(this)).on('audio-play',this.onAudioPlayerPlay.bind(this)).on('audio-pause',this.onAudioPlayerPause.bind(this)).on('audio-ended',this.onAudioPlayerEnded.bind(this));},newCompo(){this.initControls();},initControls(){this.$composer=$('.composition_ui .composer');this.$compo=$('.composition_ui .composer .composition');this.$controls=$('.composition_ui .composer .compo-player-controls');if(!this.$controls.is('.ready')&&this.$compo){this.$previous=$('<div>').addClass('previous').on('click',this.prev.bind(this)).appendTo(this.$controls);this.$playpause=$('<div>').addClass('play-pause').on('click',this.togglePlayPause.bind(this)).appendTo(this.$controls);this.$next=$('<div>').addClass('next').on('click',this.next.bind(this)).appendTo(this.$controls);this.$controls.addClass('ready');this.refresh();this.active=true;}},refresh(){this.stop();this.playlist=[];var that=this;$('.field--name-documents .field__item',this.$compo).each(function(i,el){var $link=$('a.audio-link',this);that.playlist.push({item:$(this),audio_url:$link.attr("audio_url"),nid:$link.attr("nid"),});});this.showHideControls();},togglePlayPause(){if(this.playing&&!this.paused){this.pause();}else{if(this.playing&&this.paused){this.play();}else{this.start();}}},start(){this.playing=true;this.play();},play(){if(this.paused){this.paused=false;_audioPlayer.play();}else{_audioPlayer.openDocument(this.playlist[this.current_index],this);}
this.setActiveItem().showHideControls();},pause(){this.paused=true;this.showHideControls();_audioPlayer.stop();},next(){if(this.playing){this.current_index+=1;if(this.current_index<this.playlist.length){this.play();}else{this.stop();}}},prev(){if(this.playing){this.current_index-=1;if(this.current_index>=0){this.play();}else{this.stop();}}},stop(){if(this.playing){_audioPlayer.stop();}
this.reset();},reset(){this.playing=false;this.paused=false;this.resetIndex();},resetIndex(){this.current_index=0;this.showHideControls().resetActiveItems();},setActiveItem(){this.resetActiveItems();if(this.playing&&this.current_index>=0){this.playlist[this.current_index].item.addClass('is-active');}
File diff suppressed because one or more lines are too long
@@ -11,6 +11,10 @@
var _audioPlayer;
var _randomPlayer;
var _compoPlayer;
var _ajax_timing = {
start:0,
end:0
};
// ___ _ _
// |_ _|_ _ (_) |_
@@ -79,6 +83,18 @@
// };
var state = getSysPathState(e.sys_path);
history.pushState(state, null, e.url);
// piwik
if(typeof _paq !== 'undefined'){
// page tracking
// https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
_paq.push(['setCustomUrl', e.url]);
_paq.push(['setDocumentTitle', e.title]);
_paq.push(['trackPageView']);
// js event
// trackEvent(category, action, [name], [value])
// _paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
}
}
})
.on('close_entree', function(e){
@@ -151,7 +167,7 @@
function ajaxLoadContent(state){
console.log('ajaxLoadContent : state', state);
_$body.addClass('ajax-loading');
_ajax_timing.start = performance.now();
var path = window.location.origin + Drupal.url(state.ajax_path);
$.getJSON(path, {})
.done(function(data){
@@ -302,8 +318,18 @@
// piwik
if(typeof _paq !== 'undefined'){
// page tracking
// https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
_paq.push(['setCustomUrl', state.url]);
_paq.push(['setDocumentTitle', data.title]);
// TODO: piwik track load time
_ajax_timing.end = performance.now();
_paq.push(['setGenerationTimeMs', _ajax_timing.end-_ajax_timing.start]);
_paq.push(['trackPageView']);
// js event
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
// _paq.push(['trackEvent', 'AjaxNav', 'loaded', state.url]);
}
}
};
@@ -549,7 +575,8 @@
.emmit('stop-shuffle')
.openDocument({
nid:$link.attr('nid'),
audio_url:$link.attr('audio_url')
audio_url:$link.attr('audio_url'),
title:$link.find('.field--name-title').html()
});
return false;
}
@@ -701,8 +728,9 @@
};
AudioPlayer.prototype = {
init(){
this.$container_parent = $('header[role="banner"] .region-header');
// append ui to document
this.$container.appendTo('header[role="banner"] .region-header');
this.$container.appendTo(this.$container_parent);
// record timeline width
this.timeline_w = parseInt(this.$timeline.width());
// init audio events
@@ -725,7 +753,8 @@
// console.log('AudioPlayer openDocument', node);
if(typeof node == 'undefined'
|| typeof node.nid == 'undefined'
|| typeof node.audio_url == 'undfined'){
|| typeof node.audio_url == 'undfined'
|| typeof node.document_url == 'undfined'){
console.warn('AudioPlayer openDocument() node is malformed', node);
return false;
}
@@ -738,9 +767,14 @@
// add the document opening to history to be able to share and play audio from any where
if(caller != "history_first_load"){
state = {
var state = {
audio:true,
node:node,
node:{
nid:node.nid,
audio_url:node.audio_url,
document_url:node.document_url,
title:node.title || null,
},
historic_index : this.currentHistoricIndex,
};
@@ -753,6 +787,22 @@
this.emmit('audio-open-document', {caller:caller});
// piwik
// debugger;
if(typeof _paq !== 'undefined'){
// page tracking
// https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
// _paq.push(['setCustomUrl', state.url]);
// _paq.push(['setDocumentTitle', data.title]);
// _paq.push(['trackPageView']);
// js event
// trackEvent(category, action, [name], [value])
if(typeof node.title != 'undefined'){
_paq.push(['trackEvent', 'Audio', 'play', node.title]);
}
}
this.launch();
},
launch(){
@@ -786,15 +836,18 @@
this.updateLoadingBar();
},
updateLoadingBar(){
this.$loader.css({
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
});
if( this.audio.buffered.end(0) < this.audio.duration ){
// loop through this function until file is fully loaded
var that = this;
window.requestAnimationFrame(that.updateLoadingBar.bind(that));
}else{
//console.log('Audio fully loaded');
// if (this.audio.readyState === 4){
if(this.audio.buffered.length>0){
this.$loader.css({
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
});
if( this.audio.buffered.end(0) < this.audio.duration ){
// loop through this function until file is fully loaded
var that = this;
window.requestAnimationFrame(that.updateLoadingBar.bind(that));
}else{
//console.log('Audio fully loaded');
}
}
},
onCanplay(){
@@ -893,6 +946,7 @@
},
// global
show(){
this.$container_parent.addClass('audio-player-visible');
this.$container.addClass('visible');
},
showHidePreviousBtn(){
@@ -923,6 +977,7 @@
},
hide(){
// console.log('AudioPlayer hide()');
this.$container_parent.removeClass('audio-player-visible');
this.$container.removeClass('visible');
// trigger highlighted node remove on corpus map
try {
@@ -1018,12 +1073,21 @@
this.$btn.addClass('is-active');
this.shuffle();
this.next();
// piwik
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'RandomPlayer', 'start']);
}
},
stop(){
this.active = _audioPlayer.shuffle_is_active = false;
this.$btn.removeClass('is-active');
// stop audio player
// _audioPlayer.stop();
if(typeof _paq !== 'undefined'){
// trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'RandomPlayer', 'stop']);
}
},
next(){
if(this.active && this.shuffledPlaylist.length > 0)
@@ -54,7 +54,11 @@
}
}
@mixin btn {
padding: 3px;
background-color: white;
border-radius: 3px;
}
// .layout-container{
// pointer-events: none;
// }
@@ -79,7 +83,7 @@ header[role="banner"]{
width:$w; height:$w * 0.22;
margin-top: 0.15em;
background-image: url(../img/logo.svg);
background-color: white;
// background-color: white;
background-repeat:no-repeat;
background-size: contain;
white-space: nowrap;
@@ -87,6 +91,12 @@ header[role="banner"]{
overflow: hidden;
}
}
opacity: 1;
transition: opacity 0.7s ease-in-out;
.audio-player-visible &{
opacity: 0;
}
}
#block-mainnavigation{
@@ -104,6 +114,7 @@ header[role="banner"]{
text-decoration: none;
text-transform: uppercase;
margin-left: 1em;
@include btn;
&:before{
content: "";
display:inline-block;
@@ -141,6 +152,7 @@ header[role="banner"]{
text-decoration: none;
text-transform: capitalize;
margin-left: 0.8em;
@include btn;
&:before{
content: "";
display:inline-block;
@@ -497,8 +509,8 @@ main[role="main"]{
#audio-player{
position: absolute;
top:0; left:0;
padding-left:1.2em;
background-color: white;
padding-left:0.7em;
// background-color: white;
height:100%; min-width:300px;
z-index: 20;
opacity: 0;
@@ -518,11 +530,14 @@ main[role="main"]{
max-height: 100%;
// outline: 1px solid green;
white-space: normal;
@include btn;
}
.btns{
@include audio_controls;
}
.time-line-container{
// height:50%;
background:transparent;
.time-line{
position: relative;
width:70px; height:1px;
@@ -1408,6 +1423,7 @@ footer{
}
a{
font-size: 0.756em;
@include btn;
&:before{
content: "";
display:inline-block;
@@ -1442,6 +1458,7 @@ footer{
margin-left: 1em;
}
a{
@include btn;
&:before{
content: "";
display:inline-block;
@@ -1511,7 +1528,7 @@ footer{
a{
// outline: 1px solid blue;
pointer-events: all;
background-color: #fff;
@include btn;
padding-right: 0.4em;
&:before{
content: "";
@@ -1563,7 +1580,8 @@ footer{
// outline: 1px solid blue;
pointer-events: all;
// background-color: #fff;
background-color: rgba(255,255,255, 0.6);
// background-color: rgba(255,255,255, 0.6);
@include btn;
padding-right: 0.4em;
color:black;
transition: color 0.3s ease-in-out;
@@ -1726,7 +1744,7 @@ footer{
}
}
&.opened, &.highlighted{
li:not(.opened):not(.highlighted){
li:not(.opened):not(.highlighted):not(:hover){
a.term-link{
color:#a1a1a1;
}
@@ -1739,7 +1757,9 @@ footer{
@mixin iconlinkblock($bgimgurl) {
pointer-events: all;
margin-left: 0.5em;
// @include btn;
a{
box-sizing: border-box;
$wh:$icons_w;
display: block;
width:$wh; height:$wh;
@@ -1772,12 +1792,14 @@ footer{
margin-bottom: 1em;
pointer-events: all;
margin-left: 0.2em;
// outline: 1px solid blue;
$wh:$icons_w;
position: relative;
// box-sizing: border-box;
width:$wh; height: $wh;
// background-color: blue;
h2{
box-sizing: content-box;
// @include btn;
// padding:0;
position: relative;
width:$wh; height:$wh;
background-image: url(../img/studio.svg);
@@ -11,21 +11,29 @@ dependencies:
- node.type.evenement
module:
- datetime_range
- text
- user
id: node.evenement.aside
targetEntityType: node
bundle: evenement
mode: aside
content:
body:
type: text_default
weight: 2
region: content
label: hidden
settings: { }
third_party_settings: { }
field_date:
weight: 1
label: hidden
settings:
timezone_override: ''
format_type: long
date_format: 'l j F Y G\hi'
separator: '-'
third_party_settings: { }
type: daterange_default
type: daterange_custom
region: content
links:
weight: 0
@@ -33,7 +41,6 @@ content:
settings: { }
third_party_settings: { }
hidden:
body: true
field_page_liee: true
field_workflow_generic: true
langcode: true
@@ -29,10 +29,10 @@ content:
label: hidden
settings:
timezone_override: ''
format_type: long
date_format: 'l j F Y G\hi'
separator: '-'
third_party_settings: { }
type: daterange_default
type: daterange_custom
region: content
field_page_liee:
weight: 3
@@ -5,10 +5,12 @@ dependencies:
config:
- core.entity_view_mode.node.teaser
- field.field.node.evenement.body
- field.field.node.evenement.field_date
- field.field.node.evenement.field_page_liee
- field.field.node.evenement.field_workflow_generic
- node.type.evenement
module:
- datetime_range
- text
- user
id: node.evenement.teaser
@@ -18,18 +20,34 @@ mode: teaser
content:
body:
label: hidden
type: text_summary_or_trimmed
weight: 2
settings:
trim_length: 600
type: text_default
weight: 3
settings: { }
third_party_settings: { }
region: content
field_date:
type: daterange_custom
weight: 2
region: content
label: hidden
settings:
timezone_override: ''
date_format: 'l j F Y G\hi'
separator: '-'
third_party_settings: { }
field_page_liee:
type: entity_reference_label
weight: 1
region: content
label: hidden
settings:
link: false
third_party_settings: { }
links:
weight: 0
region: content
settings: { }
third_party_settings: { }
hidden:
field_page_liee: true
field_workflow_generic: true
langcode: true