Browse Source

corpus map evolution zone linked to visible space left by modals

Bachir Soussi Chiadmi 7 years ago
parent
commit
bf0dade005

File diff suppressed because it is too large
+ 9 - 0
sites/all/modules/figli/edlp_corpus/assets/dist/scripts/corpus.min.js


File diff suppressed because it is too large
+ 22 - 0
sites/all/modules/figli/edlp_corpus/assets/dist/scripts/physics.min.js


File diff suppressed because it is too large
+ 0 - 0
sites/all/modules/figli/edlp_corpus/assets/dist/styles/corpus.min.css


+ 40 - 5
sites/all/modules/figli/edlp_corpus/assets/scripts/corpus.js

@@ -26,8 +26,8 @@
     var _ctx = _canvas.getContext('2d');
     var _dpi = window.devicePixelRatio;
     var _scene_props = {
-      width:0,
-      height:0,
+      width:window.innerWidth,
+      height:window.innerHeight,
       // 'margin_top':90, // with red border on head
       'margin_top':75, // without red border on head
       // 'margin_top':0,
@@ -36,6 +36,12 @@
       // 'margin_bottom':0,
       '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 = [];
@@ -102,12 +108,15 @@
       _canvas.height = _scene_props.height*_dpi;
       _ctx.scale(_dpi, _dpi);
 
+      moveEvolutionZone();
+
       if(_loaded){
         for (var i = 0; i < _nodes.length; i++) {
           _nodes[i].onResizeCanvas();
         }
         // move _attracter and _repulser to their right places again
-        resizePhysics();
+        // moveEvolutionZone() will trigger resizePhysics()
+        // resizePhysics();
       }
 
     };
@@ -161,7 +170,9 @@
     };
     function resizePhysics(){
       // attracters
-      _attracter.position = {x:_scene_props.width/2, y:_scene_props.height/2};
+      if(typeof _attracter != 'undefined'){
+        _attracter.position = {x:_evolution_zone.center, y:_scene_props.height/2};
+      }
     };
 
     //  _  _         _
@@ -479,7 +490,10 @@
               this.p.velocity.multiplyScalar(0.99); // 0.995
             }
           }
-          if( Math.abs(_attracter.position.x - this.x) > _scene_props.width/4
+          // limit evolution zone
+          // if( Math.abs(_attracter.position.x - this.x) > _scene_props.width/4
+          //     || Math.abs(_attracter.position.y - this.y) > _scene_props.height/4){
+          if( this.x < _evolution_zone.left || this.x > _evolution_zone.right
               || Math.abs(_attracter.position.y - this.y) > _scene_props.height/4){
             this.attract.on = true;
           }else{
@@ -731,6 +745,23 @@
       // console.log('_physics.attractions.length', _physics.attractions.length);
     };
 
+
+
+
+    //  ___         _      _   _            ____
+    // | __|_ _____| |_  _| |_(_)___ _ _   |_  /___ _ _  ___
+    // | _|\ V / _ \ | || |  _| / _ \ ' \   / // _ \ ' \/ -_)
+    // |___|\_/\___/_|\_,_|\__|_\___/_||_| /___\___/_||_\___|
+    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;
+      // move _attracter to the center of the zone
+      resizePhysics();
+    }
+
     //  ___              _             ___ _           _ _    _
     // | _ \__ _ _ _  __| |___ _ __   | _ \ |__ _ _  _| (_)__| |_
     // |   / _` | ' \/ _` / _ \ '  \  |  _/ / _` | || | | (_-<  _|
@@ -1050,6 +1081,10 @@
               .parents('.item-list').removeClass('opened');
             scrambleCollection();
           }
+        })
+        .on('visible-space-changed', function(e){
+          // limits are absolute distance from each side (not positions from left)
+          moveEvolutionZone(e.left_limit, e.right_limit);
         });
     };
 

File diff suppressed because it is too large
+ 1 - 0
sites/all/modules/figli/edlp_search/assets/dist/scripts/edlp_search.min.js


File diff suppressed because it is too large
+ 1 - 0
sites/all/modules/figli/edlp_studio/assets/dist/scripts/edlp_studio.min.js


+ 19 - 1
sites/all/themes/custom/edlptheme/assets/dist/scripts/history.min.js

@@ -1,2 +1,20 @@
+console.log('EDLP THEME HISTORY.js');
+// var edlp is provided by edlp_ajax.module file
+if(edlp.redirect){
+  console.log('history redirect', edlp);
+  console.log('window.location', window.location);
+  // window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
+  edlp.sys_path = edlp.sys_path.replace(/^\//, '');
 
-void 0;if(edlp.redirect){void 0;void 0;edlp.sys_path=edlp.sys_path.replace(/^\//,'');edlp.url=window.location.pathname;edlp.hash=window.location.hash;window.localStorage.setItem('edlp_origin',JSON.stringify(edlp));window.location.replace(window.location.origin+'/'+edlp.lang_code);}else{void 0;}
+  // window.localStorage.setItem('edlp_origin_url', window.location.pathname);
+  edlp.url = window.location.pathname;
+
+  // window.localStorage.setItem('edlp_origin_hash', window.location.hash);
+  edlp.hash = window.location.hash;
+
+  window.localStorage.setItem('edlp_origin', JSON.stringify(edlp));
+  // redirect to home
+  window.location.replace(window.location.origin+'/'+edlp.lang_code);
+}else{
+  console.log('history do not redirect');
+}

File diff suppressed because it is too large
+ 1 - 1
sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js


File diff suppressed because it is too large
+ 0 - 0
sites/all/themes/custom/edlptheme/assets/dist/styles/app.min.css


+ 50 - 9
sites/all/themes/custom/edlptheme/assets/scripts/main.js

@@ -323,6 +323,8 @@
 
       initAjaxLinks();
 
+      checkVisibleCorpusMapSpace();
+
       // trigger other modules behaviours
       _$body.trigger({'type':'new-content-ajax-loaded'});
 
@@ -407,6 +409,7 @@
       // remove the col
       $col.remove();
       checkRowEmpty();
+      checkVisibleCorpusMapSpace();
     };
 
     //    _    _            ___ _         _
@@ -604,7 +607,7 @@
         return false;
       }
 
-      // NOT USED (YET)
+      // NOT USED ( YET ? )
       // if($link.is('.language-link')){
         // TODO: change global site current language
         // load all blocks translated (exepted language switcher) ... :/
@@ -648,7 +651,6 @@
     // | (__/ _ \ '_| '_ \ || (_-<
     //  \___\___/_| | .__/\_,_/__/
     //              |_|
-
     function onCorpusMapReady(e){
       //console.log('theme : onCorpusReady', e);
       _corpus_ready = true;
@@ -690,6 +692,40 @@
       }
     };
 
+
+    function checkVisibleCorpusMapSpace(){
+      var left_limit = 0, right_limit = 0;
+      _$row.find('.col').each(function(i,e){
+        var $col = $(this);
+        var offset = $col.offset();
+        switch(true){
+          case $col.is('.float-right'):
+            right_limit = Math.max(right_limit, Math.abs(offset.left-window.innerWidth));
+            break;
+          default:
+            left_limit = Math.max(left_limit, offset.left+$col.width());
+            break;
+        }
+      });
+      console.log('checkVisibleCorpusMapSpace left_limit:'+left_limit+" right_limit:"+right_limit);
+
+      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
+          });
+        });
+      }
+    };
+
     //    _          _ _
     //   /_\ _  _ __| (_)___
     //  / _ \ || / _` | / _ \
@@ -1473,15 +1509,20 @@
     };
 
     function checkRowEmpty(){
-      // TODO: remove is-active class from index or notice entree links
       // if row is empty and we are not in productions or entree notice|index call closeAllModals()
-      if(!$('.col', _$row).length && !_$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
-          backToFrontPage();
+      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
+            backToFrontPage();
+          }else{
+            // if we were on production page just scramble collection in case of map was filtered
+            _$corpus_canvas.trigger({'type':'scramble-collection'});
+          }
         }else{
-          // if we were on production page just scramble collection in case of map was filtered
-          _$corpus_canvas.trigger({'type':'scramble-collection'});
+          // remove is-active class from index or notice entree links
+          $('.entree-content a.is-active').removeClass('is-active');
+          // TODO: remove the hash index or notice
         }
       }
     };

Some files were not shown because too many files changed in this diff