Confirmedusers, editor, Administrators
886
edits
CreativeMD (talk | contribs) No edit summary |
CreativeMD (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
defaults: { | defaults: { | ||
slideSpeed: 400, | slideSpeed: 400, | ||
easing: | easing: true, | ||
callback: false, | callback: false, | ||
callback_ticking: false | callback_ticking: false | ||
Line 10: | Line 10: | ||
thisCallArgs: { | thisCallArgs: { | ||
slideSpeed: 400, | slideSpeed: 400, | ||
easing: | easing: true, | ||
callback: false, | callback: false, | ||
callback_ticking: false | callback_ticking: false | ||
Line 73: | Line 73: | ||
} | } | ||
}, | }, | ||
}); | }); | ||
return $(this); | return $(this); | ||
}, | }, | ||
Line 135: | Line 127: | ||
} | } | ||
}); | }); | ||
return $(this); | return $(this); | ||
} | } | ||
Line 179: | Line 162: | ||
var item = { | var item = { | ||
id: id, | |||
index: i, | |||
level: 0, | level: 0, | ||
parent: parent, | parent: parent, | ||
Line 185: | Line 169: | ||
el: $el, | el: $el, | ||
left: 0, | left: 0, | ||
width: $el.width() + 12, | |||
opened: true, | |||
parentOpened: function() { | |||
if (this.opened) { | |||
this.el.show(); | |||
} | |||
this.children.forEach(function (child) { | |||
child.parentOpened(); | |||
}); | |||
}, | |||
parentClosed: function() { | |||
this.el.hide(); | |||
this.children.forEach(function (child) { | |||
child.parentClosed(); | |||
}); | |||
}, | |||
show: function() { | |||
this.opened = true; | |||
this.el.show(); | |||
this.children.forEach(function (child) { | |||
child.parentOpened(); | |||
}); | |||
}, | |||
slideUp: function() { | |||
this.opened = true; | |||
this.children.forEach(function (child) { | |||
child.parentOpened(); | |||
}); | |||
var lineUpdateUp = setInterval(function () { | |||
updateLines(item); | |||
}, 1); | |||
$("." + this.el.attr("data-tt-id")).slideRow("up", 400, function () { clearInterval(lineUpdateUp); updateLines(); }); | |||
}, | |||
hide: function() { | |||
this.opened = false; | |||
this.el.hide(); | |||
this.children.forEach(function (child) { | |||
child.parentClosed(); | |||
}); | |||
}, | |||
slideDown: function() { | |||
this.opened = false; | |||
var lineUpdateDown = setInterval(function () { | |||
updateLines(item); | |||
}, 1); | |||
$("." + this.el.attr("data-tt-id")).slideRow("down", 400, function () { clearInterval(lineUpdateDown); updateLines(); }); | |||
} | |||
}; | }; | ||
Line 206: | Line 236: | ||
item.left = 0; | item.left = 0; | ||
if (item.parent !== undefined) { | if (item.parent !== undefined) { | ||
item.left = item.parent.left + item.parent.width; | |||
} | } | ||
}); | }); | ||
Line 225: | Line 255: | ||
item.el.closest("tr").addClass("level" + item.level); | item.el.closest("tr").addClass("level" + item.level); | ||
if (item.index % 2 == 0) | |||
item.el.closest("tr").addClass("even"); | |||
else | |||
item.el.closest("tr").addClass("odd"); | |||
if (item.children.length > 0) { | if (item.children.length > 0) { | ||
item.el.addClass("tt-parent"); | item.el.addClass("tt-parent"); | ||
var className = item.el.attr("data-tt-id"); | var className = item.el.attr("data-tt-id"); | ||
var children = item.children.slice(); | |||
while(children.length > 0) { | |||
while(children.length > 0) | |||
children[0].el.closest("tr").addClass(className); | children[0].el.closest("tr").addClass(className); | ||
if(children[0].children.length > 0) | if(children[0].children.length > 0) | ||
Line 255: | Line 273: | ||
children.shift(); | children.shift(); | ||
} | } | ||
} | } | ||
}); | }); | ||
Line 267: | Line 283: | ||
} | } | ||
if(item.el.attr("data-invisible") == "true") | if(item.el.attr("data-invisible") == "true") { | ||
item.hide(); | |||
return ; | return ; | ||
} | } | ||
Line 290: | Line 305: | ||
}); | }); | ||
function updateLines(limited) | function updateLines(limited) { | ||
//Update height of all items | //Update height of all items | ||
items.forEach(function (item) { | items.forEach(function (item) { | ||
Line 317: | Line 331: | ||
$table.on("click", "div.tt div.content", function (e) { | $table.on("click", "div.tt div.content", function (e) { | ||
var $el = $(e.currentTarget).closest(".tt"); | |||
var id = $el.data('tt-id'); | var id = $el.data('tt-id'); | ||
var item = index[id]; | var item = index[id]; | ||
if (item.opened === true) { | |||
// hide all children | |||
item.slideDown(); | |||
} else { | |||
// show direct children | |||
item.slideUp(); | |||
window.location.hash = '#' + $el.attr("data-tt-id"); | |||
} | |||
updateLines(); | updateLines(); | ||
}); | }); | ||
Line 367: | Line 355: | ||
if(item.children.length > 0) { | if(item.children.length > 0) { | ||
if (item.el.attr("data-hide") == "true" || (item.parent != undefined && item.el.attr("data-hide") != "false")) { | if (item.el.attr("data-hide") == "true" || (item.parent != undefined && item.el.attr("data-hide") != "false")) { | ||
if (window.location.hash != "#" + item.el.attr("data-tt-id")) { | |||
item.hide(); | |||
} else { | |||
item.show(); | |||
} | |||
} | } | ||
} | } |