diff --git a/web/modules/custom/edlp_corpus/assets/dist/scripts/corpus.min.js b/web/modules/custom/edlp_corpus/assets/dist/scripts/corpus.min.js index 21c5d8b42..075e9ade2 100644 --- a/web/modules/custom/edlp_corpus/assets/dist/scripts/corpus.min.js +++ b/web/modules/custom/edlp_corpus/assets/dist/scripts/corpus.min.js @@ -26,14 +26,14 @@ newVelY1=(ma-mb)/Smamb*na.p.velocity.y+2*mb/Smamb*nb.p.velocity.y;newVelY2=(mb-m 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 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 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;void 0;void 0;_evolution_zone.left=left==0?left+20:Math.max(_scene_props.width/5,left+20);_evolution_zone.right=right==0?_scene_props.width-right+20: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;void 0;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){_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){_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(){var href=window.location.origin+drupalSettings.path.baseUrl+_settings.articlesindex_url;_$articles_link=$('').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($('
  • ').append($('').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=$('
    ').addClass('node-popup').attr('pos','top-right').appendTo('body');this.$content=$('
    ').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.ythis.node.wall_limits.right-350:this.$dom.attr('pos','top-left');break;case this.node.y').addClass('entrees');for(var i=0;i').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=$('').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($('
  • ').append($('').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=$('
    ').addClass('node-popup').attr('pos','top-right').appendTo('body');this.$content=$('
    ').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>_evolution_zone.right-350&&this.node.y_evolution_zone.right-350:this.$dom.attr('pos','top-left');break;case this.node.y').addClass('entrees');for(var i=0;i').addClass('entree').attr('tid',tid));} var $chutier_action=$('').addClass('chutier-icon').attr('action',this.node.chutier_action);this.$content.append($entrees).append('

    '+this.node.title+'

    ').append('
    '+this.node.description+'
    ').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';} diff --git a/web/modules/custom/edlp_corpus/assets/scripts/corpus.js b/web/modules/custom/edlp_corpus/assets/scripts/corpus.js index 4580ac9fa..2ad841c2b 100644 --- a/web/modules/custom/edlp_corpus/assets/scripts/corpus.js +++ b/web/modules/custom/edlp_corpus/assets/scripts/corpus.js @@ -755,9 +755,18 @@ 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); + console.log("moveEvolutionZone",left,right); + console.log("_scene_props", _scene_props); + _evolution_zone.left = + left == 0 + ? left+20 + : Math.max(_scene_props.width/5, left+20); + _evolution_zone.right = + right == 0 + ? _scene_props.width-right+20 + : 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; + console.log("moveEvolutionZone",_evolution_zone); // move _attracter to the center of the zone resizePhysics(); } @@ -1185,11 +1194,24 @@ }; NodePopUp.prototype.setPositioning = function(){ + // switch(true){ + // case this.node.x > this.node.wall_limits.right-350-_evolution_zone.right && 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-_evolution_zone.right: + // 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'); + // } switch(true){ - case this.node.x > this.node.wall_limits.right-350 && this.node.y < this.node.wall_limits.top+200: + case this.node.x > _evolution_zone.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: + case this.node.x > _evolution_zone.right-350: this.$dom.attr('pos', 'top-left'); break; case this.node.y < this.node.wall_limits.top+200: diff --git a/web/themes/custom/edlptheme/assets/dist/scripts/main.min.js b/web/themes/custom/edlptheme/assets/dist/scripts/main.min.js index cc5d4d39c..c350bbcfe 100644 --- a/web/themes/custom/edlptheme/assets/dist/scripts/main.min.js +++ b/web/themes/custom/edlptheme/assets/dist/scripts/main.min.js @@ -24,7 +24,7 @@ if(state.sys_path=="search"){initSearch();} 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();initAudioLinksHover();checkVisibleCorpusMapSpace();_$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 initAudioLinksHover(){void 0;_$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(){if(_is_mobile)return;$('.col',_$row).each(function(index,el){if($('span.close-col-btn',this).length) -return true;$(this).children('.wrapper').prepend($('').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'});} +return true;$(this).children('.wrapper').prepend($('').addClass('close-col-btn').on('click',onCloseModal));});};function onCloseModal(e){void 0;var $col=$(this).parents('.col');var theme=$col.attr('theme');if(theme!=''){_$body.trigger({'type':theme+'-col-closed'});} if(_$body.is('.entity-type-node.bundle-page')&&$(this).next().is('.node--type-page')){$col.add($col.siblings('.col')).remove();}else{$col.remove();} checkRowEmpty();checkVisibleCorpusMapSpace();if($col.attr('view_mode')&&$col.attr('sys_path')){$('a[data-drupal-link-system-path="'+$col.attr('sys_path')+'"][viewmode="'+$col.attr('view_mode')+'"]').removeClass('is-active');}};function initHistory(){initFirstLoad();window.addEventListener('popstate',onHistoryPopState);};function initFirstLoad(){void 0;void 0;var edlp_origin=JSON.parse(window.localStorage.getItem('edlp_origin'));void 0;if(edlp_origin!=null&&edlp_origin.sys_path){var hash=edlp_origin.hash.replace('#','');var state=getSysPathState(edlp_origin.sys_path,hash);if(edlp_origin.entity_type=="taxonomy_term"&&edlp_origin.entity_bundle=="entrees"&&hash){state.selector='entree-'+hash+'-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');closeAllModals();if(hash==""||hash=='random'){state.audio=true;state.node=node;_$body.attr('booted','booted');}else{ajaxLoadContent(state);}} @@ -72,6 +72,6 @@ $this.height(Math.min($this.attr('init-height'),_$row.height()));});};function c function initCollectionNav(){void 0;$('.field--name-field-notice, .index','.taxonomy-term.vocabulary-entrees.home_mobile').addClass('closed');$('.field--name-field-notice>.field__label','.taxonomy-term.vocabulary-entrees.home_mobile').on('click',onClickCollectionNotice);$('.index>.field__label','.taxonomy-term.vocabulary-entrees.home_mobile').on('click',onClickCollectionIndex);};function onClickCollectionNotice(e){toggleEntreeOpening($(this).parent(),'notice');};function onClickCollectionIndex(e){toggleEntreeOpening($(this).parent(),'index');};function toggleEntreeOpening($e,part){$e.toggleClass('closed').parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');} 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=$('