X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=resources%2Fsrc%2Fjquery%2Fjquery.suggestions.js;h=8c1739c547cefa87591e121ff08242cf2d7129e7;hb=8fb63bad5c22f853050806ccd93b3042bf3a2ae3;hp=884ecb6e96dd9d6d42334410da281952640458f7;hpb=500889f19005b4aed93c5b6eaafd35689fce7dcd;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/jquery/jquery.suggestions.js b/resources/src/jquery/jquery.suggestions.js index 884ecb6e96..39c601f3a3 100644 --- a/resources/src/jquery/jquery.suggestions.js +++ b/resources/src/jquery/jquery.suggestions.js @@ -19,7 +19,6 @@ * @class jQuery.plugin.suggestions */ - // jscs:disable checkParamNames /** * @method suggestions * @chainable @@ -94,9 +93,8 @@ * @param {boolean} [options.highlightInput=false] Whether to highlight matched portions of the * input or not. */ - // jscs:enable checkParamNames -( function ( $ ) { +( function ( $, mw ) { var hasOwn = Object.hasOwnProperty; @@ -178,7 +176,7 @@ context.data.prevText = val; // Try cache first if ( context.config.cache && hasOwn.call( cache, val ) ) { - if ( +new Date() - cache[ val ].timestamp < context.config.cacheMaxAge ) { + if ( mw.now() - cache[ val ].timestamp < context.config.cacheMaxAge ) { context.data.$textbox.suggestions( 'suggestions', cache[ val ].suggestions ); if ( typeof context.config.update.after === 'function' ) { context.config.update.after.call( context.data.$textbox, cache[ val ].metadata ); @@ -203,7 +201,7 @@ cache[ val ] = { suggestions: suggestions, metadata: metadata, - timestamp: +new Date() + timestamp: mw.now() }; } }, @@ -295,7 +293,7 @@ expandFrom = 'left'; // Catch invalid values, default to 'auto' - } else if ( $.inArray( expandFrom, [ 'left', 'right', 'start', 'end', 'auto' ] ) === -1 ) { + } else if ( [ 'left', 'right', 'start', 'end', 'auto' ].indexOf( expandFrom ) === -1 ) { expandFrom = 'auto'; } @@ -353,7 +351,6 @@ $results.empty(); expWidth = -1; for ( i = 0; i < context.config.suggestions.length; i++ ) { - /*jshint loopfunc:true */ text = context.config.suggestions[ i ]; $result = $( '
' ) .addClass( 'suggestions-result' ) @@ -376,7 +373,7 @@ } if ( context.config.highlightInput ) { - $result.highlightText( context.data.prevText ); + $result.highlightText( context.data.prevText, { method: 'prefixHighlight' } ); } // Widen results box if needed (new width is only calculated here, applied later). @@ -682,7 +679,7 @@ // Don't interfere with special clicks (e.g. to open in new tab) if ( !( e.which !== 1 || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey ) ) { // This will hide the link we're just clicking on, which causes problems - // when done synchronously in at least Firefox 3.6 (bug 62858). + // when done synchronously in at least Firefox 3.6 (T64858). setTimeout( function () { $.suggestions.hide( context ); }, 0 ); @@ -714,7 +711,7 @@ // Don't interfere with special clicks (e.g. to open in new tab) if ( !( e.which !== 1 || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey ) ) { // This will hide the link we're just clicking on, which causes problems - // when done synchronously in at least Firefox 3.6 (bug 62858). + // when done synchronously in at least Firefox 3.6 (T64858). setTimeout( function () { $.suggestions.hide( context ); }, 0 ); @@ -756,11 +753,11 @@ 27, // escape 13, // enter 46, // delete - 8 // backspace + 8 // backspace ]; - if ( context.data.keypressedCount === 0 - && e.which === context.data.keypressed - && $.inArray( e.which, allowed ) !== -1 + if ( context.data.keypressedCount === 0 && + e.which === context.data.keypressed && + allowed.indexOf( e.which ) !== -1 ) { $.suggestions.keypress( e, context, context.data.keypressed ); } @@ -787,4 +784,4 @@ * @mixins jQuery.plugin.suggestions */ -}( jQuery ) ); +}( jQuery, mediaWiki ) );