r62242 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62241‎ | r62242 | r62243 >
Date:13:19, 10 February 2010
Author:catrope
Status:ok
Tags:
Comment:
Some tweaks to edit.js to make currentFocused detection work in IE (was completely broken) and with the usability iframe. Will backport a simplified version to wmf-deployment shortly.
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/skins/common/edit.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/edit.js
@@ -78,7 +78,8 @@
7979 // apply tagOpen/tagClose to selection in textarea,
8080 // use sampleText instead of selection if there is none
8181 function insertTags( tagOpen, tagClose, sampleText ) {
82 - if ( typeof $j != 'undefined' && typeof $j.fn.textSelection != 'undefined' ) {
 82+ if ( typeof $j != 'undefined' && typeof $j.fn.textSelection != 'undefined' &&
 83+ ( currentFocused.nodeName.toLowerCase() == 'iframe' || currentFocused.id == 'wpTextbox1' ) ) {
8384 $j( '#wpTextbox1' ).textSelection(
8485 'encapsulateSelection', { 'pre': tagOpen, 'peri': sampleText, 'post': tagClose }
8586 );
@@ -190,16 +191,16 @@
191192 return;
192193 }
193194 function onfocus( e ) {
194 - var elm = e.target;
 195+ var elm = e.target || e.srcElement;
195196 if ( !elm ) {
196197 return;
197198 }
198199 var tagName = elm.tagName.toLowerCase();
199 - var type = elm.type.toLowerCase();
 200+ var type = elm.type || '';
200201 if ( tagName !== 'textarea' && tagName !== 'input' ) {
201202 return;
202203 }
203 - if ( tagName === 'input' && type && type !== 'text' ) {
 204+ if ( tagName === 'input' && type.toLowerCase() !== 'text' ) {
204205 return;
205206 }
206207
@@ -213,6 +214,17 @@
214215 // IE needs a specific trick here since it doesn't support the standard
215216 editForm.attachEvent( 'onfocusin', function() { onfocus( event ); } );
216217 }
 218+
 219+ // HACK: make currentFocused work with the usability iframe
 220+ // With proper focus detection support (HTML 5!) this'll be much cleaner
 221+ if ( typeof $j != 'undefined' ) {
 222+ var iframe = $j( '.wikiEditor-ui-text iframe' );
 223+ if ( iframe.length > 0 ) {
 224+ $j( iframe.get( 0 ).contentWindow.document )
 225+ .add( iframe.get( 0 ).contentWindow.document.body ) // for IE
 226+ .focus( function() { currentFocused = iframe.get( 0 ); } );
 227+ }
 228+ }
217229
218230 editForm
219231 } );
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1686,7 +1686,7 @@
16871687 * to ensure that client-side caches do not keep obsolete copies of global
16881688 * styles.
16891689 */
1690 -$wgStyleVersion = '266';
 1690+$wgStyleVersion = '267';
16911691
16921692
16931693 # Server-side caching:

Follow-up revisions

RevisionCommit summaryAuthorDate
r62243wmf-deployment: Partial backport for r62242catrope13:23, 10 February 2010

Status & tagging log