Skip to content

Commit

Permalink
MDL-36023 AJAX Move the instantiation of the dialogue to display time
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Robert Nicols committed Oct 26, 2012
1 parent 1754dc2 commit 8516492
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions lib/yui/chooserdialogue/chooserdialogue.js
Expand Up @@ -20,11 +20,25 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
// The initial overflow setting
initialoverflow : '',

bodycontent : null,
headercontent : null,
instanceconfig : null,

setup_chooser_dialogue : function(bodycontent, headercontent, config) {
this.bodycontent = bodycontent;
this.headercontent = headercontent;
this.instanceconfig = config;
},

prepare_chooser : function () {
if (this.overlay) {
return;
}

// Set Default options
var params = {
bodyContent : bodycontent.get('innerHTML'),
headerContent : headercontent.get('innerHTML'),
bodyContent : this.bodycontent.get('innerHTML'),
headerContent : this.headercontent.get('innerHTML'),
draggable : true,
visible : false, // Hide by default
zindex : 100, // Display in front of other items
Expand All @@ -33,16 +47,16 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
}

// Override with additional options
for (paramkey in config) {
params[paramkey] = config[paramkey];
for (paramkey in this.instanceconfig) {
params[paramkey] = this.instanceconfig[paramkey];
}

// Create the overlay
this.overlay = new M.core.dialogue(params);

// Remove the template for the chooser
bodycontent.remove();
headercontent.remove();
this.bodycontent.remove();
this.headercontent.remove();

// Hide and then render the overlay
this.overlay.hide();
Expand All @@ -63,6 +77,8 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
* @return void
*/
display_chooser : function (e) {
this.prepare_chooser();

// Stop the default event actions before we proceed
e.preventDefault();

Expand Down

0 comments on commit 8516492

Please sign in to comment.