Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | array( 'src' => 'js/plugins/jquery.color.js', 'version' => 1 ), |
72 | 72 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 4 ), |
73 | 73 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
74 | | - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 16 ), |
| 74 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 17 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 15 ), |
76 | 76 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 18 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 33 ), |
— | — | @@ -85,10 +85,10 @@ |
86 | 86 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ), |
87 | 87 | ), |
88 | 88 | 'combined' => array( |
89 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 400 ), |
| 89 | + array( 'src' => 'js/plugins.combined.js', 'version' => 401 ), |
90 | 90 | ), |
91 | 91 | 'minified' => array( |
92 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 400 ), |
| 92 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 401 ), |
93 | 93 | ), |
94 | 94 | ), |
95 | 95 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -33,9 +33,6 @@ |
34 | 34 | * Type: Number, Range: 0 - 1200, Default: 120 |
35 | 35 | * submitOnClick: Whether to submit the form containing the textbox when a suggestion is clicked |
36 | 36 | * Type: Boolean, Default: false |
37 | | - * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box |
38 | | - * will never be grown beyond 2 times the width of the textbox. |
39 | | - * Type: Number, Range: 1 - infinity, Default: 2 |
40 | 37 | * positionFromLeft: Whether to position the suggestion box with the left attribute or the right |
41 | 38 | * Type: Boolean, Default: true |
42 | 39 | */ |
— | — | @@ -170,17 +167,19 @@ |
171 | 168 | // Widen results box if needed |
172 | 169 | // New width is only calculated here, applied later |
173 | 170 | var $span = $result.children( 'span' ); |
174 | | - if ( $span.width() > $result.width() ) { |
175 | | - expWidth = Math.max( expWidth, Math.min( $span.width(), |
176 | | - context.data.$textbox.width()*context.config.maxExpandFactor |
177 | | - ) ); |
| 171 | + if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) { |
| 172 | + expWidth = $span.outerWidth(); |
178 | 173 | } |
179 | 174 | $autoEllipseMe = $autoEllipseMe.add( $result ); |
180 | 175 | } |
181 | 176 | } |
182 | 177 | // Apply new width for results box, if any |
183 | | - if ( expWidth != -1 ) { |
184 | | - context.data.$container.width( expWidth ); |
| 178 | + if ( expWidth > context.data.$container.width() ) { |
| 179 | + // Don't make the container too wide so it runs offscreen |
| 180 | + var maxWidth = context.config.positionFromLeft ? |
| 181 | + $('body').width() - context.data.$container.offset().left : |
| 182 | + context.data.$container.offset().left + context.data.$container.width(); |
| 183 | + context.data.$container.width( Math.min( expWidth, maxWidth ) ); |
185 | 184 | } |
186 | 185 | // autoEllipse the results. Has to be done after changing the width |
187 | 186 | $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } ); |
— | — | @@ -193,9 +192,6 @@ |
194 | 193 | case 'delay': |
195 | 194 | context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
196 | 195 | break; |
197 | | - case 'maxExpandFactor': |
198 | | - context.config[property] = Math.max( 1, value ); |
199 | | - break; |
200 | 196 | case 'submitOnClick': |
201 | 197 | case 'positionFromLeft': |
202 | 198 | context.config[property] = value ? true : false; |
— | — | @@ -348,7 +344,6 @@ |
349 | 345 | 'maxRows': 7, |
350 | 346 | 'delay': 120, |
351 | 347 | 'submitOnClick': false, |
352 | | - 'maxExpandFactor': 2, |
353 | 348 | 'positionFromLeft': true |
354 | 349 | } |
355 | 350 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -5790,9 +5790,6 @@ |
5791 | 5791 | * Type: Number, Range: 0 - 1200, Default: 120 |
5792 | 5792 | * submitOnClick: Whether to submit the form containing the textbox when a suggestion is clicked |
5793 | 5793 | * Type: Boolean, Default: false |
5794 | | - * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box |
5795 | | - * will never be grown beyond 2 times the width of the textbox. |
5796 | | - * Type: Number, Range: 1 - infinity, Default: 2 |
5797 | 5794 | * positionFromLeft: Whether to position the suggestion box with the left attribute or the right |
5798 | 5795 | * Type: Boolean, Default: true |
5799 | 5796 | */ |
— | — | @@ -5927,17 +5924,19 @@ |
5928 | 5925 | // Widen results box if needed |
5929 | 5926 | // New width is only calculated here, applied later |
5930 | 5927 | var $span = $result.children( 'span' ); |
5931 | | - if ( $span.width() > $result.width() ) { |
5932 | | - expWidth = Math.max( expWidth, Math.min( $span.width(), |
5933 | | - context.data.$textbox.width()*context.config.maxExpandFactor |
5934 | | - ) ); |
| 5928 | + if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) { |
| 5929 | + expWidth = $span.outerWidth(); |
5935 | 5930 | } |
5936 | 5931 | $autoEllipseMe = $autoEllipseMe.add( $result ); |
5937 | 5932 | } |
5938 | 5933 | } |
5939 | 5934 | // Apply new width for results box, if any |
5940 | | - if ( expWidth != -1 ) { |
5941 | | - context.data.$container.width( expWidth ); |
| 5935 | + if ( expWidth > context.data.$container.width() ) { |
| 5936 | + // Don't make the container too wide so it runs offscreen |
| 5937 | + var maxWidth = context.config.positionFromLeft ? |
| 5938 | + $('body').width() - context.data.$container.offset().left : |
| 5939 | + context.data.$container.offset().left + context.data.$container.width(); |
| 5940 | + context.data.$container.width( Math.min( expWidth, maxWidth ) ); |
5942 | 5941 | } |
5943 | 5942 | // autoEllipse the results. Has to be done after changing the width |
5944 | 5943 | $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } ); |
— | — | @@ -5950,9 +5949,6 @@ |
5951 | 5950 | case 'delay': |
5952 | 5951 | context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
5953 | 5952 | break; |
5954 | | - case 'maxExpandFactor': |
5955 | | - context.config[property] = Math.max( 1, value ); |
5956 | | - break; |
5957 | 5953 | case 'submitOnClick': |
5958 | 5954 | case 'positionFromLeft': |
5959 | 5955 | context.config[property] = value ? true : false; |
— | — | @@ -6105,7 +6101,6 @@ |
6106 | 6102 | 'maxRows': 7, |
6107 | 6103 | 'delay': 120, |
6108 | 6104 | 'submitOnClick': false, |
6109 | | - 'maxExpandFactor': 2, |
6110 | 6105 | 'positionFromLeft': true |
6111 | 6106 | } |
6112 | 6107 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -397,11 +397,11 @@ |
398 | 398 | if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();} |
399 | 399 | $.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'} |
400 | 400 | 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 $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,context.config.suggestions[i]);}else{$result.append($('<span />').css('whiteSpace','nowrap').text(context.config.suggestions[i]));var $span=$result.children('span');if($span.width()>$result.width()){expWidth=Math.max(expWidth,Math.min($span.width(),context.data.$textbox.width()*context.config.maxExpandFactor));} |
| 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 $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,context.config.suggestions[i]);}else{$result.append($('<span />').css('whiteSpace','nowrap').text(context.config.suggestions[i]));var $span=$result.children('span');if($span.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();} |
402 | 402 | $autoEllipseMe=$autoEllipseMe.add($result);}} |
403 | | -if(expWidth!=-1){context.data.$container.width(expWidth);} |
| 403 | +if(expWidth>context.data.$container.width()){var maxWidth=context.config.positionFromLeft?$('body').width()-context.data.$container.offset().left:context.data.$container.offset().left+context.data.$container.width();context.data.$container.width(Math.min(expWidth,maxWidth));} |
404 | 404 | $autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true});}} |
405 | | -break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(1200,value));break;case'maxExpandFactor':context.config[property]=Math.max(1,value);break;case'submitOnClick':case'positionFromLeft':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current');if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-results div:last')}else{result=selected.prev();if(selected.length==0){if(context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}else{result=context.data.$container.find('.suggestions-results div:last');}}}}else if(result=='next'){if(selected.length==0){result=context.data.$container.find('.suggestions-results div:first');if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}else{result=selected.next();if(selected.is('.suggestions-special')){result=$([]);}else if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}} |
| 405 | +break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(1200,value));break;case'submitOnClick':case'positionFromLeft':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current');if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-results div:last')}else{result=selected.prev();if(selected.length==0){if(context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}else{result=context.data.$container.find('.suggestions-results div:last');}}}}else if(result=='next'){if(selected.length==0){result=context.data.$container.find('.suggestions-results div:first');if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}else{result=selected.next();if(selected.is('.suggestions-special')){result=$([]);}else if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}} |
406 | 406 | selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');} |
407 | 407 | if(updateTextbox){if(result.length==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();} |
408 | 408 | context.data.$textbox.trigger('change');} |
— | — | @@ -409,7 +409,7 @@ |
410 | 410 | preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',false);} |
411 | 411 | preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;selected=context.data.$container.find('.suggestions-result-current');if(selected.size()==0){$.suggestions.cancel(context);context.config.$region.closest('form').submit();}else if(selected.is('.suggestions-special')){if(typeof context.config.special.select=='function'){context.config.special.select.call(selected,context.data.$textbox);}}else{if(typeof context.config.result.select=='function'){$.suggestions.highlight(context,selected,true);context.config.result.select.call(selected,context.data.$textbox);}else{$.suggestions.highlight(context,selected,true);}} |
412 | 412 | break;default:$.suggestions.update(context,true);break;} |
413 | | -if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'||context==null){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false,'maxExpandFactor':2,'positionFromLeft':true}};} |
| 413 | +if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'||context==null){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false,'positionFromLeft':true}};} |
414 | 414 | if(args.length>0){if(typeof args[0]=='object'){for(var key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}} |
415 | 415 | if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};var newCSS={'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'width':context.data.$textbox.outerWidth(),'display':'none'} |
416 | 416 | 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());} |