Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/ScrollObjectiveList.js
| Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | _redraw: function() { | ||||
| JX.DOM.remove(objective_node); | JX.DOM.remove(objective_node); | ||||
| continue; | continue; | ||||
| } | } | ||||
| offset = (JX.$V(anchor).y / d.y) * (list_y); | offset = (JX.$V(anchor).y / d.y) * (list_y); | ||||
| items.push({ | items.push({ | ||||
| offset: offset, | offset: offset, | ||||
| node: objective_node | node: objective_node, | ||||
| objective: objective | |||||
| }); | }); | ||||
| } | } | ||||
| // Now, sort it from top to bottom. | // Now, sort it from top to bottom. | ||||
| items.sort(function(u, v) { | items.sort(function(u, v) { | ||||
| return u.offset - v.offset; | return u.offset - v.offset; | ||||
| }); | }); | ||||
| // Lay out the items in the objective list, leaving a minimum amount | // Lay out the items in the objective list, leaving a minimum amount | ||||
| // of space between them so they do not overlap. | // of space between them so they do not overlap. | ||||
| var min = null; | var min = null; | ||||
| for (ii = 0; ii < items.length; ii++) { | for (ii = 0; ii < items.length; ii++) { | ||||
| var item = items[ii]; | var item = items[ii]; | ||||
| offset = item.offset; | offset = item.offset; | ||||
| if (min !== null) { | if (min !== null) { | ||||
| if (item.objective.shouldStack()) { | |||||
| offset = min; | |||||
| } else { | |||||
| offset = Math.max(offset, min); | offset = Math.max(offset, min); | ||||
| } | } | ||||
| } | |||||
| min = offset + 15; | min = offset + 15; | ||||
| item.node.style.top = offset + 'px'; | item.node.style.top = offset + 'px'; | ||||
| node.appendChild(item.node); | node.appendChild(item.node); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||