summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js')
-rw-r--r--MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js33
1 files changed, 27 insertions, 6 deletions
diff --git a/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js b/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js
index 266d37c4..546e2612 100644
--- a/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js
+++ b/MLEB/Translate/resources/js/ext.translate.special.searchtranslations.js
@@ -6,7 +6,7 @@
$( function () {
resultGroups = $( '.facet.groups' ).data( 'facets' );
- $( '.tux-searchpage .button' ).click( function () {
+ $( '.tux-searchpage .button' ).on( 'click', function () {
var query = $( '.tux-searchpage .searchinputbox' ).val(),
result = lexOperators( query ),
$form = $( '.tux-searchpage form[name=searchform]' );
@@ -33,7 +33,7 @@
showMessageGroups();
// Make the whole rows clickable
- $( '.tux-searchpage .row .facet-item' ).click( function ( event ) {
+ $( '.tux-searchpage .row .facet-item' ).on( 'click', function ( event ) {
window.location = $( this ).find( 'a' ).attr( 'href' );
event.stopPropagation();
} );
@@ -211,7 +211,7 @@
groupList.sort( sortGroups );
for ( i = 0; i < groupList.length; i++ ) {
groupId = groupList[ i ];
- group = mw.translate.findGroup( groupId, resultGroups );
+ group = findGroup( groupId, resultGroups );
if ( !group ) {
continue;
}
@@ -266,7 +266,7 @@
);
$parent.append( $grouSelectorTrigger );
- if ( $( 'body' ).hasClass( 'rtl' ) ) {
+ if ( $( document.body ).hasClass( 'rtl' ) ) {
position = {
my: 'right top',
at: 'right+90 top+40',
@@ -340,8 +340,8 @@
}
function sortGroups( groupIdA, groupIdB ) {
- var groupAName = mw.translate.findGroup( groupIdA, resultGroups ).count,
- groupBName = mw.translate.findGroup( groupIdB, resultGroups ).count;
+ var groupAName = findGroup( groupIdA, resultGroups ).count,
+ groupBName = findGroup( groupIdB, resultGroups ).count;
if ( groupAName > groupBName ) {
return -1;
@@ -352,6 +352,27 @@
return 0;
}
+ /**
+ * 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
+ */
+ function findGroup( targetGroupId, groups ) {
+ var group = groups[ targetGroupId ], groupId;
+ if ( group ) {
+ return group;
+ }
+
+ for ( groupId in groups ) {
+ if ( groups[ groupId ].groups ) {
+ return findGroup( targetGroupId, groups[ groupId ].groups );
+ }
+ }
+
+ return null;
+ }
+
function sortLanguages( languageA, languageB ) {
var languageNameA = mw.config.get( 'wgULSLanguages' )[ languageA ] || languageA,
languageNameB = mw.config.get( 'wgULSLanguages' )[ languageB ] || languageB;