r62156 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62155‎ | r62156 | r62157 >
Date:01:42, 9 February 2010
Author:nimishg
Status:ok (Comments)
Tags:
Comment:
fixes bug 22428
Modified paths:
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -273,6 +273,7 @@
274274 * processing of events which did not actually change the content of the iframe.
275275 */
276276 'keydown': function( event ) {
 277+
277278 switch ( event.which ) {
278279 case 90: // z
279280 if ( ( event.ctrlKey || event.metaKey ) && context.history.length ) {
@@ -359,6 +360,27 @@
360361 }
361362 }
362363 return true;
 364+ },
 365+ 'paste': function( event ) {
 366+ context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' );
 367+ setTimeout( function() {
 368+ var $selection = context.$content.find( ':not(.wikiEditor)' );
 369+ while ( $selection.length && $selection.length > 0){
 370+ var $currentElement = $selection.eq( 0 );
 371+ while ( !$currentElement.parent().is( 'body' ) && !$currentElement.parent().is( '.wikiEditor' ) ) {
 372+ $currentElement = $currentElement.parent();
 373+ }
 374+ if($currentElement.is("br")){
 375+ $currentElement.addClass('wikiEditor');
 376+ }
 377+ else{
 378+ $("<p></p>").text( $currentElement.text() ).addClass( 'wikiEditor' ).insertAfter( $currentElement );
 379+ $currentElement.remove();
 380+ }
 381+ $selection = context.$content.find( ':not(.wikiEditor)' );
 382+ }
 383+ }, 100 );
 384+ return true;
363385 }
364386 };
365387
@@ -1263,6 +1285,9 @@
12641286 .bind( 'keydown', function( event ) {
12651287 return context.fn.trigger( 'keydown', event );
12661288 } )
 1289+ .bind( 'paste', function( event ){
 1290+ return context.fn.trigger( 'paste', event );
 1291+ } )
12671292 .bind( 'keyup mouseup paste cut encapsulateSelection', function( event ) {
12681293 return context.fn.trigger( 'change', event );
12691294 } )

Follow-up revisions

RevisionCommit summaryAuthorDate
r62180UsabilityInitiative: Fix indentation, recombine, bump style versions for r621...catrope14:13, 9 February 2010

Comments

#Comment by Catrope (talk | contribs)   14:02, 9 February 2010
+			setTimeout( function() {
...
+			}, 100 ); 

Doesn't a timeout of 0 also work?

#Comment by Catrope (talk | contribs)   14:06, 9 February 2010

Needs recombine and style version bump

#Comment by Catrope (talk | contribs)   14:14, 9 February 2010

Did that myself in r62180.

Status & tagging log