Bartosz Dziewoński has uploaded a new change for review.

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

Change subject: ProcessDialog: Don't center the title label if there's not 
enough space
......................................................................

ProcessDialog: Don't center the title label if there's not enough space

If there isn't enough space to center the title label relative to the
entire window title bar, then center the label within the space
between buttons. The dialog still looks neat and the title is
readable.

Bug: 68571
Change-Id: I65da5bba363f8a6dfab445d31349b7c29957218a
---
M src/dialogs/ProcessDialog.js
1 file changed, 25 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/12/160812/1

diff --git a/src/dialogs/ProcessDialog.js b/src/dialogs/ProcessDialog.js
index 18a1ee2..9f44d36 100644
--- a/src/dialogs/ProcessDialog.js
+++ b/src/dialogs/ProcessDialog.js
@@ -164,11 +164,31 @@
  * @chainable
  */
 OO.ui.ProcessDialog.prototype.fitLabel = function () {
-       var width = Math.max(
-               this.$safeActions.is( ':visible' ) ? this.$safeActions.width() 
: 0,
-               this.$primaryActions.is( ':visible' ) ? 
this.$primaryActions.width() : 0
-       );
-       this.$location.css( { paddingLeft: width, paddingRight: width } );
+       var safeWidth, primaryWidth, biggerWidth, labelWidth, navigationWidth, 
leftWidth, rightWidth;
+
+       safeWidth = this.$safeActions.is( ':visible' ) ? 
this.$safeActions.width() : 0;
+       primaryWidth = this.$primaryActions.is( ':visible' ) ? 
this.$primaryActions.width() : 0;
+       biggerWidth = Math.max( safeWidth, primaryWidth );
+
+       labelWidth = this.title.$element.width();
+       // Is there a better way to calculate this?
+       navigationWidth = OO.ui.WindowManager.static.sizes[ this.getSize() 
].width - 20;
+
+       if ( 2 * biggerWidth + labelWidth < navigationWidth ) {
+               // We have enough space to center the label
+               leftWidth = rightWidth = biggerWidth;
+       } else {
+               // Let's hope we at least have enough space not to overlap, 
because we can't wrap the label…
+               if ( this.getDir() === 'ltr' ) {
+                       leftWidth = safeWidth;
+                       rightWidth = primaryWidth;
+               } else {
+                       leftWidth = primaryWidth;
+                       rightWidth = safeWidth;
+               }
+       }
+
+       this.$location.css( { paddingLeft: leftWidth, paddingRight: rightWidth 
} );
 
        return this;
 };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I65da5bba363f8a6dfab445d31349b7c29957218a
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to