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

    
jLayout.flow = function (options) {
        var 
my = {},
            
that = {};

        
        
my.hgap typeof options.hgap === 'number' && !isNaN(options.hgap) ? options.hgap 5;
        
my.vgap typeof options.vgap === 'number' && !isNaN(options.vgap) ? options.vgap 5;
        
my.items options.items || [];
        
my.alignment = (options.alignment && (options.alignment === 'center' || options.alignment === 'right' || options.alignment === 'left') && options.alignment) || 'left';        

        
that.items = function () {
            var 
= [];
            Array.
prototype.push.apply(rmy.items);
            return 
r;
        };

        function 
align(rowoffsetrowSizeparentSize) {
            var 
location = {
                    
xoffset.x,
                    
yoffset.y
                
},
                
0,
                
len row.length;

            switch (
my.alignment) {
            case 
'center':
                
location.+= (my.hgap parentSize.width rowSize.width) / 2;
                break;
            case 
'right':
                
location.+= parentSize.width rowSize.width my.hgap;
                break;
            }

            for (; 
len+= 1) {
                
location.offset.y;
                
row[i].bounds(location);
                
row[i].doLayout();
                
location.+= row[i].bounds().width my.hgap;
            }
        }

        
that.layout = function (container) {
            var 
parentSize container.bounds(),
                
insets container.insets(),
                
0,
                
len my.items.length,
                
itemSize,
                
currentRow = [],
                
rowSize = {
                    
width0,
                    
height0
                
},
                
offset = {
                    
xinsets.left,
                    
yinsets.top
                
};

            
parentSize.width -= insets.left insets.right;
            
parentSize.height -= insets.top insets.bottom;

            for (; 
len+= 1) {
                if (
my.items[i].isVisible()) {
                    
itemSize my.items[i].preferredSize();
                    
                    if ((
rowSize.width itemSize.width) > parentSize.width) {
                        
align(currentRowoffsetrowSizeparentSize);

                        
currentRow = [];
                        
offset.+= rowSize.height;
                        
offset.insets.left;
                        
rowSize.width 0;
                        
rowSize.height 0;
                    }
                    
rowSize.height Math.max(rowSize.heightitemSize.height my.vgap);
                    
rowSize.width += itemSize.width my.hgap;

                    
currentRow.push(my.items[i]);
                }
            }
            
align(currentRowoffsetrowSizeparentSize);
            return 
container;
        };



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

                for (; 
my.items.length+= 1) {
                    if (
my.items[i].isVisible()) {
                        
typeSize my.items[i][type 'Size']();
                        
height Math.max(heighttypeSize.height);
                        
width += typeSize.width;
                    }
                }

                return {
                    
'width'width insets.left insets.right + (my.items.length 1) * my.hgap,
                    
'height'height insets.top insets.bottom
                
};
            };
        }

        
that.preferred typeLayout('preferred');
        
that.minimum typeLayout('minimum');
        
that.maximum typeLayout('maximum');        

        return 
that;
    };
}());
?>
Онлайн: 0
Реклама