mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-28406 blocks: added JS to prevent the addition of duplicate blocks
This commit is contained in:
parent
ca3e8e98a4
commit
8d0845d30a
@ -361,21 +361,29 @@ M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
|
||||
// Make sure we have the form
|
||||
if (form) {
|
||||
// Create a function to handle our change event
|
||||
var processchange = function(e, lastindex) {
|
||||
if ((nothing===false || select.get('value') != nothing) && lastindex != select.get('selectedIndex')) {
|
||||
var processchange = function(e, paramobject) {
|
||||
if ((nothing===false || select.get('value') != nothing) && paramobject.lastindex != select.get('selectedIndex')) {
|
||||
//prevent event bubbling and detach handlers to prevent multiple submissions caused by double clicking
|
||||
e.halt();
|
||||
paramobject.eventkeypress.detach();
|
||||
paramobject.eventblur.detach();
|
||||
paramobject.eventchangeorblur.detach();
|
||||
|
||||
this.submit();
|
||||
}
|
||||
};
|
||||
// Attach the change event to the keypress, blur, and click actions.
|
||||
// We don't use the change event because IE fires it on every arrow up/down
|
||||
// event.... usability
|
||||
Y.on('key', processchange, select, 'press:13', form, select.get('selectedIndex'));
|
||||
select.on('blur', processchange, form, select.get('selectedIndex'));
|
||||
var paramobject = new Object();
|
||||
paramobject.lastindex = select.get('selectedIndex');
|
||||
paramobject.eventkeypress = Y.on('key', processchange, select, 'press:13', form, paramobject);
|
||||
paramobject.eventblur = select.on('blur', processchange, form, paramobject);
|
||||
//little hack for chrome that need onChange event instead of onClick - see MDL-23224
|
||||
if (Y.UA.webkit) {
|
||||
select.on('change', processchange, form, select.get('selectedIndex'));
|
||||
paramobject.eventchangeorblur = select.on('change', processchange, form, paramobject);
|
||||
} else {
|
||||
select.on('click', processchange, form, select.get('selectedIndex'));
|
||||
paramobject.eventchangeorblur = select.on('click', processchange, form, paramobject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user