MDL-44762 editor_atto: Closing dropdowns when item is clicked
authorFrederic Massart <fred@moodle.com>
Thu, 27 Mar 2014 03:42:29 +0000 (11:42 +0800)
committerFrederic Massart <fred@moodle.com>
Thu, 27 Mar 2014 04:17:00 +0000 (12:17 +0800)
lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-debug.js
lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-min.js
lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin.js
lib/editor/atto/yui/src/editor/js/editor-plugin-buttons.js
lib/editor/atto/yui/src/editor/js/editor-plugin-dialogue.js

index 4e5a062..28b4239 100644 (file)
Binary files a/lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-debug.js and b/lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-debug.js differ
index 30d52c5..f8d557e 100644 (file)
Binary files a/lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-min.js and b/lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin-min.js differ
index 911a37a..4a51f51 100644 (file)
Binary files a/lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin.js and b/lib/editor/atto/yui/build/moodle-editor_atto-plugin/moodle-editor_atto-plugin.js differ
index 0763f80..923a8ad 100644 (file)
@@ -474,6 +474,9 @@ EditorPluginButtons.prototype = {
      * @private
      */
     _hideMenu: function(e, menuDialogue) {
+        if (menuDialogue.get('preventHideMenu') === true) {
+            return;
+        }
         menuDialogue.hide();
         new Y.EventHandle(this._menuHideHandlers).detach();
     },
@@ -494,11 +497,18 @@ EditorPluginButtons.prototype = {
             // And the normalized callback configuration.
             buttonConfig = this._normalizeCallback(config.items[index], config.globalItemConfig);
 
-        // Clear the focus after hide so that focus is returned to the editor and changes are made correctly.
-        menuDialogue.set('focusAfterHide', null);
+        // Prevent the dialogue to be closed because of some browser weirdness.
+        menuDialogue.set('preventHideMenu', true);
 
         // Call the callback for this button.
         buttonConfig.callback(e, buttonConfig._callback, buttonConfig.callbackArgs);
+
+        // Cancel the hide menu prevention.
+        menuDialogue.set('preventHideMenu', false);
+
+        // Set the focus after hide so that focus is returned to the editor and changes are made correctly.
+        menuDialogue.set('focusAfterHide', this.get('host').editor);
+        this._hideMenu(e, menuDialogue);
     },
 
     /**
@@ -578,6 +588,7 @@ EditorPluginButtons.prototype = {
      * @param {EventFacade} e
      * @param {Function} callback The function to call which makes the relevant changes.
      * @param {Array} [callbackArgs] The arguments passed to this callback.
+     * @return {Mixed} The value returned by the callback.
      * @private
      */
     _callbackWrapper: function(e, callback, callbackArgs) {
@@ -608,7 +619,7 @@ EditorPluginButtons.prototype = {
         var args = [e, callbackArgs];
 
         // Actually call the callback now.
-        callback.apply(this, args);
+        return callback.apply(this, args);
     },
 
     /**
index d8116b3..09cc4e6 100644 (file)
@@ -92,7 +92,7 @@ EditorPluginDialogue.prototype = {
             if (focusAfterHide === true) {
                 this._dialogue.set('focusAfterHide', this.buttons[this.buttonNames[0]]);
 
-            } else if (typeof setFocusAfter === 'string') {
+            } else if (typeof focusAfterHide === 'string') {
                 this._dialogue.set('focusAfterHide', this.buttons[focusAfterHide]);
 
             } else {