Jakob has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/370628 )
Change subject: [WIP] Indicate recognized/unrecognized input in entityselector. ...................................................................... [WIP] Indicate recognized/unrecognized input in entityselector. - adds a css class to the input field depending on whether the input was recognized or not TODO: - current implementation uses silly bright green and red color for testing purposes - actual styling of the fields is waiting for UX team input Bug: T170531 Change-Id: I0aabf65fc0234a0cd2071a3b9856df6b49d7ad6f --- M view/resources/jquery/wikibase/jquery.wikibase.entityselector.js M view/resources/jquery/wikibase/themes/default/jquery.wikibase.entityselector.css 2 files changed, 34 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/28/370628/1 diff --git a/view/resources/jquery/wikibase/jquery.wikibase.entityselector.js b/view/resources/jquery/wikibase/jquery.wikibase.entityselector.js index 21b64b5..3bfec43 100644 --- a/view/resources/jquery/wikibase/jquery.wikibase.entityselector.js +++ b/view/resources/jquery/wikibase/jquery.wikibase.entityselector.js @@ -154,7 +154,33 @@ .off( 'blur' ) .on( 'eachchange.' + this.widgetName, function ( event ) { self._search( event ); - } ); + } ) + .on( 'focusout', function () { + self._indicateRecognizedInput(); + } ) + .on( 'focusin', function () { + self._inEditMode(); + }); + }, + + _indicateRecognizedInput: function () { + this._resetInputHighlighting(); + + if ( this._selectedEntity !== null ) { + this.element.addClass( 'ui-entityselector-input-recognized' ); + } else if ( this.element.val() !== '' ) { + this.element.addClass( 'ui-entityselector-input-unrecognized' ); + } + }, + + _inEditMode: function () { + this._resetInputHighlighting(); + }, + + _resetInputHighlighting: function () { + this.element.removeClass( + 'ui-entityselector-input-recognized ui-entityselector-input-unrecognized' + ); }, /** diff --git a/view/resources/jquery/wikibase/themes/default/jquery.wikibase.entityselector.css b/view/resources/jquery/wikibase/themes/default/jquery.wikibase.entityselector.css index 8f5a359..02db5e6 100644 --- a/view/resources/jquery/wikibase/themes/default/jquery.wikibase.entityselector.css +++ b/view/resources/jquery/wikibase/themes/default/jquery.wikibase.entityselector.css @@ -69,3 +69,10 @@ text-align: right; padding-right: 1.2em; } + +.ui-entityselector-input-recognized { + background-color: #0f0 !important; /* TODO: !important because valueview overrides background-color */ +} +.ui-entityselector-input-unrecognized { + background-color: #f00 !important; /* TODO: !important because valueview overrides background-color */ +} -- To view, visit https://gerrit.wikimedia.org/r/370628 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0aabf65fc0234a0cd2071a3b9856df6b49d7ad6f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Jakob <jakob.warkot...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits