Commit fbed8d82 authored by Alexey Musinov's avatar Alexey Musinov Committed by KirillovIlya

DrawingArea _this -> prototype

parent ea52adf6
......@@ -565,72 +565,70 @@ function FrozenPlace(ws, type) {
// Container
function DrawingArea(ws) {
var _this = this;
var asc = window["Asc"];
var api = asc["editor"];
this.api = asc["editor"];
_this.worksheet = ws;
_this.frozenPlaces = [];
this.worksheet = ws;
this.frozenPlaces = [];
}
// Methods
_this.init = function() {
_this.frozenPlaces = [];
if ( _this.worksheet ) {
DrawingArea.prototype.init = function() {
this.frozenPlaces = [];
if ( this.worksheet ) {
var place;
if ( _this.worksheet.topLeftFrozenCell ) {
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Top);
if ( this.worksheet.topLeftFrozenCell ) {
place = new FrozenPlace(this.worksheet, FrozenAreaType.Top);
if ( place.isValid )
_this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Bottom);
this.frozenPlaces.push(place);
place = new FrozenPlace(this.worksheet, FrozenAreaType.Bottom);
if ( place.isValid )
_this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Left);
this.frozenPlaces.push(place);
place = new FrozenPlace(this.worksheet, FrozenAreaType.Left);
if ( place.isValid )
_this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.Right);
this.frozenPlaces.push(place);
place = new FrozenPlace(this.worksheet, FrozenAreaType.Right);
if ( place.isValid )
_this.frozenPlaces.push(place);
this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.LeftTop);
place = new FrozenPlace(this.worksheet, FrozenAreaType.LeftTop);
if ( place.isValid )
_this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.RightTop);
this.frozenPlaces.push(place);
place = new FrozenPlace(this.worksheet, FrozenAreaType.RightTop);
if ( place.isValid )
_this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.LeftBottom);
this.frozenPlaces.push(place);
place = new FrozenPlace(this.worksheet, FrozenAreaType.LeftBottom);
if ( place.isValid )
_this.frozenPlaces.push(place);
place = new FrozenPlace(_this.worksheet, FrozenAreaType.RightBottom);
this.frozenPlaces.push(place);
place = new FrozenPlace(this.worksheet, FrozenAreaType.RightBottom);
if ( place.isValid )
_this.frozenPlaces.push(place);
this.frozenPlaces.push(place);
}
else
_this.frozenPlaces.push(new FrozenPlace(_this.worksheet, FrozenAreaType.Center));
this.frozenPlaces.push(new FrozenPlace(this.worksheet, FrozenAreaType.Center));
}
};
};
_this.clear = function() {
_this.worksheet.drawingGraphicCtx.clear();
};
DrawingArea.prototype.clear = function() {
this.worksheet.drawingGraphicCtx.clear();
};
_this.drawObject = function(object) {
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) {
if ( _this.frozenPlaces[i].isObjectInside(object) ) {
_this.frozenPlaces[i].drawObject(object);
DrawingArea.prototype.drawObject = function(object) {
for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
if ( this.frozenPlaces[i].isObjectInside(object) ) {
this.frozenPlaces[i].drawObject(object);
}
}
};
};
_this.reinitRanges = function()
{
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) {
_this.frozenPlaces[i].initRange();
DrawingArea.prototype.reinitRanges = function() {
for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
this.frozenPlaces[i].initRange();
}
};
};
_this.drawSelection = function(drawingDocument) {
DrawingArea.prototype.drawSelection = function(drawingDocument) {
var canvas = _this.worksheet.objectRender.getDrawingCanvas();
var canvas = this.worksheet.objectRender.getDrawingCanvas();
var shapeCtx = canvas.shapeCtx;
var shapeOverlayCtx = canvas.shapeOverlayCtx;
var autoShapeTrack = canvas.autoShapeTrack;
......@@ -640,30 +638,30 @@ function DrawingArea(ws) {
trackOverlay.Clear();
drawingDocument.Overlay = trackOverlay;
_this.worksheet.overlayCtx.clear();
_this.worksheet.overlayGraphicCtx.clear();
_this.worksheet._drawCollaborativeElements();
this.worksheet.overlayCtx.clear();
this.worksheet.overlayGraphicCtx.clear();
this.worksheet._drawCollaborativeElements();
if ( !_this.worksheet.objectRender.controller.selectedObjects.length && !api.isStartAddShape )
_this.worksheet._drawSelection();
if ( !this.worksheet.objectRender.controller.selectedObjects.length && !this.api.isStartAddShape )
this.worksheet._drawSelection();
var chart;
var controller = _this.worksheet.objectRender.controller;
var controller = this.worksheet.objectRender.controller;
var selected_objects = controller.selection.groupSelection ? controller.selection.groupSelection.selectedObjects : controller.selectedObjects;
if(selected_objects.length === 1 && selected_objects[0].getObjectType() === historyitem_type_ChartSpace)
{
chart = selected_objects[0];
_this.worksheet.objectRender.selectDrawingObjectRange(chart);
this.worksheet.objectRender.selectDrawingObjectRange(chart);
//shapeOverlayCtx.ClearMode = true;
////selected_objects[0].draw(shapeOverlayCtx);
//shapeOverlayCtx.ClearMode = false;
}
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) {
for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
_this.frozenPlaces[i].setTransform(shapeCtx, shapeOverlayCtx, autoShapeTrack);
this.frozenPlaces[i].setTransform(shapeCtx, shapeOverlayCtx, autoShapeTrack);
// Clip
_this.frozenPlaces[i].clip(shapeOverlayCtx);
this.frozenPlaces[i].clip(shapeOverlayCtx);
if (null == drawingDocument.m_oDocumentRenderer) {
if (drawingDocument.m_bIsSelection) {
......@@ -674,17 +672,17 @@ function DrawingArea(ws) {
trackOverlay.m_oContext = trackOverlay.m_oControl.HtmlElement.getContext('2d');
}
drawingDocument.private_StartDrawSelection(trackOverlay);
_this.worksheet.objectRender.controller.drawTextSelection();
this.worksheet.objectRender.controller.drawTextSelection();
drawingDocument.private_EndDrawSelection();
}
ctx.globalAlpha = 1.0;
_this.worksheet.objectRender.controller.drawSelection(drawingDocument);
if ( _this.worksheet.objectRender.controller.needUpdateOverlay() ) {
this.worksheet.objectRender.controller.drawSelection(drawingDocument);
if ( this.worksheet.objectRender.controller.needUpdateOverlay() ) {
trackOverlay.Show();
shapeOverlayCtx.put_GlobalAlpha(true, 0.5);
_this.worksheet.objectRender.controller.drawTracks(shapeOverlayCtx);
this.worksheet.objectRender.controller.drawTracks(shapeOverlayCtx);
shapeOverlayCtx.put_GlobalAlpha(true, 1);
}
}
......@@ -704,16 +702,15 @@ function DrawingArea(ws) {
}
// Restore
_this.frozenPlaces[i].restore(shapeOverlayCtx);
this.frozenPlaces[i].restore(shapeOverlayCtx);
}
};
};
_this.getOffsets = function(x, y, bEvents) {
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) {
if ( _this.frozenPlaces[i].isPointInside(x, y, bEvents) ) {
return { x: _this.frozenPlaces[i].getHorizontalScroll(), y: _this.frozenPlaces[i].getVerticalScroll() }
DrawingArea.prototype.getOffsets = function(x, y, bEvents) {
for ( var i = 0; i < this.frozenPlaces.length; i++ ) {
if ( this.frozenPlaces[i].isPointInside(x, y, bEvents) ) {
return { x: this.frozenPlaces[i].getHorizontalScroll(), y: this.frozenPlaces[i].getVerticalScroll() }
}
}
return null;
};
\ No newline at end of file
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment