mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-33649 Hide page scrollbars when a chooser is open
This has the effect of preventing page scrolling which makes the chooser difficult to use when there are many options or the page is too small.
This commit is contained in:
parent
fcbf68fd05
commit
b95b05085c
31
lib/yui/chooserdialogue/chooserdialogue.js
vendored
31
lib/yui/chooserdialogue/chooserdialogue.js
vendored
@ -17,6 +17,9 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
// Any event listeners we may need to cancel later
|
||||
listenevents : [],
|
||||
|
||||
// The initial overflow setting
|
||||
initialoverflow : '',
|
||||
|
||||
setup_chooser_dialogue : function(bodycontent, headercontent, config) {
|
||||
// Set Default options
|
||||
var params = {
|
||||
@ -65,6 +68,14 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
var bb = this.overlay.get('boundingBox');
|
||||
var dialogue = this.container.one('.alloptions');
|
||||
|
||||
// Get the overflow setting when the chooser was opened - we
|
||||
// may need this later
|
||||
if (Y.UA.ie > 0) {
|
||||
this.initialoverflow = Y.one('html').getStyle('overflow');
|
||||
} else {
|
||||
this.initialoverflow = Y.one('body').getStyle('overflow');
|
||||
}
|
||||
|
||||
var thisevent;
|
||||
|
||||
// These will trigger a check_options call to display the correct help
|
||||
@ -168,9 +179,21 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
// Set a fixed position if the window is large enough
|
||||
if (newheight > this.get('minheight')) {
|
||||
bb.setStyle('position', 'fixed');
|
||||
// Disable the page scrollbars
|
||||
if (Y.UA.ie > 0) {
|
||||
Y.one('html').setStyle('overflow', 'hidden');
|
||||
} else {
|
||||
Y.one('body').setStyle('overflow', 'hidden');
|
||||
}
|
||||
} else {
|
||||
bb.setStyle('position', 'absolute');
|
||||
offsettop = Y.one('window').get('scrollTop');
|
||||
// Ensure that the page scrollbars are enabled
|
||||
if (Y.UA.ie > 0) {
|
||||
Y.one('html').setStyle('overflow', this.initialoverflow);
|
||||
} else {
|
||||
Y.one('body').setStyle('overflow', this.initialoverflow);
|
||||
}
|
||||
}
|
||||
|
||||
// Take off 15px top and bottom for borders, plus 40px each for the title and button area before setting the
|
||||
@ -203,6 +226,14 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
|
||||
hide : function() {
|
||||
// Detach the global keypress handler before hiding
|
||||
Y.one('document').detach('keyup', this.handle_key_press, this);
|
||||
|
||||
// Re-enable the page scrollbars
|
||||
if (Y.UA.ie > 0) {
|
||||
Y.one('html').setStyle('overflow', this.initialoverflow);
|
||||
} else {
|
||||
Y.one('body').setStyle('overflow', this.initialoverflow);
|
||||
}
|
||||
|
||||
this.container.detachAll();
|
||||
this.overlay.hide();
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user