diff --git a/lib/yui/chooserdialogue/chooserdialogue.js b/lib/yui/chooserdialogue/chooserdialogue.js index ebc37e17b27..26b74959648 100644 --- a/lib/yui/chooserdialogue/chooserdialogue.js +++ b/lib/yui/chooserdialogue/chooserdialogue.js @@ -152,6 +152,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) { var bb = this.overlay.get('boundingBox'); var winheight = bb.get('winHeight'); + var winwidth = bb.get('winWidth'); var offsettop = 0; // Try and set a sensible max-height -- this must be done before setting the top @@ -187,6 +188,13 @@ YUI.add('moodle-core-chooserdialogue', function(Y) { // We need to set the height for the yui3-widget - can't work // out what we're setting at present -- shoud be the boudingBox bb.setStyle('top', dialoguetop + 'px'); + + // Calculate the left location of the chooser + // We don't set a minimum width in the same way as we do height as the width would be far lower than the + // optimal width for moodle anyway. + var dialoguewidth = bb.get('offsetWidth'); + var dialogueleft = (winwidth - dialoguewidth) / 2; + bb.setStyle('left', dialogueleft + 'px'); }, handle_key_press : function(e) {