Commit bb324194 authored by Alexey.Musinov's avatar Alexey.Musinov Committed by Alexander.Trofimov

[ios] для нативной версии добавил правки

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@67088 954022d7-b5bf-4e40-9824-e11837661b57
parent 38d07ba9
...@@ -154,6 +154,8 @@ ...@@ -154,6 +154,8 @@
selectionTimeout: 20 selectionTimeout: 20
}; };
this.dontUpdateText = false;
this._init(settings); this._init(settings);
return this; return this;
...@@ -283,6 +285,8 @@ ...@@ -283,6 +285,8 @@
} }
this.isOpened = false; this.isOpened = false;
if (!window['IS_NATIVE_EDITOR']) {
if (window.removeEventListener) { if (window.removeEventListener) {
window.removeEventListener("keydown" , this.fKeyDown , false); window.removeEventListener("keydown" , this.fKeyDown , false);
window.removeEventListener("keypress" , this.fKeyPress , false); window.removeEventListener("keypress" , this.fKeyPress , false);
...@@ -296,6 +300,7 @@ ...@@ -296,6 +300,7 @@
this._hideCursor(); this._hideCursor();
// hide // hide
this._hideCanvas(); this._hideCanvas();
}
// delete autoComplete // delete autoComplete
this.objAutoComplete = {}; this.objAutoComplete = {};
...@@ -1006,12 +1011,19 @@ ...@@ -1006,12 +1011,19 @@
} }
} }
if (doAjust) {this._adjustCanvas();} if (doAjust) {this._adjustCanvas();}
if (!window['IS_NATIVE_EDITOR']) {
this._renderText(); // вызов нужен для пересчета поля line.startX, которое используется в _updateCursorPosition this._renderText(); // вызов нужен для пересчета поля line.startX, которое используется в _updateCursorPosition
this._fireUpdated(); // вызов нужен для обновление текста верхней строки, перед обновлением позиции курсора this._fireUpdated(); // вызов нужен для обновление текста верхней строки, перед обновлением позиции курсора
this._updateCursorPosition(true); this._updateCursorPosition(true);
this._showCursor(); this._showCursor();
}
this._updateUndoRedoChanged(); this._updateUndoRedoChanged();
if (window['IS_NATIVE_EDITOR'] && !this.dontUpdateText) {
window['native'].onCellEditorChangeText(this._getFragmentsText(this.options.fragments));
}
}; };
CellEditor.prototype._fireUpdated = function () { CellEditor.prototype._fireUpdated = function () {
...@@ -1153,18 +1165,24 @@ ...@@ -1153,18 +1165,24 @@
CellEditor.prototype._drawSelection = function () { CellEditor.prototype._drawSelection = function () {
var ctx = this.overlayCtx, ppix = ctx.getPPIX(), ppiy = ctx.getPPIY(); var ctx = this.overlayCtx, ppix = ctx.getPPIX(), ppiy = ctx.getPPIY();
var begPos, endPos, top, top1, top2, begInfo, endInfo, line1, line2, i; var begPos, endPos, top, top1, top2, begInfo, endInfo, line1, line2, i, selection = [];
function drawRect(x, y, w, h) { function drawRect(x, y, w, h) {
if (window['IS_NATIVE_EDITOR']) {
selection.push([asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy), asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy)]);
} else {
ctx.fillRect( ctx.fillRect(
asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy), asc_calcnpt(x, ppix), asc_calcnpt(y, ppiy),
asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy)); asc_calcnpt(w, ppix), asc_calcnpt(h, ppiy));
} }
}
begPos = this.selectionBegin; begPos = this.selectionBegin;
endPos = this.selectionEnd; endPos = this.selectionEnd;
if (!window['IS_NATIVE_EDITOR']) {
ctx.setFillStyle(this.defaults.selectColor).clear(); ctx.setFillStyle(this.defaults.selectColor).clear();
}
if (begPos !== endPos && !this.isTopLineActive) { if (begPos !== endPos && !this.isTopLineActive) {
top = this.textRender.calcLineOffset(this.topLineIndex); top = this.textRender.calcLineOffset(this.topLineIndex);
...@@ -1186,17 +1204,25 @@ ...@@ -1186,17 +1204,25 @@
} }
} }
} }
return selection;
}; };
// Cursor // Cursor
CellEditor.prototype.showCursor = function () { CellEditor.prototype.showCursor = function () {
if (window['IS_NATIVE_EDITOR'])
return;
if (!this.options) {this.options = {};} if (!this.options) {this.options = {};}
this.options.isHideCursor = false; this.options.isHideCursor = false;
this._showCursor(); this._showCursor();
}; };
CellEditor.prototype._showCursor = function () { CellEditor.prototype._showCursor = function () {
if (window['IS_NATIVE_EDITOR'])
return;
var t = this; var t = this;
if (true === t.options.isHideCursor || t.isTopLineActive === true) {return;} if (true === t.options.isHideCursor || t.isTopLineActive === true) {return;}
window.clearInterval(t.cursorTID); window.clearInterval(t.cursorTID);
...@@ -1207,6 +1233,9 @@ ...@@ -1207,6 +1233,9 @@
}; };
CellEditor.prototype._hideCursor = function () { CellEditor.prototype._hideCursor = function () {
if (window['IS_NATIVE_EDITOR'])
return;
var t = this; var t = this;
window.clearInterval(t.cursorTID); window.clearInterval(t.cursorTID);
t.cursorStyle.display = "none"; t.cursorStyle.display = "none";
...@@ -1249,9 +1278,16 @@ ...@@ -1249,9 +1278,16 @@
curLeft >>= 1; curLeft >>= 1;
curTop >>= 1; curTop >>= 1;
} }
if (window['IS_NATIVE_EDITOR']) {
this.curLeft = curLeft;
this.curTop = curTop;
this.curHeight = curHeight;
} else {
this.cursorStyle.left = curLeft + "px"; this.cursorStyle.left = curLeft + "px";
this.cursorStyle.top = curTop + "px"; this.cursorStyle.top = curTop + "px";
this.cursorStyle.height = curHeight + "px"; this.cursorStyle.height = curHeight + "px";
}
if (cur) {this.input.scrollTop = this.input.clientHeight * cur.lineIndex;} if (cur) {this.input.scrollTop = this.input.clientHeight * cur.lineIndex;}
if (this.isTopLineActive && !this.skipTLUpdate) {this._updateTopLineCurPos();} if (this.isTopLineActive && !this.skipTLUpdate) {this._updateTopLineCurPos();}
...@@ -1404,10 +1440,14 @@ ...@@ -1404,10 +1440,14 @@
if (!this._checkMaxCellLength(length)) {return false;} if (!this._checkMaxCellLength(length)) {return false;}
this.dontUpdateText = true;
if (this.selectionBegin !== this.selectionEnd) { if (this.selectionBegin !== this.selectionEnd) {
this._removeChars(undefined, undefined, isRange); this._removeChars(undefined, undefined, isRange);
} }
this.dontUpdateText = false;
if (pos === undefined) {pos = this.cursorPos;} if (pos === undefined) {pos = this.cursorPos;}
if (!this.undoMode) { if (!this.undoMode) {
...@@ -1519,15 +1559,16 @@ ...@@ -1519,15 +1559,16 @@
function doChangeSelection(coord) { function doChangeSelection(coord) {
var pos = t._findCursorPosition(coord); var pos = t._findCursorPosition(coord);
if (pos !== undefined) {pos >= 0 ? t._selectChars(kPosition, pos) : t._selectChars(pos);} if (pos !== undefined) {pos >= 0 ? t._selectChars(kPosition, pos) : t._selectChars(pos);}
if (t.isSelectMode) { if (t.isSelectMode && !window['IS_NATIVE_EDITOR']) {
t.selectionTimer = window.setTimeout( t.selectionTimer = window.setTimeout(
function () {doChangeSelection(coord);}, function () {doChangeSelection(coord);},
t.defaults.selectionTimeout); t.defaults.selectionTimeout);
} }
} }
if (!window['IS_NATIVE_EDITOR']) {
window.clearTimeout(t.selectionTimer); window.clearTimeout(t.selectionTimer);
t.selectionTimer = window.setTimeout(function () {doChangeSelection(coord);}, 0); t.selectionTimer = window.setTimeout(function () {doChangeSelection(coord);}, 0);
}
}; };
CellEditor.prototype._findFragment = function (pos, fragments) { CellEditor.prototype._findFragment = function (pos, fragments) {
...@@ -1756,8 +1797,11 @@ ...@@ -1756,8 +1797,11 @@
}; };
CellEditor.prototype._tryCloseEditor = function (event) { CellEditor.prototype._tryCloseEditor = function (event) {
if (this.close(true)) if (this.close(true)) {
if (!window['IS_NATIVE_EDITOR']) {
this.handlers.trigger("applyCloseEvent", event); this.handlers.trigger("applyCloseEvent", event);
}
}
}; };
CellEditor.prototype._getAutoComplete = function(str) { CellEditor.prototype._getAutoComplete = function(str) {
...@@ -1844,6 +1888,9 @@ ...@@ -1844,6 +1888,9 @@
return false; return false;
case 13: // "enter" case 13: // "enter"
if (window['IS_NATIVE_EDITOR']) {
t._addNewLine();
} else {
if (!t.hasFocus) {t.setFocus(true);} if (!t.hasFocus) {t.setFocus(true);}
if (!(event.altKey && event.shiftKey)) { if (!(event.altKey && event.shiftKey)) {
if (event.altKey) if (event.altKey)
...@@ -1853,6 +1900,7 @@ ...@@ -1853,6 +1900,7 @@
t._tryCloseEditor(event); t._tryCloseEditor(event);
} }
} }
}
return false; return false;
case 9: // tab case 9: // tab
...@@ -1864,11 +1912,15 @@ ...@@ -1864,11 +1912,15 @@
return false; return false;
case 8: // "backspace" case 8: // "backspace"
if (window['IS_NATIVE_EDITOR']) {
t._removeChars(ctrlKey ? kPrevWord : kPrevChar);
} else {
// Отключим стандартную обработку браузера нажатия backspace // Отключим стандартную обработку браузера нажатия backspace
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
if (hieroglyph) {t._syncEditors();} if (hieroglyph) {t._syncEditors();}
t._removeChars(ctrlKey ? kPrevWord : kPrevChar); t._removeChars(ctrlKey ? kPrevWord : kPrevChar);
}
return false; return false;
case 46: // "del" case 46: // "del"
...@@ -2073,6 +2125,8 @@ ...@@ -2073,6 +2125,8 @@
var t = this; var t = this;
var ctrlKey = event.metaKey || event.ctrlKey; var ctrlKey = event.metaKey || event.ctrlKey;
if (!window['IS_NATIVE_EDITOR']) {
if (!t.isOpened || !t.enableKeyEvents) {return true;} if (!t.isOpened || !t.enableKeyEvents) {return true;}
if (t.skipKeyPress || event.which < 32 || event.altKey || ctrlKey) { if (t.skipKeyPress || event.which < 32 || event.altKey || ctrlKey) {
...@@ -2092,6 +2146,8 @@ ...@@ -2092,6 +2146,8 @@
} }
//t.setFocus(true); //t.setFocus(true);
}
t.isUpdateValue = false; t.isUpdateValue = false;
var tmpCursorPos; var tmpCursorPos;
...@@ -2226,6 +2282,10 @@ ...@@ -2226,6 +2282,10 @@
/** @param event {MouseEvent} */ /** @param event {MouseEvent} */
CellEditor.prototype._getCoordinates = function (event) { CellEditor.prototype._getCoordinates = function (event) {
if (window['IS_NATIVE_EDITOR']) {
return {x: event.pageX, y: event.pageY};
}
var t = this; var t = this;
var offs = $(t.canvasOverlay).offset(); var offs = $(t.canvasOverlay).offset();
var x = (event.pageX - offs.left) / t.kx; var x = (event.pageX - offs.left) / t.kx;
...@@ -2248,4 +2308,4 @@ ...@@ -2248,4 +2308,4 @@
} }
)(jQuery, window); )(jQuery, window);
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