Ankita-ks has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231864

Change subject: Suggestions correctly displayed in drop-down
......................................................................

Suggestions correctly displayed in drop-down

Change-Id: I6d5ef13c2b6bd9f68723b1e478e0ea89c759b836
---
M modules/ext.LanguageToolDialog.js
1 file changed, 28 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool 
refs/changes/64/231864/1

diff --git a/modules/ext.LanguageToolDialog.js 
b/modules/ext.LanguageToolDialog.js
index 0002da2..7e9b9ca 100644
--- a/modules/ext.LanguageToolDialog.js
+++ b/modules/ext.LanguageToolDialog.js
@@ -83,11 +83,7 @@
                        ve.ui.triggerRegistry.getMessages( 'findNext' ).join( 
', ' )
        } );
 
-       this.replaceText = new OO.ui.ComboBoxWidget( {
-               label: 'ComboBoxWidget',
-               input: { value: 'Option 123' },
-               menu: {
-                       items: [
+       this.items = [
                                new OO.ui.MenuOptionWidget( {
                                        data: '1',
                                        label: 'Option 123'
@@ -108,7 +104,13 @@
                                        data: '5',
                                        label: 'Option Five'
                                } )
-                       ]
+                               ]
+
+       this.replaceText = new OO.ui.ComboBoxWidget( {
+               label: 'ComboBoxWidget',
+               input: { value: 'Suggestions' },
+               menu: {
+                       items: this.items
                }
        } );
 
@@ -337,7 +339,6 @@
        }
        this.renderedFragments = range;
        this.highlightFocused();
-       this.displayInformation();
 };
 
 /**
@@ -386,6 +387,7 @@
                        $( 'body, html' ).animate( { scrollTop: offset - ( 
windowScrollHeight / 2  ) }, 'fast' );
                }
        }
+       this.displayInformation();
 };
 
 /**
@@ -394,7 +396,6 @@
 mw.LanguageToolDialog.prototype.findNext = function () {
        this.focusedIndex = ( this.focusedIndex + 1 ) % this.errors.length;
        this.highlightFocused( true );
-       this.displayInformation();
 };
 
 /**
@@ -403,7 +404,6 @@
 mw.LanguageToolDialog.prototype.findPrevious = function () {
        this.focusedIndex = ( this.focusedIndex + this.errors.length - 1 ) % 
this.errors.length;
        this.highlightFocused( true );
-       this.displayInformation();
 };
 
 /**
@@ -604,24 +604,35 @@
 // End of wrapper code by James Padolsey
 
 mw.LanguageToolDialog.prototype.displayInformation = function () {
-       var replacements, error;
+       var replacements, error, replaceArr, len;
 
-       if(this.errors && this.errors.length > this.focusedIndex) {
+       if( this.errors && this.errors.length > this.focusedIndex ) {
                error = this.errors[ this.focusedIndex ].description;
                replacements = this.errors[ this.focusedIndex ].replacements;
        }
 
-       if(error) {
+       if( error ) {
                this.findText.setValue( error );
        }
-       if(replacements) {
-               var replaceArr = [];
+       if( replacements.length ) {
                replaceArr = replacements.split( '#' );
-               var len = replaceArr.length;
+               len = replaceArr.length;
+               this.replaceText.getMenu().removeItems( this.items );
+               this.items = [];
                for (var i = 0; i <= len; i++) {
                        var index = i + "";
-                       this.replaceText.getMenu().getItemFromData( index 
).setData( replaceArr[ i ]);
-               };
+                       this.items.push(
+                               new OO.ui.MenuOptionWidget( {
+                                       data: replaceArr[i],
+                                       label: replaceArr[i]
+                               } )
+                       );
+               }
+               this.replaceText.getMenu().addItems( this.items );
+       }
+       else {
+               this.replaceText.getMenu().removeItems( this.items );
+               this.items = [];
        }
        return;
 };

-- 
To view, visit https://gerrit.wikimedia.org/r/231864
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d5ef13c2b6bd9f68723b1e478e0ea89c759b836
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LanguageTool
Gerrit-Branch: master
Gerrit-Owner: Ankita-ks <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to