Index: trunk/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | } |
77 | 77 | }, |
78 | 78 | delay: 120, |
79 | | - expandToLeft: !$j( 'body' ).is( 'rtl' ) |
| 79 | + positionFromLeft: $j( 'body' ).is( '.rtl' ) |
80 | 80 | } ); |
81 | 81 | $j( '#searchInput' ).suggestions( { |
82 | 82 | result: { |
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.hooks.php |
— | — | @@ -16,13 +16,13 @@ |
17 | 17 | array( 'src' => 'Modules/CollapsibleTabs/CollapsibleTabs.js', 'version' => 8 ), |
18 | 18 | array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 8 ), |
19 | 19 | array( 'src' => 'Modules/FooterCleanup/FooterCleanup.js', 'version' => 5 ), |
20 | | - array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 10 ), |
| 20 | + array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 11 ), |
21 | 21 | ), |
22 | 22 | 'combined' => array( |
23 | | - array( 'src' => 'Vector.combined.js', 'version' => 30 ), |
| 23 | + array( 'src' => 'Vector.combined.js', 'version' => 31 ), |
24 | 24 | ), |
25 | 25 | 'minified' => array( |
26 | | - array( 'src' => 'Vector.combined.min.js', 'version' => 30 ), |
| 26 | + array( 'src' => 'Vector.combined.min.js', 'version' => 31 ), |
27 | 27 | ), |
28 | 28 | ); |
29 | 29 | static $modules = array( |
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.js |
— | — | @@ -336,7 +336,7 @@ |
337 | 337 | } |
338 | 338 | }, |
339 | 339 | delay: 120, |
340 | | - expandToLeft: !$j( 'body' ).is( 'rtl' ) |
| 340 | + positionFromLeft: $j( 'body' ).is( '.rtl' ) |
341 | 341 | } ); |
342 | 342 | $j( '#searchInput' ).suggestions( { |
343 | 343 | result: { |
Index: trunk/extensions/UsabilityInitiative/Vector/Vector.combined.min.js |
— | — | @@ -14,5 +14,5 @@ |
15 | 15 | +transclusionCount |
16 | 16 | +'</strong> other pages.</label>');$j('.mw-templatesUsedExplanation').remove();$j('.collapsible-list label').click(function(){$j(this).parent().toggleClass('expanded').toggleClass('collapsed').find('ul').slideToggle('fast');return false;}).trigger('click');$j('#wpPreview, #wpDiff, .editHelp, #editpage-specialchars').remove();$j('#mw-editform-cancel').remove().appendTo('.editButtons');});if(wgVectorEnabledModules.simplesearch&&skin=='vector'&&typeof os_autoload_inputs!=='undefined'&&os_autoload_forms!=='undefined'){os_autoload_inputs=[];os_autoload_forms=[];} |
17 | 17 | $j(document).ready(function(){if(!wgVectorEnabledModules.simplesearch||skin!='vector'){return true;} |
18 | | -$j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120,expandToLeft:!$j('body').is('rtl')});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show() |
| 18 | +$j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120,positionFromLeft:$j('body').is('.rtl')});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show() |
19 | 19 | $label=$j('<div />').addClass('special-label').text(mw.usability.getMsg('vector-simplesearch-containing')).appendTo($j(this));$query=$j('<div />').addClass('special-query').text(query).appendTo($j(this));$query.autoEllipsis();}else{$j(this).find('.special-query').empty().text(query).autoEllipsis();}},select:function($textbox){$textbox.closest('form').append($j('<input />').attr({'type':'hidden','name':'fulltext','value':1}));$textbox.closest('form').submit();}},$region:$j('#simpleSearch')});}); |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 16 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 15 ), |
76 | | - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 16 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 17 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 33 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 187 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ), |
— | — | @@ -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' => 398 ), |
| 89 | + array( 'src' => 'js/plugins.combined.js', 'version' => 399 ), |
90 | 90 | ), |
91 | 91 | 'minified' => array( |
92 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 398 ), |
| 92 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 399 ), |
93 | 93 | ), |
94 | 94 | ), |
95 | 95 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -36,8 +36,8 @@ |
37 | 37 | * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box |
38 | 38 | * will never be grown beyond 2 times the width of the textbox. |
39 | 39 | * Type: Number, Range: 1 - infinity, Default: 2 |
40 | | - * expandToLeft: Whether to expand the suggestion box to the left rather than to the right |
41 | | - * Type: Boolean, Default: false |
| 40 | + * positionFromLeft: Wether to position the suggestion box with the left attribute or the right |
| 41 | + * Type: Boolean, Default: true |
42 | 42 | */ |
43 | 43 | ( function( $ ) { |
44 | 44 | |
— | — | @@ -127,14 +127,22 @@ |
128 | 128 | // Rebuild the suggestions list |
129 | 129 | context.data.$container.show(); |
130 | 130 | // Update the size and position of the list |
131 | | - context.data.$container.css( { |
| 131 | + var newCSS = { |
132 | 132 | 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
133 | 133 | 'bottom': 'auto', |
134 | 134 | 'width': context.config.$region.outerWidth(), |
135 | | - 'height': 'auto', |
136 | | - 'left': context.config.$region.offset().left, |
137 | | - 'right': 'auto' |
138 | | - } ); |
| 135 | + 'height': 'auto' |
| 136 | + } |
| 137 | + if ( context.config.positionFromLeft ) { |
| 138 | + console.log("LEFT"); |
| 139 | + newCSS['left'] = context.config.$region.offset().left; |
| 140 | + newCSS['right'] = 'auto'; |
| 141 | + } else { |
| 142 | + console.log("right"); |
| 143 | + newCSS['left'] = 'auto'; |
| 144 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 145 | + } |
| 146 | + context.data.$container.css( newCSS ); |
139 | 147 | var $results = context.data.$container.children( '.suggestions-results' ); |
140 | 148 | $results.empty(); |
141 | 149 | var expWidth = -1; |
— | — | @@ -174,12 +182,6 @@ |
175 | 183 | } |
176 | 184 | // Apply new width for results box, if any |
177 | 185 | if ( expWidth != -1 ) { |
178 | | - if ( context.config.expandToLeft ) { |
179 | | - context.data.$container.css( 'left', |
180 | | - context.data.$container.offset().left - |
181 | | - ( expWidth - context.data.$container.width() ) |
182 | | - ); |
183 | | - } |
184 | 186 | context.data.$container.width( expWidth ); |
185 | 187 | } |
186 | 188 | // autoEllipse the results. Has to be done after changing the width |
— | — | @@ -197,7 +199,7 @@ |
198 | 200 | context.config[property] = Math.max( 1, value ); |
199 | 201 | break; |
200 | 202 | case 'submitOnClick': |
201 | | - case 'expandToLeft': |
| 203 | + case 'positionFromLeft': |
202 | 204 | context.config[property] = value ? true : false; |
203 | 205 | break; |
204 | 206 | } |
— | — | @@ -339,7 +341,7 @@ |
340 | 342 | if ( typeof context == 'undefined' || context == null ) { |
341 | 343 | context = { |
342 | 344 | config: { |
343 | | - 'fetch' : function() {}, |
| 345 | + 'fetch' : function() {}, |
344 | 346 | 'cancel': function() {}, |
345 | 347 | 'special': {}, |
346 | 348 | 'result': {}, |
— | — | @@ -349,7 +351,7 @@ |
350 | 352 | 'delay': 120, |
351 | 353 | 'submitOnClick': false, |
352 | 354 | 'maxExpandFactor': 2, |
353 | | - 'expandToLeft': false |
| 355 | + 'positionFromLeft': true |
354 | 356 | } |
355 | 357 | }; |
356 | 358 | } |
— | — | @@ -388,13 +390,22 @@ |
389 | 391 | 'mouseDownOn': $( [] ), |
390 | 392 | '$textbox': $(this) |
391 | 393 | }; |
| 394 | + // Setup the css for positioning the results box |
| 395 | + var newCSS = { |
| 396 | + 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
| 397 | + 'width': context.data.$textbox.outerWidth(), |
| 398 | + 'display': 'none' |
| 399 | + } |
| 400 | + if ( context.config.positionFromLeft ) { |
| 401 | + newCSS['left'] = context.config.$region.offset().left; |
| 402 | + newCSS['right'] = 'auto'; |
| 403 | + } else { |
| 404 | + newCSS['left'] = 'auto'; |
| 405 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 406 | + } |
| 407 | + |
392 | 408 | context.data.$container = $( '<div />' ) |
393 | | - .css( { |
394 | | - 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
395 | | - 'left': Math.round( context.data.$textbox.offset().left ), |
396 | | - 'width': context.data.$textbox.outerWidth(), |
397 | | - 'display': 'none' |
398 | | - } ) |
| 409 | + .css( newCSS ) |
399 | 410 | .addClass( 'suggestions' ) |
400 | 411 | .append( |
401 | 412 | $( '<div />' ).addClass( 'suggestions-results' ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -5793,8 +5793,8 @@ |
5794 | 5794 | * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box |
5795 | 5795 | * will never be grown beyond 2 times the width of the textbox. |
5796 | 5796 | * Type: Number, Range: 1 - infinity, Default: 2 |
5797 | | - * expandToLeft: Whether to expand the suggestion box to the left rather than to the right |
5798 | | - * Type: Boolean, Default: false |
| 5797 | + * positionFromLeft: Wether to position the suggestion box with the left attribute or the right |
| 5798 | + * Type: Boolean, Default: true |
5799 | 5799 | */ |
5800 | 5800 | ( function( $ ) { |
5801 | 5801 | |
— | — | @@ -5884,14 +5884,22 @@ |
5885 | 5885 | // Rebuild the suggestions list |
5886 | 5886 | context.data.$container.show(); |
5887 | 5887 | // Update the size and position of the list |
5888 | | - context.data.$container.css( { |
| 5888 | + var newCSS = { |
5889 | 5889 | 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
5890 | 5890 | 'bottom': 'auto', |
5891 | 5891 | 'width': context.config.$region.outerWidth(), |
5892 | | - 'height': 'auto', |
5893 | | - 'left': context.config.$region.offset().left, |
5894 | | - 'right': 'auto' |
5895 | | - } ); |
| 5892 | + 'height': 'auto' |
| 5893 | + } |
| 5894 | + if ( context.config.positionFromLeft ) { |
| 5895 | + console.log("LEFT"); |
| 5896 | + newCSS['left'] = context.config.$region.offset().left; |
| 5897 | + newCSS['right'] = 'auto'; |
| 5898 | + } else { |
| 5899 | + console.log("right"); |
| 5900 | + newCSS['left'] = 'auto'; |
| 5901 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 5902 | + } |
| 5903 | + context.data.$container.css( newCSS ); |
5896 | 5904 | var $results = context.data.$container.children( '.suggestions-results' ); |
5897 | 5905 | $results.empty(); |
5898 | 5906 | var expWidth = -1; |
— | — | @@ -5931,12 +5939,6 @@ |
5932 | 5940 | } |
5933 | 5941 | // Apply new width for results box, if any |
5934 | 5942 | if ( expWidth != -1 ) { |
5935 | | - if ( context.config.expandToLeft ) { |
5936 | | - context.data.$container.css( 'left', |
5937 | | - context.data.$container.offset().left - |
5938 | | - ( expWidth - context.data.$container.width() ) |
5939 | | - ); |
5940 | | - } |
5941 | 5943 | context.data.$container.width( expWidth ); |
5942 | 5944 | } |
5943 | 5945 | // autoEllipse the results. Has to be done after changing the width |
— | — | @@ -5954,7 +5956,7 @@ |
5955 | 5957 | context.config[property] = Math.max( 1, value ); |
5956 | 5958 | break; |
5957 | 5959 | case 'submitOnClick': |
5958 | | - case 'expandToLeft': |
| 5960 | + case 'positionFromLeft': |
5959 | 5961 | context.config[property] = value ? true : false; |
5960 | 5962 | break; |
5961 | 5963 | } |
— | — | @@ -6096,7 +6098,7 @@ |
6097 | 6099 | if ( typeof context == 'undefined' || context == null ) { |
6098 | 6100 | context = { |
6099 | 6101 | config: { |
6100 | | - 'fetch' : function() {}, |
| 6102 | + 'fetch' : function() {}, |
6101 | 6103 | 'cancel': function() {}, |
6102 | 6104 | 'special': {}, |
6103 | 6105 | 'result': {}, |
— | — | @@ -6106,7 +6108,7 @@ |
6107 | 6109 | 'delay': 120, |
6108 | 6110 | 'submitOnClick': false, |
6109 | 6111 | 'maxExpandFactor': 2, |
6110 | | - 'expandToLeft': false |
| 6112 | + 'positionFromLeft': true |
6111 | 6113 | } |
6112 | 6114 | }; |
6113 | 6115 | } |
— | — | @@ -6145,13 +6147,22 @@ |
6146 | 6148 | 'mouseDownOn': $( [] ), |
6147 | 6149 | '$textbox': $(this) |
6148 | 6150 | }; |
| 6151 | + // Setup the css for positioning the results box |
| 6152 | + var newCSS = { |
| 6153 | + 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
| 6154 | + 'width': context.data.$textbox.outerWidth(), |
| 6155 | + 'display': 'none' |
| 6156 | + } |
| 6157 | + if ( context.config.positionFromLeft ) { |
| 6158 | + newCSS['left'] = context.config.$region.offset().left; |
| 6159 | + newCSS['right'] = 'auto'; |
| 6160 | + } else { |
| 6161 | + newCSS['left'] = 'auto'; |
| 6162 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 6163 | + } |
| 6164 | + |
6149 | 6165 | context.data.$container = $( '<div />' ) |
6150 | | - .css( { |
6151 | | - 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
6152 | | - 'left': Math.round( context.data.$textbox.offset().left ), |
6153 | | - 'width': context.data.$textbox.outerWidth(), |
6154 | | - 'display': 'none' |
6155 | | - } ) |
| 6166 | + .css( newCSS ) |
6156 | 6167 | .addClass( 'suggestions' ) |
6157 | 6168 | .append( |
6158 | 6169 | $( '<div />' ).addClass( 'suggestions-results' ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -395,13 +395,13 @@ |
396 | 396 | if(typeof context.config.cancel=='function'){context.config.cancel.call(context.data.$textbox);}},restore:function(context){context.data.$textbox.val(context.data.prevText);},update:function(context,delayed){function maybeFetch(){if(context.data.$textbox.val()!==context.data.prevText){context.data.prevText=context.data.$textbox.val();if(typeof context.config.fetch=='function'){context.config.fetch.call(context.data.$textbox,context.data.$textbox.val());}}} |
397 | 397 | if(context.data.timerID!=null){clearTimeout(context.data.timerID);} |
398 | 398 | if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();} |
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();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();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));} |
| 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 | +if(context.config.positionFromLeft){console.log("LEFT");newCSS['left']=context.config.$region.offset().left;newCSS['right']='auto';}else{console.log("right");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));} |
400 | 402 | $autoEllipseMe=$autoEllipseMe.add($result);}} |
401 | | -if(expWidth!=-1){if(context.config.expandToLeft){context.data.$container.css('left',context.data.$container.offset().left- |
402 | | -(expWidth-context.data.$container.width()));} |
403 | | -context.data.$container.width(expWidth);} |
| 403 | +if(expWidth!=-1){context.data.$container.width(expWidth);} |
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'expandToLeft':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,9 +409,11 @@ |
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,'expandToLeft':false}};} |
| 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}};} |
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 | | -if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};context.data.$container=$('<div />').css({'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'left':Math.round(context.data.$textbox.offset().left),'width':context.data.$textbox.outerWidth(),'display':'none'}).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;} |
| 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 | +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());} |
| 417 | +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;} |
416 | 418 | $.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);} |
417 | 419 | 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;} |
418 | 420 | context.data.$container.hide();if(typeof context.config.special.select=='function'){context.config.special.select.call($special,context.data.$textbox);} |