Advertisement
Mihalytch

Untitled

Dec 12th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var eqRndHight=function(slctr){
  2.         var maxHeightRnd = 0;
  3.         var styleRnd = 'position: absolute !important; top: -1000em !important; visibility: hidden !important; display: block !important; ';
  4.  
  5.         $(slctr).each(function(){
  6.  
  7.             var currentRndHeight = 0;
  8.             if($(this).is(":visible") && $(this).outerHeight()>0){
  9.                 this.style.height = 'auto' ;
  10.                 currentRndHeight = $(this).height();
  11.             }else{
  12.                 var true_element = $(this).clone().attr( 'style', styleRnd ).appendTo( 'body' );
  13.                 true_element.style.height = 'auto' ;  
  14.                 currentRndHeight = true_element.outerHeight();
  15.                 true_element.remove();
  16.             }
  17.  
  18.             maxHeightRnd = maxHeightRnd < currentRndHeight ? currentRndHeight : maxHeightRnd;
  19.         });
  20.  
  21.         if(maxHeightRnd>0){
  22.             $(slctr).height(maxHeightRnd);
  23. //          console.log(slctr + ' : ' + maxHeightRnd);
  24.         }
  25.     };
  26.    
  27.     var eqRndHight_run = function() {
  28.         var groups = {};
  29.        
  30.         $('[data-valign]').each(function(){
  31.             var $this = $(this);
  32.             var group = $this.attr('data-valign');
  33.            
  34.             if (typeof groups[group] === 'undefined') {
  35.                 groups[group] = [];
  36.             }
  37.            
  38.             groups[group].push( this );
  39.         });
  40.        
  41.         for( var k in groups ) {
  42.             eqRndHight( groups[k] );
  43.         }
  44.        
  45.     };
  46.    
  47.     $(document).on('ready', eqRndHight_run);
  48.     $(window).on('load resize', eqRndHight_run);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement