jenkins-bot has submitted this change and it was merged.

Change subject: sitelinkview: Applied inputautoexpand to page name input
......................................................................


sitelinkview: Applied inputautoexpand to page name input

Requires additional parameter in inputautoexpand's expand() to be effective 
properly.

Bug: T76214
Change-Id: I5a160784e8cf86cae6f45b1370c0265e8aa59bba
---
M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js
M lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
2 files changed, 32 insertions(+), 6 deletions(-)

Approvals:
  Tobias Gritschacher: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js
index 9f9ff8c..c275f48 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkgroupview.js
@@ -509,6 +509,8 @@
                                                )
                                        } );
                                }
+
+                               sitelinkview.updatePageNameInputAutoExpand();
                        } );
                },
                sitelinkgroupviewafterstopediting: function( event, 
toolbarcontroller ) {
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
index 583a267..0eaf996 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.sitelinkview.js
@@ -154,6 +154,8 @@
                        }
                } )
                .on( 'badgeselectorchange', function( event ) {
+                       // Adding/removing badges decreases/increases available 
space:
+                       self.updatePageNameInputAutoExpand();
                        self._trigger( 'change' );
                } );
 
@@ -216,16 +218,15 @@
                } ).pagesuggester( pageNameInputOptions );
 
                $pageNameInput
-               .on( 'eachchange.' + this.widgetName + ' pagesuggesterchange.' 
+ this.widgetName,
-                       function( event ) {
-                               self.setError();
-                               self._trigger( 'change' );
-                       }
-               );
+               .on( 'pagesuggesterchange.' + this.widgetName, function( event 
) {
+                       self.setError();
+                       self._trigger( 'change' );
+               } );
 
                this.$link.find( '.wikibase-sitelinkview-page' 
).empty().append( $pageNameInput );
 
                if( this.options.value ) {
+                       this.updatePageNameInputAutoExpand();
                        // Site of an existing site link is not supposed to be 
changeable.
                        return;
                }
@@ -264,6 +265,8 @@
                                if( inputautoexpand ) {
                                        inputautoexpand.expand();
                                }
+
+                               self.updatePageNameInputAutoExpand();
                        }
                );
 
@@ -275,6 +278,8 @@
                        )
                } );
 
+               this.updatePageNameInputAutoExpand();
+
                $pageNameInput
                .on( 'keydown.' + this.widgetName, function( event ) {
                        if( event.keyCode === $.ui.keyCode.BACKSPACE && 
$pageNameInput.val() === '' ) {
@@ -286,6 +291,25 @@
        },
 
        /**
+        * Updates the maximum width the page name input element may grow to.
+        */
+       updatePageNameInputAutoExpand: function() {
+               var $pageNameInput = this.$link.find( 'input' );
+
+               if( !$pageNameInput.length ) {
+                       return;
+               }
+
+               $pageNameInput.inputautoexpand( {
+                       maxWidth: Math.floor( this.element.width()
+                               - this.$siteIdContainer.outerWidth( true )
+                               - ( this.$link.outerWidth( true ) - 
$pageNameInput.width() ) )
+               } );
+
+               $pageNameInput.data( 'inputautoexpand' ).expand( true );
+       },
+
+       /**
         * @return {boolean}
         */
        isEmpty: function() {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5a160784e8cf86cae6f45b1370c0265e8aa59bba
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Adrian Lang <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to