on master help sign in
fix spacing again
commit3c7f45ff0a8287dde6e6b6978d55b4fff9d3c650 authorEvan Czaplicki <info@elm-lang.org> dateThu 1 Aug 2013, 19:46 (13 years ago) parent62dc6e8
1 file changed+73−73
runtime/Render/Element.js+73−73
runtime/Render/Element.js+73−73
@@ -12,15 +12,15 @@ function setProps(props, e) {
1212 e.style.height = (props.height|0) + 'px';
1313 if (props.opacity !== 1) { e.style.opacity = props.opacity; }
1414 if (props.color.ctor === 'Just') {
15− e.style.backgroundColor = extract(props.color._0);
15+ e.style.backgroundColor = extract(props.color._0);
1616 }
1717 if (props.tag !== '') { e.id = props.tag; }
1818 if (props.href !== '') {
19− var a = newElement('a');
20− a.href = props.href;
19+ var a = newElement('a');
20+ a.href = props.href;
2121 a.style.display = 'block';
22− a.appendChild(e);
23− return a;
22+ a.appendChild(e);
23+ return a;
2424 }
2525 if (props.hover.ctor !== '_Tuple0') {
2626 var overCount = 0;
@@ -77,11 +77,11 @@ function croppedImage(elem, w, h, src) {
7777
7878 var img = newElement('img');
7979 img.onload = function() {
80− var sw = w / elem._1, sh = h / elem._2;
81− img.style.width = ((this.width * sw)|0) + 'px';
82− img.style.height = ((this.height * sh)|0) + 'px';
83− img.style.marginLeft = ((- pos._0 * sw)|0) + 'px';
84− img.style.marginTop = ((- pos._1 * sh)|0) + 'px';
80+ var sw = w / elem._1, sh = h / elem._2;
81+ img.style.width = ((this.width * sw)|0) + 'px';
82+ img.style.height = ((this.height * sh)|0) + 'px';
83+ img.style.marginLeft = ((- pos._0 * sw)|0) + 'px';
84+ img.style.marginTop = ((- pos._1 * sh)|0) + 'px';
8585 };
8686 img.src = src;
8787 img.name = src;
@@ -95,7 +95,7 @@ function goRight(e) { e.style.styleFloat = e.style.cssFloat = "left"; return e;
9595function flowWith(f, array) {
9696 var container = newElement('div');
9797 for (var i = array.length; i--; ) {
98− container.appendChild(f(render(array[i])));
98+ container.appendChild(f(render(array[i])));
9999 }
100100 return container;
101101}
@@ -170,8 +170,8 @@ function update(node, curr, next) {
170170 if (node.tagName === 'A') { node = node.firstChild; }
171171 if (curr.props.id === next.props.id) return updateProps(node, curr, next);
172172 if (curr.element.ctor !== next.element.ctor) {
173− node.parentNode.replaceChild(render(next),node);
174− return true;
173+ node.parentNode.replaceChild(render(next),node);
174+ return true;
175175 }
176176 var nextE = next.element, currE = curr.element;
177177 switch(nextE.ctor) {
@@ -180,61 +180,61 @@ function update(node, curr, next) {
180180 if (nextE._0 !== currE._0) node.innerHTML = nextE._0;
181181 break;
182182 case "Image":
183− if (nextE._0.ctor === 'Plain') {
184− if (nextE._3 !== currE._3) node.src = nextE._3;
185− } else if (!eq(nextE,currE) ||
186− next.props.width !== curr.props.width ||
187− next.props.height !== curr.props.height) {
188− node.parentNode.replaceChild(render(next),node);
189− return true;
190− }
191− break;
183+ if (nextE._0.ctor === 'Plain') {
184+ if (nextE._3 !== currE._3) node.src = nextE._3;
185+ } else if (!eq(nextE,currE) ||
186+ next.props.width !== curr.props.width ||
187+ next.props.height !== curr.props.height) {
188+ node.parentNode.replaceChild(render(next),node);
189+ return true;
190+ }
191+ break;
192192 case "Flow":
193193 var arr = fromList(nextE._1);
194194 for (var i = arr.length; i--; ) { arr[i] = arr[i].element.ctor; }
195− if (nextE._0.ctor !== currE._0.ctor) {
196− node.parentNode.replaceChild(render(next),node);
197− return true;
198− }
199− var nexts = fromList(nextE._1);
200− var kids = node.childNodes;
201− if (nexts.length !== kids.length) {
202− node.parentNode.replaceChild(render(next),node);
203− return true;
204− }
205− var currs = fromList(currE._1);
206− var goDir = function(x) { return x; };
207− switch(nextE._0.ctor) {
208− case "DDown": case "DUp": goDir = goDown; break;
209− case "DRight": case "DLeft": goDir = goRight; break;
210− case "DOut": case "DIn": goDir = goIn; break;
211− }
212− for (var i = kids.length; i-- ;) {
213− update(kids[i],currs[i],nexts[i]);
214− goDir(kids[i]);
215− }
216− break;
195+ if (nextE._0.ctor !== currE._0.ctor) {
196+ node.parentNode.replaceChild(render(next),node);
197+ return true;
198+ }
199+ var nexts = fromList(nextE._1);
200+ var kids = node.childNodes;
201+ if (nexts.length !== kids.length) {
202+ node.parentNode.replaceChild(render(next),node);
203+ return true;
204+ }
205+ var currs = fromList(currE._1);
206+ var goDir = function(x) { return x; };
207+ switch(nextE._0.ctor) {
208+ case "DDown": case "DUp": goDir = goDown; break;
209+ case "DRight": case "DLeft": goDir = goRight; break;
210+ case "DOut": case "DIn": goDir = goIn; break;
211+ }
212+ for (var i = kids.length; i-- ;) {
213+ update(kids[i],currs[i],nexts[i]);
214+ goDir(kids[i]);
215+ }
216+ break;
217217 case "Container":
218− var inner = node.firstChild;
219− if (!update(inner, currE._1, nextE._1)) {
220− if (nextE._0.horizontal.ctor !== currE._0.horizontal.ctor) {
221− inner.style.left = inner.style.right = 'none';
222− removeTransform(inner.style);
223− }
224− if (nextE._0.vertical.ctor !== currE._0.vertical.ctor) {
225− inner.style.top = inner.style.bottom = 'none';
226− removeTransform(inner.style);
227− }
228− }
229− setPos(nextE._0, nextE._1.props.width, nextE._1.props.height, inner);
230− break;
218+ var inner = node.firstChild;
219+ if (!update(inner, currE._1, nextE._1)) {
220+ if (nextE._0.horizontal.ctor !== currE._0.horizontal.ctor) {
221+ inner.style.left = inner.style.right = 'none';
222+ removeTransform(inner.style);
223+ }
224+ if (nextE._0.vertical.ctor !== currE._0.vertical.ctor) {
225+ inner.style.top = inner.style.bottom = 'none';
226+ removeTransform(inner.style);
227+ }
228+ }
229+ setPos(nextE._0, nextE._1.props.width, nextE._1.props.height, inner);
230+ break;
231231 case "Custom":
232− if (currE.type === nextE.type) {
233− var done = nextE.update(node, currE.model, nextE.model);
234− if (done) return;
235− } else {
236− return node.parentNode.replaceChild(render(next), node);
237− }
232+ if (currE.type === nextE.type) {
233+ var done = nextE.update(node, currE.model, nextE.model);
234+ if (done) return;
235+ } else {
236+ return node.parentNode.replaceChild(render(next), node);
237+ }
238238 }
239239 updateProps(node, curr, next);
240240}
@@ -244,23 +244,23 @@ function updateProps(node, curr, next) {
244244 if (props.width !== currP.width) e.style.width = (props.width |0) + 'px';
245245 if (props.height !== currP.height) e.style.height = (props.height|0) + 'px';
246246 if (props.opacity !== 1 && props.opacity !== currP.opacity) {
247− e.style.opacity = props.opacity;
247+ e.style.opacity = props.opacity;
248248 }
249249 var nextColor = (props.color.ctor === 'Just' ?
250− extract(props.color._0) : 'transparent');
250+ extract(props.color._0) : 'transparent');
251251 if (e.style.backgroundColor !== nextColor) {
252252 e.style.backgroundColor = nextColor;
253253 }
254254 if (props.tag !== currP.tag) { e.id = props.tag; }
255255 if (props.href !== currP.href) {
256− if (currP.href === '') {
257− var a = newElement('a');
258− a.href = props.href;
259− a.appendChild(e);
260− e.parentNode.replaceChild(a,e);
261− } else {
262− node.parentNode.href = props.href;
263− }
256+ if (currP.href === '') {
257+ var a = newElement('a');
258+ a.href = props.href;
259+ a.appendChild(e);
260+ e.parentNode.replaceChild(a,e);
261+ } else {
262+ node.parentNode.href = props.href;
263+ }
264264 }
265265}
266266