DLynch has uploaded a new change for review.
https://gerrit.wikimedia.org/r/254195
Change subject: Limit the height of fragment inspectors
......................................................................
Limit the height of fragment inspectors
Fragment inspectors can currently grow to be taller than the page, at
which point they can't always be scrolled properly into view. This
mostly happens with the MW title search link inspector.
So, limit the height of the inspectors to the current size of the
viewport.
Change-Id: I534ce003d763f7986153d9b03afbe564162ad240
---
M src/ce/ve.ce.Surface.js
M src/ui/inspectors/ve.ui.FragmentInspector.js
M src/ui/ve.ui.Surface.js
3 files changed, 43 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/95/254195/1
diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 259f87c..169d39c 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -2904,10 +2904,7 @@
var surface = this,
documentModel = this.getModel().getDocument(),
data = documentModel.data,
- surfaceRect = this.getSurface().getBoundingClientRect(),
- padding = 50,
- top = Math.max( this.surface.toolbarHeight - surfaceRect.top -
padding, 0 ),
- bottom = top + this.$window.height() -
this.surface.toolbarHeight + ( padding * 2 ),
+ dimensions = this.surface.getViewportDimensions(),
documentRange = new ve.Range( 0,
this.getModel().getDocument().getInternalList().getListNode().getOuterRange().start
);
function highestIgnoreChildrenNode( childNode ) {
@@ -2951,8 +2948,8 @@
}
return new ve.Range(
- binarySearch( top, documentRange, 'bottom' ),
- binarySearch( bottom, documentRange, 'top' )
+ binarySearch( dimensions.top, documentRange, 'bottom' ),
+ binarySearch( dimensions.bottom, documentRange, 'top' )
);
};
diff --git a/src/ui/inspectors/ve.ui.FragmentInspector.js
b/src/ui/inspectors/ve.ui.FragmentInspector.js
index 3aeb6de..25b4d83 100644
--- a/src/ui/inspectors/ve.ui.FragmentInspector.js
+++ b/src/ui/inspectors/ve.ui.FragmentInspector.js
@@ -171,3 +171,24 @@
// e.g. a disabled button.
return Math.ceil( this.container.$element[ 0 ].scrollHeight ) + 1;
};
+
+/**
+ * @inheritdoc OO.ui.Window
+ */
+ve.ui.FragmentInspector.prototype.getSizeProperties = function () {
+ var surface = this.manager.getSurface(),
+ viewport = surface.getViewportDimensions(),
+ properties = ve.cloneObject(
ve.ui.FragmentInspector.super.prototype.getSizeProperties.apply( this,
arguments ) );
+ // We want to stop the inspector from possibly being bigger than the
+ // viewport. Limiting it to the window height would ignore toolbars and
+ // the find-replace dialog and suchlike. Therefore we set its max height
+ // to the surface's estimation of the actual viewport available to it.
If
+ // we wanted to stop the inspector from going off the bottom of the
+ // visible area we could do something like this:
+ // `viewport.bottom - surface.getContext().$element.offset().top`
+ // ...but that's probably not the desired behavior. It's okay if the
+ // inspector goes off the edge of the viewport, so long as it's possible
+ // to scroll and get it all in view.
+ properties.maxHeight = viewport.height -
surface.getContext().$element.offset().top;
+ return properties;
+};
diff --git a/src/ui/ve.ui.Surface.js b/src/ui/ve.ui.Surface.js
index 401c715..d12f6b2 100644
--- a/src/ui/ve.ui.Surface.js
+++ b/src/ui/ve.ui.Surface.js
@@ -110,6 +110,8 @@
*/
ve.ui.Surface.static.isMobile = false;
+ve.ui.Surface.static.viewportPadding = 25;
+
/* Methods */
/**
@@ -246,6 +248,23 @@
};
/**
+ * Get measurements of the visible area of the surface viewport
+ *
+ * @return {Object}
+ */
+ve.ui.Surface.prototype.getViewportDimensions = function () {
+ var rect = this.getBoundingClientRect(),
+ padding = this.constructor.static.viewportPadding,
+ top = Math.max( this.toolbarHeight - rect.top - padding, 0 ),
+ bottom = top + $( this.getElementWindow() ).height() - (
this.toolbarHeight + ( padding * 2 ) );
+ return {
+ top: top,
+ bottom: bottom,
+ height: bottom - top
+ };
+};
+
+/**
* Check if editing is enabled.
*
* @method
--
To view, visit https://gerrit.wikimedia.org/r/254195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I534ce003d763f7986153d9b03afbe564162ad240
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits