233 |
233 |
ganttEntryClick = function(e){
|
234 |
234 |
var icon_expander = e.target;
|
235 |
235 |
var subject = $(icon_expander.parentElement);
|
236 |
|
var subject_left = parseInt(subject.css('left')) + parseInt(icon_expander.offsetWidth);
|
|
236 |
const expander_width = parseInt(icon_expander.offsetWidth);
|
|
237 |
var subject_left = parseInt(subject.css('left')) + expander_width;
|
237 |
238 |
var target_shown = null;
|
238 |
239 |
var target_top = 0;
|
239 |
240 |
var total_height = 0;
|
240 |
241 |
var out_of_hierarchy = false;
|
241 |
242 |
var iconChange = null;
|
|
243 |
let collapsed_parent_left = null;
|
|
244 |
let parent_is_collapsed = null;
|
|
245 |
const force_collapse_expand = e.ctrlKey;
|
|
246 |
function is_expander(el) {
|
|
247 |
return $(el).find('.expander').length > 0;
|
|
248 |
}
|
242 |
249 |
if(subject.hasClass('open'))
|
243 |
250 |
iconChange = function(element){
|
244 |
251 |
$(element).find('.expander').switchClass('icon-expanded', 'icon-collapsed');
|
245 |
252 |
$(element).removeClass('open');
|
|
253 |
if (is_expander(element) && (element === subject || force_collapse_expand)) element.addClass('collapsed');
|
246 |
254 |
};
|
247 |
255 |
else
|
248 |
256 |
iconChange = function(element){
|
249 |
257 |
$(element).find('.expander').switchClass('icon-collapsed', 'icon-expanded');
|
250 |
258 |
$(element).addClass('open');
|
|
259 |
if (is_expander(element) && (element === subject || force_collapse_expand)) element.removeClass('collapsed');
|
251 |
260 |
};
|
252 |
261 |
iconChange(subject);
|
|
262 |
parent_is_collapsed = subject.hasClass('collapsed');
|
253 |
263 |
subject.nextAll('div').each(function(_, element){
|
254 |
264 |
var el = $(element);
|
255 |
265 |
var json = el.data('collapse-expand');
|
... | ... | |
268 |
278 |
return true;
|
269 |
279 |
}
|
270 |
280 |
|
271 |
|
var is_shown = el.is(':visible');
|
272 |
|
if(target_shown == null){
|
273 |
|
target_shown = is_shown;
|
274 |
|
target_top = parseInt(el.css('top'));
|
275 |
|
total_height = 0;
|
276 |
|
}
|
277 |
|
if(is_shown == target_shown){
|
278 |
|
$(el_task_bars).each(function(_, task) {
|
279 |
|
var el_task = $(task);
|
|
281 |
const is_target_to_update = (() => {
|
|
282 |
const target_left = parseInt(el.css('left'));
|
|
283 |
if (!subject.hasClass('open') || force_collapse_expand) {
|
|
284 |
return true;
|
|
285 |
} else {
|
|
286 |
if (is_expander(el)) {
|
|
287 |
if (collapsed_parent_left == null || collapsed_parent_left >= target_left + expander_width) {
|
|
288 |
// First element or the same level or higher as the most recent collapsed parent element
|
|
289 |
parent_is_collapsed = el.hasClass('collapsed');
|
|
290 |
if (parent_is_collapsed) collapsed_parent_left = target_left + expander_width;
|
|
291 |
else collapsed_parent_left = null;
|
|
292 |
return true;
|
|
293 |
}
|
|
294 |
} else if (parent_is_collapsed && collapsed_parent_left >= target_left) {
|
|
295 |
// Elements at the same level or higher as the most recent collapsed parent element
|
|
296 |
parent_is_collapsed = false;
|
|
297 |
return true;
|
|
298 |
} else if (!parent_is_collapsed) {
|
|
299 |
return true;
|
|
300 |
}
|
|
301 |
}
|
|
302 |
return false;
|
|
303 |
})();
|
|
304 |
|
|
305 |
if (is_target_to_update) {
|
|
306 |
var is_shown = el.is(':visible');
|
|
307 |
if(target_shown == null){
|
|
308 |
target_shown = is_shown;
|
|
309 |
target_top =
|
|
310 |
parseInt(subject.css('top')) +
|
|
311 |
parseInt(subject.data('collapse-expand').top_increment);
|
|
312 |
total_height = 0;
|
|
313 |
}
|
|
314 |
if(is_shown == target_shown){
|
|
315 |
$(el_task_bars).each(function(_, task) {
|
|
316 |
var el_task = $(task);
|
|
317 |
if(!is_shown)
|
|
318 |
el_task.css('top', target_top + total_height);
|
|
319 |
if(!el_task.hasClass('tooltip'))
|
|
320 |
el_task.toggle(!is_shown);
|
|
321 |
});
|
|
322 |
$(el_selected_columns).each(function (_, attr) {
|
|
323 |
var el_attr = $(attr);
|
|
324 |
if (!is_shown)
|
|
325 |
el_attr.css('top', target_top + total_height);
|
|
326 |
el_attr.toggle(!is_shown);
|
|
327 |
});
|
280 |
328 |
if(!is_shown)
|
281 |
|
el_task.css('top', target_top + total_height);
|
282 |
|
if(!el_task.hasClass('tooltip'))
|
283 |
|
el_task.toggle(!is_shown);
|
284 |
|
});
|
285 |
|
$(el_selected_columns).each(function (_, attr) {
|
286 |
|
var el_attr = $(attr);
|
287 |
|
if (!is_shown)
|
288 |
|
el_attr.css('top', target_top + total_height);
|
289 |
|
el_attr.toggle(!is_shown);
|
290 |
|
});
|
291 |
|
if(!is_shown)
|
292 |
|
el.css('top', target_top + total_height);
|
293 |
|
iconChange(el);
|
294 |
|
el.toggle(!is_shown);
|
295 |
|
total_height += parseInt(json.top_increment);
|
|
329 |
el.css('top', target_top + total_height);
|
|
330 |
if(!el.hasClass('collapsed') || force_collapse_expand) iconChange(el);
|
|
331 |
el.toggle(!is_shown);
|
|
332 |
total_height += parseInt(json.top_increment);
|
|
333 |
}
|
296 |
334 |
}
|
297 |
335 |
});
|
298 |
336 |
drawGanttHandler();
|