MDL-42928 JavaScript: Add LockScroll to all modal dialogues

This commit is contained in:
Andrew Nicols
2014-01-28 09:49:32 +08:00
parent 5ab39a0e97
commit 73747aea77
5 changed files with 59 additions and 4 deletions
@@ -118,6 +118,10 @@ Y.extend(DIALOGUE, Y.Panel, {
}
this.set('COUNT', COUNT);
if (this.get('modal')) {
this.plug(Y.M.core.LockScroll);
}
// Workaround upstream YUI bug http://yuilibrary.com/projects/yui3/ticket/2532507
// and allow setting of z-index in theme.
bb = this.get('boundingBox');
@@ -317,6 +321,11 @@ Y.extend(DIALOGUE, Y.Panel, {
header = this.headerNode,
content = this.bodyNode;
// Lock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.enableScrollLock();
}
result = DIALOGUE.superclass.show.call(this);
if (header && header !== '') {
header.focus();
@@ -325,6 +334,15 @@ Y.extend(DIALOGUE, Y.Panel, {
}
return result;
},
hide: function() {
// Unlock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.disableScrollLock();
}
return DIALOGUE.superclass.hide.call(this, arguments);
},
/**
* Setup key delegation to keep tabbing within the open dialogue.
*
@@ -550,4 +568,4 @@ Y.Base.modifyAttrs(DIALOGUE, {
M.core.dialogue = DIALOGUE;
}, '@VERSION@', {"requires": ["base", "node", "panel", "event-key", "dd-plugin"]});
}, '@VERSION@', {"requires": ["base", "node", "panel", "event-key", "dd-plugin", "moodle-core-lockscroll"]});
File diff suppressed because one or more lines are too long
@@ -118,6 +118,10 @@ Y.extend(DIALOGUE, Y.Panel, {
}
this.set('COUNT', COUNT);
if (this.get('modal')) {
this.plug(Y.M.core.LockScroll);
}
// Workaround upstream YUI bug http://yuilibrary.com/projects/yui3/ticket/2532507
// and allow setting of z-index in theme.
bb = this.get('boundingBox');
@@ -317,6 +321,11 @@ Y.extend(DIALOGUE, Y.Panel, {
header = this.headerNode,
content = this.bodyNode;
// Lock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.enableScrollLock();
}
result = DIALOGUE.superclass.show.call(this);
if (header && header !== '') {
header.focus();
@@ -325,6 +334,15 @@ Y.extend(DIALOGUE, Y.Panel, {
}
return result;
},
hide: function() {
// Unlock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.disableScrollLock();
}
return DIALOGUE.superclass.hide.call(this, arguments);
},
/**
* Setup key delegation to keep tabbing within the open dialogue.
*
@@ -548,4 +566,4 @@ Y.Base.modifyAttrs(DIALOGUE, {
M.core.dialogue = DIALOGUE;
}, '@VERSION@', {"requires": ["base", "node", "panel", "event-key", "dd-plugin"]});
}, '@VERSION@', {"requires": ["base", "node", "panel", "event-key", "dd-plugin", "moodle-core-lockscroll"]});
+18
View File
@@ -87,6 +87,10 @@ Y.extend(DIALOGUE, Y.Panel, {
}
this.set('COUNT', COUNT);
if (this.get('modal')) {
this.plug(Y.M.core.LockScroll);
}
// Workaround upstream YUI bug http://yuilibrary.com/projects/yui3/ticket/2532507
// and allow setting of z-index in theme.
bb = this.get('boundingBox');
@@ -286,6 +290,11 @@ Y.extend(DIALOGUE, Y.Panel, {
header = this.headerNode,
content = this.bodyNode;
// Lock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.enableScrollLock();
}
result = DIALOGUE.superclass.show.call(this);
if (header && header !== '') {
header.focus();
@@ -294,6 +303,15 @@ Y.extend(DIALOGUE, Y.Panel, {
}
return result;
},
hide: function() {
// Unlock scroll if the plugin is present.
if (this.lockScroll) {
this.lockScroll.disableScrollLock();
}
return DIALOGUE.superclass.hide.call(this, arguments);
},
/**
* Setup key delegation to keep tabbing within the open dialogue.
*
@@ -14,7 +14,8 @@
"node",
"panel",
"event-key",
"dd-plugin"
"dd-plugin",
"moodle-core-lockscroll"
]
},
"moodle-core-notification-alert": {