Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 4 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
67 | 67 | array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 17 ), |
68 | | - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 28 ), |
| 68 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 29 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 36 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 195 ), |
71 | 71 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ), |
— | — | @@ -80,10 +80,10 @@ |
81 | 81 | array( 'src' => 'js/thirdparty/contentCollector.js', 'version' => 2 ), |
82 | 82 | ), |
83 | 83 | 'combined' => array( |
84 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 436 ), |
| 84 | + array( 'src' => 'js/plugins.combined.js', 'version' => 437 ), |
85 | 85 | ), |
86 | 86 | 'minified' => array( |
87 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 440 ), |
| 87 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 441 ), |
88 | 88 | ), |
89 | 89 | ), |
90 | 90 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -155,6 +155,7 @@ |
156 | 156 | .attr( 'rel', i ) |
157 | 157 | .data( 'text', context.config.suggestions[i] ) |
158 | 158 | .mousemove( function( e ) { |
| 159 | + context.data.selectedWithMouse = true; |
159 | 160 | $.suggestions.highlight( |
160 | 161 | context, $(this).closest( '.suggestions-results div' ), false |
161 | 162 | ); |
— | — | @@ -278,6 +279,7 @@ |
279 | 280 | case 40: |
280 | 281 | if ( wasVisible ) { |
281 | 282 | $.suggestions.highlight( context, 'next', true ); |
| 283 | + context.data.selectedWithMouse = false; |
282 | 284 | } else { |
283 | 285 | $.suggestions.update( context, false ); |
284 | 286 | } |
— | — | @@ -287,6 +289,7 @@ |
288 | 290 | case 38: |
289 | 291 | if ( wasVisible ) { |
290 | 292 | $.suggestions.highlight( context, 'prev', true ); |
| 293 | + context.data.selectedWithMouse = false; |
291 | 294 | } |
292 | 295 | preventDefault = wasVisible; |
293 | 296 | break; |
— | — | @@ -303,8 +306,9 @@ |
304 | 307 | context.data.$container.hide(); |
305 | 308 | preventDefault = wasVisible; |
306 | 309 | selected = context.data.$container.find( '.suggestions-result-current' ); |
307 | | - if ( selected.size() == 0 ) { |
308 | | - // if nothing is selected, cancel any current requests and submit the form |
| 310 | + if ( selected.size() == 0 || context.data.selectedWithMouse ) { |
| 311 | + // if nothing is selected OR if something was selected with the mouse, |
| 312 | + // cancel any current requests and submit the form |
309 | 313 | $.suggestions.cancel( context ); |
310 | 314 | context.config.$region.closest( 'form' ).submit(); |
311 | 315 | } else if ( selected.is( '.suggestions-special' ) ) { |
— | — | @@ -392,7 +396,8 @@ |
393 | 397 | 'visibleResults': 0, |
394 | 398 | // Suggestion the last mousedown event occured on |
395 | 399 | 'mouseDownOn': $( [] ), |
396 | | - '$textbox': $(this) |
| 400 | + '$textbox': $(this), |
| 401 | + 'selectedWithMouse': false |
397 | 402 | }; |
398 | 403 | // Setup the css for positioning the results box |
399 | 404 | var newCSS = { |
— | — | @@ -454,6 +459,7 @@ |
455 | 460 | context.data.$textbox.focus(); |
456 | 461 | } ) |
457 | 462 | .mousemove( function( e ) { |
| 463 | + context.data.selectedWithMouse = true; |
458 | 464 | $.suggestions.highlight( |
459 | 465 | context, $( e.target ).closest( '.suggestions-special' ), false |
460 | 466 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -1124,6 +1124,7 @@ |
1125 | 1125 | .attr( 'rel', i ) |
1126 | 1126 | .data( 'text', context.config.suggestions[i] ) |
1127 | 1127 | .mousemove( function( e ) { |
| 1128 | + context.data.selectedWithMouse = true; |
1128 | 1129 | $.suggestions.highlight( |
1129 | 1130 | context, $(this).closest( '.suggestions-results div' ), false |
1130 | 1131 | ); |
— | — | @@ -1247,6 +1248,7 @@ |
1248 | 1249 | case 40: |
1249 | 1250 | if ( wasVisible ) { |
1250 | 1251 | $.suggestions.highlight( context, 'next', true ); |
| 1252 | + context.data.selectedWithMouse = false; |
1251 | 1253 | } else { |
1252 | 1254 | $.suggestions.update( context, false ); |
1253 | 1255 | } |
— | — | @@ -1256,6 +1258,7 @@ |
1257 | 1259 | case 38: |
1258 | 1260 | if ( wasVisible ) { |
1259 | 1261 | $.suggestions.highlight( context, 'prev', true ); |
| 1262 | + context.data.selectedWithMouse = false; |
1260 | 1263 | } |
1261 | 1264 | preventDefault = wasVisible; |
1262 | 1265 | break; |
— | — | @@ -1272,8 +1275,9 @@ |
1273 | 1276 | context.data.$container.hide(); |
1274 | 1277 | preventDefault = wasVisible; |
1275 | 1278 | selected = context.data.$container.find( '.suggestions-result-current' ); |
1276 | | - if ( selected.size() == 0 ) { |
1277 | | - // if nothing is selected, cancel any current requests and submit the form |
| 1279 | + if ( selected.size() == 0 || context.data.selectedWithMouse ) { |
| 1280 | + // if nothing is selected OR if something was selected with the mouse, |
| 1281 | + // cancel any current requests and submit the form |
1278 | 1282 | $.suggestions.cancel( context ); |
1279 | 1283 | context.config.$region.closest( 'form' ).submit(); |
1280 | 1284 | } else if ( selected.is( '.suggestions-special' ) ) { |
— | — | @@ -1361,7 +1365,8 @@ |
1362 | 1366 | 'visibleResults': 0, |
1363 | 1367 | // Suggestion the last mousedown event occured on |
1364 | 1368 | 'mouseDownOn': $( [] ), |
1365 | | - '$textbox': $(this) |
| 1369 | + '$textbox': $(this), |
| 1370 | + 'selectedWithMouse': false |
1366 | 1371 | }; |
1367 | 1372 | // Setup the css for positioning the results box |
1368 | 1373 | var newCSS = { |
— | — | @@ -1423,6 +1428,7 @@ |
1424 | 1429 | context.data.$textbox.focus(); |
1425 | 1430 | } ) |
1426 | 1431 | .mousemove( function( e ) { |
| 1432 | + context.data.selectedWithMouse = true; |
1427 | 1433 | $.suggestions.highlight( |
1428 | 1434 | context, $( e.target ).closest( '.suggestions-special' ), false |
1429 | 1435 | ); |
— | — | @@ -7349,3 +7355,5 @@ |
7350 | 7356 | |
7351 | 7357 | return cc; |
7352 | 7358 | } |
| 7359 | + |
| 7360 | + |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();} |
64 | 64 | $.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'} |
65 | 65 | 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());} |
66 | | -context.data.$container.css(newCSS);var $results=context.data.$container.children('.suggestions-results');$results.empty();var expWidth=-1;var $autoEllipseMe=$([]);var matchedText=null;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]).mousemove(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{if(context.config.highlightInput){matchedText=text.substr(0,context.data.prevText.length);} |
| 66 | +context.data.$container.css(newCSS);var $results=context.data.$container.children('.suggestions-results');$results.empty();var expWidth=-1;var $autoEllipseMe=$([]);var matchedText=null;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]).mousemove(function(e){context.data.selectedWithMouse=true;$.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{if(context.config.highlightInput){matchedText=text.substr(0,context.data.prevText.length);} |
67 | 67 | $result.append($('<span />').css('whiteSpace','nowrap').text(text));var $span=$result.children('span');if($span.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();} |
68 | 68 | $autoEllipseMe=$autoEllipseMe.add($result);}} |
69 | 69 | if(expWidth>context.data.$container.width()){var maxWidth=context.config.maxExpandFactor*context.data.$textbox.width();context.data.$container.width(Math.min(expWidth,maxWidth));} |
— | — | @@ -70,19 +70,19 @@ |
71 | 71 | 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':case'highlightInput':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-result: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');}}} |
72 | 72 | selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');} |
73 | 73 | if(updateTextbox){if(result.length==0||result.is('.suggestions-special')){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();} |
74 | | -context.data.$textbox.trigger('change');}},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);} |
75 | | -preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',true);} |
76 | | -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);}} |
| 74 | +context.data.$textbox.trigger('change');}},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);context.data.selectedWithMouse=false;}else{$.suggestions.update(context,false);} |
| 75 | +preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',true);context.data.selectedWithMouse=false;} |
| 76 | +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||context.data.selectedWithMouse){$.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);}} |
77 | 77 | break;default:$.suggestions.update(context,true);break;} |
78 | 78 | 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,'highlightInput':false}};} |
79 | 79 | 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]]);}}} |
80 | | -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'} |
| 80 | +if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this),'selectedWithMouse':false};var newCSS={'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'width':context.data.$textbox.outerWidth(),'display':'none'} |
81 | 81 | 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());} |
82 | 82 | context.data.$container=$('<div />').css(newCSS).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;} |
83 | 83 | $.suggestions.highlight(context,$result,true);context.data.$container.hide();if(typeof context.config.result.select=='function'){context.config.result.select.call($result,context.data.$textbox);} |
84 | 84 | context.data.$textbox.focus();})).append($('<div />').addClass('suggestions-special').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-special');}).mouseup(function(e){var $special=$(e.target).closest('.suggestions-special');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($special.get(0)!=$other.get(0)){return;} |
85 | 85 | context.data.$container.hide();if(typeof context.config.special.select=='function'){context.config.special.select.call($special,context.data.$textbox);} |
86 | | -context.data.$textbox.focus();}).mousemove(function(e){$.suggestions.highlight(context,$(e.target).closest('.suggestions-special'),false);})).appendTo($('body'));$(this).attr('autocomplete','off').keydown(function(e){context.data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;context.data.keypressedCount=0;switch(context.data.keypressed){case 40:e.preventDefault();e.stopImmediatePropagation();break;case 38:case 27:case 13:if(context.data.$container.is(':visible')){e.preventDefault();e.stopImmediatePropagation();}}}).keypress(function(e){context.data.keypressedCount++;$.suggestions.keypress(e,context,context.data.keypressed);}).keyup(function(e){if(context.data.keypressedCount==0){$.suggestions.keypress(e,context,context.data.keypressed);}}).blur(function(){if(context.data.mouseDownOn.length>0){return;} |
| 86 | +context.data.$textbox.focus();}).mousemove(function(e){context.data.selectedWithMouse=true;$.suggestions.highlight(context,$(e.target).closest('.suggestions-special'),false);})).appendTo($('body'));$(this).attr('autocomplete','off').keydown(function(e){context.data.keypressed=(e.keyCode==undefined)?e.which:e.keyCode;context.data.keypressedCount=0;switch(context.data.keypressed){case 40:e.preventDefault();e.stopImmediatePropagation();break;case 38:case 27:case 13:if(context.data.$container.is(':visible')){e.preventDefault();e.stopImmediatePropagation();}}}).keypress(function(e){context.data.keypressedCount++;$.suggestions.keypress(e,context,context.data.keypressed);}).keyup(function(e){if(context.data.keypressedCount==0){$.suggestions.keypress(e,context,context.data.keypressed);}}).blur(function(){if(context.data.mouseDownOn.length>0){return;} |
87 | 87 | context.data.$container.hide();$.suggestions.cancel(context);});} |
88 | 88 | $(this).data('suggestions-context',context);});return returnValue!==null?returnValue:$(this);};})(jQuery);(function($){$.fn.textSelection=function(command,options){var fn={getContents:function(){return this.val();},getSelection:function(){var e=this.get(0);var retval='';if($(e).is(':hidden')){}else if(document.selection&&document.selection.createRange){e.focus();var range=document.selection.createRange();retval=range.text;}else if(e.selectionStart||e.selectionStart=='0'){retval=e.value.substring(e.selectionStart,e.selectionEnd);} |
89 | 89 | return retval;},encapsulateSelection:function(options){return this.each(function(){function checkSelectedText(){if(!selText){selText=options.peri;isSample=true;}else if(options.replace){selText=options.peri;}else if(selText.charAt(selText.length-1)==' '){selText=selText.substring(0,selText.length-1);options.post+=' ';}} |