411 | | // When content doc is in standards mode, IE doesn't focus the editor when |
412 | | // clicking at the region below body (on html element) content, we emulate |
413 | | // the normal behavior on old IEs. (#1659, #7932) |
414 | | if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) |
415 | | && doc.$.compatMode != 'BackCompat' ) |
| 411 | // When content doc is in standards mode, IE doesn't produce text selection |
| 412 | // when click on the region outside of body, we emulate |
| 413 | // the correct behavior here. (#1659, #7932, # 9097) |
| 414 | if ( doc.$.compatMode != 'BackCompat' ) |
417 | | function moveRangeToPoint( range, x, y ) |
418 | | { |
419 | | // Error prune in IE7. (#9034, #9110) |
420 | | try { range.moveToPoint( x, y ); } catch ( e ) {} |
421 | | } |
| 416 | if ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) |
| 417 | { |
| 418 | function moveRangeToPoint( range, x, y ) |
| 419 | { |
| 420 | // Error prune in IE7. (#9034, #9110) |
| 421 | try { range.moveToPoint( x, y ); } catch ( e ) {} |
| 422 | } |
423 | | html.on( 'mousedown', function( evt ) |
424 | | { |
425 | | // Expand the text range along with mouse move. |
426 | | function onHover( evt ) |
427 | | { |
428 | | evt = evt.data.$; |
429 | | if ( textRng ) |
430 | | { |
431 | | // Read the current cursor. |
432 | | var rngEnd = body.$.createTextRange(); |
| 424 | html.on( 'mousedown', function( evt ) |
| 425 | { |
| 426 | // Expand the text range along with mouse move. |
| 427 | function onHover( evt ) |
| 428 | { |
| 429 | evt = evt.data.$; |
| 430 | if ( textRng ) |
| 431 | { |
| 432 | // Read the current cursor. |
| 433 | var rngEnd = body.$.createTextRange(); |
450 | | // We're sure that the click happens at the region |
451 | | // below body, but not on scrollbar. |
452 | | if ( evt.y < html.$.clientHeight |
453 | | && evt.y > body.$.offsetTop + body.$.clientHeight |
454 | | && evt.x < html.$.clientWidth ) |
455 | | { |
456 | | // Start to build the text range. |
457 | | var textRng = body.$.createTextRange(); |
458 | | moveRangeToPoint( textRng, evt.x, evt.y ); |
| 451 | // We're sure that the click happens at the region |
| 452 | // below body, but not on scrollbar. |
| 453 | if ( evt.getTarget().is( 'html' ) ) |
| 454 | { |
| 455 | // Start to build the text range. |
| 456 | var textRng = body.$.createTextRange(); |
| 457 | moveRangeToPoint( textRng, evt.$.x, evt.$.y ); |
474 | | // It's much simpler for IE8, we just need to reselect the reported range. |
475 | | if ( CKEDITOR.env.ie8 ) |
476 | | { |
477 | | html.on( 'mouseup', function( evt ) |
478 | | { |
479 | | // The event is not fired when clicking on the scrollbars, |
480 | | // so we can safely check the following to understand |
481 | | // whether the empty space following <body> has been clicked. |
482 | | if ( evt.data.getTarget().getName() == 'html' ) |
483 | | { |
484 | | var sel = CKEDITOR.document.$.selection, |
485 | | range = sel.createRange(); |
486 | | // The selection range is reported on host, but actually it should applies to the content doc. |
487 | | if ( sel.type != 'None' && range.parentElement().ownerDocument == doc.$ ) |
488 | | range.select(); |
489 | | } |
490 | | } ); |
491 | | } |
| 473 | // It's much simpler for IE > 8, we just need to reselect the reported range. |
| 474 | if ( CKEDITOR.env.ie8 ) |
| 475 | { |
| 476 | html.on( 'mousedown', function( evt ) { |
| 477 | |
| 478 | if ( evt.data.getTarget().is( 'html' ) ) |
| 479 | { |
| 480 | html.on( 'mouseup', function( evt ) |
| 481 | { |
| 482 | evt.removeListener(); |
| 483 | |
| 484 | // The event is not fired when clicking on the scrollbars, |
| 485 | // so we can safely check the following to understand |
| 486 | // whether the empty space following <body> has been clicked. |
| 487 | var sel = CKEDITOR.document.$.selection, |
| 488 | range = sel.createRange(); |
| 489 | // The selection range is reported on host, but actually it should applies to the content doc. |
| 490 | if ( sel.type != 'None' && range.parentElement().ownerDocument == doc.$ ) |
| 491 | range.select(); |
| 492 | } ); |
| 493 | } |
| 494 | |
| 495 | }); |
| 496 | } |