Allow identifying the context of the different ULS panels within one app

Add the ulsPurpose option. Empty string by default.

This is useful for web application that use ULS in several different context,
and need to distinguish what was the purpose of the particular ULS panel.

An example of usage can be found at
https://phabricator.wikimedia.org/T179402
This commit is contained in:
Amire80
2018-03-04 23:01:35 +02:00
parent 2d98203aab
commit ddb691a918
2 changed files with 10 additions and 1 deletions

View File

@@ -233,7 +233,11 @@
resultHandler: function ( query, results, autofillLabel ) {
if ( results.length === 0 ) {
this.$suggestion.val( '' );
this.$element.trigger( 'noresults.uls', query );
this.$element.trigger(
'noresults.uls',
query,
this.$element.parents( '.uls-menu' ).data( 'uls-purpose' )
);
return;
}