Add functions for sections' shown status.
Signed-off-by: Gökay Şatır <gokaysatir@collabora.com> Change-Id: Ia480364c76b149177643971a0a29a2410c32475epull/9012/head
parent
932b99cf12
commit
b9e7d071a2
|
@ -76,14 +76,14 @@ class AutoFillMarkerSection extends CanvasSectionObject {
|
|||
}
|
||||
|
||||
var position: Array<number> = [0, 0];
|
||||
this.showSection = true;
|
||||
this.setShowSection(true);
|
||||
|
||||
if (this.sectionProperties.selectedAreaPoint !== null)
|
||||
position = [this.sectionProperties.selectedAreaPoint[0] - center, this.sectionProperties.selectedAreaPoint[1]];
|
||||
else if (this.sectionProperties.cellCursorPoint !== null)
|
||||
position = [this.sectionProperties.cellCursorPoint[0] - center, this.sectionProperties.cellCursorPoint[1]];
|
||||
else
|
||||
this.showSection = false;
|
||||
this.setShowSection(false);
|
||||
|
||||
// At this point, position is calculated without taking splitter into account.
|
||||
var splitPosCore = {x: 0, y: 0};
|
||||
|
@ -96,12 +96,12 @@ class AutoFillMarkerSection extends CanvasSectionObject {
|
|||
if (position[0] <= splitPosCore.x)
|
||||
position[0] += this.documentTopLeft[0];
|
||||
else if (position[0] - this.documentTopLeft[0] <= splitPosCore.x)
|
||||
this.showSection = false;
|
||||
this.setShowSection(false);
|
||||
|
||||
if (position[1] <= splitPosCore.y)
|
||||
position[1] += this.documentTopLeft[1];
|
||||
else if (position[1] - this.documentTopLeft[1] <= splitPosCore.y)
|
||||
this.showSection = false;
|
||||
this.setShowSection(false);
|
||||
|
||||
this.setPosition(position[0], position[1]);
|
||||
}
|
||||
|
|
|
@ -265,6 +265,24 @@ class CanvasSectionObject {
|
|||
return this.callbacks.onMouseUp(point, e);
|
||||
}
|
||||
|
||||
setShowSection(show: boolean) {
|
||||
this.showSection = show;
|
||||
if (this.onSectionShowStatusChange)
|
||||
this.onSectionShowStatusChange();
|
||||
|
||||
if (this.containerObject) { // Is section added to container.
|
||||
this.isVisible = this.containerObject.isDocumentObjectVisible(this);
|
||||
this.onDocumentObjectVisibilityChange();
|
||||
}
|
||||
}
|
||||
|
||||
/// Called when setShowSection is called. This is a callback to be overwritten.
|
||||
onSectionShowStatusChange() { return; }
|
||||
|
||||
isSectionShown() { return this.showSection; }
|
||||
|
||||
onDocumentObjectVisibilityChange() { return; } // We will turn this class definition into interface. Until then, let's keep these empty ones.
|
||||
|
||||
/// Parameters: Point [x, y], e (native event object)
|
||||
onMouseEnter(point: Array<number>, e: MouseEvent): void {
|
||||
if (this.callbacks.onMouseEnter)
|
||||
|
@ -415,7 +433,12 @@ class CanvasSectionObject {
|
|||
this.myTopLeft[1] = this.containerObject.getDocumentAnchor()[1] + y - this.containerObject.getDocumentTopLeft()[1];
|
||||
this.position[0] = x;
|
||||
this.position[1] = y;
|
||||
this.isVisible = this.containerObject.isDocumentObjectVisible(this);
|
||||
const isVisible = this.containerObject.isDocumentObjectVisible(this);
|
||||
if (isVisible !== this.isVisible) {
|
||||
this.isVisible = isVisible;
|
||||
this.onDocumentObjectVisibilityChange();
|
||||
}
|
||||
|
||||
if (this.containerObject.testing)
|
||||
this.containerObject.createUpdateSingleDivElement(this);
|
||||
}
|
||||
|
@ -918,7 +941,11 @@ class CanvasSectionContainer {
|
|||
|
||||
if (section.documentObject === true) {
|
||||
section.myTopLeft = [this.documentAnchor[0] + section.position[0] - this.documentTopLeft[0], this.documentAnchor[1] + section.position[1] - this.documentTopLeft[1]];
|
||||
section.isVisible = this.isDocumentObjectVisible(section);
|
||||
const isVisible = this.isDocumentObjectVisible(section);
|
||||
if (isVisible !== section.isVisible) {
|
||||
section.isVisible = isVisible;
|
||||
section.onDocumentObjectVisibilityChange();
|
||||
}
|
||||
}
|
||||
|
||||
this.sections[i].onNewDocumentTopLeft(this.getDocumentTopLeft());
|
||||
|
|
|
@ -3261,10 +3261,8 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
}
|
||||
}
|
||||
else {
|
||||
this._selectionHandles.start.showSection = false;
|
||||
this._selectionHandles.end.showSection = false;
|
||||
this._selectionHandles.start.setHTMLObjectVisibility(false);
|
||||
this._selectionHandles.end.setHTMLObjectVisibility(false);
|
||||
this._selectionHandles.start.setShowSection(false);
|
||||
this._selectionHandles.end.setShowSection(false);
|
||||
this._selectionHandles.active = false;
|
||||
|
||||
this._textCSelections.clear();
|
||||
|
@ -3517,9 +3515,8 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
this._twipsToLatLng(bottomRightTwips, this._map.getZoom()));
|
||||
|
||||
this._updateScrollOnCellSelection(oldSelection, this._textSelectionEnd);
|
||||
this._selectionHandles.end.setShowSection(true);
|
||||
this._updateMarkers();
|
||||
this._selectionHandles.end.showSection = true;
|
||||
this._selectionHandles.end.setHTMLObjectVisibility(true);
|
||||
}
|
||||
else {
|
||||
this._textSelectionEnd = null;
|
||||
|
@ -3542,8 +3539,7 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
|
||||
this._updateScrollOnCellSelection(oldSelection, this._textSelectionStart);
|
||||
|
||||
this._selectionHandles.start.showSection = true;
|
||||
this._selectionHandles.start.setHTMLObjectVisibility(true);
|
||||
this._selectionHandles.start.setShowSection(true);
|
||||
this._selectionHandles.active = true;
|
||||
}
|
||||
else {
|
||||
|
@ -4796,10 +4792,8 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
this._textSelectionEnd = null;
|
||||
this._selectedTextContent = '';
|
||||
|
||||
this._selectionHandles.start.showSection = false;
|
||||
this._selectionHandles.end.showSection = false;
|
||||
this._selectionHandles.start.setHTMLObjectVisibility(false);
|
||||
this._selectionHandles.end.setHTMLObjectVisibility(false);
|
||||
this._selectionHandles.start.setShowSection(false);
|
||||
this._selectionHandles.end.setShowSection(false);
|
||||
this._selectionHandles.active = false;
|
||||
|
||||
this._textCSelections.clear();
|
||||
|
@ -4809,7 +4803,7 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
if (!app.file.textCursor.visible || !this._textSelectionStart)
|
||||
return;
|
||||
|
||||
if (!this._selectionHandles.start.showSection || !this._selectionHandles.end.showSection)
|
||||
if (!this._selectionHandles.start.isSectionShown() || !this._selectionHandles.end.isSectionShown())
|
||||
return;
|
||||
|
||||
var startPos = this._map._docLayer._latLngToCorePixels(this._textSelectionStart.getSouthWest());
|
||||
|
@ -5606,9 +5600,9 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
this._map.setMarkersOpacity(0);
|
||||
}
|
||||
|
||||
if (this._selectionHandles.start.showSection)
|
||||
if (this._selectionHandles.start.isSectionShown())
|
||||
this._selectionHandles.start.setOpacity(0);
|
||||
if (this._selectionHandles.end.showSection)
|
||||
if (this._selectionHandles.end.isSectionShown())
|
||||
this._selectionHandles.end.setOpacity(0);
|
||||
|
||||
this.eachView(this._viewCursors, function (item) {
|
||||
|
@ -5634,9 +5628,9 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
this._map.setMarkersOpacity(1);
|
||||
}
|
||||
|
||||
if (this._selectionHandles.start.showSection)
|
||||
if (this._selectionHandles.start.isSectionShown())
|
||||
this._selectionHandles.start.setOpacity(1);
|
||||
if (this._selectionHandles.end.showSection)
|
||||
if (this._selectionHandles.end.isSectionShown())
|
||||
this._selectionHandles.end.setOpacity(1);
|
||||
|
||||
if (this._annotations) {
|
||||
|
|
|
@ -130,7 +130,7 @@ export class CommentSection extends CanvasSectionObject {
|
|||
this.initializeContextMenus();
|
||||
|
||||
if ((<any>window).mode.isMobile()) {
|
||||
this.showSection = false;
|
||||
this.setShowSection(false);
|
||||
this.size[0] = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -445,7 +445,7 @@ export class Comment extends CanvasSectionObject {
|
|||
const sizeX = cellPos[2];
|
||||
startX += sizeX; // but adjust for width of the cell.
|
||||
}
|
||||
this.showSection = true;
|
||||
this.setShowSection(true);
|
||||
var position: Array<number> = [Math.round(cellPos[0] * ratio), Math.round(cellPos[1] * ratio)];
|
||||
var splitPosCore = {x: 0, y: 0};
|
||||
if (this.map._docLayer.getSplitPanesContext())
|
||||
|
@ -457,12 +457,12 @@ export class Comment extends CanvasSectionObject {
|
|||
if (position[0] < splitPosCore.x)
|
||||
position[0] += this.documentTopLeft[0];
|
||||
else if (position[0] - this.documentTopLeft[0] < splitPosCore.x)
|
||||
this.showSection = false;
|
||||
this.setShowSection(false);
|
||||
|
||||
if (position[1] < splitPosCore.y)
|
||||
position[1] += this.documentTopLeft[1];
|
||||
else if (position[1] - this.documentTopLeft[1] < splitPosCore.y)
|
||||
this.showSection = false;
|
||||
this.setShowSection(false);
|
||||
|
||||
this.setPosition(position[0], position[1]);
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
class HTMLObjectSection extends CanvasSectionObject {
|
||||
|
||||
constructor (sectionName: string, objectWidth: number, objectHeight: number, documentPosition: cool.SimplePoint, extraClass: string = "", visible: boolean = true) {
|
||||
constructor (sectionName: string, objectWidth: number, objectHeight: number, documentPosition: cool.SimplePoint, extraClass: string = "", showSection: boolean = true) {
|
||||
super({
|
||||
name: "will-be-set-at-initialization", // There may be multiple instances of this class.
|
||||
anchor: [],
|
||||
position: new Array<number>(0),
|
||||
size: new Array<number>(0),
|
||||
expand: '',
|
||||
showSection: true,
|
||||
showSection: showSection,
|
||||
processingOrder: L.CSections.HTMLObject.processingOrder,
|
||||
drawingOrder: L.CSections.HTMLObject.drawingOrder,
|
||||
zIndex: L.CSections.HTMLObject.zIndex,
|
||||
|
@ -56,7 +56,7 @@ class HTMLObjectSection extends CanvasSectionObject {
|
|||
};
|
||||
tempFunction(this.sectionProperties.objectDiv);
|
||||
|
||||
if (!visible)
|
||||
if (!showSection)
|
||||
this.sectionProperties.objectDiv.style.display = 'none';
|
||||
}
|
||||
|
||||
|
@ -64,13 +64,11 @@ class HTMLObjectSection extends CanvasSectionObject {
|
|||
this.setPosition(this.position[0], this.position[1]);
|
||||
}
|
||||
|
||||
public setHTMLObjectVisibility(value: boolean) {
|
||||
this.showSection = value;
|
||||
|
||||
if (!value)
|
||||
this.sectionProperties.objectDiv.style.display = 'none';
|
||||
else
|
||||
public onSectionShowStatusChange(): void {
|
||||
if (this.showSection)
|
||||
this.sectionProperties.objectDiv.style.display = '';
|
||||
else
|
||||
this.sectionProperties.objectDiv.style.display = 'none';
|
||||
}
|
||||
|
||||
public onDraw() {
|
||||
|
@ -86,7 +84,7 @@ class HTMLObjectSection extends CanvasSectionObject {
|
|||
}
|
||||
|
||||
public onNewDocumentTopLeft(): void {
|
||||
if (this.isVisible && this.showSection) {
|
||||
if (this.isVisible && this.isSectionShown()) {
|
||||
if (this.sectionProperties.objectDiv.style.display !== '')
|
||||
this.sectionProperties.objectDiv.style.display = '';
|
||||
}
|
||||
|
|
|
@ -60,6 +60,13 @@ class TextSelectionHandle extends HTMLObjectSection {
|
|||
}
|
||||
}
|
||||
|
||||
onDocumentObjectVisibilityChange(): void {
|
||||
if (this.showSection && this.isVisible)
|
||||
this.sectionProperties.objectDiv.style.display = '';
|
||||
else
|
||||
this.sectionProperties.objectDiv.style.display = 'none';
|
||||
}
|
||||
|
||||
onClick(point: number[], e: MouseEvent): void {
|
||||
e.stopPropagation();
|
||||
this.stopPropagating();
|
||||
|
|
|
@ -140,7 +140,7 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Change table properties / l
|
|||
mobileHelper.closeMobileWizard();
|
||||
writerHelper.selectAllTextOfDoc();
|
||||
// Check markers are in the same row (we have text selection only)
|
||||
cy.cGet('.leaflet-marker-icon').should(function(markers) {
|
||||
cy.cGet('.html-object-section').should(function(markers) {
|
||||
expect(markers).to.have.lengthOf(2);
|
||||
expect(markers[0].getBoundingClientRect().top).to.equal(markers[1].getBoundingClientRect().top);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue