Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
c70b3b24
Commit
c70b3b24
authored
7 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-3100: adapt the drawing interaction to touch device
parent
61b1f850
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/webapp/static/js/jquery/openolat/jquery.paint.js
+57
-19
57 additions, 19 deletions
src/main/webapp/static/js/jquery/openolat/jquery.paint.js
with
57 additions
and
19 deletions
src/main/webapp/static/js/jquery/openolat/jquery.paint.js
+
57
−
19
View file @
c70b3b24
...
@@ -82,13 +82,18 @@
...
@@ -82,13 +82,18 @@
});
});
/* Mouse Capturing Work */
/* Mouse Capturing Work */
jQuery
(
tmp_canvas
).
on
(
'
mousemove
'
,
function
(
e
)
{
jQuery
(
tmp_canvas
).
on
(
'
mousemove touchmove
'
,
function
(
e
)
{
mouse
.
x
=
typeof
e
.
offsetX
!==
'
undefined
'
?
e
.
offsetX
:
e
.
layerX
;
if
(
typeof
e
.
offsetX
==
'
undefined
'
&&
typeof
e
.
layerX
==
'
undefined
'
)
{
mouse
.
y
=
typeof
e
.
offsetY
!==
'
undefined
'
?
e
.
offsetY
:
e
.
layerY
;
mouse
.
x
=
e
.
originalEvent
.
layerX
;
mouse
.
y
=
e
.
originalEvent
.
layerY
;
}
else
{
mouse
.
x
=
typeof
e
.
offsetX
!==
'
undefined
'
?
e
.
offsetX
:
e
.
layerX
;
mouse
.
y
=
typeof
e
.
offsetY
!==
'
undefined
'
?
e
.
offsetY
:
e
.
layerY
;
}
});
});
/* Mouse Capturing Work out of the canvas */
/* Mouse Capturing Work out of the canvas */
jQuery
(
document
).
on
(
'
mousemove
'
,
function
(
e
)
{
jQuery
(
document
).
on
(
'
mousemove
touchmove
'
,
function
(
e
)
{
if
(
mouse
.
leave
)
{
if
(
mouse
.
leave
)
{
var
rect
=
tmp_canvas
.
getBoundingClientRect
();
var
rect
=
tmp_canvas
.
getBoundingClientRect
();
mouse
.
out_x
=
e
.
clientX
-
rect
.
left
;
mouse
.
out_x
=
e
.
clientX
-
rect
.
left
;
...
@@ -96,9 +101,14 @@
...
@@ -96,9 +101,14 @@
}
}
});
});
jQuery
(
this
.
canvas
).
on
(
'
mousemove
'
,
function
(
e
)
{
jQuery
(
this
.
canvas
).
on
(
'
mousemove touchmove
'
,
function
(
e
)
{
mouse
.
x
=
typeof
e
.
offsetX
!==
'
undefined
'
?
e
.
offsetX
:
e
.
layerX
;
if
(
typeof
e
.
offsetX
==
'
undefined
'
&&
typeof
e
.
layerX
==
'
undefined
'
)
{
mouse
.
y
=
typeof
e
.
offsetY
!==
'
undefined
'
?
e
.
offsetY
:
e
.
layerY
;
mouse
.
x
=
e
.
originalEvent
.
layerX
;
mouse
.
y
=
e
.
originalEvent
.
layerY
;
}
else
{
mouse
.
x
=
typeof
e
.
offsetX
!==
'
undefined
'
?
e
.
offsetX
:
e
.
layerX
;
mouse
.
y
=
typeof
e
.
offsetY
!==
'
undefined
'
?
e
.
offsetY
:
e
.
layerY
;
}
});
});
//NEWTHING
//NEWTHING
...
@@ -130,11 +140,20 @@
...
@@ -130,11 +140,20 @@
empty_canv
=
this
.
canvas
.
toDataURL
();
//NEWTHING
empty_canv
=
this
.
canvas
.
toDataURL
();
//NEWTHING
undo_arr
.
push
(
empty_canv
);
//NEWTHING
undo_arr
.
push
(
empty_canv
);
//NEWTHING
jQuery
(
tmp_canvas
).
on
(
'
mousedown
'
,
function
(
e
)
{
jQuery
(
tmp_canvas
).
on
(
'
mousedown touchstart
'
,
function
(
e
)
{
jQuery
(
tmp_canvas
).
on
(
'
mousemove
'
,
onPaint
);
if
(
isDoubleTouch
(
e
))
{
return
;
}
mouse
.
x
=
typeof
e
.
offsetX
!==
'
undefined
'
?
e
.
offsetX
:
e
.
layerX
;
jQuery
(
tmp_canvas
).
on
(
'
mousemove touchmove
'
,
onPaint
);
mouse
.
y
=
typeof
e
.
offsetY
!==
'
undefined
'
?
e
.
offsetY
:
e
.
layerY
;
if
(
typeof
e
.
offsetX
==
'
undefined
'
&&
typeof
e
.
layerX
==
'
undefined
'
)
{
mouse
.
x
=
e
.
originalEvent
.
layerX
;
mouse
.
y
=
e
.
originalEvent
.
layerY
;
}
else
{
mouse
.
x
=
typeof
e
.
offsetX
!==
'
undefined
'
?
e
.
offsetX
:
e
.
layerX
;
mouse
.
y
=
typeof
e
.
offsetY
!==
'
undefined
'
?
e
.
offsetY
:
e
.
layerY
;
}
mouse
.
paint
=
true
;
mouse
.
paint
=
true
;
start_mouse
.
x
=
mouse
.
x
;
start_mouse
.
x
=
mouse
.
x
;
...
@@ -145,14 +164,14 @@
...
@@ -145,14 +164,14 @@
//spraying tool.
//spraying tool.
sprayIntervalID
=
setInterval
(
onPaint
,
50
);
sprayIntervalID
=
setInterval
(
onPaint
,
50
);
onPaint
();
onPaint
(
e
);
}).
on
(
'
mousedown
'
,
{
formId
:
formDispatchFieldId
},
setFlexiFormDirtyByListener
);
}).
on
(
'
mousedown
touchstart
'
,
{
formId
:
formDispatchFieldId
},
setFlexiFormDirtyByListener
);
jQuery
(
tmp_canvas
).
on
(
'
mouseup click
'
,
function
()
{
jQuery
(
tmp_canvas
).
on
(
'
mouseup click
touchend
'
,
function
()
{
stopPainting
();
stopPainting
();
});
});
jQuery
(
tmp_canvas
).
on
(
'
dragstart
'
,
function
()
{
jQuery
(
tmp_canvas
).
on
(
'
dragstart
scroll
'
,
function
()
{
return
false
;
return
false
;
});
});
...
@@ -162,18 +181,18 @@
...
@@ -162,18 +181,18 @@
ppts
.
push
({
x
:
-
1
,
y
:
-
1
});
ppts
.
push
({
x
:
-
1
,
y
:
-
1
});
}
}
jQuery
(
document
).
on
(
"
mouseup
"
,
function
(
e
){
jQuery
(
document
).
on
(
"
mouseup
touchend
"
,
function
(
e
){
stopPainting
();
stopPainting
();
});
});
});
});
jQuery
(
tmp_canvas
).
on
(
'
mouseenter
'
,
function
(
e
)
{
jQuery
(
tmp_canvas
).
on
(
'
mouseenter
'
,
function
(
e
)
{
mouse
.
leave
=
false
;
mouse
.
leave
=
false
;
jQuery
(
document
).
off
(
"
mouseup
"
);
jQuery
(
document
).
off
(
"
mouseup
touchend
"
);
});
});
var
stopPainting
=
function
()
{
var
stopPainting
=
function
()
{
jQuery
(
tmp_canvas
).
off
(
'
mousemove
'
,
onPaint
);
jQuery
(
tmp_canvas
).
off
(
'
mousemove
touchmove
'
,
onPaint
);
// for erasing
// for erasing
ctx
.
globalCompositeOperation
=
'
source-over
'
;
ctx
.
globalCompositeOperation
=
'
source-over
'
;
...
@@ -444,8 +463,27 @@
...
@@ -444,8 +463,27 @@
ctx
.
clearRect
(
0
,
0
,
tmp_canvas
.
width
,
tmp_canvas
.
height
);
ctx
.
clearRect
(
0
,
0
,
tmp_canvas
.
width
,
tmp_canvas
.
height
);
ctx
.
drawImage
(
undo_img
,
0
,
0
);
ctx
.
drawImage
(
undo_img
,
0
,
0
);
};
};
function
isDoubleTouch
(
e
)
{
try
{
if
(
!
(
typeof
e
==
"
undefined
"
)
&&
!
(
typeof
e
.
originalEvent
.
touches
==
"
undefined
"
)
&&
e
.
originalEvent
.
touches
.
length
>
1
)
{
return
true
;
}
}
catch
(
ex
)
{
if
(
window
.
console
)
console
.
log
(
ex
);
}
return
false
;
}
var
onPaint
=
function
()
{
function
onPaint
(
e
)
{
if
(
!
(
typeof
e
==
"
undefined
"
))
{
if
(
isDoubleTouch
(
e
))
{
return
;
}
e
.
preventDefault
();
}
if
(
tool
==
'
brush
'
)
{
if
(
tool
==
'
brush
'
)
{
onPaintBrush
();
onPaintBrush
();
}
else
if
(
tool
==
'
circle
'
)
{
}
else
if
(
tool
==
'
circle
'
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment