refactored articles, added articles index
This commit is contained in:
@@ -55,7 +55,8 @@ function edlp_ajax_page_attachments(array &$attachments) {
|
||||
|| preg_match('/^\/?agenda/', $current_path)
|
||||
|| preg_match('/^\/?studio/', $current_path)
|
||||
|| preg_match('/^\/?search/', $current_path)
|
||||
|| preg_match('/^\/?lastdocs/', $current_path)){
|
||||
|| preg_match('/^\/?lastdocs/', $current_path)
|
||||
|| preg_match('/^\/?articles/', $current_path)){
|
||||
$redirect = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
(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:window.innerWidth,height:window.innerHeight,'margin_top':75,'margin_right':0,'margin_bottom':65,'margin_left':0};var _evolution_zone={left:_scene_props.width/4,right:_scene_props.width-_scene_props.width/4,center:_scene_props.width/2,};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 _loaded=false;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);moveEvolutionZone();if(_loaded){for(var i=0;i<_nodes.length;i++){_nodes[i].onResizeCanvas();}}};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){void 0;initPhysics();buildNodes(data.nodes);initArtilesLink();initNodePopup();initEvents();checkPreOpenedEntry();startAnime();_loaded=true;};function initPhysics(){_attracter=_physics.makeParticle(1000);_attracter.fixed=true;resizePhysics();};function resizePhysics(){if(typeof _attracter!='undefined'){_attracter.position={x:_evolution_zone.center,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,'document_url':nodes[i].document_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:window.innerWidth,height:window.innerHeight,'margin_top':75,'margin_right':0,'margin_bottom':65,'margin_left':0};var _evolution_zone={left:_scene_props.width/4,right:_scene_props.width-_scene_props.width/4,center:_scene_props.width/2,};var _physics=new Physics();var _nodes=[];var _articles_nodes=[];var _no_articles_nodes=[];var _nodes_by_entries={};var _nodes_by_nid={};var _nodes_Nid_Id={};var _nodes_centered=[];var _nodes_centered_attractions=[];var _loaded=false;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);moveEvolutionZone();if(_loaded){for(var i=0;i<_nodes.length;i++){_nodes[i].onResizeCanvas();}}};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){void 0;initPhysics();buildNodes(data.nodes);initArtilesLink();initNodePopup();initEvents();checkPreOpenedEntry();startAnime();_loaded=true;};function initPhysics(){_attracter=_physics.makeParticle(1000);_attracter.fixed=true;resizePhysics();};function resizePhysics(){if(typeof _attracter!='undefined'){_attracter.position={x:_evolution_zone.center,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,'document_url':nodes[i].document_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);}
|
||||
@@ -29,15 +29,11 @@ function closeNode(){if(_node_opened_id!=-1){_nodes[_node_opened_id].close();_no
|
||||
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 moveEvolutionZone(l,r){var left=l||0;var right=r||0;_evolution_zone.left=Math.max(_scene_props.width/5,left+20);_evolution_zone.right=Math.min(_scene_props.width-_scene_props.width/5,_scene_props.width-right+20);_evolution_zone.center=_evolution_zone.left+(_evolution_zone.right-_evolution_zone.left)/2;resizePhysics();}
|
||||
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]);}}
|
||||
scrambleCollection();_$body.trigger({'type':'close_entree','tid':tid});}};function filterEntree(t){_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 filterByNids(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]);}}
|
||||
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 filterByNids(nids){_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;closeAllEntries();_nodes_centered=[];for(var i=0;i<_articles_nodes.length;i++){_articles_nodes[i].setCentered();_nodes_centered.push(_articles_nodes[i]);}
|
||||
for(var i=0;i<_no_articles_nodes.length;i++){_no_articles_nodes[i].setAside();}
|
||||
updateRandomPlaylist(_articles_nodes);if(typeof _paq!=='undefined'){_paq.push(['trackEvent','Corpus Articles','on']);}};function deactivateArticlesFilter(){_articles_filter_on=false;scrambleCollection();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();}).on('scramble-collection',function(e){void 0;scrambleCollection();}).on('shuffle-collection',function(e){void 0;onResizeCanvas();});_$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('ajax-node-loaded-linked-documents',function(e){void 0;filterByNids(e.nids);}).on('search-results-loaded',function(e){filterByNids(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();}}).on('visible-space-changed',function(e){moveEvolutionZone(e.left_limit,e.right_limit);});};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));}
|
||||
updateRandomPlaylist(_playlist);};function closeAllEntries(){_$entrees_block_termlinks.each(function(index,el){if($(this).parents('li').is('.opened')){$(this).trigger('click');return false;}});};function initArtilesLink(){var href=window.location.origin+drupalSettings.path.baseUrl+_settings.articlesindex_url;_$articles_link=$('<a>').html('Articles').attr("href",href).attr("data-drupal-link-system-path",_settings.articlesindex_url).addClass('articles-link ajax-link');$('.item-list ul',_$entrees_block).append($('<li>').append($('<span class="oblique-wrapper">').append(_$articles_link)));};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],};_$canvas.trigger(event);}else{_$canvas.trigger('corpus-cliked-on-map');}}}).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();}).on('scramble-collection',function(e){void 0;scrambleCollection();}).on('shuffle-collection',function(e){void 0;onResizeCanvas();});_$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('ajax-node-loaded-linked-documents',function(e){void 0;filterByNids(e.nids);}).on('search-results-loaded',function(e){filterByNids(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();}}).on('visible-space-changed',function(e){moveEvolutionZone(e.left_limit,e.right_limit);});};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,_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';}
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
var _nodes = [];
|
||||
var _articles_nodes = [];
|
||||
var _no_articles_nodes = [];
|
||||
var _articles_filter_on = false;
|
||||
// var _articles_filter_on = false;
|
||||
var _nodes_by_entries = {};
|
||||
var _nodes_by_nid = {};
|
||||
var _nodes_Nid_Id = {};
|
||||
@@ -807,7 +807,7 @@
|
||||
}
|
||||
};
|
||||
function filterEntree(t){
|
||||
shutDownArticles();
|
||||
// shutDownArticles();
|
||||
|
||||
_nodes_centered = [];
|
||||
for (var n = 0; n < _nodes.length; n++) {
|
||||
@@ -850,7 +850,7 @@
|
||||
// |___/\___\__,_|_| \__|_||_|
|
||||
// and ajax modal content filtering
|
||||
function filterByNids(nids){
|
||||
shutDownArticles();
|
||||
// shutDownArticles();
|
||||
|
||||
_nodes_centered = [];
|
||||
for (var n = 0; n < _nodes.length; n++) {
|
||||
@@ -903,11 +903,14 @@
|
||||
// /_/ \_\_| \__|_\__|_\___/__/
|
||||
function initArtilesLink(){
|
||||
// add "articles link to blockentrees"
|
||||
var href = window.location.origin + drupalSettings.path.baseUrl +_settings.articlesindex_url;
|
||||
_$articles_link = $('<a>')
|
||||
.html('Articles')
|
||||
.attr("href", "#articles")
|
||||
.addClass('articles-link')
|
||||
.on('click', onCLickedOnArticles);
|
||||
.attr("href", href)
|
||||
.attr("data-drupal-link-system-path", _settings.articlesindex_url)
|
||||
.addClass('articles-link ajax-link');
|
||||
// main.js from template will load the index then trigger the filter here
|
||||
// .on('click', onCLickedOnArticles);
|
||||
|
||||
$('.item-list ul',_$entrees_block).append(
|
||||
$('<li>').append(
|
||||
@@ -915,69 +918,98 @@
|
||||
)
|
||||
);
|
||||
};
|
||||
function onCLickedOnArticles(e){
|
||||
e.preventDefault();
|
||||
$(this).toggleClass('is-active');
|
||||
if($(this).is('.is-active')){
|
||||
activateArticlesFilter();
|
||||
closeAllEntries();
|
||||
}else{
|
||||
deactivateArticlesFilter();
|
||||
}
|
||||
// _$canvas.trigger({
|
||||
// 'type':'corpus-cliqued-on-articles'
|
||||
// });
|
||||
return false;
|
||||
};
|
||||
function activateArticlesFilter(){
|
||||
//console.log('activateArticlesFilter');
|
||||
_articles_filter_on = true;
|
||||
// OPTION 1 : just fade no article nodes
|
||||
// for (var i = 0; i < _no_articles_nodes.length; i++) {
|
||||
// _no_articles_nodes[i].fade();
|
||||
// }
|
||||
|
||||
// OPTION 2 : center the articles nodes and aside others
|
||||
closeAllEntries();
|
||||
_nodes_centered = [];
|
||||
for (var i = 0; i < _articles_nodes.length; i++) {
|
||||
_articles_nodes[i].setCentered();
|
||||
// record centered nodes for inter node repulsions
|
||||
_nodes_centered.push(_articles_nodes[i]);
|
||||
}
|
||||
for (var i = 0; i < _no_articles_nodes.length; i++) {
|
||||
_no_articles_nodes[i].setAside();
|
||||
}
|
||||
|
||||
updateRandomPlaylist(_articles_nodes);
|
||||
if(typeof _paq !== 'undefined'){
|
||||
// trackEvent(category, action, [name], [value])
|
||||
_paq.push(['trackEvent', 'Corpus Articles', 'on']);
|
||||
}
|
||||
};
|
||||
function deactivateArticlesFilter(){
|
||||
//console.log('deactivateArticlesFilter');
|
||||
_articles_filter_on = false;
|
||||
|
||||
// OPTION 1 : just fade no article nodes
|
||||
// for (var i = 0; i < _no_articles_nodes.length; i++) {
|
||||
// _no_articles_nodes[i].unFade();
|
||||
// }
|
||||
|
||||
// OPTION 2 : centered / aside
|
||||
scrambleCollection();
|
||||
|
||||
updateRandomPlaylist(_playlist);
|
||||
if(typeof _paq !== 'undefined'){
|
||||
// trackEvent(category, action, [name], [value])
|
||||
_paq.push(['trackEvent', 'Corpus Articles', 'off']);
|
||||
}
|
||||
};
|
||||
function shutDownArticles(){
|
||||
// function onCLickedOnArticles(e){
|
||||
// e.preventDefault();
|
||||
// $(this).toggleClass('is-active');
|
||||
// if($(this).is('.is-active')){
|
||||
// activateArticlesFilter();
|
||||
// closeAllEntries();
|
||||
// }else{
|
||||
// deactivateArticlesFilter();
|
||||
// }
|
||||
// // _$canvas.trigger({
|
||||
// // 'type':'corpus-cliqued-on-articles'
|
||||
// // });
|
||||
// return false;
|
||||
// };
|
||||
// function activateArticlesFilter(){
|
||||
// //console.log('activateArticlesFilter');
|
||||
// _articles_filter_on = true;
|
||||
// // OPTION 1 : just fade no article nodes
|
||||
// // for (var i = 0; i < _no_articles_nodes.length; i++) {
|
||||
// // _no_articles_nodes[i].fade();
|
||||
// // }
|
||||
// // END OPTION 1
|
||||
//
|
||||
// // OPTION 2 : center the articles nodes and aside others
|
||||
// closeAllEntries();
|
||||
// _nodes_centered = [];
|
||||
// for (var i = 0; i < _articles_nodes.length; i++) {
|
||||
// _articles_nodes[i].setCentered();
|
||||
// // record centered nodes for inter node repulsions
|
||||
// _nodes_centered.push(_articles_nodes[i]);
|
||||
// }
|
||||
// for (var i = 0; i < _no_articles_nodes.length; i++) {
|
||||
// _no_articles_nodes[i].setAside();
|
||||
// }
|
||||
// // TODO: open an index of nodes with articles
|
||||
// // loadArticlesIndex();
|
||||
// // END OPTION 2
|
||||
//
|
||||
// updateRandomPlaylist(_articles_nodes);
|
||||
// if(typeof _paq !== 'undefined'){
|
||||
// // trackEvent(category, action, [name], [value])
|
||||
// _paq.push(['trackEvent', 'Corpus Articles', 'on']);
|
||||
// }
|
||||
// };
|
||||
// function loadArticlesIndex(){
|
||||
// var path = window.location.origin + drupalSettings.path.baseUrl +_settings.articlesindex_url+'/ajax';
|
||||
// $.getJSON(path)
|
||||
// .done(function(data){
|
||||
// onArticlesIndexLoaded(data);
|
||||
// })
|
||||
// .fail(function(jqxhr, textStatus, error){
|
||||
// onArticlesIndexLoadFail(jqxhr, textStatus, error);
|
||||
// });
|
||||
// };
|
||||
//
|
||||
// function onArticlesIndexLoaded(data){
|
||||
// // insert index col
|
||||
// _$container.find('main[role="main"] .row').append(data.rendered);
|
||||
//
|
||||
// // trigger event
|
||||
// _$body.trigger({
|
||||
// 'type':'articles-index-loaded',
|
||||
// 'results':data.results_nids
|
||||
// });
|
||||
// };
|
||||
//
|
||||
// function onArticlesIndexLoadFail(jqxhr, textStatus, error){
|
||||
// console.warn('EdlpCorpus : articles index ajax load failed : '+error, jqxhr.responseText);
|
||||
// };
|
||||
// function deactivateArticlesFilter(){
|
||||
// //console.log('deactivateArticlesFilter');
|
||||
// _articles_filter_on = false;
|
||||
//
|
||||
// // OPTION 1 : just fade no article nodes
|
||||
// // for (var i = 0; i < _no_articles_nodes.length; i++) {
|
||||
// // _no_articles_nodes[i].unFade();
|
||||
// // }
|
||||
//
|
||||
// // OPTION 2 : centered / aside
|
||||
// scrambleCollection();
|
||||
//
|
||||
// updateRandomPlaylist(_playlist);
|
||||
// if(typeof _paq !== 'undefined'){
|
||||
// // trackEvent(category, action, [name], [value])
|
||||
// _paq.push(['trackEvent', 'Corpus Articles', 'off']);
|
||||
// }
|
||||
// };
|
||||
// function shutDownArticles(){
|
||||
// shutdown articles if active
|
||||
if(_$articles_link.is('.is-active'))
|
||||
_$articles_link.trigger('click');
|
||||
};
|
||||
// if(_$articles_link.is('.is-active'))
|
||||
// _$articles_link.trigger('click');
|
||||
// };
|
||||
|
||||
// ___ _
|
||||
// | __|_ _____ _ _| |_ ___
|
||||
@@ -1009,7 +1041,7 @@
|
||||
var event = {
|
||||
'type':'corpus-cliked-on-node',
|
||||
'target_node':_nodes[_node_hover_id],
|
||||
'article':_articles_filter_on
|
||||
// 'article':_articles_filter_on
|
||||
};
|
||||
_$canvas.trigger(event);
|
||||
// instead of directly opening the doc, create an event listener (e.g. : audio played from random)
|
||||
@@ -1017,7 +1049,7 @@
|
||||
}else{
|
||||
// console.log('corpus : click on map');
|
||||
_$canvas.trigger('corpus-cliked-on-map');
|
||||
shutDownArticles();
|
||||
// shutDownArticles();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -35,6 +35,13 @@ function edlp_corpus_theme($existing, $type, $theme, $path) {
|
||||
'lastdocs_nodes' => NULL,
|
||||
),
|
||||
),
|
||||
'edlp_corpus_articlesindex' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_corpus_articlesindex.inc',
|
||||
'variables' => array(
|
||||
'articles_nodes' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -230,6 +237,11 @@ function edlp_corpus_page_attachments(array &$attachments) {
|
||||
// load corpus
|
||||
$url = Url::fromRoute('edlp_corpus.corpusjson');
|
||||
$attachments['#attached']['drupalSettings']['edlp_corpus']['load_corpus_ajax_url'] = $url->getInternalPath();
|
||||
|
||||
|
||||
// load corpus
|
||||
$url = Url::fromRoute('edlp_corpus.articlesindex');
|
||||
$attachments['#attached']['drupalSettings']['edlp_corpus']['articlesindex_url'] = $url->getInternalPath();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,3 +30,20 @@ edlp_corpus.lastdocsajax:
|
||||
_title: 'Last docs'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
|
||||
edlp_corpus.articlesindex:
|
||||
path: '/articles'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::articlesindex'
|
||||
_title: 'Articles Index'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_corpus.articlesindexajax:
|
||||
path: '/articles/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::articlesindexjson'
|
||||
_title: 'Articles Index'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_corpus_articlesindex(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
if(count($vars['articles_nodes'])){
|
||||
$articles_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['articles_nodes'] as $node){
|
||||
$articles_list['#items'][] = $view_builder->view($node, 'index');
|
||||
}
|
||||
|
||||
$vars['articles'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['articles']
|
||||
),
|
||||
"#markup"=>"<h3>".t("Articles")."</h3>",
|
||||
"articles"=>$articles_list
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -243,4 +243,110 @@ class CorpusController extends ControllerBase {
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// _ _ _ _ ___ _
|
||||
// /_\ _ _| |_(_)__| |___ ___ |_ _|_ _ __| |_____ __
|
||||
// / _ \| '_| _| / _| / -_|_-< | || ' \/ _` / -_) \ /
|
||||
// /_/ \_\_| \__|_\__|_\___/__/ |___|_||_\__,_\___/_\_\
|
||||
|
||||
|
||||
private function articlesQuery() {
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->condition('body', '', "<>")
|
||||
->sort('created', 'DESC')
|
||||
->range(0,20);
|
||||
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
|
||||
$this->articles_nodes = [];
|
||||
$this->articles_nids = [];
|
||||
foreach ($nodes as $node) {
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
|
||||
if($sid != 'corpus_documents_publie') continue;
|
||||
|
||||
$this->articles_nodes[] = $node;
|
||||
// record an array of nids for corpus map filtering
|
||||
$this->articles_nids[] = $node->get('nid')->getString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function articlesToRenderable(){
|
||||
$this->articlesQuery();
|
||||
// dpm($this->next_event_node);
|
||||
|
||||
return array(
|
||||
"#theme"=>'edlp_corpus_articlesindex',
|
||||
'#articles_nodes' => $this->articles_nodes
|
||||
);
|
||||
|
||||
}
|
||||
/**
|
||||
* Display lastdocs as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function articlesindex() {
|
||||
return $this->articlesToRenderable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastdocs data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function articlesindexjson() {
|
||||
|
||||
$renderable = $this->articlesToRenderable();
|
||||
// $rendered = render($renderable);
|
||||
// We can't render directly the entity as it throw an exception with cachable data
|
||||
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
|
||||
return render($renderable);
|
||||
});
|
||||
|
||||
$data = [
|
||||
'rendered'=> $rendered,
|
||||
'title'=>'Articles',
|
||||
'articles' => $this->articles_nids,
|
||||
'documents_lies' => $this->articles_nids,
|
||||
];
|
||||
|
||||
// translations links
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Language\LanguageInterface;
|
||||
$route_name = 'edlp_corpus.articlesindex';
|
||||
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
|
||||
if (isset($links->links)) {
|
||||
$translations_build = [
|
||||
'#theme' => 'links__language_block',
|
||||
'#links' => $links->links,
|
||||
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
|
||||
'#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;
|
||||
}
|
||||
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => ['edlp-articlesindex-cache']
|
||||
];
|
||||
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{{ articles }}
|
||||
@@ -6,7 +6,7 @@ function checkLayout(){var $audioplayer=$("#audio-player");if($audioplayer.lengt
|
||||
checkGridBlockHeight();checkGridBlockVisible();};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');_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;var $rendered=$(data.rendered);$rendered.attr({'sys_path':state.sys_path,'view_mode':state.view_mode});if(data.entity_type=="node"&&data.bundle=="evenement"){if(_$row.find('.col.event').length){_$row.find('.col.event').replaceWith($rendered);}else if(_$row.find('.col.aside').length){_$row.find('.col.aside').replaceWith($rendered);}else{_$row.append($rendered);}}else{_$row.removeAttr('style').html($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');initAudioLinksHover();}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.addClass('path-edlp-node');$('.ajax-loading').removeClass('ajax-loading');$('.ajax-link.is-active:not(.articles-link)').removeClass('is-active');$('.is-active-trail').removeClass('is-active-trail');if(typeof state.selector!='undefined'){void 0;$('a[selector="'+state.selector+'"]').addClass('is-active');initAudioLinksHover();}else{if(typeof state.view_mode!='undefined'){$('a[viewmode="'+state.view_mode+'"][data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');}else{_corpus_promise.done(function(){$('a[data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');});}
|
||||
_$body.trigger({'type':'new-content-not-entree-ajax-loaded'});}
|
||||
if(typeof data.bundle!='undefined'&&data.bundle=="page"){$('a[data-drupal-link-system-path="productions"]').addClass('is-active-trail');}
|
||||
if(typeof data.menu_parents!='undefined'){for(var i=0;i<data.menu_parents.length;i++){var menu_sys_path=data.menu_parents[i];$('a[data-drupal-link-system-path="'+menu_sys_path+'"]').addClass('is-active-trail');}}
|
||||
@@ -34,7 +34,7 @@ var sys_path=$(this).attr('data-drupal-link-system-path');if(sys_path=='<front>'
|
||||
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');}
|
||||
$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').openDocument(e.target_node);});_randomPlayer=new RandomPlayer(e.playlist);initAjaxLinks();_$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 checkVisibleCorpusMapSpace(){var left_limit=0,right_limit=0;_$row.find('.col').each(function(i,e){var $col=$(this);var offset=$col.offset();void 0;switch(true){case $col.is('.float-right'):right_limit=Math.max(right_limit,Math.abs(offset.left-15-window.innerWidth));break;default:left_limit=Math.max(left_limit,offset.left+$col.width()+15);break;}});void 0;if(_corpus_ready){_$body.trigger({type:'visible-space-changed',left_limit:left_limit,right_limit:right_limit});}else{_corpus_promise.done(function(){_$body.trigger({type:'visible-space-changed',left_limit:left_limit,right_limit:right_limit});});}};function AudioPlayer(){var that=this;this.fid;this.audio=new Audio();this.audio_events=["loadedmetadata","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.scndCartel_visible=0;this.cartelSwitchIntervalMS=7000;this.cartelSwitchInterval=false;this.hideTimer=false;this.hideTimeMS=15000;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());this.$loader.on('click',this.seek.bind(this));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){void 0;if(typeof node=='undefined'||typeof node.nid=='undefined'||typeof node.audio_url=='undefined'){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"){if(typeof node.document_url=='undefined'){void 0;}else{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,};var url=node.document_url+(caller=='random'?'#random':'');history.pushState(state,null,url);}}}else{this.currentHistoricIndex=historic_index;}
|
||||
@@ -43,7 +43,7 @@ this.emmit('audio-open-document',{caller:caller});if(typeof _paq!=='undefined'){
|
||||
this.launch();},launch(){this.clearTimeOutToHide();this.clearIntervalAutoCartelSwitch();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;var that=this;_corpus_promise.done(function(){_$corpus_canvas.trigger({'type':'audio-node-opened','nid':that.historic[that.currentHistoricIndex].nid});});}
|
||||
this.showHidePreviousBtn();this.showHideNextBtn();this.show();},openSound(url,title){this.hide();this.clearTimeOutToHide();this.$cartel.html("");this.setSRC(url);this.show();if(typeof _paq!=='undefined'){_paq.push(['trackEvent','Audio','play',url]);}},setSRC(url){void 0;this.audio.src=url;this.play();},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(){void 0;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){window.requestAnimationFrame(this.updateLoadingBar.bind(this));}else{void 0;}}else{window.requestAnimationFrame(this.updateLoadingBar.bind(this));}},onError(){void 0;},play(){this.clearTimeOutToHide();var promise=this.audio.play();if(promise!==undefined){promise.catch(function(error){void 0;}).then(function(){void 0;});}},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.play();}else{this.stop();}},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();}},seek(e){var seek=e.originalEvent.layerX/this.timeline_w*this.audio.duration
|
||||
void 0;this.audio.currentTime=seek;},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.stop();this.emmit('audio-ended');},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){void 0;this.$cartel.html(data.rendered).removeClass('loading');_$body.trigger({'type':'new-audio-cartel-loaded'});initAjaxLinks();this.scndCartel_visible=0;this.$cartel.removeClass('second-visible');if(this.$cartel.find('.second-cartel .col-left').children().length>1||this.$cartel.find('.second-cartel').children('.col-right').length){this.cartelSwitchInterval=setInterval(this.switchCartel.bind(this),this.cartelSwitchIntervalMS);}
|
||||
Drupal.attachBehaviors(this.$cartel);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;}},switchCartel(){if(this.scndCartel_visible){this.$cartel.removeClass('second-visible');this.scndCartel_visible=0;this.clearIntervalAutoCartelSwitch();}else{this.$cartel.addClass('second-visible');this.scndCartel_visible=1;}},clearIntervalAutoCartelSwitch(){if(this.cartelSwitchInterval){clearInterval(this.cartelSwitchInterval);this.cartelSwitchInterval=false;}},hide(){this.$container_parent.removeClass('audio-player-visible');this.$container.removeClass('visible');try{_$corpus_canvas.trigger('audio-node-closed');}catch(e){void 0;}},deActivateRandom(){this.shuffle_is_active=false;this.showHideNextBtn();},on(event_name,handler){if(typeof this.event_handlers[event_name]=='undefined'){void 0;}
|
||||
Drupal.attachBehaviors(this.$cartel);this.setAutoOpenArticle();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=$('a.articles-link').is('.is-active');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;}},switchCartel(){if(this.scndCartel_visible){this.$cartel.removeClass('second-visible');this.scndCartel_visible=0;this.clearIntervalAutoCartelSwitch();}else{this.$cartel.addClass('second-visible');this.scndCartel_visible=1;}},clearIntervalAutoCartelSwitch(){if(this.cartelSwitchInterval){clearInterval(this.cartelSwitchInterval);this.cartelSwitchInterval=false;}},hide(){this.$container_parent.removeClass('audio-player-visible');this.$container.removeClass('visible');try{_$corpus_canvas.trigger('audio-node-closed');}catch(e){void 0;}},deActivateRandom(){this.shuffle_is_active=false;this.showHideNextBtn();},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){void 0;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];(function(handler,args){setTimeout(function(){handler(args);},0);}(handler,args));}
|
||||
return this;},}
|
||||
function RandomPlayer(playlist){this.active=false;this.playlist=playlist;this.path=drupalSettings.path.baseUrl+drupalSettings.path.pathPrefix+'#random'
|
||||
@@ -62,5 +62,5 @@ return this;},deactivate(){this.stop();this.active=false;},onAudioOpenDocument(a
|
||||
$this.height(Math.min($this.attr('init-height'),_$row.height()));});};function checkGridBlockVisible(){var $r_h=_$row.height();var $this,pos;$('.grid .col',_$row).each(function(i,e){$this=$(this);pos=$this.position();if(pos.top+$this.height()<=$r_h){$this.removeClass('offfield');}else{$this.addClass('offfield');}});}
|
||||
function initSearch(){$('#edit-entries--wrapper legend','#edlp-search-form').on('click',function(){$(this).parent().toggleClass('opened');});};function initEnregistrementTranscript(){void 0;var $node=_$row.find('article.node--type-enregistrement.node--view-mode-transcript');var $nav=$('<nav>').prependTo($node);$node.find('.field--name-field-transcript-vo').addClass('visible').find('.field__label').clone().appendTo($nav).addClass('is-active').attr('field_target','.field--name-field-transcript-vo');$node.find('.field--name-field-transcript-trad').find('.field__label').clone().appendTo($nav).attr('field_target','.field--name-field-transcript-trad');$nav.find('.field__label').on('click',function(){var $this=$(this).addClass('is-active');$this.siblings('.is-active').removeClass('is-active');$this.parents('article.node').find('.field.visible').removeClass('visible');$this.parents('article.node').find($this.attr('field_target')).addClass('visible');});};function backToFrontPage(pop_state){void 0;closeAllModals();$('body').removeClass().addClass('path-frontpage');$('a[data-drupal-link-system-path="<front>"]').addClass('is-active');_$corpus_canvas.trigger({'type':'close-all-entree'});_$corpus_canvas.trigger({'type':'scramble-collection'});if(typeof pop_state=="undefined"||!pop_state){void 0;history.pushState({home:true},null,drupalSettings.path.baseUrl+drupalSettings.path.currentLanguage);}}
|
||||
function initHome(){addCloseModalBtnToCols();return;void 0;var $grid=$('.grid',_$row).masonry({itemSelector:'.col',columnWidth:'.col-2',horizontalOrder:true,containerStyle:null,});$grid.imagesLoaded().progress(function(){$grid.masonry('layout');});$grid.imagesLoaded(function(){$grid.masonry('layout');});}
|
||||
function closeAllModals(){_$row.html('');_$ajaxLinks.removeClass('is-active');_$body.trigger({'type':'all-modal-closed'});};function checkRowEmpty(){if(!$('.col',_$row).length){if(!_$body.is('.entity-type-taxonomy_term.bundle-entrees')){if(!_$body.is('.entity-type-node.bundle-page')){if(!$('a.articles-link').is('.is-active')){backToFrontPage();}}else{_$corpus_canvas.trigger({'type':'scramble-collection'});$('a[data-drupal-link-system-path="productions"]','#block-mainnavigation').removeClass('is-active').trigger('click');}}else{$('.entree-content a.is-active').removeClass('is-active');}}};init();}
|
||||
function closeAllModals(){_$row.html('');_$ajaxLinks.removeClass('is-active');_$body.trigger({'type':'all-modal-closed'});};function checkRowEmpty(){void 0;if(!$('.col',_$row).length){if(!_$body.is('.entity-type-taxonomy_term.bundle-entrees')){if(!_$body.is('.entity-type-node.bundle-page')){if(_$body.is('.bundle-enregistrement.view-mode-article')&&$('a.articles-link').is('.is-active')){void 0;$('a.articles-link').removeClass('is-active').trigger('click');}else{backToFrontPage();}}else{_$corpus_canvas.trigger({'type':'scramble-collection'});$('a[data-drupal-link-system-path="productions"]','#block-mainnavigation').removeClass('is-active').trigger('click');}}else{$('.entree-content a.is-active').removeClass('is-active');}}};init();}
|
||||
$(document).ready(function($){if(drupalSettings.path.isFront){var edlptheme=new EdlpTheme();}else{$('body').attr('booted','booted');}});})(jQuery,Drupal,drupalSettings);
|
||||
File diff suppressed because one or more lines are too long
@@ -301,7 +301,7 @@
|
||||
|
||||
// handle clicked link classes
|
||||
$('.ajax-loading').removeClass('ajax-loading');
|
||||
$('.ajax-link.is-active').removeClass('is-active');
|
||||
$('.ajax-link.is-active:not(.articles-link)').removeClass('is-active');
|
||||
$('.is-active-trail').removeClass('is-active-trail');
|
||||
|
||||
if(typeof state.selector != 'undefined'){
|
||||
@@ -314,7 +314,10 @@
|
||||
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');
|
||||
// wait for corpus map beeing ready (e.g. for articles link)
|
||||
_corpus_promise.done(function(){
|
||||
$('a[data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');
|
||||
});
|
||||
}
|
||||
// as new content is not related to entree, we trigger close entree
|
||||
_$body.trigger({'type':'new-content-not-entree-ajax-loaded'});
|
||||
@@ -787,12 +790,15 @@
|
||||
//console.log('theme : corpus-cliked-on-node', e);
|
||||
_audioPlayer
|
||||
.emmit('stop-shuffle')
|
||||
.setAutoOpenArticle(e.article)
|
||||
// .setAutoOpenArticle(e.article)
|
||||
.openDocument(e.target_node);
|
||||
});
|
||||
|
||||
_randomPlayer = new RandomPlayer(e.playlist);
|
||||
|
||||
// mainly for articles link
|
||||
initAjaxLinks();
|
||||
|
||||
_$body.attr('corpus-map', 'ready');
|
||||
}
|
||||
function openEntree(tid){
|
||||
@@ -1193,6 +1199,7 @@
|
||||
// call drupal behaviours (for addtoany)
|
||||
Drupal.attachBehaviors(this.$cartel);
|
||||
// open automaticly tha article if needed
|
||||
this.setAutoOpenArticle();
|
||||
if(this.auto_open_article){
|
||||
this.$cartel.find('a.link-article').trigger('click');
|
||||
this.auto_open_article = false;
|
||||
@@ -1203,7 +1210,7 @@
|
||||
this.$cartel.removeClass('loading').html('');
|
||||
},
|
||||
setAutoOpenArticle(art){
|
||||
this.auto_open_article = art;
|
||||
this.auto_open_article = $('a.articles-link').is('.is-active');
|
||||
return this;
|
||||
},
|
||||
// global
|
||||
@@ -1881,15 +1888,26 @@
|
||||
};
|
||||
|
||||
function checkRowEmpty(){
|
||||
console.log('checkRowEmpty');
|
||||
// if row is empty and we are not in productions or entree notice|index call closeAllModals()
|
||||
if(!$('.col', _$row).length){
|
||||
if(!_$body.is('.entity-type-taxonomy_term.bundle-entrees')){
|
||||
if(!_$body.is('.entity-type-node.bundle-page')){
|
||||
// we weren't on production or entree, so go back to front page
|
||||
if(!$('a.articles-link').is('.is-active')){
|
||||
// don't go back to front page if articles filter is on
|
||||
// debugger;
|
||||
if(_$body.is('.bundle-enregistrement.view-mode-article')
|
||||
&& $('a.articles-link').is('.is-active')){
|
||||
console.log('Closing article while article index is active');
|
||||
// if node article and articles is active, reload index
|
||||
$('a.articles-link').removeClass('is-active').trigger('click');
|
||||
}else{
|
||||
backToFrontPage();
|
||||
}
|
||||
// if(!$('a.articles-link').is('.is-active')){
|
||||
// // don't go back to front page if articles filter is on
|
||||
// backToFrontPage();
|
||||
// }else{
|
||||
// }
|
||||
}else{
|
||||
// if we were on production page just scramble collection in case of map was filtered
|
||||
_$corpus_canvas.trigger({'type':'scramble-collection'});
|
||||
|
||||
@@ -459,6 +459,25 @@ main[role="main"]{
|
||||
}
|
||||
}
|
||||
|
||||
div.articles{
|
||||
padding-top:1em!important;
|
||||
&:not(.home_mobile)>h3{
|
||||
display:none;
|
||||
// @include content_subtitles;
|
||||
// margin: 1em 0 0.5em;
|
||||
}
|
||||
&.home_mobile h2{
|
||||
margin:0;
|
||||
@include content_titles;
|
||||
}
|
||||
article.node--type-enregistrement{
|
||||
h2.node-title{
|
||||
@include content_subtitles;
|
||||
margin:0.9em 0 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.lastdocs{
|
||||
article.node--type-enregistrement{
|
||||
h2.node-title{
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<div class="col small-col-12 med-col-6 large-col-6">
|
||||
<div class="wrapper">
|
||||
{{ articles }}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user