JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.4
[ckeditor.git] / _source / plugins / selection / plugin.js
index aff5ba2..3a0a181 100644 (file)
@@ -414,10 +414,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat )\r
                                                         && doc.$.compatMode != 'BackCompat' )\r
                                                {\r
-                                                       html.on( 'mousedown', function( evt )\r
+                                                       function moveRangeToPoint( range, x, y )\r
                                                        {\r
-                                                               evt = evt.data.$;\r
+                                                               // Error prune in IE7. (#9034, #9110)\r
+                                                               try { range.moveToPoint( x, y ); } catch ( e ) {}\r
+                                                       }\r
 \r
+                                                       html.on( 'mousedown', function( evt )\r
+                                                       {\r
                                                                // Expand the text range along with mouse move.\r
                                                                function onHover( evt )\r
                                                                {\r
@@ -426,7 +430,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        {\r
                                                                                // Read the current cursor.\r
                                                                                var rngEnd = body.$.createTextRange();\r
-                                                                               rngEnd.moveToPoint( evt.x, evt.y );\r
+\r
+                                                                               moveRangeToPoint( rngEnd, evt.x, evt.y );\r
 \r
                                                                                // Handle drag directions.\r
                                                                                textRng.setEndPoint(\r
@@ -440,6 +445,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        }\r
                                                                }\r
 \r
+                                                               evt = evt.data.$;\r
+\r
                                                                // We're sure that the click happens at the region\r
                                                                // below body, but not on scrollbar.\r
                                                                if ( evt.y < html.$.clientHeight\r
@@ -448,8 +455,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                {\r
                                                                        // Start to build the text range.\r
                                                                        var textRng = body.$.createTextRange();\r
-                                                                       textRng.moveToPoint( evt.x, evt.y );\r
-                                                                       textRng.select();\r
+                                                                       moveRangeToPoint( textRng, evt.x, evt.y );\r
 \r
                                                                        html.on( 'mousemove', onHover );\r
 \r
@@ -457,8 +463,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        {\r
                                                                                html.removeListener( 'mousemove', onHover );\r
                                                                                evt.removeListener();\r
+\r
+                                                                               // Make it in effect on mouse up. (#9022)\r
                                                                                textRng.select();\r
-                                                                               textRng = null;\r
                                                                        } );\r
                                                                }\r
                                                        });\r
@@ -585,7 +592,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        command : 'selectAll'\r
                                });\r
 \r
-                       editor.selectionChange = checkSelectionChangeTimeout;\r
+                       /**\r
+                        * Check if to fire the {@link CKEDITOR.editor#selectionChange} event\r
+                        * for the current editor instance.\r
+                        *\r
+                        * @param {Boolean} checkNow Check immediately without any delay.\r
+                        */\r
+                       editor.selectionChange = function( checkNow )\r
+                       {\r
+                               ( checkNow ? checkSelectionChange : checkSelectionChangeTimeout ).call( this );\r
+                       };\r
 \r
                        // IE9 might cease to work if there's an object selection inside the iframe (#7639).\r
                        CKEDITOR.env.ie9Compat && editor.on( 'destroy', function()\r
@@ -1435,8 +1451,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        this.isLocked = 0;\r
                                        this.reset();\r
 \r
-                                       doc.getBody().focus();\r
-\r
                                        if ( selectedElement )\r
                                                this.selectElement( selectedElement );\r
                                        else\r