MediaWiki talk:Gadget-Search.js

Latest comment: 11 months ago by Mormegil in topic Fixing toggle position

Resource loader edit

Hi,

This gadget is quite broken in right-to-left languages currently. Can anybody think whether it will be a problem to make it ResourceLoader-enabled, so its CSS would be automatically flipped? --Amir E. Aharoni (talk) 18:18, 3 January 2013 (UTC)Reply

There is an oppertunity to set for rtl languages. I hope it works fine for you. --Bene* talk 19:11, 3 January 2013 (UTC)Reply
Thank you for fixing! It works nicely.
However, putting the CSS in a proper CSS file and making this gadget work with ResourceLoader will make maintaining such issues easier. --Amir E. Aharoni (talk) 19:17, 3 January 2013 (UTC)Reply
Is there a documentation or tutorial how to work with ResourceLoader? If so I will try to implement this. --Bene* talk 19:25, 3 January 2013 (UTC)Reply
The page mw:Extension:Gadgets says a few things about making Gadgets work with Resource Loader. There's also a detailed guide at mw:ResourceLoader.
The main steps would probably be to add the ResourceLoader option to this gadget's entry at MediaWiki:Gadgets-definition and to move all the CSS to a separate MediaWiki:Gadget-Search.css page. You may have to change some of the JavaScript code, too. --Amir E. Aharoni (talk) 19:53, 3 January 2013 (UTC)Reply

Monobook edit

I've discovered this gadget in a discussion on it.wiki. Indeed it's wonderful, without it search on wikidata would be impossible. Just a note that it doesn't work on monobook. If you think it's not worth fixing, I understand. :) --Nemo 09:17, 31 January 2013 (UTC)Reply

Yes, I agree it's quite a useful gadget. I've checked the other skins, and I saw that it works only in Vector, so I've disabled it as a gadget for all other skins. However, you can use Special:ItemByTitle and Special:ItemDisambiguation to search.  Hazard-SJ  ✈ :: 01:05, 13 February 2013 (UTC)Reply
I will add the support for monobook. Where should the icon appear? --Bene* talk 20:19, 16 February 2013 (UTC)Reply

fa.wiki edit

please add this translation

		'fa': {
			'title': 'بهبود جستجو',
			'description': 'جستجوی آیتم بر اساس وب‌گاه و عنوان',
			'placeholder': 'آیتم بر اساس عنوان',
			/* Only if rtl language */
			'dir': 'ltr', // Do not translate
			'right': 'right', // Do not translate
			'left': 'left' // Do not translate
		},

Reza1615 (talk) 19:32, 14 February 2013 (UTC)Reply

  Done. --Stryn (talk) 20:55, 15 February 2013 (UTC)Reply

bug for RTl langs edit

Hi, it has direction bug for fa (farsi)

  • direction of the new search box is left to right
  • the rectangle icon (tool's icon) is under wiki's search!

thanks Reza1615 (talk) 21:38, 15 February 2013 (UTC)Reply

That is fixed now. --Bene* talk 20:19, 16 February 2013 (UTC)Reply

suggestion edit

Is it possible instead of hidden search box .replace it with mediawiki's search box and set if input text contains namespaces or q or praperty it switch or copy text to mediawiki's search box. Reza1615 (talk) 00:59, 17 February 2013 (UTC)Reply

Auto complete doesn't work edit

The Auto complete of search box can not selected by mouse or keyboard. for example when I write US it shows USD but I can not use it's suggestions! by click or Arrow key (Up and Down in keyboard) Reza1615 (talk) 19:51, 17 February 2013 (UTC)Reply

Portuguese translations edit

Please add the following translations for Portuguese (pt) and Brazilian Portuguese (pt-br):

			'title': 'Pesquisa aprimorada',
			'description': 'Pesquisar itens por site e título',
			'placeholder': 'Pesquisa por título'

And, if possible, please see the problem reported at Wikidata:Contact the development team#pt-brwiki in "Item by title" search box. Thanks. Opraco (talk) 20:45, 19 February 2013 (UTC)Reply

  Done --Bene* talk 19:05, 27 February 2013 (UTC)Reply

mw.user.options edit

The script uses mw.user.options.get( 'language' ) and mw.user.options.get( 'skin' ) at the moment. These are the user settings. It should use mw.config.get( 'wgUserLanguage' ) and mw.config.get( 'skin' ), because these are actual settings. The user settings and the actual settings can differ, when you use the URL parameter uselang or useskin. --Fomafix (talk) 10:27, 27 February 2013 (UTC)Reply

  Done --Bene* talk 19:05, 27 February 2013 (UTC)Reply

text suggestion for RTL languages has bug edit

text suggestion for RTL languages (i.e. Farsi) has bug and it is shown in right (under wikidata logo!) instead of left.you can test by typing or copying مرداد . thanks Reza1615 (talk) 21:01, 27 February 2013 (UTC)Reply

  Done works now. --Bene* talk 15:50, 28 February 2013 (UTC)Reply

Galician edit

{{Edit request}}

'gl': {
			'title': 'Busca mellorada',
			'description': 'Busca de elementos por sitio e título',
			'placeholder': 'Elemento por título'
		},

Please add this translation --Vivaelcelta (talk) 12:27, 2 March 2013 (UTC)Reply

  Done. --Stryn (talk) 15:35, 2 March 2013 (UTC)Reply

Spanish edit

{{Edit request}}

'es': {
			'title': 'Búsqueda mejorada',
			'description': 'Búsqueda de elementos por sitio y título',
			'placeholder': 'Elemento por título'
		},

Please update this translation --Vivaelcelta (talk) 12:27, 2 March 2013 (UTC)Reply

  Done. --Stryn (talk) 15:35, 2 March 2013 (UTC)Reply

Suggestion for localization edit

Translation texts for this gadget are almost the same as messages of Special:ItemByTitle. Is it possible to auto-generate translations from those messages? It would greatly reduce works needed to localize this gadget. --fryed-peach (talk) 12:42, 5 March 2013 (UTC)Reply

I imported the message manually now. Maybe there would also be a better solution, I don't know. --Bene* talk 19:18, 5 March 2013 (UTC)Reply
Thank you! --fryed-peach (talk) 08:32, 7 March 2013 (UTC)Reply
That will be possible in Gadgets 2.0. Helder 17:59, 7 March 2013 (UTC)

Hack for be_x_oldwiki edit

Hi. Can you make a hack, so wgUserLanguage = be-tarask is treated as be_x_oldwiki in terms of projects? For be-tarask it uses bewiki, but it should use be_x_oldwiki. Thank you. Wizardist (talk) 16:48, 8 March 2013 (UTC)Reply

  Done --Bene* talk 18:07, 8 March 2013 (UTC)Reply
Seems legit. Thank you very much for a very quick reaction! Wizardist (talk) 22:36, 8 March 2013 (UTC)Reply
You're welcome. --Bene* talk 11:00, 10 March 2013 (UTC)Reply

Request for change in mk (Macedonian) edit

Could I please ask someone to change the line "Предмет по врска до мреж. место"  to  "Предмет по викиврска". Thanks a lot --B. Jankuloski (talk) 05:50, 14 March 2013 (UTC)Reply

Bengali translation edit

Please add the following translations:

		'bn': {
			'title': 'উন্নত অনুসন্ধান',
			'description': 'সাইট এবং শিরোনাম অনুযায়ী আইটেম জন্য অনুসন্ধান',
			'placeholder': 'আইটেম অনুযায়ী সাইটলিঙ্ক'

Thanks--Leemontalk 15:44, 16 March 2013 (UTC)Reply

  Done. --Stryn (talk) 15:55, 16 March 2013 (UTC)Reply
..please fix it

- remove this 'description': 'সাইট এবং শিরোনাম অনুযায়ী আইটেম জন্য অনুসন্ধান' and add this ->

 'description': 'সাইট এবং শিরোনাম অনুযায়ী আইটেমের জন্য অনুসন্ধান',
  Done. --Stryn (talk) 16:11, 16 March 2013 (UTC)Reply

Indonesian & Minangkabau translations edit

Please add Indonesian & Minangkabau translations.

		'id': {
			'title': 'Pencarian tingkat lanjut',
			'description': 'Cari item berdasarkan wiki dan judul',
			'placeholder': 'Item berdasarkan wiki'
		},
		'min': {
			'title': 'Pancarian tingkek lanjuik',
			'description': 'Cari item badasarkan wiki jo judul',
			'placeholder': 'Item badasarkan wiki'
		},

Thanks in advance.  Ę-oиė  >>> 22:00, 18 March 2013 (UTC)Reply

  Done--CENNOXX (talk) 02:55, 20 March 2013 (UTC)Reply

Request for modification in Macedonian (mk) edit

Can someone to change the line

Предмет по врска до мреж. место

to

Предмет по викиврска

I asked for this in mid March but I have still no response. --B. Jankuloski (talk) 04:20, 23 April 2013 (UTC)Reply

  Done Javad|Talk (4 Ordibehesht 1392) 19:04, 24 April 2013 (UTC)Reply

Fix for nowiki edit

{{Edit request}} After the hack for be_x_oldwiki on line 235, could you add a hack for nb, like so?

	if( i18nLang === 'be-tarask' ) { // Hack for be_x_oldwiki
		lang = 'be-x-old';
		site = 'be_x_oldwiki';
	}
	else if( i18nLang === 'nb' ) { // Hack for nb
		site = 'nowiki';
	}

And while on it, here's a nb localization:

		'nb': {
			'title': 'Forbedret søk',
			'description': 'Søk etter elementer fra nettsted og tittel',
			'placeholder': 'Element fra nettstedlenke'
		},

Danmichaelo (talk) 13:51, 31 December 2013 (UTC)Reply

  Done (diff) --Fomafix (talk) 15:22, 31 December 2013 (UTC)Reply

Small improvements edit

{{Edit request}} I suggest the following changes: 1. The magnifying glass icon is a little bit misplaced in the Vector skin. This is a very simple, straightforward fix.

.append(
	$( '<button>' )
	.attr( {
		id: 'searchButton', // This is a hack.
		'class': 'improvedsearch-search',
		title: i18n( 'description' )
	} )
)
.append(
	$( '<button>' )
	.attr( {
		id: 'searchButton', // This is a hack.
		'class': 'improvedsearch-search',
		title: i18n( 'description' )
	} )
	.css( { 'padding': 0 } )
)

2. Make the gadget more responsive. It's nice to have it animated but there is no need to delay the animation that much since the visual distraction is very, very small anyway.

$( '#improvedsearch' ).toggle( 'normal' );
$( '#improvedsearch' ).toggle( 'fast' );

--Thiemo Mättig (WMDE) 15:37, 12 February 2014 (UTC)Reply

Implemented the improvements, thanks. -- Bene* talk 16:25, 12 February 2014 (UTC)Reply

{{Edit request}} Could it be that the styles changed again and made the magnifying glass icon look misplaced again? Here is a fix:

.css( { 'padding': 0 } )
.css( { 'background-color': 'transparent', 'border': 0, 'padding': 0, 'position': 'absolute' } )

--Thiemo Mättig (WMDE) 16:26, 13 May 2014 (UTC)Reply

  Done John F. Lewis (talk) 16:39, 13 May 2014 (UTC)Reply

{{Edit request}} A method used by this gadget got deprecated. It still works but complaints in the console. Here is a fix.

$( '<input>' )
.attr( {
	id: 'searchInput', // This is a hack.
	'class': 'improvedsearch-page',
	type: 'text',
	accesskey: 'g',
	title: i18n( 'title' ) + ' [' + mw.util.tooltipAccessKeyPrefix + 'g]',
	name: 'page',
	autocomplete: 'off',
	placeholder: i18n( 'placeholder' )
} )
$( '<input>' )
.attr( {
	id: 'searchInput', // This is a hack.
	'class': 'improvedsearch-page',
	type: 'text',
	accesskey: 'g',
	title: i18n( 'title' ) + ' [g]',
	name: 'page',
	autocomplete: 'off',
	placeholder: i18n( 'placeholder' )
} )
.updateTooltipAccessKeys()

--Thiemo Mättig (WMDE) 10:29, 15 May 2014 (UTC)Reply

Done. The title suffix ' [g]' is not necessary. --Fomafix (talk) 13:06, 15 May 2014 (UTC)Reply
It is. It's a fallback in case the method can not determine a better hint. That's why the method is called "update" and not "set". The original search box does the same. Please re-add it. --Thiemo Mättig (WMDE) 20:41, 15 May 2014 (UTC)Reply
No, it isn’t. PHP generates a title suffix for clients without JavaScript. updateTooltipAccessKeys() cuts away this suffix and generates a new one. This input box is generated by JavaScript, so a fallback for clients without JavaScript is not necessary. --Fomafix (talk) 06:06, 16 May 2014 (UTC)Reply
That's not what I was talking about. I actually spend time on this and wrote the code the way it is written on purpose. If the update method doesn't know the user agent (and it can't know all user agents in the world) it can't know what keys need to be pressed and therefor can't just "generate a new one". Even if the current implementation adds a default "[g]" or even assumes "[alt-g]" (which is pretty problematic for many reasons) this may change at any time. Not that it matters much in this case. I just wanted to be on the safe side, which is to mimic exactly what the original search box does. --Thiemo Mättig (WMDE) 16:13, 16 May 2014 (UTC)Reply
Once again. The original search box is generated with PHP on server side. --Fomafix (talk) 21:39, 16 May 2014 (UTC)Reply
Once again, that's completely unrelated to what I'm talking about. Please don't alter code if you don't fully understand it. Could an other administrator please copy the line as I gave it above? --Thiemo Mättig (WMDE) 08:55, 21 May 2014 (UTC)Reply
I implemented the part of the code [1]. Do you see any problems there? --Fomafix (talk) 21:09, 21 May 2014 (UTC)Reply
The lines of code you are referring to are unrelated to what I'm talking about. I'm very sorry that I couldn't make myself clear. I just wanted, as I already said, to be on the safe side. It's sad that we are wasting time on an implementation detail that, in the end, doesn't really matter. Let's spend our time on things that matter more, like finding the reason for bugzilla:65340. --Thiemo Mättig (WMDE) 09:43, 23 May 2014 (UTC)Reply

Fix for "search-ltr.png?303-4 404 (Not Found)" edit

{{Editprotected}}

Please change from:

src: mw.config.get( 'stylepath' ) + '/vector/images/search-' + i18n( 'dir' ) + '.png?303-4'

to:

src: mw.config.get( 'stylepath' ) + '/Vector/images/search-' + i18n( 'dir' ) + '.png?303-4'

The directory name for Vector skin is now capitalized. Thanks Aude (talk) 15:11, 27 June 2014 (UTC)Reply

  Done Thank you! –ebraminiotalk 15:15, 27 June 2014 (UTC)Reply

Misplacing search box edit

This gadget seems to be moving the input box such that it's no longer inside the normal search area. --Yair rand (talk) 21:31, 9 September 2014 (UTC)Reply

Seems to be a bug introduced by a recent change in MediaWiki. Let me see how we can fix this. -- Bene* talk 05:18, 10 September 2014 (UTC)Reply
Fixed this now but the CSS hacks became even more evil. We have to find a better way to add the toggle button. -- Bene* talk 16:58, 10 September 2014 (UTC)Reply

Arabic edit

Please add this:


		'ar': {
			'title': 'بحث محسن',
			'description': 'البحث عن عناصر حسب الموقع والعنوان',
			'placeholder': 'عناصر حسب الموقع'
		},

--Mr. Ibrahem (talk) 12:20, 9 May 2016 (UTC)Reply

  Done (diff) --Fomafix (talk) 20:45, 14 May 2016 (UTC)Reply

Swedish translation edit

Please add this:

		'sv': {
			'title': 'Förbättrad sökning',
			'description': 'Sök efter objekt efter webbplats och titel',
			'placeholder': 'Objekt efter webbplatslänk'
		}

Thanks in advance! // WikiPhoenix [Talk] 21:28, 29 June 2016 (UTC)Reply

  Done (diff) --Fomafix (talk) 06:11, 30 June 2016 (UTC)Reply


Greek translation edit

@Fomafix: Please add this:

		'el': {
			'title': 'Βελτιωμένη αναζήτηση',
			'description': 'Αναζήτηση αντικειμένου με βάση τον ιστότοπο και τον τίτλο',
			'placeholder': 'Στοιχεία ανά ιστότοπο'
		},

Xaris333 (talk) 20:05, 24 November 2016 (UTC)Reply

  Done (diff) --Fomafix (talk) 21:38, 26 November 2016 (UTC)Reply

Change pl translation edit

Please change pl translation to this one. Sp5uhe (talk) 07:17, 6 February 2017 (UTC)Reply

		'pl': {
			'title': 'Ulepszone wyszukiwanie',
			'description': 'Szukaj elementów względem witryny i tytułu',
			'placeholder': 'Elementy według linku'
		},
  Done Matěj Suchánek (talk) 12:47, 14 May 2017 (UTC)Reply

Portuguese (pt) translation edit

{{Editprotected}}

Please add this translation to Portuguese (pt):

		'pt': {
			'title': 'Pesquisa aprimorada',
			'description': 'Pesquisar itens por sítio e título',
			'placeholder': 'Pesquisar por título'

In advance, thank you. Fúlvio (talk) 14:35, 20 April 2017 (UTC)Reply

  Done Matěj Suchánek (talk) 12:47, 14 May 2017 (UTC)Reply

Basque edit

{{Editprotected}} Please add this:

		'eu': {
			'title': 'Bilaketa hobetua',
			'description': 'Bilatu elementuak tokiaren eta izenburuaren arabera',
			'placeholder': 'Elementua tokiaren loturaren arabera'
		},

Asierog (talk) 22:31, 2 May 2017 (UTC)Reply

  Done Matěj Suchánek (talk) 12:47, 14 May 2017 (UTC)Reply

HR translation edit

{{Edit request}} Please, add translation in croatian.

'hr': {
			'title': 'Poboljšano pretraživanje',
			'description': 'Pretraga stavki prema mrežnom mjestu i naslovu',
			'placeholder': 'Stavke prema poveznicama na mrežna mjesta'
		},

Thanks.--Ma Ga 17:48, 8 June 2017 (UTC)Reply

  Done Matěj Suchánek (talk) 07:10, 9 June 2017 (UTC)Reply

SR translation edit

{{Edit request}} Please, add translation in Serbian.

'sr': {
			'title': 'Побољшано претраживање',
			'description': 'Претрага ставки према сајтлинку и наслову',
			'placeholder': 'Ставка према сајтлинку'
		},

If it goes by sr-ec and/or sr-el, then this translation above is also for sr-ec and this one below for sr-el.

'sr-el': {
			'title': 'Poboljšano pretraživanje',
			'description': 'Pretraga stavki prema sajtlinku i naslovu',
			'placeholder': 'Stavka prema sajtlinku'
		},

Thanks.--Obsuser (talk) 16:08, 17 October 2017 (UTC)Reply

Fixing toggle position edit

{{edit request}}

Right now there is unusual spacing between dropdown button and Search input. I have tried to fix it and replacing the following code will fix it. Replace code from line 491 to 499 with

var toggleCss = {
				width: '20px',
				height: '20px'
			};
			toggleCss['margin-' + i18n( 'left' )] = 'calc(20vw + 8px)';
			toggleCss['margin-top'] = '-24px';
			toggleCss['background-image'] = 'linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0)), url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjIyIiBoZWlnaHQ9IjE2Ij48cGF0aCBkPSJNMTUuNTAyIDYuMDAxbC01IDUuMDAxLTUtNS4wMDF6IiBmaWxsPSIjNzk3OTc5Ii8+PC9zdmc+")';
			toggleCss['background-position'] = 'center';
			toggleCss['background-repeat'] = 'no-repeat';

‐‐1997kB (talk) 12:10, 24 January 2021 (UTC)Reply

@Lymantria: Pinging since nobody seems active on this page. ‐‐1997kB (talk) 12:20, 24 January 2021 (UTC)Reply

  Done --Lymantria (talk) 12:26, 24 January 2021 (UTC)Reply
 
Huge margin
@1997kB, Lymantria: Not sure what changed in surrounding HTML or project-wide CSS or where but I never noticed any issues with the dropdown button until a few days ago: the spacing is unbearable on my 2560px-wide screen now. But, honestly, I can’t see how the style could have had worked…? .vector-search-box-inner has width: 20vw but together with max-width: 20em, so for viewports wider than 100em (1600px for a default font size of 16px), 20vw begins to be too much and a gap appears. Again, I don’t know what has changed recently so that this started to be a problem only now. --Mormegil (talk) 07:14, 26 April 2023 (UTC)Reply

Accesskey edit

The accesskey used for this search box is interfering with MediaWiki's "native" accesskey for accessing Wikidata items, i.e. the "Wikidata item" link in the left toolbar. Would it be possible to change it to something else? Also, at least in my browser, the accesskey doesn't work unless you have already toggled the search box on, which kind of defeats the purpose of an accesskey, so maybe it can just be removed entirely? Jon Harald Søby (talk) 00:42, 6 November 2021 (UTC)Reply

Return to "Gadget-Search.js" page.