r66662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66661‎ | r66662 | r66663 >
Date:22:23, 19 May 2010
Author:adam
Status:deferred
Tags:
Comment:
Follow up to r66658. Not sure if this fixes everything but i can not figure out how to make this work with spans right now.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (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.suggestions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -72,7 +72,7 @@
7373 array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ),
7474 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 18 ),
7575 array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 15 ),
76 - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 19 ),
 76+ array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 20 ),
7777 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 33 ),
7878 array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 188 ),
7979 array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ),
@@ -85,10 +85,10 @@
8686 array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ),
8787 ),
8888 'combined' => array(
89 - array( 'src' => 'js/plugins.combined.js', 'version' => 404 ),
 89+ array( 'src' => 'js/plugins.combined.js', 'version' => 405 ),
9090 ),
9191 'minified' => array(
92 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 404 ),
 92+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 405 ),
9393 ),
9494 ),
9595 );
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js
@@ -149,13 +149,6 @@
150150 var $autoEllipseMe = $( [] );
151151 for ( var i = 0; i < context.config.suggestions.length; i++ ) {
152152 var text = context.config.suggestions[i];
153 - if( context.config.highlightInput ) {
154 - var text = '<strong>'
155 - + text.substr( 0, context.data.prevText.length)
156 - + '</strong>'
157 - + text.substr( context.data.prevText.length, text.length );
158 - }
159 -
160153 var $result = $( '<div />' )
161154 .addClass( 'suggestions-result' )
162155 .attr( 'rel', i )
@@ -172,14 +165,24 @@
173166 context.config.result.render.call( $result, text );
174167 } else {
175168 // Add <span> with text
176 - $result.append( $( '<div />' )
177 - .css( 'whiteSpace', 'nowrap' )
178 - .html( text )
179 - );
 169+ if( context.config.highlightInput ) {
 170+ var matchedText = text.substr( 0, context.data.prevText.length );
 171+ text = text.substr( context.data.prevText.length, text.length );
 172+ $result.append( $( '<div />' )
 173+ .css( 'whiteSpace', 'nowrap' )
 174+ .text( text )
 175+ .prepend( $( '<strong />' ).text( matchedText ) )
 176+ );
 177+ } else {
 178+ $result.append( $( '<div />' )
 179+ .css( 'whiteSpace', 'nowrap' )
 180+ .text( text )
 181+ );
 182+ }
180183
181184 // Widen results box if needed
182185 // New width is only calculated here, applied later
183 - var $span = $result.children( 'span' );
 186+ var $span = $result.children( 'div' );
184187 if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) {
185188 expWidth = $span.outerWidth();
186189 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -5906,13 +5906,6 @@
59075907 var $autoEllipseMe = $( [] );
59085908 for ( var i = 0; i < context.config.suggestions.length; i++ ) {
59095909 var text = context.config.suggestions[i];
5910 - if( context.config.highlightInput ) {
5911 - var text = '<strong>'
5912 - + text.substr( 0, context.data.prevText.length)
5913 - + '</strong>'
5914 - + text.substr( context.data.prevText.length, text.length );
5915 - }
5916 -
59175910 var $result = $( '<div />' )
59185911 .addClass( 'suggestions-result' )
59195912 .attr( 'rel', i )
@@ -5929,14 +5922,24 @@
59305923 context.config.result.render.call( $result, text );
59315924 } else {
59325925 // Add <span> with text
5933 - $result.append( $( '<div />' )
5934 - .css( 'whiteSpace', 'nowrap' )
5935 - .html( text )
5936 - );
 5926+ if( context.config.highlightInput ) {
 5927+ var matchedText = text.substr( 0, context.data.prevText.length );
 5928+ text = text.substr( context.data.prevText.length, text.length );
 5929+ $result.append( $( '<div />' )
 5930+ .css( 'whiteSpace', 'nowrap' )
 5931+ .text( text )
 5932+ .prepend( $( '<strong />' ).text( matchedText ) )
 5933+ );
 5934+ } else {
 5935+ $result.append( $( '<div />' )
 5936+ .css( 'whiteSpace', 'nowrap' )
 5937+ .text( text )
 5938+ );
 5939+ }
59375940
59385941 // Widen results box if needed
59395942 // New width is only calculated here, applied later
5940 - var $span = $result.children( 'span' );
 5943+ var $span = $result.children( 'div' );
59415944 if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) {
59425945 expWidth = $span.outerWidth();
59435946 }
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -397,11 +397,8 @@
398398 if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();}
399399 $.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');context.config.special.render.call($special,context.data.$textbox.val());},1);}},configure:function(context,property,value){switch(property){case'fetch':case'cancel':case'special':case'result':case'$region':context.config[property]=value;break;case'suggestions':context.config[property]=value;if(typeof context.data!=='undefined'){if(context.data.$textbox.val().length==0){context.data.$container.hide();}else{context.data.$container.show();var newCSS={'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto'}
400400 if(context.config.positionFromLeft){newCSS['left']=context.config.$region.offset().left;newCSS['right']='auto';}else{newCSS['left']='auto';newCSS['right']=$('body').width()-(context.config.$region.offset().left+context.config.$region.outerWidth());}
401 -context.data.$container.css(newCSS);var $results=context.data.$container.children('.suggestions-results');$results.empty();var expWidth=-1;var $autoEllipseMe=$([]);for(var i=0;i<context.config.suggestions.length;i++){var text=context.config.suggestions[i];if(context.config.highlightInput){var text='<strong>'
402 -+text.substr(0,context.data.prevText.length)
403 -+'</strong>'
404 -+text.substr(context.data.prevText.length,text.length);}
405 -var $result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).mouseover(function(e){$.suggestions.highlight(context,$(this).closest('.suggestions-results div'),false);}).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,text);}else{$result.append($('<div />').css('whiteSpace','nowrap').html(text));var $span=$result.children('span');if($span.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();}
 401+context.data.$container.css(newCSS);var $results=context.data.$container.children('.suggestions-results');$results.empty();var expWidth=-1;var $autoEllipseMe=$([]);for(var i=0;i<context.config.suggestions.length;i++){var text=context.config.suggestions[i];var $result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).mouseover(function(e){$.suggestions.highlight(context,$(this).closest('.suggestions-results div'),false);}).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,text);}else{if(context.config.highlightInput){var matchedText=text.substr(0,context.data.prevText.length);text=text.substr(context.data.prevText.length,text.length);$result.append($('<div />').css('whiteSpace','nowrap').text(text).prepend($('<strong />').text(matchedText)));}else{$result.append($('<div />').css('whiteSpace','nowrap').text(text));}
 402+var $span=$result.children('div');if($span.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();}
406403 $autoEllipseMe=$autoEllipseMe.add($result);}}
407404 if(expWidth>context.data.$container.width()){var maxWidth=context.config.maxExpandFactor*context.data.$textbox.width();context.data.$container.width(Math.min(expWidth,maxWidth));}
408405 $autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true});}}

Follow-up revisions

RevisionCommit summaryAuthorDate
r67741UsabilityInitiative: Temporarily revert r66658, r66662, r66690 so UsabilityIn...catrope18:42, 9 June 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66658Adding match highlighting to the suggestions pluginadam21:18, 19 May 2010

Status & tagging log