Commit ff0ad167 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

мобильный скролл.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54188 954022d7-b5bf-4e40-9824-e11837661b57
parent 0e124c57
...@@ -32,7 +32,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -32,7 +32,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.topLineEditorElement = null; this.topLineEditorElement = null;
this.isViewerMode = false; this.isViewerMode = false;
this.controller = null; // Создадим позднее, т.к. не знаем мобильная версия или нет
// if ("function" === typeof(eventsController)) { // if ("function" === typeof(eventsController)) {
// var prot = eventsController.prototype; // var prot = eventsController.prototype;
...@@ -42,10 +41,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -42,10 +41,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// prot.reinitializeScroll = prot["reinitializeScroll"]; // prot.reinitializeScroll = prot["reinitializeScroll"];
// prot.scrollVertical = prot["scrollVertical"]; // prot.scrollVertical = prot["scrollVertical"];
// prot.scrollHorizontal = prot["scrollHorizontal"]; // prot.scrollHorizontal = prot["scrollHorizontal"];
//
// this.controller = new eventsController(); // this.controller = new eventsController();
// } else { // } else {
// this.controller = new asc.asc_CEventsController(); this.controller = new asc.asc_CEventsController();
// } // }
this.handlers = new asc.asc_CHandlersList(eventsHandlers); this.handlers = new asc.asc_CHandlersList(eventsHandlers);
...@@ -506,7 +505,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -506,7 +505,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_OpenDocument: function(url, data) asc_OpenDocument: function(url, data)
{ {
this._initEventController(); // this._initEventController();
var wb = new Workbook(url, this.handlers, this); var wb = new Workbook(url, this.handlers, this);
this.initGlobalObjects(wb); this.initGlobalObjects(wb);
...@@ -721,8 +720,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -721,8 +720,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_setViewerMode: function (isViewerMode) { asc_setViewerMode: function (isViewerMode) {
this.isViewerMode = isViewerMode; this.isViewerMode = isViewerMode;
// Если нет controller-а, мы выставим позднее режим // Если нет controller-а, мы выставим позднее режим
if (null !== this.controller) // if (null !== this.controller)
this.controller.setViewerMode(isViewerMode); // this.controller.setViewerMode(isViewerMode);
if (this.collaborativeEditing) if (this.collaborativeEditing)
this.collaborativeEditing.setViewerMode(isViewerMode); this.collaborativeEditing.setViewerMode(isViewerMode);
...@@ -1232,8 +1231,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -1232,8 +1231,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}, },
asc_getController: function() { asc_getController: function() {
//return this.controller; return this.controller;
return null; // return null;
}, },
// Посылает эвент о том, что обновились листы // Посылает эвент о том, что обновились листы
......
...@@ -130,6 +130,8 @@ ...@@ -130,6 +130,8 @@
<script type="text/javascript" src="../../../../OfficeWeb/Excel/model/UndoRedo.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/model/UndoRedo.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Common/scroll.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Common/scroll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/mobileTouch.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/iscroll.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/StringRender.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/StringRender.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellTextRender.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellTextRender.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellEditorView.js"></script> <script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellEditorView.js"></script>
......
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
this.vsbApiLockMouse = false; this.vsbApiLockMouse = false;
this.hsbApiLockMouse = false; this.hsbApiLockMouse = false;
return this; return this;
} }
...@@ -112,7 +113,23 @@ ...@@ -112,7 +113,23 @@
this.element = canvasElem; this.element = canvasElem;
this.handlers = new asc.asc_CHandlersList(handlers); this.handlers = new asc.asc_CHandlersList(handlers);
this.settings = $.extend(true, {}, this.settings, settings); this.settings = $.extend(true, {}, this.settings, settings);
if( this.view.Api.isMobileVersion ){
var __hasTouch = 'ontouchstart' in window;
if (__hasTouch)
{
this.element.addEventListener("touchstart" , function (e) {self._onTouchStart(e); return false;} , false);
this.element.addEventListener("touchmove" , function (e) {self._onTouchMove(e); return false;} , false);
this.element.addEventListener("touchend" , function (e) {self._onTouchEnd(e); return false;} , false);
}
else{
this.element.addEventListener("touchstart" , function (e) {self._onMouseDown(e.touches[0]); return false;} , false);
this.element.addEventListener("touchmove" , function (e) {self._onMouseMove(e.touches[0]); return false;} , false);
this.element.addEventListener("touchend" , function (e) {self._onMouseUp(e.changedTouches[0]); return false;} , false);
}
// this.element.addEventListener("dblclick" , function () {alert("123");/*return self._onMouseDblClick.apply(self, arguments);*/} , false);
return;
}
this._createScrollBars(); this._createScrollBars();
// initialize events // initialize events
...@@ -147,14 +164,17 @@ ...@@ -147,14 +164,17 @@
// for Mozilla Firefox (можно делать проверку на window.MouseScrollEvent || window.WheelEvent для FF) // for Mozilla Firefox (можно делать проверку на window.MouseScrollEvent || window.WheelEvent для FF)
this.element.addEventListener("DOMMouseScroll", function () {return self._onMouseWheel.apply(self, arguments);} , false); this.element.addEventListener("DOMMouseScroll", function () {return self._onMouseWheel.apply(self, arguments);} , false);
if(!this.view.Api.isMobileVersion){
this.element.addEventListener("touchstart" , function (e) {self._onMouseDown(e.touches[0]); return false;} , false); this.element.addEventListener("touchstart" , function (e) {self._onMouseDown(e.touches[0]); return false;} , false);
this.element.addEventListener("touchmove" , function (e) {self._onMouseMove(e.touches[0]); return false;} , false); this.element.addEventListener("touchmove" , function (e) {self._onMouseMove(e.touches[0]); return false;} , false);
this.element.addEventListener("touchend" , function (e) {self._onMouseUp(e.changedTouches[0]); return false;} , false); this.element.addEventListener("touchend" , function (e) {self._onMouseUp(e.changedTouches[0]); return false;} , false);
}
} }
// Курсор для графических объектов. Определяем mousedown и mouseup для выделения текста. // Курсор для графических объектов. Определяем mousedown и mouseup для выделения текста.
var oShapeCursor = document.getElementById("id_target_cursor"); var oShapeCursor = document.getElementById("id_target_cursor");
if (null != oShapeCursor && oShapeCursor.addEventListener) { if (null != oShapeCursor && oShapeCursor.addEventListener && !this.view.Api.isMobileVersion) {
oShapeCursor.addEventListener("mousedown" , function () {return self._onMouseDown.apply(self, arguments);}, false); oShapeCursor.addEventListener("mousedown" , function () {return self._onMouseDown.apply(self, arguments);}, false);
oShapeCursor.addEventListener("mouseup" , function () {return self._onMouseUp.apply(self, arguments);} , false); oShapeCursor.addEventListener("mouseup" , function () {return self._onMouseUp.apply(self, arguments);} , false);
oShapeCursor.addEventListener("mousemove" , function () {return self._onMouseMove.apply(self, arguments);}, false); oShapeCursor.addEventListener("mousemove" , function () {return self._onMouseMove.apply(self, arguments);}, false);
...@@ -223,11 +243,13 @@ ...@@ -223,11 +243,13 @@
this.handlers.trigger("reinitializeScroll", whichSB, function (vSize, hSize) { this.handlers.trigger("reinitializeScroll", whichSB, function (vSize, hSize) {
if (isVert) { if (isVert) {
vSize = self.vsb.offsetHeight + Math.max(vSize * opt.vscrollStep, 1); vSize = self.vsb.offsetHeight + Math.max(vSize * opt.vscrollStep, 1);
// this.m_dScrollY_max = vSize;
self.vsbHSt.height = vSize + "px"; self.vsbHSt.height = vSize + "px";
self.vsbApi.Reinit(opt, opt.vscrollStep * ws.getFirstVisibleRow(/*allowPane*/true)); self.vsbApi.Reinit(opt, opt.vscrollStep * ws.getFirstVisibleRow(/*allowPane*/true));
} }
if (isHoriz) { if (isHoriz) {
hSize = self.hsb.offsetWidth + Math.max(hSize * opt.hscrollStep, 1); hSize = self.hsb.offsetWidth + Math.max(hSize * opt.hscrollStep, 1);
// this.m_dScrollX_max = hSize ;
self.hsbHSt.width = hSize + "px"; self.hsbHSt.width = hSize + "px";
self.hsbApi.Reinit(opt, opt.vscrollStep * ws.getFirstVisibleCol(/*allowPane*/true)); self.hsbApi.Reinit(opt, opt.vscrollStep * ws.getFirstVisibleCol(/*allowPane*/true));
} }
...@@ -1463,6 +1485,16 @@ ...@@ -1463,6 +1485,16 @@
return {x: x, y: y}; return {x: x, y: y};
}; };
asc_CEventsController.prototype._onTouchStart = function (event){
this.view.MobileTouchManager.onTouchStart(event);
}
asc_CEventsController.prototype._onTouchMove = function (event){
var n = new Date().getTime()
this.view.MobileTouchManager.onTouchMove(event);
}
asc_CEventsController.prototype._onTouchEnd = function (event){
this.view.MobileTouchManager.onTouchEnd(event);
}
/* /*
* Export * Export
......
...@@ -109,6 +109,13 @@ ...@@ -109,6 +109,13 @@
this.defaultFont = new asc_FP(this.model.getDefaultFont(), this.model.getDefaultSize()); this.defaultFont = new asc_FP(this.model.getDefaultFont(), this.model.getDefaultSize());
//----------------------- //-----------------------
this.m_dScrollY = 0;
this.m_dScrollX = 0;
this.m_dScrollY_max = 1;
this.m_dScrollX_max = 1;
this.MobileTouchManager = null;
this._init(fontRenderingMode); this._init(fontRenderingMode);
return this; return this;
...@@ -394,6 +401,11 @@ ...@@ -394,6 +401,11 @@
this.clipboard.Api = this.Api; this.clipboard.Api = this.Api;
this.clipboard.init(); this.clipboard.init();
if (this.Api.isMobileVersion){
this.MobileTouchManager = new CMobileTouchManager();
this.MobileTouchManager.Init(this);
}
return this; return this;
}; };
...@@ -462,20 +474,36 @@ ...@@ -462,20 +474,36 @@
var ws = this.getWorksheet(), var ws = this.getWorksheet(),
vsize = !whichSB || whichSB === 1 ? ws.getVerticalScrollRange() : undefined, vsize = !whichSB || whichSB === 1 ? ws.getVerticalScrollRange() : undefined,
hsize = !whichSB || whichSB === 2 ? ws.getHorizontalScrollRange() : undefined; hsize = !whichSB || whichSB === 2 ? ws.getHorizontalScrollRange() : undefined;
if( vsize != undefined )
this.m_dScrollY_max = /*this.canvas.offsetHeight +*/ Math.max(this.controller.settings.vscrollStep * vsize, 1);
if( hsize != undefined )
this.m_dScrollX_max = /*this.canvas.offsetWidth +*/ Math.max(this.controller.settings.hscrollStep * hsize, 1);
if(this.Api.isMobileVersion){
this.MobileTouchManager.Resize();
return;
}
asc_applyFunction(callback, vsize, hsize); asc_applyFunction(callback, vsize, hsize);
}; };
WorkbookView.prototype._onScrollY = function (pos) { WorkbookView.prototype._onScrollY = function (pos) {
console.log("_onScrollY " + pos)
// document.getElementById("cv1" ).value = "_onScrollY " + pos;
var ws = this.getWorksheet(); var ws = this.getWorksheet();
var delta = asc_round(pos - ws.getFirstVisibleRow(/*allowPane*/true)); var delta = asc_round(pos - ws.getFirstVisibleRow(/*allowPane*/true));
console.log("deltaY " + delta)
if (delta !== 0) { if (delta !== 0) {
ws.scrollVertical(delta, this.cellEditor); ws.scrollVertical(delta, this.cellEditor);
} }
}; };
WorkbookView.prototype._onScrollX = function (pos) { WorkbookView.prototype._onScrollX = function (pos) {
console.log("_onScrollX " + pos)
// document.getElementById("cv1" ).value = "_onScrollX " + pos;
var ws = this.getWorksheet(); var ws = this.getWorksheet();
var delta = asc_round(pos - ws.getFirstVisibleCol(/*allowPane*/true)); var delta = asc_round(pos - ws.getFirstVisibleCol(/*allowPane*/true));
console.log("deltaX " + delta)
if (delta !== 0) { if (delta !== 0) {
ws.scrollHorizontal(delta, this.cellEditor); ws.scrollHorizontal(delta, this.cellEditor);
} }
...@@ -1144,8 +1172,8 @@ ...@@ -1144,8 +1172,8 @@
WorkbookView.prototype._canResize = function () { WorkbookView.prototype._canResize = function () {
var oldWidth = this.canvas.width; var oldWidth = this.canvas.width;
var oldHeight = this.canvas.height; var oldHeight = this.canvas.height;
var width = this.element.offsetWidth - this.defaults.scroll.widthPx; var width = this.element.offsetWidth - (this.Api.isMobileVersion ? 0 : this.defaults.scroll.widthPx);
var height = this.element.offsetHeight - this.defaults.scroll.heightPx; var height = this.element.offsetHeight - (this.Api.isMobileVersion ? 0 : this.defaults.scroll.heightPx);
if (oldWidth === width && oldHeight === height) if (oldWidth === width && oldHeight === height)
return false; return false;
......
This diff is collapsed.
This diff is collapsed.
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