Nikerabbit has uploaded a new change for review.

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

Change subject: Replace datalist with jquery.suggest for source article 
selection
......................................................................

Replace datalist with jquery.suggest for source article selection

Change-Id: Ida9e110765537bef7f13d5b888c89f5efe972497
---
M Resources.php
M modules/source/ext.cx.source.selector.js
2 files changed, 12 insertions(+), 17 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/62/172962/1

diff --git a/Resources.php b/Resources.php
index 61cad91..cf831e4 100644
--- a/Resources.php
+++ b/Resources.php
@@ -140,6 +140,7 @@
        ),
        'dependencies' => array(
                'ext.cx.sitemapper',
+               'jquery.suggestions',
                'jquery.throttle-debounce',
                'jquery.uls.data',
        ),
diff --git a/modules/source/ext.cx.source.selector.js 
b/modules/source/ext.cx.source.selector.js
index a561f21..702ff31 100644
--- a/modules/source/ext.cx.source.selector.js
+++ b/modules/source/ext.cx.source.selector.js
@@ -21,14 +21,13 @@
                // @todo Refactor
                this.siteMapper = mw.cx.siteMapper;
 
-               this.$dialog = null;
                this.languagePairs = null;
                this.sourceLanguages = [];
                this.targetLanguages = [];
+
+               this.$dialog = null;
                this.$sourceLanguage = null;
                this.$targetLanguage = null;
-               this.sourceLanguage = null;
-               this.targetLanguage = null;
                this.$messageBar = null;
                this.$sourceTitleInput = null;
                this.$targetTitleInput = null;
@@ -170,17 +169,13 @@
         * Handles searching for titles based on source title input
         */
        CXSourceSelector.prototype.searchHandler = function () {
-               var selector = this;
+               var $input = this.$sourceTitleInput;
 
-               this.sourceLanguage = this.$sourceLanguage.val();
-               this.searchTitles( this.sourceLanguage, 
this.$sourceTitleInput.val() ).done( function ( response ) {
-                       var i, len, suggestions = response[ 1 ];
-                       selector.$titleList.empty();
-                       if ( suggestions.length ) {
-                               for ( i = 0, len = suggestions.length; i < len; 
i++ ) {
-                                       selector.$titleList.append( $( 
'<option>' ).attr( 'value', suggestions[ i ] ) );
-                               }
-                       }
+               this.searchTitles(
+                       this.$sourceLanguage.val(),
+                       $input.val()
+               ).done( function ( response ) {
+                       $input.suggestions( 'suggestions', response[ 1 ] );
                } );
        };
 
@@ -590,7 +585,6 @@
                                placeholder: mw.msg( 
'cx-sourceselector-dialog-target-title-placeholder' )
                        } );
 
-               this.$titleList = $( '<datalist>' ).prop( 'id', 'searchresults' 
);
                $sourceInputs = $( '<div>' )
                        .addClass( 'cx-sourceselector-dialog__source-inputs' )
                        .append( $sourceLanguageLabel,
@@ -618,15 +612,15 @@
                        .prop( 'disabled', true )
                        .click( $.proxy( this.startPageInCX, this ) );
 
-               $actions = $( '<div>' ).addClass( 
'cx-sourceselector-dialog__actions' )
+               $actions = $( '<div>' )
+                       .addClass( 'cx-sourceselector-dialog__actions' )
                        .append( this.$translateFromButton );
 
                this.$dialog.append( $heading,
                        $sourceInputs,
                        $targetInputs,
                        this.$messageBar,
-                       $actions,
-                       this.$titleList
+                       $actions
                );
 
                if ( localStorage && localStorage.cxSourceLanguage ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ida9e110765537bef7f13d5b888c89f5efe972497
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>

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

Reply via email to