From dc5c56e90ca97f73b234b51b0b22e2e5ced42503 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 3 Oct 2012 14:38:25 +1300 Subject: [PATCH] MDL-33448 enrol_manual: Reordered things to improve JS performance when enrolling users --- enrol/manual/yui/quickenrolment/quickenrolment.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/enrol/manual/yui/quickenrolment/quickenrolment.js b/enrol/manual/yui/quickenrolment/quickenrolment.js index 81774afab73..f57c75dfc8f 100644 --- a/enrol/manual/yui/quickenrolment/quickenrolment.js +++ b/enrol/manual/yui/quickenrolment/quickenrolment.js @@ -154,6 +154,11 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) { } this.get(UEP.BASE).one('.'+CSS.SEARCHOPTIONS+' .'+CSS.COLLAPSIBLEHEADING).one('img').setAttribute('src', M.util.image_url(collapsedimage, 'moodle')); + this.get(UEP.BASE).one('.'+CSS.SEARCHOPTIONS+' .'+CSS.COLLAPSIBLEHEADING).once('click', function() { + // We want to do this just once, the first time the controls are shown. + this.populateStartDates(); + this.populateDuration(); + }, this); this.get(UEP.BASE).one('.'+CSS.SEARCHOPTIONS+' .'+CSS.COLLAPSIBLEHEADING).on('click', function(){ this.get(UEP.BASE).one('.'+CSS.SEARCHOPTIONS+' .'+CSS.COLLAPSIBLEHEADING).toggleClass(CSS.ACTIVE); this.get(UEP.BASE).one('.'+CSS.SEARCHOPTIONS+' .'+CSS.COLLAPSIBLEAREA).toggleClass(CSS.HIDDEN); @@ -163,10 +168,7 @@ YUI.add('moodle-enrol_manual-quickenrolment', function(Y) { this.get(UEP.BASE).one('.'+CSS.SEARCHOPTIONS+' .'+CSS.COLLAPSIBLEHEADING).one('img').setAttribute('src', M.util.image_url('t/expanded', 'moodle')); } }, this); - this.populateAssignableRoles(); - this.populateStartDates(); - this.populateDuration(); }, populateAssignableRoles : function() { this.on('assignablerolesloaded', function(){