Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/193286
Change subject: Add a threshold to 'read more' calculation in media dialog info ...................................................................... Add a threshold to 'read more' calculation in media dialog info When calculating whether to show the 'read more' button on fields that are configured 'descriptions', use a threshold to check if the height is enough to be shown. Bug: T87265 Change-Id: I0601e4fa92cb58903641a146500cf560bc029425 --- M modules/ve-mw/ui/widgets/ve.ui.MWMediaInfoFieldWidget.js 1 file changed, 13 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/86/193286/1 diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWMediaInfoFieldWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWMediaInfoFieldWidget.js index ff0316e..ac52c3b 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWMediaInfoFieldWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWMediaInfoFieldWidget.js @@ -105,16 +105,25 @@ /* Static Properties */ ve.ui.MWMediaInfoFieldWidget.static.tagName = 'div'; +ve.ui.MWMediaInfoFieldWidget.static.threshold = 24; /** * Toggle the read more button according to whether it should be * visible or not. */ ve.ui.MWMediaInfoFieldWidget.prototype.toggleReadMoreButton = function () { - var show = this.$text.height() < this.$text.prop( 'scrollHeight' ); - // Only show the readMore button if it should be shown, and not while - // the expansion animation is ongoing - this.readMoreButton.toggle( show ); + var actualHeight = this.$text.prop( 'scrollHeight' ), + containerHeight = this.$text.outerHeight( true ); + + if ( actualHeight < containerHeight + this.constructor.static.threshold ) { + // The contained result is big enough to show. Remove the maximum height + this.$text + .css( 'maxHeight', '' ); + } else { + // Only show the readMore button if it should be shown + this.readMoreButton.toggle( containerHeight < actualHeight ); + } + }; /** -- To view, visit https://gerrit.wikimedia.org/r/193286 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0601e4fa92cb58903641a146500cf560bc029425 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits