Explorar o código

improved grid display without masonry

Bachir Soussi Chiadmi %!s(int64=7) %!d(string=hai) anos
pai
achega
cab8fca868

+ 2 - 1
sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js

@@ -50,7 +50,8 @@ return this;},showHideControls(){if(this.$controls){if(this.playing&&!this.pause
 if(this.$playpause){if(this.playlist.length>0){this.$playpause.addClass('is-active');}else{this.$playpause.removeClass('is-active');}}
 if(this.$next){if(this.playing&&this.playlist.length>1&&this.current_index<this.playlist.length-1){this.$next.addClass('is-active');}else{this.$next.removeClass('is-active');}}
 if(this.$previous){if(this.playing&&this.playlist.length>1&&this.current_index>0){this.$previous.addClass('is-active');}else{this.$previous.removeClass('is-active');}}
-return this;},deactivate(){this.stop();this.active=false;},onAudioOpenDocument(args){if(args.caller!==this){this.reset();}},onAudioPlayerPlay(){if(this.playing&&this.paused){this.paused=false;this.showHideControls();}},onAudioPlayerPause(){if(this.playing&&!this.paused){this.paused=true;this.showHideControls();}},onAudioPlayerEnded(){if(this.playing){this.next();}},};function initGrid(){void 0;checkGridBlockHeight();_$row.find('.col').addClass('offfield');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{checkGridBlockVisible();}};function checkGridBlockHeight(){void 0;var $r_h=_$row.height();$('.grid .col',_$row).each(function(i,e){if($(this).height()>$r_h){$(this).height($r_h);}});};function checkGridBlockVisible(){void 0;var $r_h=_$row.height();var $this,pos;$('.grid .col',_$row).each(function(i,e){$this=$(this);pos=$this.position();void 0;if(pos.top+$this.height()<=$r_h){$this.removeClass('offfield');}});}
+return this;},deactivate(){this.stop();this.active=false;},onAudioOpenDocument(args){if(args.caller!==this){this.reset();}},onAudioPlayerPlay(){if(this.playing&&this.paused){this.paused=false;this.showHideControls();}},onAudioPlayerPause(){if(this.playing&&!this.paused){this.paused=true;this.showHideControls();}},onAudioPlayerEnded(){if(this.playing){this.next();}},};function initGrid(){void 0;checkGridBlockHeight();_$row.find('.col').addClass('offfield');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{checkGridBlockVisible();}};function checkGridBlockHeight(){void 0;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(){void 0;var $r_h=_$row.height();var $this,pos;$('.grid .col',_$row).each(function(i,e){$this=$(this);pos=$this.position();void 0;if(pos.top+$this.height()<=$r_h){$this.removeClass('offfield');}else{$this.addClass('offfield');}});}
 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');_$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,drupalSettings.path.baseUrl+drupalSettings.path.currentLanguage);}}
 function initHome(){addCloseModalBtnToCols();return;void 0;var $grid=$('.grid',_$row).masonry({itemSelector:'.col',columnWidth:'.col-2',horizontalOrder:true,containerStyle:null,});$grid.imagesLoaded().progress(function(){$grid.masonry('layout');});$grid.imagesLoaded(function(){$grid.masonry('layout');});}
 function closeAllModals(){_$row.html('');_$ajaxLinks.removeClass('is-active');_$body.trigger({'type':'all-modal-closed'});};function checkRowEmpty(){if(!$('.col',_$row).length){if(!_$body.is('.entity-type-taxonomy_term.bundle-entrees')){if(!_$body.is('.entity-type-node.bundle-page')){backToFrontPage();}else{_$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();}

+ 13 - 4
sites/all/themes/custom/edlptheme/assets/scripts/main.js

@@ -1537,13 +1537,20 @@
     function checkGridBlockHeight(){
       console.log('checkGridBlockHeight');
       var $r_h = _$row.height();
+      var $this;
       // console.log($r_h);
       $('.grid .col', _$row).each(function(i,e){
-        // console.log($(this).height(), $(this).innerHeight(), $(this).outerHeight());
-        if($(this).height() > $r_h){
-          $(this).height($r_h);
+        $this = $(this);
+        if(!$this.is('[init-height]')){
+          $this.attr('init-height', $this.outerHeight())
         }
-        // $(this).innerHeight(Math.min($(this).innerHeight(), _$row.height()));
+        // console.log($(this).height(), $(this).innerHeight(), $(this).outerHeight());
+        // if($this.height() > $r_h){
+        //   $this.height($r_h);
+        // }else{
+        //   $this.height('auto');
+        // }
+        $this.height(Math.min($this.attr('init-height'), _$row.height()));
       });
     };
 
@@ -1558,6 +1565,8 @@
           console.log(pos.top, $this.height(), pos.top+$this.height(), $r_h, $this);
           if(pos.top+$this.height() <= $r_h){
             $this.removeClass('offfield');
+          }else{
+            $this.addClass('offfield');
           }
         // });
       });

+ 1 - 0
sites/all/themes/custom/edlptheme/assets/styles/app.scss

@@ -1512,6 +1512,7 @@ body.path-frontpage, body.path-productions{
 
           }
           &.node--view-mode-text-1-column{
+            // box-sizing: border-box;
             padding:0 1em;
           }
         }