diff options
Diffstat (limited to 'MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js')
-rw-r--r-- | MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js b/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js index 546e2612..e3f5ecb8 100644 --- a/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js +++ b/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js @@ -6,21 +6,21 @@ $( function () { resultGroups = $( '.facet.groups' ).data( 'facets' ); - $( '.tux-searchpage .button' ).on( 'click', function () { + $( '.tux-searchpage .mw-ui-button' ).on( 'click', function () { var query = $( '.tux-searchpage .searchinputbox' ).val(), result = lexOperators( query ), $form = $( '.tux-searchpage form[name=searchform]' ); - $.each( result, function ( index, value ) { + Object.keys( result ).forEach( function ( index ) { var $input = $( '<input>' ).prop( 'type', 'hidden' ), $elem = $form.find( 'input[name=' + index + ']' ); if ( $elem.length ) { - $elem.val( value ); + $elem.val( result[ index ] ); } else { $form.append( $input .prop( { - value: value, + value: result[ index ], name: index } ) ); @@ -135,7 +135,7 @@ ); } - $.each( Object.keys( languages ), function ( index, languageCode ) { + Object.keys( languages ).forEach( function ( languageCode ) { ulslanguages[ languageCode ] = mw.config.get( 'wgTranslateLanguages' )[ languageCode ]; } ); @@ -191,7 +191,6 @@ currentGroup = $( '.facet.groups' ).data( 'group' ), resultCount = groupList.length, position, - groups, options, grouppath; @@ -282,32 +281,30 @@ options = { language: mw.config.get( 'wgUserLanguage' ), position: position, - onSelect: function ( group ) { - var uri = new mw.Uri( location.href ); - uri.extend( { group: group.id, grouppath: group.id } ); - location.href = uri.toString(); + onSelect: function ( selectedGroup ) { + var currentUri = new mw.Uri( location.href ); + currentUri.extend( { group: selectedGroup.id, grouppath: selectedGroup.id } ); + location.href = currentUri.toString(); }, preventSelector: true }; - groups = $.map( resultGroups, function ( value, index ) { - return index; - } ); + $grouSelectorTrigger.msggroupselector( options, - groups + Object.keys( resultGroups ) ); } } function lexOperators( str ) { - var string = str.split( ' ' ), + var splitValues = str.split( ' ' ), result = {}, query = ''; - $.each( string, function ( index, value ) { - matchOperators( value, function ( obj ) { + splitValues.forEach( function ( string ) { + matchOperators( string, function ( obj ) { if ( obj === false ) { - query = query + ' ' + value; + query = query + ' ' + string; } else { result[ obj.operator ] = obj.value; } @@ -324,7 +321,7 @@ // Add operators for different filters operatorRegex = [ 'language', 'group', 'filter' ]; - $.each( operatorRegex, function ( index, value ) { + operatorRegex.forEach( function ( value ) { var regex = new RegExp( value + ':(\\S+)', 'i' ); if ( ( matches = regex.exec( str ) ) !== null ) { counter = true; @@ -354,6 +351,7 @@ /** * Finds a specific group from a groups object containing nested groups. + * * @param {string} targetGroupId * @param {Object} groups * @return {Object} Message group object, or null if group is not found |