Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
f76faa42
Commit
f76faa42
authored
Sep 28, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
base add multiselect
parent
fb5ca696
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
170 additions
and
120 deletions
+170
-120
cell/utils/utils.js
cell/utils/utils.js
+12
-6
cell/view/EventsController.js
cell/view/EventsController.js
+57
-39
cell/view/WorkbookView.js
cell/view/WorkbookView.js
+2
-2
cell/view/WorksheetView.js
cell/view/WorksheetView.js
+99
-73
No files found.
cell/utils/utils.js
View file @
f76faa42
...
...
@@ -571,8 +571,7 @@
SelectionRange
.
prototype
.
clean
=
function
()
{
this
.
ranges
=
[
new
Range
(
0
,
0
,
0
,
0
)];
this
.
cell
.
clean
();
this
.
cellIndex
=
0
;
this
.
cellIndex
=
-
1
;
};
SelectionRange
.
prototype
.
contains
=
function
(
c
,
r
)
{
return
this
.
ranges
.
some
(
function
(
item
)
{
...
...
@@ -594,6 +593,11 @@
return
false
;
// todo return this.cell.isEqual(range.cell);
};
SelectionRange
.
prototype
.
addRange
=
function
()
{
this
.
ranges
.
push
(
new
Range
(
0
,
0
,
0
,
0
));
this
.
cellIndex
=
-
1
;
this
.
cell
.
clean
();
};
SelectionRange
.
prototype
.
offsetCell
=
function
(
dr
,
dc
)
{
var
curRange
;
var
lastRow
=
this
.
cell
.
row
;
...
...
@@ -657,10 +661,12 @@
SelectionRange
.
prototype
.
update
=
function
()
{
//меняем выделеную ячейку, если она не входит в диапазон
//возможно, в будующем придется пределать логику, пока нет примеров, когда это работает плохо
if
(
!
this
.
contains2
(
this
.
cell
))
{
var
last
=
this
.
getLast
();
this
.
cell
.
col
=
last
.
c1
;
this
.
cell
.
row
=
last
.
r1
;
var
range
=
this
.
ranges
[
this
.
cellIndex
];
if
(
!
range
||
range
.
contains
(
this
.
cell
.
col
,
this
.
cell
.
row
))
{
range
=
this
.
getLast
();
this
.
cell
.
col
=
range
.
c1
;
this
.
cell
.
row
=
range
.
r1
;
this
.
cellIndex
=
this
.
ranges
.
length
-
1
;
}
};
...
...
cell/view/EventsController.js
View file @
f76faa42
...
...
@@ -446,7 +446,7 @@
}
this
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
false
,
coord
.
x
,
coord
.
y
,
/*isCoord*/
true
,
/*isSelectMode*/
isSelectMode
,
/*isCoord*/
true
,
/*isSelectMode*/
isSelectMode
,
false
,
function
(
d
)
{
t
.
scroll
(
d
);
...
...
@@ -820,7 +820,7 @@
stop
();
// Обработать как спец селект
if
(
ctrlKey
&&
shiftKey
)
{
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
true
,
0
,
0
,
/*isCoord*/
true
,
/*isSelectMode*/
false
);
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
true
,
0
,
0
,
/*isCoord*/
true
,
/*isSelectMode*/
false
,
false
);
}
else
if
(
ctrlKey
)
{
t
.
handlers
.
trigger
(
"
selectColumnsByRange
"
);
}
else
{
...
...
@@ -940,7 +940,7 @@
t
.
handlers
.
trigger
(
"
setFontAttributes
"
,
"
s
"
);
},
65
:
function
()
{
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
true
,
-
1
,
-
1
,
/*isCoord*/
true
,
/*isSelectMode*/
false
);
false
,
false
);
},
66
:
function
()
{
t
.
handlers
.
trigger
(
"
setFontAttributes
"
,
"
b
"
);
},
73
:
function
()
{
...
...
@@ -1011,7 +1011,7 @@
}
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
!
shiftKey
,
dc
,
dr
,
/*isCoord*/
false
,
/*isSelectMode*/
false
,
function
(
d
)
{
false
,
f
alse
,
f
unction
(
d
)
{
t
.
scroll
(
d
);
if
(
t
.
isFormulaEditMode
)
{
...
...
@@ -1213,15 +1213,18 @@
/** @param event {MouseEvent} */
asc_CEventsController
.
prototype
.
_onMouseDown
=
function
(
event
)
{
if
(
AscCommon
.
g_inputContext
)
if
(
AscCommon
.
g_inputContext
)
{
AscCommon
.
g_inputContext
.
externalChangeFocus
();
}
var
t
=
this
;
var
ctrlKey
=
event
.
metaKey
||
event
.
ctrlKey
;
var
coord
=
t
.
_getCoordinates
(
event
);
event
.
isLocked
=
t
.
isMousePressed
=
true
;
if
(
t
.
handlers
.
trigger
(
"
isGlobalLockEditCell
"
))
if
(
t
.
handlers
.
trigger
(
"
isGlobalLockEditCell
"
))
{
return
;
}
if
(
!
this
.
enableKeyEvents
)
{
t
.
handlers
.
trigger
(
"
canvasClick
"
);
...
...
@@ -1229,13 +1232,15 @@
// Shapes
var
graphicsInfo
=
t
.
handlers
.
trigger
(
"
getGraphicsInfo
"
,
coord
.
x
,
coord
.
y
);
if
(
asc
[
"
editor
"
].
isStartAddShape
||
graphicsInfo
)
{
if
(
asc
[
"
editor
"
].
isStartAddShape
||
graphicsInfo
)
{
// При выборе диапазона не нужно выделять автофигуру
if
(
t
.
isSelectionDialogMode
)
if
(
t
.
isSelectionDialogMode
)
{
return
;
}
if
(
this
.
handlers
.
trigger
(
"
getCellEditMode
"
)
&&
!
this
.
handlers
.
trigger
(
"
stopCellEditing
"
))
if
(
this
.
handlers
.
trigger
(
"
getCellEditMode
"
)
&&
!
this
.
handlers
.
trigger
(
"
stopCellEditing
"
))
{
return
;
}
t
.
isShapeAction
=
true
;
t
.
isUpOnCanvas
=
false
;
...
...
@@ -1243,21 +1248,24 @@
t
.
clickCounter
.
mouseDownEvent
(
coord
.
x
,
coord
.
y
,
event
.
button
);
event
.
ClickCount
=
t
.
clickCounter
.
clickCount
;
if
(
0
===
event
.
ClickCount
%
2
)
if
(
0
===
event
.
ClickCount
%
2
)
{
t
.
isDblClickInMouseDown
=
true
;
}
t
.
handlers
.
trigger
(
"
graphicObjectMouseDown
"
,
event
,
coord
.
x
,
coord
.
y
);
t
.
handlers
.
trigger
(
"
updateSelectionShape
"
,
/*isSelectOnShape*/
true
);
return
;
}
else
}
else
{
t
.
isShapeAction
=
false
;
}
if
(
2
===
event
.
detail
)
{
// Это означает, что это MouseDown для dblClick эвента (его обрабатывать не нужно)
// Порядок эвентов для dblClick - http://javascript.ru/tutorial/events/mouse#dvoynoy-levyy-klik
// Проверка для IE, т.к. он присылает DblClick при сдвиге мыши...
if
(
this
.
mouseDownLastCord
&&
coord
.
x
===
this
.
mouseDownLastCord
.
x
&&
coord
.
y
===
this
.
mouseDownLastCord
.
y
&&
0
===
event
.
button
&&
!
this
.
handlers
.
trigger
(
'
isFormatPainter
'
))
{
if
(
this
.
mouseDownLastCord
&&
coord
.
x
===
this
.
mouseDownLastCord
.
x
&&
coord
.
y
===
this
.
mouseDownLastCord
.
y
&&
0
===
event
.
button
&&
!
this
.
handlers
.
trigger
(
'
isFormatPainter
'
))
{
// Выставляем, что мы уже сделали dblClick (иначе вдруг браузер не поддерживает свойство detail)
this
.
isDblClickInMouseDown
=
true
;
// Нам нужно обработать эвент браузера о dblClick (если мы редактируем ячейку, то покажем курсор, если нет - то просто ничего не произойдет)
...
...
@@ -1270,14 +1278,18 @@
}
// Для IE preventDefault делать не нужно
if
(
!
(
AscBrowser
.
isIE
||
AscBrowser
.
isOpera
))
{
if
(
event
.
preventDefault
)
if
(
event
.
preventDefault
)
{
event
.
preventDefault
();
else
}
else
{
event
.
returnValue
=
false
;
}
}
if
(
!
this
.
targetInfo
)
this
.
handlers
.
trigger
(
"
updateWorksheet
"
,
this
.
element
,
coord
.
x
,
coord
.
y
,
false
,
function
(
info
){
t
.
targetInfo
=
info
;});
if
(
!
this
.
targetInfo
)
{
this
.
handlers
.
trigger
(
"
updateWorksheet
"
,
this
.
element
,
coord
.
x
,
coord
.
y
,
false
,
function
(
info
)
{
t
.
targetInfo
=
info
;
});
}
// Запоминаем координаты нажатия
this
.
mouseDownLastCord
=
coord
;
...
...
@@ -1289,7 +1301,7 @@
t
.
_changeSelection
(
event
,
/*isSelectMode*/
true
);
return
;
}
if
(
t
.
targetInfo
){
if
(
t
.
targetInfo
)
{
if
(
t
.
targetInfo
.
target
===
c_oTargetType
.
ColumnResize
||
t
.
targetInfo
.
target
===
c_oTargetType
.
RowResize
)
{
t
.
isResizeMode
=
true
;
t
.
_resizeElement
(
event
);
...
...
@@ -1309,7 +1321,7 @@
return
;
}
else
if
(
undefined
!==
t
.
targetInfo
.
commentIndexes
&&
false
===
this
.
settings
.
isViewerMode
)
{
t
.
_commentCellClick
(
event
);
}
else
if
(
t
.
targetInfo
.
target
===
c_oTargetType
.
MoveResizeRange
&&
false
===
this
.
settings
.
isViewerMode
)
{
}
else
if
(
t
.
targetInfo
.
target
===
c_oTargetType
.
MoveResizeRange
&&
false
===
this
.
settings
.
isViewerMode
)
{
this
.
isMoveResizeRange
=
true
;
t
.
_moveResizeRangeHandle
(
event
,
t
.
targetInfo
);
return
;
...
...
@@ -1323,7 +1335,9 @@
}
}
else
{
if
(
!
t
.
isFormulaEditMode
)
{
if
(
!
t
.
handlers
.
trigger
(
"
stopCellEditing
"
))
{
return
;}
if
(
!
t
.
handlers
.
trigger
(
"
stopCellEditing
"
))
{
return
;
}
}
else
{
if
(
event
.
shiftKey
)
{
t
.
isSelectMode
=
true
;
...
...
@@ -1332,25 +1346,29 @@
}
else
{
if
(
t
.
isFormulaEditMode
)
{
// !!! в зависимости от цели делаем разные действия - либо селектим область либо мувим существующий диапазон
if
(
t
.
targetInfo
&&
t
.
targetInfo
.
target
===
c_oTargetType
.
MoveResizeRange
&&
false
===
this
.
settings
.
isViewerMode
){
if
(
t
.
targetInfo
&&
t
.
targetInfo
.
target
===
c_oTargetType
.
MoveResizeRange
&&
false
===
this
.
settings
.
isViewerMode
)
{
this
.
isMoveResizeRange
=
true
;
t
.
_moveResizeRangeHandle
(
event
,
t
.
targetInfo
);
return
;
}
else
if
(
false
===
t
.
handlers
.
trigger
(
"
canEnterCellRange
"
))
{
// для определения рэнджа под курсором и активизации его для WorksheetView
if
(
!
t
.
handlers
.
trigger
(
"
stopCellEditing
"
))
{
return
;}
if
(
!
t
.
handlers
.
trigger
(
"
stopCellEditing
"
))
{
return
;
}
}
}
t
.
isSelectMode
=
true
;
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
true
,
coord
.
x
,
coord
.
y
,
/*isCoord*/
true
,
/*isSelectMode*/
true
,
function
(
d
)
{
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
true
,
coord
.
x
,
coord
.
y
,
/*isCoord*/
true
,
/*isSelectMode*/
true
,
ctrlKey
,
function
(
d
)
{
t
.
scroll
(
d
);
if
(
t
.
isFormulaEditMode
)
{
t
.
handlers
.
trigger
(
"
enterCellRange
"
);
}
else
if
(
t
.
handlers
.
trigger
(
"
getCellEditMode
"
))
{
if
(
!
t
.
handlers
.
trigger
(
"
stopCellEditing
"
))
{
return
;}
if
(
!
t
.
handlers
.
trigger
(
"
stopCellEditing
"
))
{
return
;
}
}
});
return
;
...
...
@@ -1362,14 +1380,14 @@
if
(
2
===
event
.
button
)
{
t
.
handlers
.
trigger
(
"
changeSelectionRightClick
"
,
coord
.
x
,
coord
.
y
);
}
else
{
if
(
t
.
targetInfo
&&
t
.
targetInfo
.
target
===
c_oTargetType
.
FillHandle
&&
false
===
this
.
settings
.
isViewerMode
)
{
if
(
t
.
targetInfo
&&
t
.
targetInfo
.
target
===
c_oTargetType
.
FillHandle
&&
false
===
this
.
settings
.
isViewerMode
)
{
// В режиме автозаполнения
t
.
isFillHandleMode
=
true
;
t
.
_changeFillHandle
(
event
);
}
else
{
t
.
isSelectMode
=
true
;
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
true
,
coord
.
x
,
coord
.
y
,
/*isCoord*/
true
,
/*isSelectMode*/
true
);
t
.
handlers
.
trigger
(
"
changeSelection
"
,
/*isStartPoint*/
true
,
coord
.
x
,
coord
.
y
,
/*isCoord*/
true
,
/*isSelectMode*/
true
,
ctrlKey
);
}
}
};
...
...
cell/view/WorkbookView.js
View file @
f76faa42
...
...
@@ -939,9 +939,9 @@
}
};
WorkbookView
.
prototype
.
_onChangeSelection
=
function
(
isStartPoint
,
dc
,
dr
,
isCoord
,
isSelectMode
,
callback
)
{
WorkbookView
.
prototype
.
_onChangeSelection
=
function
(
isStartPoint
,
dc
,
dr
,
isCoord
,
isSelectMode
,
isCtrl
,
callback
)
{
var
ws
=
this
.
getWorksheet
();
var
d
=
isStartPoint
?
ws
.
changeSelectionStartPoint
(
dc
,
dr
,
isCoord
,
isSelectMode
)
:
var
d
=
isStartPoint
?
ws
.
changeSelectionStartPoint
(
dc
,
dr
,
isCoord
,
isSelectMode
,
isCtrl
)
:
ws
.
changeSelectionEndPoint
(
dc
,
dr
,
isCoord
,
isSelectMode
);
if
(
!
isCoord
&&
!
isStartPoint
&&
!
isSelectMode
)
{
// Выделение с зажатым shift
...
...
cell/view/WorksheetView.js
View file @
f76faa42
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment