MDL-30899 modchooser Changing from overlay to panel references

This commit is contained in:
David Monllao 2012-09-10 13:27:23 +08:00
parent 64cd465f13
commit 2a88835d5a
2 changed files with 20 additions and 18 deletions

View file

@ -5,8 +5,8 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
} }
Y.extend(CHOOSERDIALOGUE, Y.Base, { Y.extend(CHOOSERDIALOGUE, Y.Base, {
// The overlay widget // The panel widget
overlay: null, panel: null,
// The submit button - we disable this until an element is set // The submit button - we disable this until an element is set
submitbutton : null, submitbutton : null,
@ -50,23 +50,23 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
params[paramkey] = this.instanceconfig[paramkey]; params[paramkey] = this.instanceconfig[paramkey];
} }
// Create the overlay // Create the panel
this.overlay = new M.core.dialogue(params); this.panel = new M.core.dialogue(params);
// Remove the template for the chooser // Remove the template for the chooser
this.bodycontent.remove(); this.bodycontent.remove();
this.headercontent.remove(); this.headercontent.remove();
// Hide and then render the overlay // Hide and then render the panel
this.overlay.hide(); this.panel.hide();
this.overlay.render(); this.panel.render();
// Set useful links // Set useful links
this.container = this.overlay.get('boundingBox').one('.choosercontainer'); this.container = this.panel.get('boundingBox').one('.choosercontainer');
this.options = this.container.all('.option input[type=radio]'); this.options = this.container.all('.option input[type=radio]');
// Add the chooserdialogue class to the container for styling // Add the chooserdialogue class to the container for styling
this.overlay.get('boundingBox').addClass('chooserdialogue'); this.panel.get('boundingBox').addClass('chooserdialogue');
}, },
/** /**
@ -81,7 +81,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
// Stop the default event actions before we proceed // Stop the default event actions before we proceed
e.preventDefault(); e.preventDefault();
var bb = this.overlay.get('boundingBox'); var bb = this.panel.get('boundingBox');
var dialogue = this.container.one('.alloptions'); var dialogue = this.container.one('.alloptions');
// Get the overflow setting when the chooser was opened - we // Get the overflow setting when the chooser was opened - we
@ -135,7 +135,9 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
// Hook onto the cancel button to hide the form // Hook onto the cancel button to hide the form
thisevent = this.container.one('#addcancel').on('click', this.cancel_popup, this); thisevent = this.container.one('#addcancel').on('click', this.cancel_popup, this);
this.listenevents.push(thisevent); this.listenevents.push(thisevent);
thisevent = bb.one('div.closebutton').on('click', this.cancel_popup, this);
// Hide will be managed by cancel_popup after restoring the body overflow
thisevent = bb.one('button.closebutton').on('click', this.cancel_popup, this);
this.listenevents.push(thisevent); this.listenevents.push(thisevent);
// Grab global keyup events and handle them // Grab global keyup events and handle them
@ -152,8 +154,8 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
// Ensure that the options are shown // Ensure that the options are shown
this.options.removeAttribute('disabled'); this.options.removeAttribute('disabled');
// Display the overlay // Display the panel
this.overlay.show(); this.panel.show();
// Re-centre the dialogue after we've shown it. // Re-centre the dialogue after we've shown it.
this.center_dialogue(dialogue); this.center_dialogue(dialogue);
@ -191,7 +193,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
* @return void * @return void
*/ */
center_dialogue : function(dialogue) { center_dialogue : function(dialogue) {
var bb = this.overlay.get('boundingBox'); var bb = this.panel.get('boundingBox');
var winheight = bb.get('winHeight'); var winheight = bb.get('winHeight');
var winwidth = bb.get('winWidth'); var winwidth = bb.get('winWidth');
@ -275,7 +277,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
} }
this.container.detachAll(); this.container.detachAll();
this.overlay.hide(); this.panel.hide();
}, },
check_options : function(e) { check_options : function(e) {
@ -318,6 +320,6 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
M.core.chooserdialogue = CHOOSERDIALOGUE; M.core.chooserdialogue = CHOOSERDIALOGUE;
}, },
'@VERSION@', { '@VERSION@', {
requires:['base', 'overlay', 'moodle-enrol-notification'] requires:['base', 'panel', 'moodle-enrol-notification']
} }
); );

View file

@ -849,7 +849,7 @@ sup {vertical-align: super;}
-moz-box-shadow: 5px 5px 20px 0px #666666; -moz-box-shadow: 5px 5px 20px 0px #666666;
} }
.chooserdialogue .moodle-dialogue-hd { .chooserdialogue .moodle-dialogue-wrap .moodle-dialogue-hd {
font-size:12px!important; font-size:12px!important;
font-weight: normal!important; font-weight: normal!important;
letter-spacing: 1px; letter-spacing: 1px;
@ -870,7 +870,7 @@ sup {vertical-align: super;}
/* Question Bank - Question Chooser "Close" button */ /* Question Bank - Question Chooser "Close" button */
#page-question-edit.dir-rtl a.container-close {right:auto;left:6px;} #page-question-edit.dir-rtl a.container-close {right:auto;left:6px;}
.chooserdialogue .moodle-dialogue-bd { .chooserdialogue .moodle-dialogue-wrap .moodle-dialogue-bd {
font-size: 12px; font-size: 12px;
color: #555555; color: #555555;
overflow: auto; overflow: auto;