Some tweaks to edit.js to make currentFocused detection work in IE (was completely...
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 10 Feb 2010 13:19:21 +0000 (13:19 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 10 Feb 2010 13:19:21 +0000 (13:19 +0000)
includes/DefaultSettings.php
skins/common/edit.js

index 79ec6b9..2c964db 100644 (file)
@@ -1686,7 +1686,7 @@ $wgCacheEpoch = '20030516000000';
  * to ensure that client-side caches do not keep obsolete copies of global
  * styles.
  */
-$wgStyleVersion = '266';
+$wgStyleVersion = '267';
 
 
 # Server-side caching:
index 8001164..423205f 100644 (file)
@@ -78,7 +78,8 @@ function mwSetupToolbar() {
 // apply tagOpen/tagClose to selection in textarea,
 // use sampleText instead of selection if there is none
 function insertTags( tagOpen, tagClose, sampleText ) {
-       if ( typeof $j != 'undefined' && typeof $j.fn.textSelection != 'undefined' ) {
+       if ( typeof $j != 'undefined' && typeof $j.fn.textSelection != 'undefined' &&
+                       ( currentFocused.nodeName.toLowerCase() == 'iframe' || currentFocused.id == 'wpTextbox1' ) ) {
                $j( '#wpTextbox1' ).textSelection(
                        'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose }
                );
@@ -190,16 +191,16 @@ hookEvent( 'load', function() {
                return;
        }
        function onfocus( e ) {
-               var elm = e.target;
+               var elm = e.target || e.srcElement;
                if ( !elm ) {
                        return;
                }
                var tagName = elm.tagName.toLowerCase();
-               var type = elm.type.toLowerCase();
+               var type = elm.type || '';
                if ( tagName !== 'textarea' && tagName !== 'input' ) {
                        return;
                }
-               if ( tagName === 'input' && type && type !== 'text' ) {
+               if ( tagName === 'input' && type.toLowerCase() !== 'text' ) {
                        return;
                }
 
@@ -213,6 +214,17 @@ hookEvent( 'load', function() {
                // IE needs a specific trick here since it doesn't support the standard
                editForm.attachEvent( 'onfocusin', function() { onfocus( event ); } );
        }
+       
+       // HACK: make currentFocused work with the usability iframe
+       // With proper focus detection support (HTML 5!) this'll be much cleaner
+       if ( typeof $j != 'undefined' ) {
+               var iframe = $j( '.wikiEditor-ui-text iframe' );
+               if ( iframe.length > 0 ) {
+                       $j( iframe.get( 0 ).contentWindow.document )
+                               .add( iframe.get( 0 ).contentWindow.document.body ) // for IE
+                               .focus( function() { currentFocused = iframe.get( 0 ); } );
+               }
+       }
 
        editForm
 } );