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";
this.topLineEditorElement = null;
this.isViewerMode = false;
this.controller = null; // Создадим позднее, т.к. не знаем мобильная версия или нет
// if ("function" === typeof(eventsController)) {
// var prot = eventsController.prototype;
......@@ -42,10 +41,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// prot.reinitializeScroll = prot["reinitializeScroll"];
// prot.scrollVertical = prot["scrollVertical"];
// prot.scrollHorizontal = prot["scrollHorizontal"];
//
// this.controller = new eventsController();
// } else {
// this.controller = new asc.asc_CEventsController();
this.controller = new asc.asc_CEventsController();
// }
this.handlers = new asc.asc_CHandlersList(eventsHandlers);
......@@ -506,7 +505,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_OpenDocument: function(url, data)
{
this._initEventController();
// this._initEventController();
var wb = new Workbook(url, this.handlers, this);
this.initGlobalObjects(wb);
......@@ -721,8 +720,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_setViewerMode: function (isViewerMode) {
this.isViewerMode = isViewerMode;
// Если нет controller-а, мы выставим позднее режим
if (null !== this.controller)
this.controller.setViewerMode(isViewerMode);
// if (null !== this.controller)
// this.controller.setViewerMode(isViewerMode);
if (this.collaborativeEditing)
this.collaborativeEditing.setViewerMode(isViewerMode);
......@@ -1232,8 +1231,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
},
asc_getController: function() {
//return this.controller;
return null;
return this.controller;
// return null;
},
// Посылает эвент о том, что обновились листы
......
......@@ -130,6 +130,8 @@
<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/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/CellTextRender.js"></script>
<script type="text/javascript" src="../../../../OfficeWeb/Excel/view/CellEditorView.js"></script>
......
......@@ -93,6 +93,7 @@
this.vsbApiLockMouse = false;
this.hsbApiLockMouse = false;
return this;
}
......@@ -112,7 +113,23 @@
this.element = canvasElem;
this.handlers = new asc.asc_CHandlersList(handlers);
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();
// initialize events
......@@ -147,20 +164,23 @@
// for Mozilla Firefox (можно делать проверку на window.MouseScrollEvent || window.WheelEvent для FF)
this.element.addEventListener("DOMMouseScroll", function () {return self._onMouseWheel.apply(self, arguments);} , 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("touchend" , function (e) {self._onMouseUp(e.changedTouches[0]); return false;} , false);
if(!this.view.Api.isMobileVersion){
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);
}
}
// Курсор для графических объектов. Определяем mousedown и mouseup для выделения текста.
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("mouseup" , function () {return self._onMouseUp.apply(self, arguments);} , false);
oShapeCursor.addEventListener("mousemove" , function () {return self._onMouseMove.apply(self, arguments);}, false);
}
return this;
return this;
};
asc_CEventsController.prototype.destroy = function () {
......@@ -223,11 +243,13 @@
this.handlers.trigger("reinitializeScroll", whichSB, function (vSize, hSize) {
if (isVert) {
vSize = self.vsb.offsetHeight + Math.max(vSize * opt.vscrollStep, 1);
self.vsbHSt.height = vSize + "px";
// this.m_dScrollY_max = vSize;
self.vsbHSt.height = vSize + "px";
self.vsbApi.Reinit(opt, opt.vscrollStep * ws.getFirstVisibleRow(/*allowPane*/true));
}
if (isHoriz) {
hSize = self.hsb.offsetWidth + Math.max(hSize * opt.hscrollStep, 1);
// this.m_dScrollX_max = hSize ;
self.hsbHSt.width = hSize + "px";
self.hsbApi.Reinit(opt, opt.vscrollStep * ws.getFirstVisibleCol(/*allowPane*/true));
}
......@@ -1393,7 +1415,7 @@
return true;
};
/** @param event {jQuery.Event} */
/** @param event {jQuery.Event} */
asc_CEventsController.prototype._onMouseLeave = function (event) {
var t = this;
this.hasCursor = false;
......@@ -1463,11 +1485,21 @@
return {x: x, y: y};
};
/*
* Export
* -----------------------------------------------------------------------------
*/
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
* -----------------------------------------------------------------------------
*/
window["Asc"]["asc_CEventsController"] = window["Asc"].asc_CEventsController = asc_CEventsController;
......
......@@ -108,7 +108,14 @@
this.maxDigitWidth = 0;
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);
return this;
......@@ -394,6 +401,11 @@
this.clipboard.Api = this.Api;
this.clipboard.init();
if (this.Api.isMobileVersion){
this.MobileTouchManager = new CMobileTouchManager();
this.MobileTouchManager.Init(this);
}
return this;
};
......@@ -462,20 +474,36 @@
var ws = this.getWorksheet(),
vsize = !whichSB || whichSB === 1 ? ws.getVerticalScrollRange() : undefined,
hsize = !whichSB || whichSB === 2 ? ws.getHorizontalScrollRange() : undefined;
asc_applyFunction(callback, vsize, hsize);
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);
};
WorkbookView.prototype._onScrollY = function (pos) {
console.log("_onScrollY " + pos)
// document.getElementById("cv1" ).value = "_onScrollY " + pos;
var ws = this.getWorksheet();
var delta = asc_round(pos - ws.getFirstVisibleRow(/*allowPane*/true));
console.log("deltaY " + delta)
if (delta !== 0) {
ws.scrollVertical(delta, this.cellEditor);
}
};
WorkbookView.prototype._onScrollX = function (pos) {
console.log("_onScrollX " + pos)
// document.getElementById("cv1" ).value = "_onScrollX " + pos;
var ws = this.getWorksheet();
var delta = asc_round(pos - ws.getFirstVisibleCol(/*allowPane*/true));
console.log("deltaX " + delta)
if (delta !== 0) {
ws.scrollHorizontal(delta, this.cellEditor);
}
......@@ -1144,8 +1172,8 @@
WorkbookView.prototype._canResize = function () {
var oldWidth = this.canvas.width;
var oldHeight = this.canvas.height;
var width = this.element.offsetWidth - this.defaults.scroll.widthPx;
var height = this.element.offsetHeight - this.defaults.scroll.heightPx;
var width = this.element.offsetWidth - (this.Api.isMobileVersion ? 0 : this.defaults.scroll.widthPx);
var height = this.element.offsetHeight - (this.Api.isMobileVersion ? 0 : this.defaults.scroll.heightPx);
if (oldWidth === width && oldHeight === height)
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