mirror of
https://github.com/moodle/moodle.git
synced 2025-07-25 00:02:18 +02:00
Merge branch 'wip-MDL-30912-master' of git://github.com/abgreeve/moodle
This commit is contained in:
@@ -376,30 +376,49 @@ M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
|
||||
})();
|
||||
// Make sure we have the form
|
||||
if (form) {
|
||||
var buttonflag = 0;
|
||||
// Create a function to handle our change event
|
||||
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();
|
||||
// chrome doesn't pick up on a click when selecting an element in a select menu, so we use
|
||||
// the on change event to fire this function. This just checks to see if a button was
|
||||
// first pressed before redirecting to the appropriate page.
|
||||
if (Y.UA.os == 'windows' && Y.UA.chrome){
|
||||
if (buttonflag == 1) {
|
||||
buttonflag = 0;
|
||||
this.submit();
|
||||
}
|
||||
} else {
|
||||
this.submit();
|
||||
}
|
||||
}
|
||||
if (e.button == 1) {
|
||||
buttonflag = 1;
|
||||
}
|
||||
};
|
||||
// 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
|
||||
|
||||
var changedown = function(e, paramobject) {
|
||||
if ((nothing===false || select.get('value') != nothing) && paramobject.lastindex != select.get('selectedIndex')) {
|
||||
if(e.keyCode == 13) {
|
||||
form.submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
paramobject.eventchangeorblur = select.on('change', processchange, form, paramobject);
|
||||
paramobject.eventchangeorblur = select.on('click', processchange, form, paramobject);
|
||||
// Bad hack to circumvent problems with different browsers on different systems.
|
||||
if (Y.UA.os == 'macintosh') {
|
||||
if(Y.UA.webkit) {
|
||||
paramobject.eventchangeorblur = select.on('change', processchange, form, paramobject);
|
||||
}
|
||||
paramobject.eventkeypress = Y.on('key', processchange, select, 'press:13', form, paramobject);
|
||||
} else {
|
||||
paramobject.eventchangeorblur = select.on('click', processchange, form, paramobject);
|
||||
if(Y.UA.os == 'windows' && Y.UA.chrome) {
|
||||
paramobject.eventchangeorblur = select.on('change', processchange, form, paramobject);
|
||||
}
|
||||
paramobject.eventkeypress = Y.on('keydown', changedown, select, '', form, paramobject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,6 +427,9 @@ M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
|
||||
|
||||
/**
|
||||
* Attach handler to url_select
|
||||
* Deprecated from 2.4 onwards.
|
||||
* Please use @see init_select_autosubmit() for redirecting to a url (above).
|
||||
* This function has accessability issues and also does not use the formid passed through as a parameter.
|
||||
*/
|
||||
M.util.init_url_select = function(Y, formid, selectid, nothing) {
|
||||
YUI().use('node', function(Y) {
|
||||
|
Reference in New Issue
Block a user