Browse Source

fixed back to home mobile #423

Bachir Soussi Chiadmi 5 years ago
parent
commit
11d54412cd

+ 2 - 2
web/themes/custom/edlptheme/assets/dist/scripts/main.min.js

@@ -95,9 +95,9 @@ function initGrid(){void 0;if(!_is_mobile){checkGridBlockHeight();_$row.find('.c
 if(false){var $grid=$('.grid',_$row).masonry({itemSelector:'.col',columnWidth:'.col-2',containerStyle:null,resizeContainer:false,transitionDuration:0,});$grid.imagesLoaded().progress(function(){$grid.masonry('layout');});$grid.imagesLoaded(function(){$grid.masonry('layout');});$grid.on('layoutComplete',checkGridBlockVisible);}else{if(!_is_mobile){checkGridBlockVisible();}}};function checkGridBlockHeight(){var $r_h=_$row.height();var $this;$('.grid .col',_$row).each(function(i,e){$this=$(this);if(!$this.is('[init-height]')){$this.attr('init-height',$this.outerHeight())}
 $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 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'});}
+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;if(!_is_mobile){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;state={home:true,context:"home",caller:null}
-_states_history.unshift(state);history.pushState(state,null,_base_url+drupalSettings.path.currentLanguage);}}
+_states_history.unshift(state);history.pushState(state,null,_base_url+drupalSettings.path.currentLanguage);}}else{ajaxLoadContent({home:true,ajax_path:'home_m/ajax',sys_path:'frontpage'});}}
 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);

+ 24 - 18
web/themes/custom/edlptheme/assets/scripts/main.js

@@ -829,7 +829,7 @@
       }
     };
     function onHistoryPopState(e){
-      console.log('onPopState',e.state);
+      console.log('onHistoryPopState',e.state);
       if(e.state.home){
         backToFrontPage(true);
       }
@@ -2247,25 +2247,31 @@
     //                             |___/
     function backToFrontPage(pop_state){
       console.log('backToFrontPage', pop_state);
-      closeAllModals();
-      // assume we are going back to front page
-      $('body').removeClass().addClass('path-frontpage');
-      $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
-      // close entrees
-      if(_corpus_ready){
-        _$corpus_canvas.trigger({'type':'close-all-entree'});
-        _$corpus_canvas.trigger({'type':'scramble-collection'});
-      }
 
-      if(typeof pop_state == "undefined" || !pop_state){
-        console.log('backToFrontPage push state');
-        state = {
-          home:true,
-          context:"home",
-          caller:null
+      if(!_is_mobile){
+        closeAllModals();
+        // assume we are going back to front page
+        $('body').removeClass().addClass('path-frontpage');
+        $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
+        // close entrees
+        if(_corpus_ready){
+          _$corpus_canvas.trigger({'type':'close-all-entree'});
+          _$corpus_canvas.trigger({'type':'scramble-collection'});
         }
-        _states_history.unshift(state);
-        history.pushState(state, null, _base_url+drupalSettings.path.currentLanguage);
+
+        if(typeof pop_state == "undefined" || !pop_state){
+          console.log('backToFrontPage push state');
+          state = {
+            home:true,
+            context:"home",
+            caller:null
+          }
+          _states_history.unshift(state);
+          history.pushState(state, null, _base_url+drupalSettings.path.currentLanguage);
+        }
+      }else{
+        // if mobile reload the front page
+        ajaxLoadContent({home: true, ajax_path: 'home_m/ajax', sys_path: 'frontpage'});
       }
     }