Revert "MDL-30912 - lib - A tidy up of the submit url jump functions for greater...
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 5 Jul 2012 14:10:37 +0000 (16:10 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 5 Jul 2012 14:10:37 +0000 (16:10 +0200)
lib/javascript-static.js
lib/outputrenderers.php

index ed9aaba..6bf2e28 100644 (file)
@@ -381,26 +381,26 @@ M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
                     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();
                     }
                 };
-
-                var changedown = function(e, paramobject) {
-                    if ((nothing===false || select.get('value') != nothing) && paramobject.lastindex != select.get('selectedIndex')) {
-                        if(e.keyCode == 13) {
-                            form.submit();
-                        }
-                    }
-                }
-
-                // Attach the change event to the keydown and click actions.
+                // 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 paramobject = new Object();
                 paramobject.lastindex = select.get('selectedIndex');
-                paramobject.eventchangeorblur = select.on('click', processchange, form, paramobject);
-                paramobject.eventkeypress = Y.on('keydown', changedown, select, '', form, paramobject);
+                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);
+                } else {
+                    paramobject.eventchangeorblur = select.on('click', processchange, form, paramobject);
+                }
             }
         }
     });
@@ -408,9 +408,6 @@ M.util.init_select_autosubmit = function(Y, formid, selectid, nothing) {
 
 /**
  * Attach handler to url_select
- * Deprecated from 2.3 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(M.yui.loader).use('node', function(Y) {
index ea0f784..9654364 100644 (file)
@@ -1472,7 +1472,7 @@ class core_renderer extends renderer_base {
             $go = html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('go')));
             $output .= html_writer::tag('noscript', html_writer::tag('div', $go), array('style'=>'inline'));
             $nothing = empty($select->nothing) ? false : key($select->nothing);
-            $output .= $this->page->requires->js_init_call('M.util.init_select_autosubmit', array($select->formid, $select->attributes['id'], $nothing));
+            $output .= $this->page->requires->js_init_call('M.util.init_url_select', array($select->formid, $select->attributes['id'], $nothing));
         } else {
             $output .= html_writer::empty_tag('input', array('type'=>'submit', 'value'=>$select->showbutton));
         }