Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-36023 AJAX Move the instantiation of the dialogue to display time

  • Loading branch information...
commit 8516492cc4725c3da7e05f4bc826b312475ec735 1 parent 1754dc2
Andrew Nicols andrewnicols authored

Showing 1 changed file with 22 additions and 6 deletions. Show diff stats Hide diff stats

  1. +22 6 lib/yui/chooserdialogue/chooserdialogue.js
28 lib/yui/chooserdialogue/chooserdialogue.js
@@ -20,11 +20,25 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
20 20 // The initial overflow setting
21 21 initialoverflow : '',
22 22
  23 + bodycontent : null,
  24 + headercontent : null,
  25 + instanceconfig : null,
  26 +
23 27 setup_chooser_dialogue : function(bodycontent, headercontent, config) {
  28 + this.bodycontent = bodycontent;
  29 + this.headercontent = headercontent;
  30 + this.instanceconfig = config;
  31 + },
  32 +
  33 + prepare_chooser : function () {
  34 + if (this.overlay) {
  35 + return;
  36 + }
  37 +
24 38 // Set Default options
25 39 var params = {
26   - bodyContent : bodycontent.get('innerHTML'),
27   - headerContent : headercontent.get('innerHTML'),
  40 + bodyContent : this.bodycontent.get('innerHTML'),
  41 + headerContent : this.headercontent.get('innerHTML'),
28 42 draggable : true,
29 43 visible : false, // Hide by default
30 44 zindex : 100, // Display in front of other items
@@ -33,16 +47,16 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
33 47 }
34 48
35 49 // Override with additional options
36   - for (paramkey in config) {
37   - params[paramkey] = config[paramkey];
  50 + for (paramkey in this.instanceconfig) {
  51 + params[paramkey] = this.instanceconfig[paramkey];
38 52 }
39 53
40 54 // Create the overlay
41 55 this.overlay = new M.core.dialogue(params);
42 56
43 57 // Remove the template for the chooser
44   - bodycontent.remove();
45   - headercontent.remove();
  58 + this.bodycontent.remove();
  59 + this.headercontent.remove();
46 60
47 61 // Hide and then render the overlay
48 62 this.overlay.hide();
@@ -63,6 +77,8 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
63 77 * @return void
64 78 */
65 79 display_chooser : function (e) {
  80 + this.prepare_chooser();
  81 +
66 82 // Stop the default event actions before we proceed
67 83 e.preventDefault();
68 84

0 comments on commit 8516492

Please sign in to comment.
Something went wrong with that request. Please try again.