浏览代码

improved node popup placement with corpus evolution_zone, fix #540

Bachir Soussi Chiadmi 5 年之前
父节点
当前提交
4433431b9c

文件差异内容过多而无法显示
+ 1 - 1
web/modules/custom/edlp_corpus/assets/dist/scripts/corpus.min.js


+ 26 - 4
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:

+ 2 - 2
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($('<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'});}
+return true;$(this).children('.wrapper').prepend($('<span>').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=$('<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');if(_corpus_ready){_$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,_base_url+drupalSettings.path.currentLanguage);}}
-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{if(_corpus_ready){_$corpus_canvas.trigger({'type':'scramble-collection'});}
+function closeAllModals(){_$row.html('');_$ajaxLinks.removeClass('is-active');_$body.trigger({'type':'all-modal-closed'});checkVisibleCorpusMapSpace();};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{if(_corpus_ready){_$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);

+ 3 - 6
web/themes/custom/edlptheme/assets/scripts/main.js

@@ -71,7 +71,6 @@
         .on('submit', onSubmitLogForm)
         .addClass('ajax-enabled');
     };
-
     function onSubmitLogForm(e){
       e.preventDefault();
       // console.log('onSubmitLogForm', e);
@@ -83,7 +82,6 @@
       logIn(args).then(getStudioLinkBlock);
       return false;
     };
-
     function logIn(args){
       console.log('logIn', args);
       _$log_form.addClass('ajax-loading');
@@ -110,7 +108,6 @@
         }
       });
     };
-
     function getStudioLinkBlock(){
       var path = _origin+_base_url+'edlp/ajax/blocks/json/';
       $.getJSON(path+"studiolinkblock", {})
@@ -119,7 +116,6 @@
           console.warn('Studio ink block load failed', jqxhr.responseText);
         });
     };
-
     function onStudioLinkBlockLoaded(data){
       console.log('onStudioLinkBlockLoaded', data);
       $('#block-studiouserlogin').replaceWith(data.blocks.studiolinkblock.rendered);
@@ -587,6 +583,7 @@
     };
 
     function onCloseModal(e){
+      console.log("onCloseModal");
       // check for theme attribute and emmit event
       var $col = $(this).parents('.col');
       var theme = $col.attr('theme');
@@ -1824,7 +1821,6 @@
         }
       }
     };
-
     function checkGridBlockHeight(){
       // console.log('checkGridBlockHeight');
       // if(_is_mobile) return;
@@ -1846,7 +1842,6 @@
         $this.height(Math.min($this.attr('init-height'), _$row.height()));
       });
     };
-
     function checkGridBlockVisible(){
       // console.log('checkGridBlockVisible');
       // if(_is_mobile) return;
@@ -2049,6 +2044,8 @@
       _$ajaxLinks.removeClass('is-active');
       _$body.trigger({'type':'all-modal-closed'});
       // checkRowEmpty();
+
+      checkVisibleCorpusMapSpace();
     };
 
     function checkRowEmpty(){

部分文件因为文件数量过多而无法显示