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' => 17 ), |
| 74 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 18 ), |
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' => 401 ), |
| 89 | + array( 'src' => 'js/plugins.combined.js', 'version' => 402 ), |
90 | 90 | ), |
91 | 91 | 'minified' => array( |
92 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 401 ), |
| 92 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 402 ), |
93 | 93 | ), |
94 | 94 | ), |
95 | 95 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -33,6 +33,9 @@ |
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: 3 |
37 | 40 | * positionFromLeft: Whether to position the suggestion box with the left attribute or the right |
38 | 41 | * Type: Boolean, Default: true |
39 | 42 | */ |
— | — | @@ -175,10 +178,7 @@ |
176 | 179 | } |
177 | 180 | // Apply new width for results box, if any |
178 | 181 | 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(); |
| 182 | + var maxWidth = context.config.maxExpandFactor*context.data.$textbox.width(); |
183 | 183 | context.data.$container.width( Math.min( expWidth, maxWidth ) ); |
184 | 184 | } |
185 | 185 | // autoEllipse the results. Has to be done after changing the width |
— | — | @@ -192,6 +192,9 @@ |
193 | 193 | case 'delay': |
194 | 194 | context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
195 | 195 | break; |
| 196 | + case 'maxExpandFactor': |
| 197 | + context.config[property] = Math.max( 1, value ); |
| 198 | + break; |
196 | 199 | case 'submitOnClick': |
197 | 200 | case 'positionFromLeft': |
198 | 201 | context.config[property] = value ? true : false; |
— | — | @@ -344,6 +347,7 @@ |
345 | 348 | 'maxRows': 7, |
346 | 349 | 'delay': 120, |
347 | 350 | 'submitOnClick': false, |
| 351 | + 'maxExpandFactor': 3, |
348 | 352 | 'positionFromLeft': true |
349 | 353 | } |
350 | 354 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -5790,6 +5790,9 @@ |
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: 3 |
5794 | 5797 | * positionFromLeft: Whether to position the suggestion box with the left attribute or the right |
5795 | 5798 | * Type: Boolean, Default: true |
5796 | 5799 | */ |
— | — | @@ -5932,10 +5935,7 @@ |
5933 | 5936 | } |
5934 | 5937 | // Apply new width for results box, if any |
5935 | 5938 | 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(); |
| 5939 | + var maxWidth = context.config.maxExpandFactor*context.data.$textbox.width(); |
5940 | 5940 | context.data.$container.width( Math.min( expWidth, maxWidth ) ); |
5941 | 5941 | } |
5942 | 5942 | // autoEllipse the results. Has to be done after changing the width |
— | — | @@ -5949,6 +5949,9 @@ |
5950 | 5950 | case 'delay': |
5951 | 5951 | context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
5952 | 5952 | break; |
| 5953 | + case 'maxExpandFactor': |
| 5954 | + context.config[property] = Math.max( 1, value ); |
| 5955 | + break; |
5953 | 5956 | case 'submitOnClick': |
5954 | 5957 | case 'positionFromLeft': |
5955 | 5958 | context.config[property] = value ? true : false; |
— | — | @@ -6101,6 +6104,7 @@ |
6102 | 6105 | 'maxRows': 7, |
6103 | 6106 | 'delay': 120, |
6104 | 6107 | 'submitOnClick': false, |
| 6108 | + 'maxExpandFactor': 3, |
6105 | 6109 | 'positionFromLeft': true |
6106 | 6110 | } |
6107 | 6111 | }; |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -399,9 +399,9 @@ |
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 | 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>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));} |
| 403 | +if(expWidth>context.data.$container.width()){var maxWidth=context.config.maxExpandFactor*context.data.$textbox.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'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'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');}}} |
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,'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,'maxExpandFactor':3,'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());} |