Skip to content

Commit ce59114

Browse files
committed
After implementing heights (without testing yet)...
1 parent 00b6cfa commit ce59114

6 files changed

Lines changed: 324 additions & 33 deletions

File tree

js/almcss3/almcss.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ var ALMCSS = function() {
127127
positionedElements = ALMCSS.template.positionedElements,
128128
moveElementsIntoSlots = ALMCSS.template.dom.moveElementsIntoSlots,
129129
computeWidths = ALMCSS.template.sizing.computeWidths,
130+
computeHeights = ALMCSS.template.sizing.computeHeights,
130131
i;
131132

132133
info('Starting the main function of ALMCSS3...');
@@ -146,6 +147,7 @@ var ALMCSS = function() {
146147
createTemplateElements(templates);
147148
moveElementsIntoSlots(positionedElements);
148149
computeWidths(templates);
150+
computeHeights(templates);
149151
};
150152

151153
// Loading Modules

js/almcss3/domUtils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ ALMCSS.domUtils = function() {
137137
getComputedHeight: getComputedHeight,
138138
lengthToPixels: lengthToPixels,
139139
computeIntrinsicPreferredWidth: computeIntrinsicPreferredWidth,
140-
computeIntrinsicMinimumWidth: computeIntrinsicMinimumWidth
140+
computeIntrinsicMinimumWidth: computeIntrinsicMinimumWidth,
141+
computeContentHeight: computeContentHeight
141142
};
142143

143144
}();

js/almcss3/template/dom.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,52 @@ ALMCSS.template.dom = function() {
113113
}
114114
};
115115

116+
// Painting
117+
// --------
118+
119+
var paintTemplate = function (template) {
120+
121+
var getColumnOffset = function (column) {
122+
var computedWidths = template.computedWidths,
123+
result = 0, i;
124+
for (i = 0; i < column; i++) {
125+
result = result + computedWidths[i];
126+
}
127+
return result;
128+
};
129+
130+
var getRowOffset = function (row) {
131+
var rows = template.getRows(),
132+
result = 0, i;
133+
for (i = 0; i < row; i++) {
134+
result = result + rows[i].computedHeight;
135+
}
136+
return result;
137+
};
138+
139+
var slot, htmlElement, slotsIterator = template.iterator();
140+
while (slotsIterator.hasNext()) {
141+
slot = slotsIterator.next();
142+
htmlElement = slot.htmlElement;
143+
htmlElement.style.left = getColumnOffset(slot.startColumn);
144+
htmlElement.style.top = getRowOffset(slot.startRow);
145+
htmlElement.style.width = slot.computedWidth;
146+
htmlElement.style.height = slot.computedHeight;
147+
htmlElement.style.position = 'absolute';
148+
}
149+
150+
};
151+
152+
var paint = function (templates) {
153+
for (var i = 0; i < templates.length; i++) {
154+
paintTemplate(templates[i]);
155+
}
156+
};
157+
116158
return {
117159
createTemplateElements: createTemplateElements,
118-
moveElementsIntoSlots: moveElementsIntoSlots
160+
moveElementsIntoSlots: moveElementsIntoSlots,
161+
paint: paint
119162
};
120163

121164
}();

js/almcss3/template/layout.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)