r61491 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61490‎ | r61491 | r61492 >
Date:14:51, 25 January 2010
Author:catrope
Status:deferred
Tags:
Comment:
UsabilityInitiative: Fix bug where the header dropdown always adds headers to the top in IE by moving the onclick handler from the wrapping dropdown <div> to the label <div> and making the latter an <a>. Apparently IE resets the selection in the iframe when you click on a <div> or <a> in the main document; <a href="#"> and <img> are fine though. Also fix ownline bugs in encapsulateSelection: it wasn't detecting the start/end of lines right, inserting newlines wrongly in certain cases.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.min.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/wikiEditor.toolbar.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -21,7 +21,7 @@
2222 array( 'src' => 'css/suggestions.css', 'version' => 6 ),
2323 array( 'src' => 'css/vector.collapsibleNav.css', 'version' => 6 ),
2424 array( 'src' => 'css/vector.footerCleanup.css', 'version' => 1 ),
25 - array( 'src' => 'css/wikiEditor.css', 'version' => 7 ),
 25+ array( 'src' => 'css/wikiEditor.css', 'version' => 8 ),
2626 array( 'src' => 'css/wikiEditor.dialogs.css', 'version' => 13 ),
2727 array( 'src' => 'css/wikiEditor.preview.css', 'version' => 1 ),
2828 array( 'src' => 'css/wikiEditor.toc.css', 'version' => 28 ),
@@ -29,11 +29,11 @@
3030 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ),
3131 ),
3232 'combined' => array(
33 - array( 'src' => 'css/combined.css', 'version' => 54 ),
 33+ array( 'src' => 'css/combined.css', 'version' => 55 ),
3434 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ),
3535 ),
3636 'minified' => array(
37 - array( 'src' => 'css/combined.min.css', 'version' => 54 ),
 37+ array( 'src' => 'css/combined.min.css', 'version' => 55 ),
3838 array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ),
3939 ),
4040 )
@@ -140,7 +140,7 @@
141141 array(
142142 'src' => 'js/plugins/jquery.wikiEditor.js',
143143 'class' => 'j.wikiEditor',
144 - 'version' => 62
 144+ 'version' => 63
145145 ),
146146 array(
147147 'src' => 'js/plugins/jquery.wikiEditor.highlight.js',
@@ -150,7 +150,7 @@
151151 array(
152152 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js',
153153 'class' => 'j.wikiEditor.modules.toolbar',
154 - 'version' => 42
 154+ 'version' => 43
155155 ),
156156 array(
157157 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js',
@@ -178,10 +178,10 @@
179179 'version' => 1 ),
180180 ),
181181 'combined' => array(
182 - array( 'src' => 'js/plugins.combined.js', 'version' => 169 ),
 182+ array( 'src' => 'js/plugins.combined.js', 'version' => 170 ),
183183 ),
184184 'minified' => array(
185 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 169 ),
 185+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 170 ),
186186 ),
187187 ),
188188 );
Index: trunk/extensions/UsabilityInitiative/css/wikiEditor.toolbar.css
@@ -198,6 +198,7 @@
199199 padding-right: 22px;
200200 margin-right: 4px;
201201 cursor: pointer;
 202+ text-decoration: none;
202203 color: #333333;
203204 }
204205 body.rtl .wikiEditor-ui-toolbar .group .tool-select .label {
Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -753,6 +753,7 @@
754754 padding-right: 22px;
755755 margin-right: 4px;
756756 cursor: pointer;
 757+ text-decoration: none;
757758 color: #333333;
758759 }
759760 body.rtl .wikiEditor-ui-toolbar .group .tool-select .label {
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -700,6 +700,7 @@
701701 padding-right:22px;
702702 margin-right:4px;
703703 cursor:pointer;
 704+text-decoration:none;
704705 color:#333333;
705706 }
706707 body.rtl .wikiEditor-ui-toolbar .group .tool-select .label{
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -438,12 +438,16 @@
439439 // Firefox and Opera
440440 var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 );
441441 if ( options.ownline ) {
 442+ var body = context.$content.get( 0 );
442443 // TODO: This'll probably break with syntax highlighting
443 - if ( range.startOffset != 0 ) {
 444+ // When the selection starts at the beginning of a line, it'll have either
 445+ // startOffset == 0 or startContainer == body
 446+ if ( range.startOffset != 0 && range.startContainer != body ) {
444447 pre = "\n" + options.pre;
445448 }
446449 // TODO: Will this still work with syntax highlighting?
447 - if ( range.endContainer == range.commonAncestorContainer ) {
 450+ // When the selection ends at the end of a line, it'll have endContainer == body
 451+ if ( range.endContainer != body ) {
448452 post += "\n";
449453 }
450454 }
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toolbar.js
@@ -312,11 +312,7 @@
313313 return $button;
314314 case 'select':
315315 var $select = $( '<div />' )
316 - .attr( { 'rel' : id, 'class' : 'tool tool-select' } )
317 - .click( function() {
318 - var $options = $(this).find( '.options' );
319 - $options.animate( { 'opacity': 'toggle' }, 'fast' );
320 - } );
 316+ .attr( { 'rel' : id, 'class' : 'tool tool-select' } );
321317 $options = $( '<div />' ).addClass( 'options' );
322318 if ( 'list' in tool ) {
323319 for ( option in tool.list ) {
@@ -329,15 +325,31 @@
330326 $.wikiEditor.modules.toolbar.fn.doAction(
331327 $(this).data( 'context' ), $(this).data( 'action' ), $(this)
332328 );
 329+ // Hide the dropdown
 330+ // Sanity check: if this somehow gets called while the dropdown
 331+ // is hidden, don't show it
 332+ if ( $(this).parent().is( ':visible' ) ) {
 333+ $(this).parent().animate( { 'opacity': 'toggle' }, 'fast' );
 334+ }
 335+ return false;
333336 } )
334337 .text( optionLabel )
335338 .addClass( 'option' )
336 - .attr( 'rel', option )
 339+ .attr( { 'rel': option, 'href': '#' } )
337340 );
338341 }
339342 }
340343 $select.append( $( '<div />' ).addClass( 'menu' ).append( $options ) );
341 - $select.append( $( '<div />' ).addClass( 'label' ).text( label ) );
 344+ $select.append( $( '<a />' )
 345+ .addClass( 'label' )
 346+ .text( label )
 347+ .data( 'options', $options )
 348+ .attr( 'href', '#' )
 349+ .click( function() {
 350+ $(this).data( 'options' ).animate( { 'opacity': 'toggle' }, 'fast' );
 351+ return false;
 352+ } )
 353+ );
342354 return $select;
343355 default:
344356 return null;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -6919,12 +6919,16 @@
69206920 // Firefox and Opera
69216921 var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 );
69226922 if ( options.ownline ) {
 6923+ var body = context.$content.get( 0 );
69236924 // TODO: This'll probably break with syntax highlighting
6924 - if ( range.startOffset != 0 ) {
 6925+ // When the selection starts at the beginning of a line, it'll have either
 6926+ // startOffset == 0 or startContainer == body
 6927+ if ( range.startOffset != 0 && range.startContainer != body ) {
69256928 pre = "\n" + options.pre;
69266929 }
69276930 // TODO: Will this still work with syntax highlighting?
6928 - if ( range.endContainer == range.commonAncestorContainer ) {
 6931+ // When the selection ends at the end of a line, it'll have endContainer == body
 6932+ if ( range.endContainer != body ) {
69296933 post += "\n";
69306934 }
69316935 }
@@ -9569,11 +9573,7 @@
95709574 return $button;
95719575 case 'select':
95729576 var $select = $( '<div />' )
9573 - .attr( { 'rel' : id, 'class' : 'tool tool-select' } )
9574 - .click( function() {
9575 - var $options = $(this).find( '.options' );
9576 - $options.animate( { 'opacity': 'toggle' }, 'fast' );
9577 - } );
 9577+ .attr( { 'rel' : id, 'class' : 'tool tool-select' } );
95789578 $options = $( '<div />' ).addClass( 'options' );
95799579 if ( 'list' in tool ) {
95809580 for ( option in tool.list ) {
@@ -9586,15 +9586,31 @@
95879587 $.wikiEditor.modules.toolbar.fn.doAction(
95889588 $(this).data( 'context' ), $(this).data( 'action' ), $(this)
95899589 );
 9590+ // Hide the dropdown
 9591+ // Sanity check: if this somehow gets called while the dropdown
 9592+ // is hidden, don't show it
 9593+ if ( $(this).parent().is( ':visible' ) ) {
 9594+ $(this).parent().animate( { 'opacity': 'toggle' }, 'fast' );
 9595+ }
 9596+ return false;
95909597 } )
95919598 .text( optionLabel )
95929599 .addClass( 'option' )
9593 - .attr( 'rel', option )
 9600+ .attr( { 'rel': option, 'href': '#' } )
95949601 );
95959602 }
95969603 }
95979604 $select.append( $( '<div />' ).addClass( 'menu' ).append( $options ) );
9598 - $select.append( $( '<div />' ).addClass( 'label' ).text( label ) );
 9605+ $select.append( $( '<a />' )
 9606+ .addClass( 'label' )
 9607+ .text( label )
 9608+ .data( 'options', $options )
 9609+ .attr( 'href', '#' )
 9610+ .click( function() {
 9611+ $(this).data( 'options' ).animate( { 'opacity': 'toggle' }, 'fast' );
 9612+ return false;
 9613+ } )
 9614+ );
95999615 return $select;
96009616 default:
96019617 return null;
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -452,8 +452,8 @@
453453 +'</pre>');$pre.find(".wikiEditor-noinclude").each(function(){$(this).remove();});$pre.find(".wikiEditor-tab").each(function(){$(this).text("\t")});return $pre.text();},'getSelection':function(){var retval;if(context.$iframe[0].contentWindow.getSelection){retval=context.$iframe[0].contentWindow.getSelection();}else if(context.$iframe[0].contentWindow.document.selection){retval=context.$iframe[0].contentWindow.document.selection.createRange();}
454454 if(typeof retval.text!='undefined'){retval=retval.text;}else if(retval.toString){retval=retval.toString();}
455455 return retval;},'encapsulateSelection':function(options){var selText=$(this).textSelection('getSelection');var selectAfter=false;var pre=options.pre,post=options.post;if(!selText){selText=options.peri;selectAfter=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);post+=' ';}
456 -if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){if(range.startOffset!=0){pre="\n"+options.pre;}
457 -if(range.endContainer==range.commonAncestorContainer){post+="\n";}}
 456+if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);if(options.ownline){var body=context.$content.get(0);if(range.startOffset!=0&&range.startContainer!=body){pre="\n"+options.pre;}
 457+if(range.endContainer!=body){post+="\n";}}
458458 var insertText=pre+selText+post;var insertLines=insertText.split("\n");range.extractContents();var lastNode;for(var i=insertLines.length-1;i>=0;i--){range.insertNode(context.$iframe[0].contentWindow.document.createTextNode(insertLines[i]));if(i>0){lastNode=range.insertNode(context.$iframe[0].contentWindow.document.createElement('br'));}}
459459 if(lastNode){context.fn.scrollToTop(lastNode);}}else if(context.$iframe[0].contentWindow.document.selection){context.$iframe[0].contentWindow.focus();var range=context.$iframe[0].contentWindow.document.selection.createRange();if(options.ownline&&range.moveStart){var range2=context.$iframe[0].contentWindow.document.selection.createRange();range2.collapse();range2.moveStart('character',-1);if(range2.text!="\r"&&range2.text!="\n"&&range2.text!=""){pre="\n"+pre;}
460460 var range3=context.$iframe[0].contentWindow.document.selection.createRange();range3.collapse(false);range3.moveEnd('character',1);if(range3.text!="\r"&&range3.text!="\n"&&range3.text!=""){post+="\n";}}
@@ -640,8 +640,9 @@
641641 var empty=true;if('tools'in group){for(tool in group.tools){var tool=$.wikiEditor.modules.toolbar.fn.buildTool(context,tool,group.tools[tool]);if(tool){empty=false;$group.append(tool);}}}
642642 return empty?null:$group;},buildTool:function(context,id,tool){if('filters'in tool){for(filter in tool.filters){if($(tool.filters[filter]).size()==0){return null;}}}
643643 var label=$.wikiEditor.autoMsg(tool,'label');switch(tool.type){case'button':var src=$.wikiEditor.autoIcon(tool.icon,$.wikiEditor.imgPath+'toolbar/');$button=$('<img />').attr({'src':src,'width':22,'height':22,'alt':label,'title':label,'rel':id,'class':'tool tool-button'});if('action'in tool){$button.data('action',tool.action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));return false;});}
644 -return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'}).click(function(){var $options=$(this).find('.options');$options.animate({'opacity':'toggle'},'fast');});$options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));}).text(optionLabel).addClass('option').attr('rel',option));}}
645 -$select.append($('<div />').addClass('menu').append($options));$select.append($('<div />').addClass('label').text(label));return $select;default:return null;}},buildBookmark:function(context,id,page){var label=$.wikiEditor.autoMsg(page,'label');return $('<div />').text(label).attr('rel',id).data('context',context).bind('mousedown',function(){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');if($.trackAction!=undefined){$.trackAction(section+'.'+$(this).attr('rel'));}
 644+return $button;case'select':var $select=$('<div />').attr({'rel':id,'class':'tool tool-select'});$options=$('<div />').addClass('options');if('list'in tool){for(option in tool.list){var optionLabel=$.wikiEditor.autoMsg(tool.list[option],'label');$options.append($('<a />').data('action',tool.list[option].action).data('context',context).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).data('context'),$(this).data('action'),$(this));if($(this).parent().is(':visible')){$(this).parent().animate({'opacity':'toggle'},'fast');}
 645+return false;}).text(optionLabel).addClass('option').attr({'rel':option,'href':'#'}));}}
 646+$select.append($('<div />').addClass('menu').append($options));$select.append($('<a />').addClass('label').text(label).data('options',$options).attr('href','#').click(function(){$(this).data('options').animate({'opacity':'toggle'},'fast');return false;}));return $select;default:return null;}},buildBookmark:function(context,id,page){var label=$.wikiEditor.autoMsg(page,'label');return $('<div />').text(label).attr('rel',id).data('context',context).bind('mousedown',function(){$(this).parent().parent().find('.page').hide();$(this).parent().parent().find('.page-'+$(this).attr('rel')).show();$(this).siblings().removeClass('current');$(this).addClass('current');var section=$(this).parent().parent().attr('rel');if($.trackAction!=undefined){$.trackAction(section+'.'+$(this).attr('rel'));}
646647 $.cookie('wikiEditor-'+$(this).data('context').instance+'-booklet-'+section+'-page',$(this).attr('rel'));});},buildPage:function(context,id,page){var $page=$('<div />').attr({'class':'page page-'+id,'rel':id});switch(page.layout){case'table':$page.addClass('page-table');var html='<table cellpadding=0 cellspacing=0 '+'border=0 width="100%" class="table table-"'+id+'">';if('headings'in page){html+=$.wikiEditor.modules.toolbar.fn.buildHeading(context,page.headings)}
647648 if('rows'in page){for(row in page.rows){html+=$.wikiEditor.modules.toolbar.fn.buildRow(context,page.rows[row])}}
648649 $page.html(html);break;case'characters':$page.addClass('page-characters');$characters=$('<div />').data('context',context).data('actions',{});var actions=$characters.data('actions');if('language'in page){$characters.attr('lang',page.language);}

Status & tagging log