Вход Регистрация
Файл: backup_fzrf 2/templates/Old/js/jquery.photo.js
Строк: 169
<?php
$.fn.wookmark = function(options) {
  
  if(!
this.wookmarkOptions) {
    
this.wookmarkOptions = $.extend( {
        
container: $('tiles'),
        
offset3,
        
autoResizefalse,
        
itemWidth: $(this[0]).outerWidth(),
        
resizeDelay50
      
}, options);
  } else if(
options) {
    
this.wookmarkOptions = $.extend(this.wookmarkOptionsoptions);
  }
  
  
// Layout variables.
  
if(!this.wookmarkColumns) {
    
this.wookmarkColumns null;
    
this.wookmarkContainerWidth null;
  }
  
  
// Main layout function.
  
this.wookmarkLayout = function() {
    
// Calculate basic layout parameters.
    
var columnWidth this.wookmarkOptions.itemWidth this.wookmarkOptions.offset;
    var 
containerWidth this.wookmarkOptions.container.width();
    var 
columns Math.floor((containerWidth+this.wookmarkOptions.offset)/columnWidth);
    var 
offset Math.round((containerWidth - (columns*columnWidth-this.wookmarkOptions.offset))/2);
    
    
// If container and column count hasn't changed, we can only update the columns.
    
var bottom 0;
    if(
this.wookmarkColumns != null && this.wookmarkColumns.length == columns) {
      
bottom this.wookmarkLayoutColumns(columnWidthoffset);
    } else {
      
bottom this.wookmarkLayoutFull(columnWidthcolumnsoffset);
    }
    
    
// Set container height to height of the grid.
    
this.wookmarkOptions.container.css('height'bottom+'px');
  };
  
  
/**
   * Perform a full layout update.
   */
  
this.wookmarkLayoutFull = function(columnWidthcolumnsoffset) {
    
// Prepare Array to store height of columns.
    
var heights = [];
    while(
heights.length columns) {
      
heights.push(0);
    }
    
    
// Store column data.
    
this.wookmarkColumns = [];
    while(
this.wookmarkColumns.length columns) {
      
this.wookmarkColumns.push([]);
    }
    
    
// Loop over items.
    
var itemtoplefti=0k=0length=this.lengthshortest=nullshortestIndex=nullbottom 0;
    for(; 
i<lengthi++ ) {
      
item = $(this[i]);
      
      
// Find the shortest column.
      
shortest null;
      
shortestIndex 0;
      for(
k=0k<columnsk++) {
        if(
shortest == null || heights[k] < shortest) {
          
shortest heights[k];
          
shortestIndex k;
        }
      }
      
      
// Postion the item.
      
item.css({
        
position'absolute',
        
topshortest+'px',
        
left: (shortestIndex*columnWidth offset)+'px'
      
});
      
      
// Update column height.
      
heights[shortestIndex] = shortest item.outerHeight() + this.wookmarkOptions.offset;
      
bottom Math.max(bottomheights[shortestIndex]);
      
      
this.wookmarkColumns[shortestIndex].push(item);
    }
    
    return 
bottom;
  };
  
  
/**
   * This layout function only updates the vertical position of the 
   * existing column assignments.
   */
  
this.wookmarkLayoutColumns = function(columnWidthoffset) {
    var 
heights = [];
    while(
heights.length this.wookmarkColumns.length) {
      
heights.push(0);
    }
    
    var 
i=0length this.wookmarkColumns.lengthcolumn;
    var 
k=0kLengthitem;
    var 
bottom 0;
    for(; 
i<lengthi++) {
      
column this.wookmarkColumns[i];
      
kLength column.length;
      for(
k=0k<kLengthk++) {
        
item column[k];
        
item.css({
          
left: (i*columnWidth offset)+'px',
          
topheights[i]+'px'
        
});
        
heights[i] += item.outerHeight() + this.wookmarkOptions.offset;
        
        
bottom Math.max(bottomheights[i]);
      }
    }
    
    return 
bottom;
  };
  
  
// Listen to resize event if requested.
  
this.wookmarkResizeTimer null;
  if(!
this.wookmarkResizeMethod) {
    
this.wookmarkResizeMethod null;
  }
  if(
this.wookmarkOptions.autoResize) {
    
// This timer ensures that layout is not continuously called as window is being dragged.
    
this.wookmarkOnResize = function(event) {
      if(
this.wookmarkResizeTimer) {
        
clearTimeout(this.wookmarkResizeTimer);
      }
      
this.wookmarkResizeTimer setTimeout($.proxy(this.wookmarkLayoutthis), this.wookmarkOptions.resizeDelay)
    };
    
    
// Bind event listener.
    
if(!this.wookmarkResizeMethod) {
      
this.wookmarkResizeMethod = $.proxy(this.wookmarkOnResizethis);
    }
    $(
window).resize(this.wookmarkResizeMethod);
  };
  
  
/**
   * Clear event listeners and time outs.
   */
  
this.wookmarkClear = function() {
    if(
this.wookmarkResizeTimer) {
      
clearTimeout(this.wookmarkResizeTimer);
      
this.wookmarkResizeTimer null;
    }
    if(
this.wookmarkResizeMethod) {
      $(
window).unbind('resize'this.wookmarkResizeMethod);
    }
  };
  
  
// Apply layout
  
this.wookmarkLayout();
  
  
// Display items (if hidden).
  
this.show();
};
?>
Онлайн: 0
Реклама