Changeset 66639 in spip-zone


Ignore:
Timestamp:
Oct 10, 2012, 7:50:26 AM (7 years ago)
Author:
cedric@…
Message:

mise en forme js de la grille des albums sur la home. On verra si on generalise le script...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • _squelettes_/sarkaspip/trunk/noisettes/sommaire/inc_albums_recents.html

    r66633 r66639  
    3636        </div>
    3737</B_album>
     38<script type="text/javascript">/*<![CDATA[*/
     39var colEqualize = function(selector){
     40        var currentTallest = 0,
     41             currentRowStart = 0,
     42             rowDivs = new Array(),
     43             $el,
     44             topPosition = 0;
     45
     46        jQuery(selector).each(function() {
     47
     48         $el = $(this);
     49         topPostion = $el.position().top;
     50
     51         if (currentRowStart != topPostion) {
     52           // we just came to a new row.  Set all the heights on the completed row
     53           for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
     54             rowDivs[currentDiv].height(currentTallest);
     55           }
     56
     57           // set the variables for the new row
     58           rowDivs.length = 0; // empty the array
     59           currentRowStart = topPostion;
     60           currentTallest = $el.height();
     61           rowDivs.push($el);
     62
     63         } else {
     64           // another div on the current row.  Add it to the list and check if it's taller
     65           rowDivs.push($el);
     66           currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
     67        }
     68
     69         // do the last row
     70         for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
     71           rowDivs[currentDiv].height(currentTallest);
     72         }
     73
     74        });
     75}
     76var activeColEqualization = function(selector){
     77        var t = null;
     78        jQuery(selector).height('auto');
     79        t = setTimeout(function(){colEqualize(selector)},250);
     80        jQuery(window).resize(function(){
     81                if (t) clearTimeout(t);
     82                t = setTimeout(function(){colEqualize(selector)},500);
     83        });
     84}
     85jQuery(function(){
     86        activeColEqualization('#albums_recents .thumbnails .thumbnail');
     87});
     88/*]]>*/</script>
Note: See TracChangeset for help on using the changeset viewer.