Вход Регистрация
Файл: framework/admin/thirdparty/jlayout/lib/jlayout.grid.js
Строк: 86
<?php
/**
 * @preserve jLayout Grid Layout - JavaScript Layout Algorithms v0.41
 *
 * Licensed under the new BSD License.
 * Copyright 2008-2009, Bram Stein
 * All rights reserved.
 */
/*global jLayout:true */
(function () {
    
jLayout = (typeof jLayout === 'undefined') ? {} : jLayout;

    
jLayout.grid = function (specshared) {
        var 
my shared || {},
            
that = {};

        
my.hgap spec.hgap || 0;
        
my.vgap spec.vgap || 0;

        
// initialize the number of columns to the number of items
        // we're laying out.
        
my.items spec.items || [];
        
my.columns spec.columns || my.items.length;
        
my.rows spec.rows || 0;
        
my.fillVertical spec.fill && spec.fill === 'vertical';

        if (
my.rows 0) {
            
my.columns Math.floor((my.items.length my.rows 1) / my.rows); 
        } else {
            
my.rows Math.floor((my.items.length my.columns 1) / my.columns);
        }
    
        
that.items = function () {
            var 
= [];
            Array.
prototype.push.apply(rmy.items);
            return 
r;
        };

        
that.layout = function (container) {
            var 
ij,
                
insets container.insets(),
                
insets.left,
                
insets.top,
                
width = (container.bounds().width - (insets.left insets.right) - (my.columns 1) * my.hgap) / my.columns,
                
height = (container.bounds().height - (insets.top insets.bottom) - (my.rows 1) * my.vgap) / my.rows;

            for (
01my.items.length+= 1+= 1) {
                
my.items[i].bounds({'x'x'y'y'width'width'height'height});

                if (!
my.fillVertical) {
                    if (
>= my.columns) {
                        
+= height my.vgap;
                        
insets.left;
                        
0;
                    }
                    else {
                        
+= width my.hgap;
                    }
                } else {
                    if (
>= my.rows) {
                        
+= width my.hgap;
                        
insets.top;
                        
0;
                    } else {
                        
+= height my.vgap;
                    }
                }
                
my.items[i].doLayout();
            }
            return 
container;
        };

        function 
typeLayout(type) {
            return function (
container) {
                var 
0
                    
width 0
                    
height 0
                    
type_size,
                    
insets container.insets();

                for (; 
my.items.length+= 1) {
                    
type_size my.items[i][type 'Size']();
                    
width Math.max(widthtype_size.width);
                    
height Math.max(heighttype_size.height);
                }
                return {
                    
'width'insets.left insets.right my.columns width + (my.columns 1) * my.hgap
                    
'height'insets.top insets.bottom my.rows height + (my.rows 1) * my.vgap
                
};
            };
        }

        
// this creates the min and preferred size methods, as they
        // only differ in the function they call.
        
that.preferred typeLayout('preferred');
        
that.minimum typeLayout('minimum');
        
that.maximum typeLayout('maximum');
        return 
that;
    };
}());
?>
Онлайн: 0
Реклама