Blame view

framework/admin/thirdparty/jlayout/lib/jlayout.column.js 2.01 KB
0084d336   Administrator   Importers CRUD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
  /**
   * @preserve jLayout Column Layout - JavaScript Layout Algorithms v0.1
   *
   * Licensed under the new BSD License.
   * Copyright 2008-2009, Bram Stein
   * All rights reserved.
   */
  /*global jLayout */
  /*
  (function () {
  	jLayout = typeof jLayout === 'undefined' ? {} : jLayout;
  
  	jLayout.column = function (options) {	
  		var that = {},
  			my = {};
  
  		my.hgap = options.hgap || 0;
  		my.vgap = options.vgap || 0;
  		my.columns = options.columns || 2;
  		my.items = options.items || [];
  		my.maxHeight = options.maxHeight || -1;
  
  		that.items = function () {
  			var r = [];
  			Array.prototype.push.apply(r, my.items);
  			return r;
  		};
  
  		that.layout = function (container) {
  			var i = 0, j = 1,
  				insets = container.insets(),
  				x = insets.left,
  				y = insets.top,
  				rows = 0,
  				width = (container.bounds().width - (insets.left + insets.right) - (my.columns - 1) * my.hgap) / my.columns,
  				// TODO: if maxHeight is not available the height should be the height that divides the content equally over all columns.
  				height = my.maxHeight,
  				itemSize;
  
  	//		container.bounds({'height': height * 4});
  
  			console.log(height);
  
  			for (; i < my.items.length; i += 1) {
  				my.items[i].bounds({'width': width});
  			}
  			for (i = 0; i < my.items.length; i += 1) {
  				itemSize = my.items[i].preferredSize();
  
  				if (y + itemSize.height + my.hgap > height) {
  					if (j === my.columns) {
  						rows += 1;
  						y = insets.top + my.hgap + height * rows;
  						x = insets.left;
  						j = 1;
  						
  					} else {
  						y = insets.top + (rows * height);
  						x += width + my.vgap;
  						j += 1;
  					}
  				} 
  				my.items[i].bounds({'x': x, 'y': y});
  				y += itemSize.height + my.hgap;
  				
  				my.items[i].doLayout();
  			}			
  
  			//console.log(width);
  			return container;
  		};
  
  		function typeLayout(type) {
  			return function (container) {
  				return {
  					width: 800,
  					height: 600
  				};
  			};
  		}
  
  		that.preferred = typeLayout('preferred');
  		that.minimum = typeLayout('minimum');
  		that.maximum = typeLayout('maximum');	
  	
  		return that;
  	};
  })();*/