r93382 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93381‎ | r93382 | r93383 >
Date:11:02, 28 July 2011
Author:diebuche
Status:reverted
Tags:
Comment:
r91728 : Fix whitespace and two vars per CR
Modified paths:
  • /trunk/phase3/resources/mediawiki.page/mediawiki.page.mwsuggest.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.page/mediawiki.page.mwsuggest.js
@@ -1,18 +1,18 @@
22 jQuery( document ).ready( function( $ ) {
3 - var $container = $('<div>', {'class' : 'open-search-suggestions'}),
 3+ var $container = $( '<div>', { 'class' : 'open-search-suggestions' } ),
44 cache = {},
55 $suggestionList,
6 - url = mw.config.get('wgScriptPath') + '/api.php?format=json&action=opensearch&search=',
 6+ url = mw.config.get( 'wgScriptPath' ) + '/api.php?format=json&action=opensearch&search=',
77 maxRowWindow;
88
99 //Append the container which will hold the menu to the body
10 - $('body').append( $container );
 10+ $( 'body' ).append( $container );
1111
1212 /* Grabs namespaces from search form or
1313 * in case we're not on a search page, take it from wgSearchNamespaces.
1414 * @return Array: List of Namespaces that should be searched
1515 */
16 - getNamespaces = function() {
 16+ var getNamespaces = function() {
1717 var namespaces = [];
1818 $('form#powersearch, form#search').find( '[name^="ns"]' ).each(function() {
1919 if ( this.checked || ( this.type == 'hidden' && this.value == '1' ) ) {
@@ -26,7 +26,7 @@
2727 };
2828
2929 /* Helper function to make sure that the list doesn't expand below the visible part of the window */
30 - deliverResult = function( obj, response, maxRowWindow ) {
 30+ var deliverResult = function( obj, response, maxRowWindow ) {
3131 if ( obj && obj.length > 1 ) {
3232 response( obj[1] );
3333 // Get the lowest from multiple numbers using fn.apply
@@ -38,33 +38,33 @@
3939 };
4040
4141 /* The actual autocomplete setup */
42 - $("#searchInput").autocomplete({
 42+ $( "#searchInput" ).autocomplete({
4343 minLength: 2,
4444 source: function ( request, response ) {
4545 var namespaces = getNamespaces();
4646 // We're caching queries for performance
4747 var term = request.term + namespaces;
48 - if (term in cache) {
 48+ if ( term in cache ) {
4949 deliverResult( cache[term], response, maxRowWindow );
5050 return;
5151 }
52 - $.getJSON(url + mw.util.rawurlencode( request.term ) + '&namespace=' + namespaces, function ( obj ) {
 52+ $.getJSON( url + mw.util.rawurlencode( request.term ) + '&namespace=' + namespaces, function ( obj ) {
5353 // Save to cache
54 - cache[term] = obj;
 54+ cache[ term ] = obj;
5555 deliverResult( obj, response, maxRowWindow );
5656 });
5757 },
58 - select: function() {
59 - $('#searchGoButton').click();
 58+ select : function() {
 59+ $( '#searchGoButton' ).click();
6060 },
6161 create : function() {
62 - $suggestionList = $container.find('ul');
 62+ $suggestionList = $container.find( 'ul' );
6363 },
64 - appendTo: '.open-search-suggestions',
65 - open: function() {
66 - maxRowWindow = Math.floor(
67 - ( $(window).height() - $suggestionList.offset().top + $(window).scrollTop() ) /
68 - $suggestionList.find( '.ui-menu-item' ).eq( 0 ).height()
 64+ appendTo : '.open-search-suggestions',
 65+ open : function() {
 66+ maxRowWindow = Math.floor(
 67+ ( $( window ).height() - $suggestionList.offset().top + $( window ).scrollTop() ) /
 68+ $suggestionList.find( '.ui-menu-item' ).eq( 0 ).height()
6969 );
7070 }
7171 });

Follow-up revisions

RevisionCommit summaryAuthorDate
r95409Revert r91728...reedy18:22, 24 August 2011
r964981.18: MFT r95171, r95409, r95436, r95458, r95467, r95470, r95475, r95493, r95...catrope21:04, 7 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91728Rewrite mwsuggest.js using j.ui.autocomplete. This gets rid of a lot of the l...diebuche14:59, 8 July 2011

Status & tagging log