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' => 9 ), |
| 74 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 10 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 30 ), |
76 | 76 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 181 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 52 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 377 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 378 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 377 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 378 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -177,16 +177,32 @@ |
178 | 178 | var selected = context.data.$container.find( '.suggestions-result-current' ); |
179 | 179 | if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) { |
180 | 180 | if ( result == 'prev' ) { |
181 | | - result = selected.prev(); |
| 181 | + if( selected.is( '.suggestions-special' ) ) { |
| 182 | + result = context.data.$container.find( '.suggestions-results div:last' ) |
| 183 | + } else { |
| 184 | + result = selected.prev(); |
| 185 | + if ( selected.size() == 0 ) { |
| 186 | + // we are at the begginning, so lets jump to the last item |
| 187 | + if ( context.data.$container.find( '.suggestions-special' ).html() != "" ) { |
| 188 | + result = context.data.$container.find( '.suggestions-special' ); |
| 189 | + } else { |
| 190 | + result = context.data.$container.find( '.suggestions-results div:last' ); |
| 191 | + } |
| 192 | + |
| 193 | + } |
| 194 | + } |
182 | 195 | } else if ( result == 'next' ) { |
183 | 196 | if ( selected.size() == 0 ) |
184 | 197 | // No item selected, go to the first one |
185 | 198 | result = context.data.$container.find( '.suggestions-results div:first' ); |
186 | 199 | else { |
187 | 200 | result = selected.next(); |
188 | | - if ( result.size() == 0 ) |
189 | | - // We were at the last item, stay there |
190 | | - result = selected; |
| 201 | + if ( selected.is( '.suggestions-special' ) ) { |
| 202 | + result = []; |
| 203 | + } else if ( result.size() == 0 && context.data.$container.find( '.suggestions-special' ).html() != "" ) { |
| 204 | + // We were at the last item, jump to the specials! |
| 205 | + result = context.data.$container.find( '.suggestions-special' ); |
| 206 | + } |
191 | 207 | } |
192 | 208 | } |
193 | 209 | selected.removeClass( 'suggestions-result-current' ); |
— | — | @@ -215,7 +231,7 @@ |
216 | 232 | // Arrow down |
217 | 233 | case 40: |
218 | 234 | if ( wasVisible ) { |
219 | | - $.suggestions.highlight( context, 'next', true ); |
| 235 | + $.suggestions.highlight( context, 'next', false ); |
220 | 236 | } else { |
221 | 237 | $.suggestions.update( context, false ); |
222 | 238 | } |
— | — | @@ -225,7 +241,7 @@ |
226 | 242 | // Arrow up |
227 | 243 | case 38: |
228 | 244 | if ( wasVisible ) { |
229 | | - $.suggestions.highlight( context, 'prev', true ); |
| 245 | + $.suggestions.highlight( context, 'prev', false ); |
230 | 246 | } |
231 | 247 | context.data.$textbox.trigger( 'change' ); |
232 | 248 | preventDefault = wasVisible; |
— | — | @@ -242,11 +258,16 @@ |
243 | 259 | case 13: |
244 | 260 | context.data.$container.hide(); |
245 | 261 | preventDefault = wasVisible; |
246 | | - if ( typeof context.config.result.select == 'function' ) { |
247 | | - context.config.result.select.call( |
248 | | - context.data.$container.find( '.suggestions-result-current' ), |
249 | | - context.data.$textbox |
250 | | - ); |
| 262 | + selected = context.data.$container.find( '.suggestions-result-current' ) |
| 263 | + if ( selected.is( '.suggestions-special' ) ) { |
| 264 | + if ( typeof context.config.special.select == 'function' ) { |
| 265 | + context.config.special.select.call( selected, context.data.$textbox ); |
| 266 | + } |
| 267 | + } else { |
| 268 | + if ( typeof context.config.result.select == 'function' ) { |
| 269 | + context.data.$textbox.val( selected.text() ); |
| 270 | + context.config.result.select.call( selected, context.data.$textbox ); |
| 271 | + } |
251 | 272 | } |
252 | 273 | break; |
253 | 274 | default: |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -5915,16 +5915,32 @@ |
5916 | 5916 | var selected = context.data.$container.find( '.suggestions-result-current' ); |
5917 | 5917 | if ( !result.get || selected.get( 0 ) != result.get( 0 ) ) { |
5918 | 5918 | if ( result == 'prev' ) { |
5919 | | - result = selected.prev(); |
| 5919 | + if( selected.is( '.suggestions-special' ) ) { |
| 5920 | + result = context.data.$container.find( '.suggestions-results div:last' ) |
| 5921 | + } else { |
| 5922 | + result = selected.prev(); |
| 5923 | + if ( selected.size() == 0 ) { |
| 5924 | + // we are at the begginning, so lets jump to the last item |
| 5925 | + if ( context.data.$container.find( '.suggestions-special' ).html() != "" ) { |
| 5926 | + result = context.data.$container.find( '.suggestions-special' ); |
| 5927 | + } else { |
| 5928 | + result = context.data.$container.find( '.suggestions-results div:last' ); |
| 5929 | + } |
| 5930 | + |
| 5931 | + } |
| 5932 | + } |
5920 | 5933 | } else if ( result == 'next' ) { |
5921 | 5934 | if ( selected.size() == 0 ) |
5922 | 5935 | // No item selected, go to the first one |
5923 | 5936 | result = context.data.$container.find( '.suggestions-results div:first' ); |
5924 | 5937 | else { |
5925 | 5938 | result = selected.next(); |
5926 | | - if ( result.size() == 0 ) |
5927 | | - // We were at the last item, stay there |
5928 | | - result = selected; |
| 5939 | + if ( selected.is( '.suggestions-special' ) ) { |
| 5940 | + result = []; |
| 5941 | + } else if ( result.size() == 0 && context.data.$container.find( '.suggestions-special' ).html() != "" ) { |
| 5942 | + // We were at the last item, jump to the specials! |
| 5943 | + result = context.data.$container.find( '.suggestions-special' ); |
| 5944 | + } |
5929 | 5945 | } |
5930 | 5946 | } |
5931 | 5947 | selected.removeClass( 'suggestions-result-current' ); |
— | — | @@ -5953,7 +5969,7 @@ |
5954 | 5970 | // Arrow down |
5955 | 5971 | case 40: |
5956 | 5972 | if ( wasVisible ) { |
5957 | | - $.suggestions.highlight( context, 'next', true ); |
| 5973 | + $.suggestions.highlight( context, 'next', false ); |
5958 | 5974 | } else { |
5959 | 5975 | $.suggestions.update( context, false ); |
5960 | 5976 | } |
— | — | @@ -5963,7 +5979,7 @@ |
5964 | 5980 | // Arrow up |
5965 | 5981 | case 38: |
5966 | 5982 | if ( wasVisible ) { |
5967 | | - $.suggestions.highlight( context, 'prev', true ); |
| 5983 | + $.suggestions.highlight( context, 'prev', false ); |
5968 | 5984 | } |
5969 | 5985 | context.data.$textbox.trigger( 'change' ); |
5970 | 5986 | preventDefault = wasVisible; |
— | — | @@ -5980,11 +5996,16 @@ |
5981 | 5997 | case 13: |
5982 | 5998 | context.data.$container.hide(); |
5983 | 5999 | preventDefault = wasVisible; |
5984 | | - if ( typeof context.config.result.select == 'function' ) { |
5985 | | - context.config.result.select.call( |
5986 | | - context.data.$container.find( '.suggestions-result-current' ), |
5987 | | - context.data.$textbox |
5988 | | - ); |
| 6000 | + selected = context.data.$container.find( '.suggestions-result-current' ) |
| 6001 | + if ( selected.is( '.suggestions-special' ) ) { |
| 6002 | + if ( typeof context.config.special.select == 'function' ) { |
| 6003 | + context.config.special.select.call( selected, context.data.$textbox ); |
| 6004 | + } |
| 6005 | + } else { |
| 6006 | + if ( typeof context.config.result.select == 'function' ) { |
| 6007 | + context.data.$textbox.val( selected.text() ); |
| 6008 | + context.config.result.select.call( selected, context.data.$textbox ); |
| 6009 | + } |
5989 | 6010 | } |
5990 | 6011 | break; |
5991 | 6012 | default: |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -395,14 +395,14 @@ |
396 | 396 | if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();} |
397 | 397 | $.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');if($special.children().length==0){$special.mousemove(function(){$.suggestions.highlight(context,$([]),false);});} |
398 | 398 | 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();context.data.$container.css({'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto','left':context.config.$region.offset().left,'right':'auto'});var $results=context.data.$container.children('.suggestions-results');$results.empty();for(var i=0;i<context.config.suggestions.length;i++){$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.text(context.config.suggestions[i]).autoEllipsis();}}}} |
399 | | -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':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'){result=selected.prev();}else if(result=='next'){if(selected.size()==0) |
400 | | -result=context.data.$container.find('.suggestions-results div:first');else{result=selected.next();if(result.size()==0) |
401 | | -result=selected;}} |
| 399 | +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':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.size()==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.size()==0) |
| 400 | +result=context.data.$container.find('.suggestions-results div:first');else{result=selected.next();if(selected.is('.suggestions-special')){result=[];}else if(result.size()==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}} |
402 | 401 | selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');} |
403 | 402 | if(updateTextbox){if(result.size()==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();}} |
404 | | -$.suggestions.special(context);},keypress:function(e,context,key){var wasVisible=context.data.$container.is(':visible');var preventDefault=false;switch(key){case 40:if(wasVisible){$.suggestions.highlight(context,'next',true);}else{$.suggestions.update(context,false);} |
405 | | -context.data.$textbox.trigger('change');preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',true);} |
406 | | -context.data.$textbox.trigger('change');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;if(typeof context.config.result.select=='function'){context.config.result.select.call(context.data.$container.find('.suggestions-result-current'),context.data.$textbox);} |
| 403 | +$.suggestions.special(context);},keypress:function(e,context,key){var wasVisible=context.data.$container.is(':visible');var preventDefault=false;switch(key){case 40:if(wasVisible){$.suggestions.highlight(context,'next',false);}else{$.suggestions.update(context,false);} |
| 404 | +context.data.$textbox.trigger('change');preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',false);} |
| 405 | +context.data.$textbox.trigger('change');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') |
| 406 | +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'){context.data.$textbox.val(selected.text());context.config.result.select.call(selected,context.data.$textbox);}} |
407 | 407 | break;default:$.suggestions.update(context,true);break;} |
408 | 408 | 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={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false}};} |
409 | 409 | 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]]);}}} |