MDL-24932 moodleemoticon tinymce: use restoreSelection() instead of custom bookmark...
authorDavid Mudrak <david.mudrak@gmail.com>
Mon, 1 Nov 2010 19:53:53 +0000 (19:53 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Mon, 1 Nov 2010 19:53:53 +0000 (19:53 +0000)
Credit goes to Mauno Korpelainen for the tip on how to sort out this IE
behaviour. Also, I moved compressed dialog.js to the revision directory to prevent
browser caching issues.

lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/dialog.php
lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/js/dialog_src.js [moved from lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/js/dialog.js with 85% similarity]
lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/js/rev2/dialog.js [new file with mode: 0644]

index bf96db5..fcd6e80 100644 (file)
@@ -40,7 +40,7 @@ $stringmanager = get_string_manager();
 <head>
     <title><?php print_string('moodleemoticon:desc', 'editor_tinymce'); ?></title>
     <script type="text/javascript" src="../../tiny_mce_popup.js?v=3.3.9.2"></script>
-    <script type="text/javascript" src="js/dialog.js?v=3.3.9.2&rev=6"></script>
+    <script type="text/javascript" src="js/rev2/dialog.js?v=3.3.9.2"></script>
 </head>
 <body>
 
@@ -1,10 +1,6 @@
 var MoodleEmoticonDialog = {
 
-    bookmark : null,
-
     init : function() {
-        this.bookmark = tinyMCEPopup.editor.selection.getBookmark(1, true);
-
         // register event handlers for the table rows
         tinymce.each(tinymce.DOM.select('tr.emoticoninfo', document), function(row) {
 
@@ -34,9 +30,10 @@ var MoodleEmoticonDialog = {
         i = 0;
         for (var emoticon in emoticons) {
             if (i == index) {
-                tinyMCEPopup.editor.selection.moveToBookmark(this.bookmark);
+                if (tinymce.isIE) {
+                    tinyMCEPopup.restoreSelection();
+                }
                 tinyMCEPopup.editor.execCommand('mceInsertContent', false, emoticons[emoticon]);
-                this.bookmark = tinyMCEPopup.editor.selection.getBookmark(1, true);
                 tinyMCEPopup.close();
                 return;
             }
diff --git a/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/js/rev2/dialog.js b/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/js/rev2/dialog.js
new file mode 100644 (file)
index 0000000..69b696c
--- /dev/null
@@ -0,0 +1 @@
+var MoodleEmoticonDialog={init:function(){tinymce.each(tinymce.DOM.select('tr.emoticoninfo',document),function(c){tinymce.dom.Event.add(c,'mouseover',function(e){this.style.backgroundColor='white'},c);tinymce.dom.Event.add(c,'mouseout',function(e){this.style.backgroundColor='transparent'},c);tinymce.dom.Event.add(c,'click',function(e){var a=/^emoticoninfo emoticoninfo-index-([0-9]+)$/.exec(this.className);if(a.length!=2){return true}var b=a[1];MoodleEmoticonDialog.insert(b)},c)})},insert:function(a){emoticons=tinyMCEPopup.editor._emoticons;i=0;for(var b in emoticons){if(i==a){if(tinymce.isIE){tinyMCEPopup.restoreSelection()}tinyMCEPopup.editor.execCommand('mceInsertContent',false,emoticons[b]);tinyMCEPopup.close();return}i++}},highlight:function(a){a.style.backgroundColor="white"},unhighlight:function(a){a.style.backgroundColor="transparent"}};tinyMCEPopup.onInit.add(MoodleEmoticonDialog.init,MoodleEmoticonDialog);