MDL-36803 TinyMCE: Fix TinyMCE following touch events on iOS browsers
authorAndrew Nicols <andrew@nicols.co.uk>
Mon, 19 Aug 2013 18:12:39 +0000 (19:12 +0100)
committerAndrew Nicols <andrew@nicols.co.uk>
Tue, 20 Aug 2013 22:58:59 +0000 (23:58 +0100)
lib/editor/tinymce/module.js

index 8871c4f..7ee56f4 100644 (file)
@@ -56,6 +56,21 @@ M.editor_tinymce.init_editor = function(Y, editorid, options) {
                 M.cfg.wwwroot + '/lib/editor/tinymce/plugins/' + filedetails[1]);
         }
     }
+
+    // We have to override the editor setup to work around a bug in iOS browsers - MDL-36803.
+    if (Y.UA.ios) {
+        // Retain any setup which is already defined.
+        options.originalSetupFunction = options.setup || function(){};
+        options.setup = function(editor) {
+            options.originalSetupFunction();
+            editor.onPostRender.add(function(ed) {
+                // Whenever there is a keydown event, ensure that the contentWindow still have focus.
+                ed.contentDocument.addEventListener('keydown', function() {
+                    ed.contentWindow.focus();
+                });
+            });
+        };
+    }
     tinyMCE.init(options);
 
     var item = document.getElementById(editorid+'_filemanager');