Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit b95b05085c1ee1e68f275186acef77cb2a9dcd1d 1 parent fcbf68f
@andrewnicols andrewnicols authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 lib/yui/chooserdialogue/chooserdialogue.js
View
31 lib/yui/chooserdialogue/chooserdialogue.js
@@ -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();
},
Please sign in to comment.
Something went wrong with that request. Please try again.