Prechádzať zdrojové kódy

included entree and entree#notice entree#index in ajax history nav

Bachir Soussi Chiadmi 6 rokov pred
rodič
commit
1d3a3dd6fd

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 9 - 0
sites/all/modules/figli/edlp_corpus/assets/dist/scripts/corpus.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 22 - 0
sites/all/modules/figli/edlp_corpus/assets/dist/scripts/physics.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
sites/all/modules/figli/edlp_corpus/assets/dist/styles/corpus.min.css


+ 64 - 12
sites/all/modules/figli/edlp_corpus/assets/scripts/corpus.js

@@ -139,6 +139,7 @@
       initArtilesLink();
       initNodePopup();
       initEvents();
+      checkPreOpenedEntry();
       startAnime();
     };
 
@@ -654,6 +655,26 @@
     // | __|_ _| |_ _ _ ___ ___ ___
     // | _|| ' \  _| '_/ -_) -_|_-<
     // |___|_||_\__|_| \___\___/__/
+    // TODO : this functionn is not clear as it should be called toggleEntry
+    function openEntree(tid, bubbling){
+      //var $link = $('a.term-link[tid="'+tid+'"]');
+      var $link = _$entrees_block_termlinks.filter('[tid="'+tid+'"]');
+      var $li = $link.parents('li');
+      var sys_path = $link.attr('data-drupal-link-system-path');
+      var url = $link.attr('href');
+      if(!$li.is('.opened')){
+        _$entrees_block_termlinks.parents('li').removeClass('opened');
+        $li.addClass('opened');
+        filterEntree(tid);
+        if(bubbling){
+          _$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
+        }
+      }else if(bubbling){
+        $li.removeClass('opened');
+        scrambleCollection();
+        _$body.trigger({'type':'close_entree', 'tid':tid});
+      }
+    };
     function filterEntree(t){
       shutDownArticles();
 
@@ -792,6 +813,7 @@
     // | _|\ V / -_) ' \  _(_-<
     // |___|\_/\___|_||_\__/__/
     function initEvents(){
+      console.log('Corpus, initEvents');
       _$canvas
         .on('mousemove', function(event) {
           event.preventDefault();
@@ -836,22 +858,33 @@
         })
         .on('audio-node-closed', function(e){
           closeNode();
+        })
+        .on('open-entree', function(e){
+          openEntree(e.tid);
+        })
+        .on('close-all-entree', function(e){
+          closeAllEntries();
         });
 
       _$entrees_block_termlinks.on('click', function(event) {
+        console.log('_$entrees_block_termlinks click', this);
         event.preventDefault();
-        var tid = $(this).attr('tid');
-        var $li = $(this).parents('li');
-        if(!$li.is('.opened')){
-          _$entrees_block_termlinks.parents('li').removeClass('opened');
-          $li.addClass('opened');
-          filterEntree(tid);
-          _$body.trigger({'type':'open_entree', 'tid':tid});
-        }else{
-          $li.removeClass('opened');
-          scrambleCollection();
-          _$body.trigger({'type':'close_entree', 'tid':tid});
-        }
+        openEntree($(this).attr('tid'), true);
+        // var $link = $(this);
+        // var tid = $link.attr('tid');
+        // var $li = $link.parents('li');
+        // var sys_path = $link.attr('data-drupal-link-system-path');
+        // var url = $link.attr('href');
+        // if(!$li.is('.opened')){
+        //   _$entrees_block_termlinks.parents('li').removeClass('opened');
+        //   $li.addClass('opened');
+        //   openEntree(tid);
+        //   _$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
+        // }else{
+        //   $li.removeClass('opened');
+        //   scrambleCollection();
+        //   _$body.trigger({'type':'close_entree', 'tid':tid});
+        // }
         return false;
       });
 
@@ -866,9 +899,28 @@
         })
         .on('search-closed', function(e){
           scrambleCollection();
+        })
+        .on('new-content-not-entree-ajax-loaded', function(e){
+          // close all entries only if entry already opened
+          if(_$entrees_block_termlinks.parents('li.opened').length){
+            _$entrees_block_termlinks.parents('li').removeClass('opened');
+            scrambleCollection();
+          }
         });
     };
 
+
+    function checkPreOpenedEntry(){
+      _$entrees_block.find('li.entree').each(function(index, el) {
+        var $li = $(this);
+        if($('a.is-active', $li).length){
+          $li.addClass('opened');
+          filterEntree($li.attr('tid'));
+          return false;
+        }
+      });
+    };
+
     //  _  _         _     ___          _   _
     // | \| |___  __| |___| _ \___ _ __| | | |_ __
     // | .` / _ \/ _` / -_)  _/ _ \ '_ \ |_| | '_ \

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 0
sites/all/modules/figli/edlp_search/assets/dist/scripts/edlp_search.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 0
sites/all/modules/figli/edlp_studio/assets/dist/scripts/edlp_studio.min.js


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

@@ -4,6 +4,7 @@ if(edlp.redirect){
   console.log('history redirect');
   window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
   window.localStorage.setItem('edlp_origin_url', window.location.pathname);
+  window.localStorage.setItem('edlp_origin_hash', window.location.hash);
   // redirect to home
   window.location.replace(window.location.origin);
 }else{

+ 166 - 64
sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js

@@ -5,6 +5,7 @@ console.log('EDLP THEME MAIN.js');
     var _ajax_settings = drupalSettings.edlp_ajax;
     var _$body = $('body');
     var _is_front = _$body.is('.path-frontpage');
+    var _corpus_ready = false;
     var _$corpus_canvas;
     var _$row = $('main[role="main"]>.layout-content>.row');
     var _$ajaxLinks;
@@ -19,6 +20,8 @@ console.log('EDLP THEME MAIN.js');
     function init(){
       console.log("EdlpTheme init()");
 
+      initAjaxLinks();
+
       initHistory();
 
       if(!drupalSettings.path.isFront)
@@ -29,7 +32,6 @@ console.log('EDLP THEME MAIN.js');
       _audioPlayer = new AudioPlayer();
       _compoPlayer = new CompoPlayer();
 
-      initAjaxLinks();
 
       // if (_$body.is('.path-productions')) initProductions();
       // if(_$body.is('.path-frontpage')) initHome();
@@ -59,7 +61,31 @@ console.log('EDLP THEME MAIN.js');
           _compoPlayer.newCompo();
         })
         .on('search-results-loaded', initAjaxLinks)
-        .on('open_entree', closeAllModals)
+        // do not close index or notice modale on entree click
+        .on('open_entree', function(e){
+          console.log('on_open_entree : e', e);
+          closeAllModals();
+
+          // add body class for currently loaded content
+          // var body_classes = [
+          //   'path-'+sys_path.replace(/\//g, '-'),
+          //   'entity-type-'+data.entity_type,
+          //   'bundle-'+data.bundle,
+          //   'view-mode-'+data.view_mode
+          // ];
+          _$body.removeClass();//.addClass(body_classes.join(' '));
+
+          // record new history state
+          if(typeof e.url != 'undefined'){
+            // var state = {
+            //   ajax_path:null,
+            //   sys_path:null,
+            //   entree_tid:e.tid
+            // };
+            var state = getSysPathState(e.sys_path);
+            history.pushState(state, null, e.url);
+          }
+        })
         .on('close_entree', backToFrontPage);
     }
 
@@ -84,44 +110,56 @@ console.log('EDLP THEME MAIN.js');
     //  / _ \ | / _` \ \ /
     // /_/ \_\/ \__,_/_\_\
     //      |__/
-    function parseAjaxSysPath(sys_path, view_mode){
-      // console.log('Theme : parseAjaxSysPath', sys_path);
-      var ajax_path = sys_path;
+    function getSysPathState(sys_path, view_mode){
+      // console.log('Theme : getSysPathState', sys_path);
+      var state = {
+        'sys_path':sys_path,
+        'ajax_path': sys_path
+      };
 
       // convert node link to edlp_ajax_node module links
-      var node_match = ajax_path.match(/^\/?(node\/\d+)$/g);
-      var term_match = ajax_path.match(/^\/?(taxonomy\/term\/\d+)$/g);
+      var node_match = state.ajax_path.match(/^\/?(node\/(\d+))$/i);
+      console.log('node_match', node_match);
+      var term_match = state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);
+      console.log('term_match', term_match);
       if(node_match){
-        ajax_path = _ajax_settings.entityjson_path+'/'+node_match[0];
+        state.ajax_path = _ajax_settings.entityjson_path+'/'+node_match[1];
+        state.node_nid = node_match[2];
         // check for viewmode attribute
         if(view_mode){
-          ajax_path += '/'+view_mode;
+          state.ajax_path += '/'+view_mode;
         }
       }else if(term_match){
-        ajax_path = _ajax_settings.entityjson_path+'/'+term_match[0];
-        ajax_path = ajax_path.replace(/taxonomy\/term/, 'taxonomy_term');
+        // terms are always entrees, there's no other vocabulary links in front
+        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];
         // check for viewmode attribute
         if(view_mode){
-          ajax_path += '/'+view_mode;
+          state.ajax_path += '/'+view_mode;
+          state.view_mode = view_mode;
+        }else{
+          state.ajax_path = null;
         }
       }else{
         // convert other link to ajax
         // TODO: we assume that other links (no node, no term) are all from own modules (e.g. productions) !! may not be true !!
-        ajax_path += '/ajax'
+        state.ajax_path += '/ajax'
       }
-      return ajax_path;
+      return state;
     };
-    function ajaxLoadContent(url, sys_path, ajax_path, selector){
-      console.log('ajaxLoadContent : url', url);
+    // function ajaxLoadContent(url, sys_path, ajax_path, selector){
+    function ajaxLoadContent(state){
+      console.log('ajaxLoadContent : url', state.url);
       _$body.addClass('ajax-loading');
 
-      var path = window.location.origin + Drupal.url(ajax_path);
+      var path = window.location.origin + Drupal.url(state.ajax_path);
       $.getJSON(path, {})
         .done(function(data){
-          onAjaxLoaded(data, url, ajax_path, sys_path, selector);
+          onAjaxLoaded(data, state);
         })
         .fail(function(jqxhr, textStatus, error){
-          onAjaxLoadError(jqxhr, textStatus, error, sys_path);
+          onAjaxLoadError(jqxhr, textStatus, error, state.sys_path);
         });
     };
     function onAjaxLoadError(jqxhr, textStatus, error, sys_path){
@@ -129,22 +167,18 @@ console.log('EDLP THEME MAIN.js');
       $('.ajax-loading').removeClass('ajax-loading');
       _$body.removeClass('ajax-loading');
     };
-    function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
-      console.log('ajax loaded url:'+url+' ajax_path:'+ajax_path+' sys_path:'+sys_path);
+    // function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
+    function onAjaxLoaded(data, state){
+      console.log('ajax loaded url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
 
       // reset all style may been added by other pages (like masonry for productions)
       // and replace all content with newly loaded
       // TODO: build a system to replace or append contents (like studio + search)
       _$row.removeAttr('style').html(data.rendered);
 
-      // add close btn
-      if(sys_path != 'productions'){
-        addCloseBtnToCols();
-      }
-
       // add body class for currently loaded content
       var body_classes = [
-        'path-'+sys_path.replace(/\//g, '-'),
+        'path-'+state.sys_path.replace(/\//g, '-'),
         'entity-type-'+data.entity_type,
         'bundle-'+data.bundle,
         'view-mode-'+data.view_mode
@@ -152,8 +186,9 @@ console.log('EDLP THEME MAIN.js');
       _$body.removeClass().addClass(body_classes.join(' '));
 
       // id node add a generic path-node class to body
-      m = sys_path.match(/^\/?(node\/\d+)$/g);
-      if(m)
+      // m = state.sys_path.match(/^\/?(node\/\d+)$/g);
+      // if(m)
+      if(state.node_nid)
         _$body.addClass('path-edlp-node');
 
       // handle clicked link classes
@@ -161,10 +196,14 @@ console.log('EDLP THEME MAIN.js');
       $('.is-active').removeClass('is-active');
       $('.is-active-trail').removeClass('is-active-trail');
 
-      if(typeof selector != 'undefined'){
-        $('a[selector="'+selector+'"]').addClass('is-active');
+      if(typeof state.selector != 'undefined'){
+        // in case of entree link (actualy, selector is used only for entries links)
+        console.log('selector', state.selector);
+        $('a[selector="'+state.selector+'"]').addClass('is-active');
       }else{
-        $('a[data-drupal-link-system-path="'+sys_path+'"]').addClass('is-active');
+        $('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'});
       }
 
       // if bundle page (productions) activate production links
@@ -190,13 +229,17 @@ console.log('EDLP THEME MAIN.js');
 
       // initScrollbars();
 
-      if(sys_path == "productions")
+      if(state.sys_path == "productions"){
         initProductions();
+      }else{
+        addCloseBtnToCols();
+      }
 
       initAjaxLinks();
 
       // trigger other modules behaviours
       _$body.trigger({'type':'new-content-ajax-loaded'});
+
       // and call druapl behaviours
       Drupal.attachBehaviors(_$row[0]);
 
@@ -204,16 +247,17 @@ console.log('EDLP THEME MAIN.js');
       _$body.removeClass('ajax-loading');
 
 
-      var state = {
-        ajax_path:ajax_path,
-        sys_path:sys_path,
-      };
       // url is null means that we are loading content on popState event
       // so we don't record the state again
-      if(url){
+      if(state.url){
+        // var state = {
+        //   ajax_path:ajax_path,
+        //   sys_path:sys_path,
+        // };
         // console.log('url:'+url+' ; state',state);
+        // console.log(window.location);
         // we can not pushestate with absolute url
-        history.pushState(state, null, url);
+        history.pushState(state, null, state.url);
       }
     };
 
@@ -253,41 +297,73 @@ console.log('EDLP THEME MAIN.js');
       window.addEventListener('popstate', onHistoryPopState);
     };
     function initFirstLoad(){
-      console.log('theme : initFirstLoad()', window.location);
-      console.log(document.cookie);
-      var url = window.location.pathname;
-      // var origin_path = getCookie('edlp_origin_path');
-      // console.log('origin_path', origin_path);
+      console.log('theme : initFirstLoad()');
+
       var origin_sys_path = window.localStorage.getItem('edlp_origin_path');
-      console.log('origin_sys_path', origin_sys_path);
-      var origin_url = window.localStorage.getItem('edlp_origin_url');
-      console.log('origin_url', origin_url);
       if(origin_sys_path){
+        var origin_url = window.localStorage.getItem('edlp_origin_url');
+        // origin_hash is used as viewmode for taxonomy term entrees load (index or notice)
+        var origin_hash = window.localStorage.getItem('edlp_origin_hash');
+        var view_mode = origin_hash.replace('#', '');
+        if(view_mode){
+          var $link = $('[href="'+origin_url+'"][viewmode="'+view_mode+'"]');
+          var selector = $link.attr('selector') || null;
+          if(selector){
+            // in case of entree link (actualy, selector is used only for entries links)
+            if(_corpus_ready){
+              _$corpus_canvas.trigger({
+                type:'open-entree',
+                tid:$link.attr('tid')
+              });
+            }else{
+              // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
+              // .is-active class is added by onAjaxLoaded() (when content is loaded)
+              // but what if corpus ready before onAjaxLoaded
+              $('li.entree[tid="'+$link.attr('tid')+'"] a.term-link').addClass('is-active');
+            }
+          }
+        }
+
         // create history state
-        var state = {
-          ajax_path: parseAjaxSysPath(origin_sys_path),
-          sys_path: origin_sys_path,
-        };
-        console.log('state', state);
+        var state = getSysPathState(origin_sys_path, view_mode);
+
+        // only if not entree path
+        if(state.ajax_path){
+          // load content through ajax
+          // ajaxLoadContent(null, state.sys_path, state.ajax_path, selector);
+          ajaxLoadContent(state);
+        }
+
+        // TODO what about entree alone (without notice or index)
+        if(state.entree_tid){
+          openEntree(state.entree_tid);
+        }
+
         // record history state
-        history.replaceState(state, null, origin_url);
-        // load content through ajax
-        ajaxLoadContent(null, state.sys_path, state.ajax_path);
+        history.replaceState(state, null, origin_url+origin_hash);
+
         // reset the storage
         window.localStorage.removeItem("edlp_origin_path");
         window.localStorage.removeItem("edlp_origin_url");
 
       }else{
-        history.replaceState({home:true}, null, url);
+        history.replaceState({home:true}, null, window.location.pathname);
         _$body.attr('booted', 'booted');
       }
     };
     function onHistoryPopState(e){
-      //console.log('onPopState',e);
+      console.log('onPopState',e.state);
       if(e.state.home){
         backToFrontPage();
       }else{
-        ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
+        if(e.state.entree_tid){
+          openEntree(e.state.entree_tid);
+        }
+        if(e.state.ajax_path){
+          e.state.url = null;
+          // ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
+          ajaxLoadContent(e.state);
+        }
       }
     };
 
@@ -338,7 +414,6 @@ console.log('EDLP THEME MAIN.js');
       }
 
       // other links
-      var url = $(this).attr('href');
       var sys_path = $(this).attr('data-drupal-link-system-path');
 
       // front page
@@ -349,15 +424,21 @@ console.log('EDLP THEME MAIN.js');
       }
 
       var view_mode = $link.attr('viewmode');
-      var ajax_path = parseAjaxSysPath(sys_path, view_mode);
+      var state = getSysPathState(sys_path, view_mode);
+      state.url = $(this).attr('href');
 
-      $link.addClass('ajax-loading');
+      if(view_mode){
+        state.url += "#"+view_mode;
+      }
 
       if($link.is('[selector]')){
-        var selector = $link.attr('selector');
+        state.selector = $link.attr('selector');
       }
 
-      ajaxLoadContent(url, sys_path, ajax_path, selector);
+      $link.addClass('ajax-loading');
+      // ajaxLoadContent(url, sys_path, state.ajax_path, selector);
+      ajaxLoadContent(state);
+
       return false;
     };
 
@@ -368,6 +449,7 @@ console.log('EDLP THEME MAIN.js');
     //              |_|
     function onCorpusMapReady(e){
       //console.log('theme : onCorpusReady', e);
+      _corpus_ready = true;
       _$corpus_canvas = $('canvas#corpus-map');
       _$corpus_canvas
         .on('corpus-cliked-on-map', function(e) {
@@ -386,6 +468,25 @@ console.log('EDLP THEME MAIN.js');
       _$body.attr('corpus-map', 'ready');
     }
 
+    function openEntree(tid){
+      if(tid){
+        closeAllModals();
+
+        _$body.removeClass();//.addClass(body_classes.join(' '));
+
+        // open entree
+        if(_corpus_ready){
+          _$corpus_canvas.trigger({
+            type:'open-entree',
+            tid:tid
+          });
+        }else{
+          // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
+          $('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');
+        }
+      }
+    };
+
     //    _          _ _
     //   /_\ _  _ __| (_)___
     //  / _ \ || / _` | / _ \
@@ -981,7 +1082,8 @@ console.log('EDLP THEME MAIN.js');
       // assume we are going back to front page
       $('body').removeClass().addClass('path-frontpage');
       $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
-
+      // TODO: close entrees
+      _$corpus_canvas.trigger({'type':'close-all-entree'});
     }
 
     function initHome(){

+ 1 - 0
sites/all/themes/custom/edlptheme/assets/scripts/history.js

@@ -4,6 +4,7 @@ if(edlp.redirect){
   console.log('history redirect');
   window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
   window.localStorage.setItem('edlp_origin_url', window.location.pathname);
+  window.localStorage.setItem('edlp_origin_hash', window.location.hash);
   // redirect to home
   window.location.replace(window.location.origin);
 }else{

+ 166 - 64
sites/all/themes/custom/edlptheme/assets/scripts/main.js

@@ -5,6 +5,7 @@ console.log('EDLP THEME MAIN.js');
     var _ajax_settings = drupalSettings.edlp_ajax;
     var _$body = $('body');
     var _is_front = _$body.is('.path-frontpage');
+    var _corpus_ready = false;
     var _$corpus_canvas;
     var _$row = $('main[role="main"]>.layout-content>.row');
     var _$ajaxLinks;
@@ -19,6 +20,8 @@ console.log('EDLP THEME MAIN.js');
     function init(){
       console.log("EdlpTheme init()");
 
+      initAjaxLinks();
+
       initHistory();
 
       if(!drupalSettings.path.isFront)
@@ -29,7 +32,6 @@ console.log('EDLP THEME MAIN.js');
       _audioPlayer = new AudioPlayer();
       _compoPlayer = new CompoPlayer();
 
-      initAjaxLinks();
 
       // if (_$body.is('.path-productions')) initProductions();
       // if(_$body.is('.path-frontpage')) initHome();
@@ -59,7 +61,31 @@ console.log('EDLP THEME MAIN.js');
           _compoPlayer.newCompo();
         })
         .on('search-results-loaded', initAjaxLinks)
-        .on('open_entree', closeAllModals)
+        // do not close index or notice modale on entree click
+        .on('open_entree', function(e){
+          console.log('on_open_entree : e', e);
+          closeAllModals();
+
+          // add body class for currently loaded content
+          // var body_classes = [
+          //   'path-'+sys_path.replace(/\//g, '-'),
+          //   'entity-type-'+data.entity_type,
+          //   'bundle-'+data.bundle,
+          //   'view-mode-'+data.view_mode
+          // ];
+          _$body.removeClass();//.addClass(body_classes.join(' '));
+
+          // record new history state
+          if(typeof e.url != 'undefined'){
+            // var state = {
+            //   ajax_path:null,
+            //   sys_path:null,
+            //   entree_tid:e.tid
+            // };
+            var state = getSysPathState(e.sys_path);
+            history.pushState(state, null, e.url);
+          }
+        })
         .on('close_entree', backToFrontPage);
     }
 
@@ -84,44 +110,56 @@ console.log('EDLP THEME MAIN.js');
     //  / _ \ | / _` \ \ /
     // /_/ \_\/ \__,_/_\_\
     //      |__/
-    function parseAjaxSysPath(sys_path, view_mode){
-      // console.log('Theme : parseAjaxSysPath', sys_path);
-      var ajax_path = sys_path;
+    function getSysPathState(sys_path, view_mode){
+      // console.log('Theme : getSysPathState', sys_path);
+      var state = {
+        'sys_path':sys_path,
+        'ajax_path': sys_path
+      };
 
       // convert node link to edlp_ajax_node module links
-      var node_match = ajax_path.match(/^\/?(node\/\d+)$/g);
-      var term_match = ajax_path.match(/^\/?(taxonomy\/term\/\d+)$/g);
+      var node_match = state.ajax_path.match(/^\/?(node\/(\d+))$/i);
+      console.log('node_match', node_match);
+      var term_match = state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);
+      console.log('term_match', term_match);
       if(node_match){
-        ajax_path = _ajax_settings.entityjson_path+'/'+node_match[0];
+        state.ajax_path = _ajax_settings.entityjson_path+'/'+node_match[1];
+        state.node_nid = node_match[2];
         // check for viewmode attribute
         if(view_mode){
-          ajax_path += '/'+view_mode;
+          state.ajax_path += '/'+view_mode;
         }
       }else if(term_match){
-        ajax_path = _ajax_settings.entityjson_path+'/'+term_match[0];
-        ajax_path = ajax_path.replace(/taxonomy\/term/, 'taxonomy_term');
+        // terms are always entrees, there's no other vocabulary links in front
+        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];
         // check for viewmode attribute
         if(view_mode){
-          ajax_path += '/'+view_mode;
+          state.ajax_path += '/'+view_mode;
+          state.view_mode = view_mode;
+        }else{
+          state.ajax_path = null;
         }
       }else{
         // convert other link to ajax
         // TODO: we assume that other links (no node, no term) are all from own modules (e.g. productions) !! may not be true !!
-        ajax_path += '/ajax'
+        state.ajax_path += '/ajax'
       }
-      return ajax_path;
+      return state;
     };
-    function ajaxLoadContent(url, sys_path, ajax_path, selector){
-      console.log('ajaxLoadContent : url', url);
+    // function ajaxLoadContent(url, sys_path, ajax_path, selector){
+    function ajaxLoadContent(state){
+      console.log('ajaxLoadContent : url', state.url);
       _$body.addClass('ajax-loading');
 
-      var path = window.location.origin + Drupal.url(ajax_path);
+      var path = window.location.origin + Drupal.url(state.ajax_path);
       $.getJSON(path, {})
         .done(function(data){
-          onAjaxLoaded(data, url, ajax_path, sys_path, selector);
+          onAjaxLoaded(data, state);
         })
         .fail(function(jqxhr, textStatus, error){
-          onAjaxLoadError(jqxhr, textStatus, error, sys_path);
+          onAjaxLoadError(jqxhr, textStatus, error, state.sys_path);
         });
     };
     function onAjaxLoadError(jqxhr, textStatus, error, sys_path){
@@ -129,22 +167,18 @@ console.log('EDLP THEME MAIN.js');
       $('.ajax-loading').removeClass('ajax-loading');
       _$body.removeClass('ajax-loading');
     };
-    function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
-      console.log('ajax loaded url:'+url+' ajax_path:'+ajax_path+' sys_path:'+sys_path);
+    // function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
+    function onAjaxLoaded(data, state){
+      console.log('ajax loaded url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
 
       // reset all style may been added by other pages (like masonry for productions)
       // and replace all content with newly loaded
       // TODO: build a system to replace or append contents (like studio + search)
       _$row.removeAttr('style').html(data.rendered);
 
-      // add close btn
-      if(sys_path != 'productions'){
-        addCloseBtnToCols();
-      }
-
       // add body class for currently loaded content
       var body_classes = [
-        'path-'+sys_path.replace(/\//g, '-'),
+        'path-'+state.sys_path.replace(/\//g, '-'),
         'entity-type-'+data.entity_type,
         'bundle-'+data.bundle,
         'view-mode-'+data.view_mode
@@ -152,8 +186,9 @@ console.log('EDLP THEME MAIN.js');
       _$body.removeClass().addClass(body_classes.join(' '));
 
       // id node add a generic path-node class to body
-      m = sys_path.match(/^\/?(node\/\d+)$/g);
-      if(m)
+      // m = state.sys_path.match(/^\/?(node\/\d+)$/g);
+      // if(m)
+      if(state.node_nid)
         _$body.addClass('path-edlp-node');
 
       // handle clicked link classes
@@ -161,10 +196,14 @@ console.log('EDLP THEME MAIN.js');
       $('.is-active').removeClass('is-active');
       $('.is-active-trail').removeClass('is-active-trail');
 
-      if(typeof selector != 'undefined'){
-        $('a[selector="'+selector+'"]').addClass('is-active');
+      if(typeof state.selector != 'undefined'){
+        // in case of entree link (actualy, selector is used only for entries links)
+        console.log('selector', state.selector);
+        $('a[selector="'+state.selector+'"]').addClass('is-active');
       }else{
-        $('a[data-drupal-link-system-path="'+sys_path+'"]').addClass('is-active');
+        $('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'});
       }
 
       // if bundle page (productions) activate production links
@@ -190,13 +229,17 @@ console.log('EDLP THEME MAIN.js');
 
       // initScrollbars();
 
-      if(sys_path == "productions")
+      if(state.sys_path == "productions"){
         initProductions();
+      }else{
+        addCloseBtnToCols();
+      }
 
       initAjaxLinks();
 
       // trigger other modules behaviours
       _$body.trigger({'type':'new-content-ajax-loaded'});
+
       // and call druapl behaviours
       Drupal.attachBehaviors(_$row[0]);
 
@@ -204,16 +247,17 @@ console.log('EDLP THEME MAIN.js');
       _$body.removeClass('ajax-loading');
 
 
-      var state = {
-        ajax_path:ajax_path,
-        sys_path:sys_path,
-      };
       // url is null means that we are loading content on popState event
       // so we don't record the state again
-      if(url){
+      if(state.url){
+        // var state = {
+        //   ajax_path:ajax_path,
+        //   sys_path:sys_path,
+        // };
         // console.log('url:'+url+' ; state',state);
+        // console.log(window.location);
         // we can not pushestate with absolute url
-        history.pushState(state, null, url);
+        history.pushState(state, null, state.url);
       }
     };
 
@@ -253,41 +297,73 @@ console.log('EDLP THEME MAIN.js');
       window.addEventListener('popstate', onHistoryPopState);
     };
     function initFirstLoad(){
-      console.log('theme : initFirstLoad()', window.location);
-      console.log(document.cookie);
-      var url = window.location.pathname;
-      // var origin_path = getCookie('edlp_origin_path');
-      // console.log('origin_path', origin_path);
+      console.log('theme : initFirstLoad()');
+
       var origin_sys_path = window.localStorage.getItem('edlp_origin_path');
-      console.log('origin_sys_path', origin_sys_path);
-      var origin_url = window.localStorage.getItem('edlp_origin_url');
-      console.log('origin_url', origin_url);
       if(origin_sys_path){
+        var origin_url = window.localStorage.getItem('edlp_origin_url');
+        // origin_hash is used as viewmode for taxonomy term entrees load (index or notice)
+        var origin_hash = window.localStorage.getItem('edlp_origin_hash');
+        var view_mode = origin_hash.replace('#', '');
+        if(view_mode){
+          var $link = $('[href="'+origin_url+'"][viewmode="'+view_mode+'"]');
+          var selector = $link.attr('selector') || null;
+          if(selector){
+            // in case of entree link (actualy, selector is used only for entries links)
+            if(_corpus_ready){
+              _$corpus_canvas.trigger({
+                type:'open-entree',
+                tid:$link.attr('tid')
+              });
+            }else{
+              // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
+              // .is-active class is added by onAjaxLoaded() (when content is loaded)
+              // but what if corpus ready before onAjaxLoaded
+              $('li.entree[tid="'+$link.attr('tid')+'"] a.term-link').addClass('is-active');
+            }
+          }
+        }
+
         // create history state
-        var state = {
-          ajax_path: parseAjaxSysPath(origin_sys_path),
-          sys_path: origin_sys_path,
-        };
-        console.log('state', state);
+        var state = getSysPathState(origin_sys_path, view_mode);
+
+        // only if not entree path
+        if(state.ajax_path){
+          // load content through ajax
+          // ajaxLoadContent(null, state.sys_path, state.ajax_path, selector);
+          ajaxLoadContent(state);
+        }
+
+        // TODO what about entree alone (without notice or index)
+        if(state.entree_tid){
+          openEntree(state.entree_tid);
+        }
+
         // record history state
-        history.replaceState(state, null, origin_url);
-        // load content through ajax
-        ajaxLoadContent(null, state.sys_path, state.ajax_path);
+        history.replaceState(state, null, origin_url+origin_hash);
+
         // reset the storage
         window.localStorage.removeItem("edlp_origin_path");
         window.localStorage.removeItem("edlp_origin_url");
 
       }else{
-        history.replaceState({home:true}, null, url);
+        history.replaceState({home:true}, null, window.location.pathname);
         _$body.attr('booted', 'booted');
       }
     };
     function onHistoryPopState(e){
-      //console.log('onPopState',e);
+      console.log('onPopState',e.state);
       if(e.state.home){
         backToFrontPage();
       }else{
-        ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
+        if(e.state.entree_tid){
+          openEntree(e.state.entree_tid);
+        }
+        if(e.state.ajax_path){
+          e.state.url = null;
+          // ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
+          ajaxLoadContent(e.state);
+        }
       }
     };
 
@@ -338,7 +414,6 @@ console.log('EDLP THEME MAIN.js');
       }
 
       // other links
-      var url = $(this).attr('href');
       var sys_path = $(this).attr('data-drupal-link-system-path');
 
       // front page
@@ -349,15 +424,21 @@ console.log('EDLP THEME MAIN.js');
       }
 
       var view_mode = $link.attr('viewmode');
-      var ajax_path = parseAjaxSysPath(sys_path, view_mode);
+      var state = getSysPathState(sys_path, view_mode);
+      state.url = $(this).attr('href');
 
-      $link.addClass('ajax-loading');
+      if(view_mode){
+        state.url += "#"+view_mode;
+      }
 
       if($link.is('[selector]')){
-        var selector = $link.attr('selector');
+        state.selector = $link.attr('selector');
       }
 
-      ajaxLoadContent(url, sys_path, ajax_path, selector);
+      $link.addClass('ajax-loading');
+      // ajaxLoadContent(url, sys_path, state.ajax_path, selector);
+      ajaxLoadContent(state);
+
       return false;
     };
 
@@ -368,6 +449,7 @@ console.log('EDLP THEME MAIN.js');
     //              |_|
     function onCorpusMapReady(e){
       //console.log('theme : onCorpusReady', e);
+      _corpus_ready = true;
       _$corpus_canvas = $('canvas#corpus-map');
       _$corpus_canvas
         .on('corpus-cliked-on-map', function(e) {
@@ -386,6 +468,25 @@ console.log('EDLP THEME MAIN.js');
       _$body.attr('corpus-map', 'ready');
     }
 
+    function openEntree(tid){
+      if(tid){
+        closeAllModals();
+
+        _$body.removeClass();//.addClass(body_classes.join(' '));
+
+        // open entree
+        if(_corpus_ready){
+          _$corpus_canvas.trigger({
+            type:'open-entree',
+            tid:tid
+          });
+        }else{
+          // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
+          $('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');
+        }
+      }
+    };
+
     //    _          _ _
     //   /_\ _  _ __| (_)___
     //  / _ \ || / _` | / _ \
@@ -981,7 +1082,8 @@ console.log('EDLP THEME MAIN.js');
       // assume we are going back to front page
       $('body').removeClass().addClass('path-frontpage');
       $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
-
+      // TODO: close entrees
+      _$corpus_canvas.trigger({'type':'close-all-entree'});
     }
 
     function initHome(){

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov