Santhosh has uploaded a new change for review. https://gerrit.wikimedia.org/r/212748
Change subject: Source selector: Relax the validations on source title ...................................................................... Source selector: Relax the validations on source title Since we have a pageselector, and it works on prefix search, validating title on every input event does not make sense. Most of the time we might be doing a validation on the prefix. Showing error message everytime the pageselector is open is not good. Following changes are made: * Enable the translate button as soon as the user type something as a gesture of invitation. * Make sure the validations are done when you press the translate button even if we missed to validate in any previous events. * Do not do validations when user type something on source title input. User will most likely select something from pageselector, which is a valid title for sure. * If the user did not select anything from page selector, but typed some random title, the translate button press will catch it. Or the validation for target title will include the validation for this wrong source title. In effect, less frequent validations and therefore less number of API hits for source title. Showing lot of errors or warnings are not good while we trust the user to select a meaningful source title. Ultimately the translate button will capture anything missed to validate. Change-Id: I3725e6493de63c1b06e429ce9832601aa680cbff --- M modules/source/ext.cx.source.selector.js 1 file changed, 13 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation refs/changes/48/212748/1 diff --git a/modules/source/ext.cx.source.selector.js b/modules/source/ext.cx.source.selector.js index 8c0f3e9..a53a02c 100644 --- a/modules/source/ext.cx.source.selector.js +++ b/modules/source/ext.cx.source.selector.js @@ -231,7 +231,7 @@ // Don't let the target be the same as source sourceLanguage = this.getSourceLanguage(); - targetLanguageCodes = jQuery.grep( this.targetLanguages, function( language ) { + targetLanguageCodes = jQuery.grep( this.targetLanguages, function ( language ) { return language !== sourceLanguage; } ); @@ -259,14 +259,19 @@ * Listen for events. */ CXSourceSelector.prototype.listen = function () { + var self = this; // Open or close the dialog when clicking the link. // The dialog will be unitialized until the first click. this.$trigger.click( $.proxy( this.show, this ) ); - // Source title input or target title input, input or search (check) - this.$dialog.on( - 'input blur', - '.cx-sourceselector-dialog__title', + this.$sourceTitleInput.on( 'input', function () { + self.$translateFromButton.prop( 'disabled', false ); + // Hide any previous errors. + self.$messageBar.hide(); + } ); + + // Target title input (check) + this.$targetTitleInput.on( 'input blur', $.debounce( 600, false, $.proxy( this.check, this ) ) ); @@ -708,8 +713,9 @@ * Does nothing if source page does not exist. */ CXSourceSelector.prototype.startPageInCX = function () { - var targetTitle, originalSourceTitle, sourceLanguage, targetLanguage, siteMapper; + var targetTitle, originalSourceTitle, sourceLanguage, targetLanguage, siteMapper, selector; + selector = this; siteMapper = this.siteMapper; sourceLanguage = this.getSourceLanguage(); targetLanguage = this.getTargetLanguage(); @@ -721,6 +727,7 @@ originalSourceTitle ).done( function ( sourceTitle ) { if ( sourceTitle === false ) { + selector.showSourceTitleError( sourceLanguage ); return; } -- To view, visit https://gerrit.wikimedia.org/r/212748 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3725e6493de63c1b06e429ce9832601aa680cbff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits