[img]https:// i.sstatic.net/gsAKe9Iz.png[/img]
Вот вызывающая функция (скриншот):

Вот вызывающая функция (полный код):
Код: Выделить всё
NS.run_expansion = function(categorynode) {
var categorychildren = categorynode.one(SELECTORS.CONTENTNODE),
self = this,
ancestor = categorynode.ancestor(SELECTORS.COURSECATEGORYTREE);
// Add our animation to the categorychildren.
this.add_animation(categorychildren);
// If we already have the class, remove it before showing otherwise we perform the
// animation whilst the node is hidden.
if (categorynode.hasClass(CSS.SECTIONCOLLAPSED)) {
// To avoid a jump effect, we need to set the height of the children to 0 here before removing the SECTIONCOLLAPSED class.
categorychildren.setStyle('height', '0');
categorynode.removeClass(CSS.SECTIONCOLLAPSED);
categorynode.setAttribute('aria-expanded', 'true');
categorychildren.fx.set('reverse', false);
} else {
categorychildren.fx.set('reverse', true);
categorychildren.fx.once('end', function(e, categorynode) {
categorynode.addClass(CSS.SECTIONCOLLAPSED);
categorynode.setAttribute('aria-expanded', 'false');
}, this, categorynode);
}
categorychildren.fx.once('end', function(e, categorychildren) {
// Remove the styles that the animation has set.
categorychildren.setStyles({
height: '',
opacity: ''
});
// To avoid memory gobbling, remove the animation. It will be added back if called again.
this.destroy();
self.update_collapsible_actions(ancestor);
}, categorychildren.fx, categorychildren);
// Now that everything has been set up, run the animation.
categorychildren.fx.run();
};
[img]https://i.sstatic. net/0bJyirYC.png[/img]
Неверная функция (полный код):
Код: Выделить всё
NS.update_collapsible_actions = function(ancestor) {
var foundmaximisedchildren = false,
// Grab the anchor for the collapseexpand all link.
**togglelink = ancestor.one(SELECTORS.COLLAPSEEXPAND);**
if (!togglelink) {
// We should always have a togglelink but ensure.
return;
}
// Search for any visibly expanded children.
ancestor.all(SELECTORS.CATEGORYWITHMAXIMISEDLOADEDCHILDREN).each(function(n) {
// If we can find any collapsed ancestors, skip.
if (n.ancestor(SELECTORS.CATEGORYWITHCOLLAPSEDLOADEDCHILDREN)) {
return false;
}
foundmaximisedchildren = true;
return true;
});
if (foundmaximisedchildren) {
// At least one maximised child found. Show the collapseall.
togglelink.setHTML(M.util.get_string('collapseall', 'moodle'))
.addClass(CSS.COLLAPSEALL)
.removeClass(CSS.DISABLED);
} else {
// No maximised children found but there are collapsed children. Show the expandall.
togglelink.setHTML(M.util.get_string('expandall', 'moodle'))
.removeClass(CSS.COLLAPSEALL)
.removeClass(CSS.DISABLED);
}
};
Подробнее здесь: https://stackoverflow.com/questions/793 ... or-is-null
Мобильная версия