MDL-24932 way around for bloody IE8 loosing caret position in moodleemoticon
authorDavid Mudrak <david.mudrak@gmail.com>
Fri, 29 Oct 2010 22:01:07 +0000 (22:01 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Fri, 29 Oct 2010 22:01:07 +0000 (22:01 +0000)
Credit goes to Jan Sindberg for the idea published at
http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=59653#p59653

lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/js/dialog.js

index d5edbbe..86359a9 100644 (file)
@@ -1,6 +1,10 @@
 var MoodleEmoticonDialog = {
 
+    bookmark : null,
+
     init : function() {
+        this.bookmark = tinyMCEPopup.editor.selection.getBookmark();
+
         // register event handlers for the table rows
         tinymce.each(tinymce.DOM.select('tr.emoticoninfo', document), function(row) {
 
@@ -30,7 +34,9 @@ var MoodleEmoticonDialog = {
         i = 0;
         for (var emoticon in emoticons) {
             if (i == index) {
+                tinyMCEPopup.editor.selection.moveToBookmark(this.bookmark);
                 tinyMCEPopup.editor.execCommand('mceInsertContent', false, emoticons[emoticon]);
+                this.bookmark = tinyMCEPopup.editor.selection.getBookmark();
                 tinyMCEPopup.close();
                 return;
             }