Skip to content

Commit

Permalink
MDL-48643 Javascript: Create modals hidden, then show, to prevent scroll
Browse files Browse the repository at this point in the history
Modal dialogs need to be created with visible: false and then call
.show() on it to make it visible. This prevents the page from jumping to
the top.
  • Loading branch information
ericmerrill committed Dec 22, 2014
1 parent 981f06f commit 6f0776b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion course/dndupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -635,13 +635,14 @@ M.course_dndupload = {
bodyContent: content,
width: '350px',
modal: true,
visible: true,
visible: false,
render: true,
align: {
node: null,
points: [Y.WidgetPositionAlign.CC, Y.WidgetPositionAlign.CC]
}
});
panel.show();
// When the panel is hidden - destroy it and then check for other pending uploads
panel.after("visibleChange", function(e) {
if (!panel.get('visible')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,10 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
// Create the confirmation dialogue.
var confirm = new M.core.confirm({
question: confirmstring,
modal: true
modal: true,
visible: false
});
confirm.show();

// If it is confirmed.
confirm.on('complete-yes', function() {
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,10 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
// Create the confirmation dialogue.
var confirm = new M.core.confirm({
question: confirmstring,
modal: true
modal: true,
visible: false
});
confirm.show();

// If it is confirmed.
confirm.on('complete-yes', function() {
Expand Down
4 changes: 3 additions & 1 deletion course/yui/src/toolboxes/js/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,10 @@ Y.extend(RESOURCETOOLBOX, TOOLBOX, {
// Create the confirmation dialogue.
var confirm = new M.core.confirm({
question: confirmstring,
modal: true
modal: true,
visible: false
});
confirm.show();

// If it is confirmed.
confirm.on('complete-yes', function() {
Expand Down
6 changes: 4 additions & 2 deletions enrol/yui/rolemanager/rolemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,16 @@ YUI.add('moodle-enrol-rolemanager', function(Y) {
event.detach();
var confirmation = {
modal: true,
visible : true,
visible : false,
centered : true,
title : M.util.get_string('confirmunassigntitle', 'role'),
question : M.util.get_string('confirmunassign', 'role'),
yesLabel : M.util.get_string('confirmunassignyes', 'role'),
noLabel : M.util.get_string('confirmunassignno', 'role')
};
new M.core.confirm(confirmation).on('complete-yes', this.removeRoleCallback, this, user.get(USERID), roleid);
new M.core.confirm(confirmation)
.show()
.on('complete-yes', this.removeRoleCallback, this, user.get(USERID), roleid);
}, this);
this._loadAssignableRoles();
},
Expand Down

0 comments on commit 6f0776b

Please sign in to comment.