Skip to content
Snippets Groups Projects
Commit b255c857 authored by hendrik.donath's avatar hendrik.donath Committed by Friederike Schwager
Browse files

Strikeout and Highlight annotation are now possible to use for mobile devices

parent 06dca502
Branches
Tags
No related merge requests found
...@@ -5934,7 +5934,33 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -5934,7 +5934,33 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
svg.parentNode.appendChild(overlay); svg.parentNode.appendChild(overlay);
document.addEventListener('mousemove',handleDocumentMousemove); document.addEventListener('mousemove',handleDocumentMousemove);
(0,_utils.disableUserSelect)(); (0,_utils.disableUserSelect)();
}/** }
function handleDocumentTouchstart(e){
document.documentElement.style.overflow = 'hidden';
document.getElementById('content-wrapper').style.overflow = 'hidden';
document.body.style.overflow = 'hidden';
var svg=void 0;
if(_type!=='area'||!(svg=(0,_utils.findSVGAtPoint)(e.touches[0].clientX,e.touches[0].clientY))){
return;
}
var rect=svg.getBoundingClientRect();
originY=e.touches[0].clientY;
originX=e.touches[0].clientX;
overlay=document.createElement('div');
overlay.style.position='absolute';
overlay.style.top=originY-rect.top+'px';
overlay.style.left=originX-rect.left+'px';
overlay.style.border='3px solid '+_utils.BORDER_COLOR;
overlay.style.borderRadius='3px';
svg.parentNode.appendChild(overlay);
document.addEventListener('touchmove',handleDocumentTouchmove);
(0,_utils.disableUserSelect)();
}
/**
* Handle document.mousemove event * Handle document.mousemove event
* *
* @param {Event} e The DOM event to handle * @param {Event} e The DOM event to handle
...@@ -5949,6 +5975,17 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -5949,6 +5975,17 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
} }
} }
   
function handleDocumentTouchmove(e){
var svg=overlay.parentNode.querySelector('svg.annotationLayer');
var rect=svg.getBoundingClientRect();
if(originX+(e.touches[0].clientX-originX)<rect.right){
overlay.style.width=e.touches[0].clientX-originX+'px';
}
if(originY+(e.touches[0].clientY-originY)<rect.bottom){
overlay.style.height=e.touches[0].clientY-originY+'px';
}
}
/** /**
* Tests if the overlay is too small. An overlay is too small if the width or height are less 10 px or are NaN * Tests if the overlay is too small. An overlay is too small if the width or height are less 10 px or are NaN
* @param {type} overlay * @param {type} overlay
...@@ -5992,46 +6029,14 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -5992,46 +6029,14 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
} }
} }
   
function handleDocumentTouchend(e){
function handeContentTouchstart(e) {
document.documentElement.style.overflow = 'hidden';
document.getElementById('content-wrapper').style.overflow = 'hidden';
document.body.style.overflow = 'hidden';
var svg=void 0;
if(_type!=='area'||!(svg=(0,_utils.findSVGAtPoint)(e.touches[0].clientX,e.touches[0].clientY))){
return;
}
var rect=svg.getBoundingClientRect();
originY=e.touches[0].clientY;
originX=e.touches[0].clientX;
overlay=document.createElement('div');
overlay.style.position='absolute';
overlay.style.top=originY-rect.top+'px';
overlay.style.left=originX-rect.left+'px';
overlay.style.border='3px solid '+_utils.BORDER_COLOR;
overlay.style.borderRadius='3px';
svg.parentNode.appendChild(overlay);
(0,_utils.disableUserSelect)();
}
function handeContentTouchmove(e) {
var svg=overlay.parentNode.querySelector('svg.annotationLayer');
var rect=svg.getBoundingClientRect();
if(originX+(e.touches[0].clientX-originX)<rect.right){
overlay.style.width=e.touches[0].clientX-originX+'px';
}
if(originY+(e.touches[0].clientY-originY)<rect.bottom){
overlay.style.height=e.touches[0].clientY-originY+'px';
}
}
function handeContentTouchend(e) {
document.documentElement.style.overflow = 'auto'; document.documentElement.style.overflow = 'auto';
document.getElementById('content-wrapper').style.overflow = 'auto'; document.getElementById('content-wrapper').style.overflow = 'auto';
document.body.style.overflow = 'auto'; document.body.style.overflow = 'auto';
   
//if the cursor is clicked nothing should happen!
if((typeof e.target.getAttribute('className')!='string') && e.target.className.indexOf('cursor') === -1){ if((typeof e.target.getAttribute('className')!='string') && e.target.className.indexOf('cursor') === -1){
document.removeEventListener('touchmove',handleDocumentTouchmove);
disableRect(); disableRect();
if(_type==='area'&&overlay){ if(_type==='area'&&overlay){
if(isOverlayTooSmall(overlay)){ if(isOverlayTooSmall(overlay)){
...@@ -6057,12 +6062,6 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6057,12 +6062,6 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
} }
} }
   
function handeContentTouchcancel(e) {
document.documentElement.style.overflow = 'auto';
document.getElementById('content-wrapper').style.overflow = 'auto';
document.body.style.overflow = 'auto';
}
function handleToolbarClick(e){ function handleToolbarClick(e){
//delete Overlay //delete Overlay
if(_type==='area'&&overlay){ if(_type==='area'&&overlay){
...@@ -6074,6 +6073,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6074,6 +6073,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
deleteUndefinedRect(); deleteUndefinedRect();
} }
   
function handleSubmitClick(e){ function handleSubmitClick(e){
var rects=void 0; var rects=void 0;
if(_type!=='area'&&(rects=rectsSelection)){ if(_type!=='area'&&(rects=rectsSelection)){
...@@ -6088,6 +6088,11 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6088,6 +6088,11 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
} }
function handleCancelClick(e){ function handleCancelClick(e){
// When using on mobile devices the documentscrolling will be prevented, here we have to allow it again
document.documentElement.style.overflow = 'auto';
document.getElementById('content-wrapper').style.overflow = 'auto';
document.body.style.overflow = 'auto';
//delete Overlay //delete Overlay
if(_type==='area'&&overlay){ if(_type==='area'&&overlay){
overlay.parentNode.removeChild(overlay); overlay.parentNode.removeChild(overlay);
...@@ -6110,8 +6115,6 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6110,8 +6115,6 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
deleteUndefinedRect(); deleteUndefinedRect();
} }
   
/** /**
* Handle document.keyup event * Handle document.keyup event
* *
...@@ -6140,6 +6143,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6140,6 +6143,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
} }
} }
   
function initializeAnnotation(type,rects,color,svg){ function initializeAnnotation(type,rects,color,svg){
var node=void 0; var node=void 0;
...@@ -6172,6 +6176,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6172,6 +6176,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
return annotation; return annotation;
} }
   
/** /**
* Save a rect annotation * Save a rect annotation
* *
...@@ -6195,7 +6200,6 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6195,7 +6200,6 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
document.removeEventListener('mousemove',handleDocumentMousemove); document.removeEventListener('mousemove',handleDocumentMousemove);
(0,_utils.enableUserSelect)(); (0,_utils.enableUserSelect)();
} }
// Add the annotation // Add the annotation
_PDFJSAnnotate2.default.getStoreAdapter() _PDFJSAnnotate2.default.getStoreAdapter()
.addAnnotation(documentId,pageNumber,annotation) .addAnnotation(documentId,pageNumber,annotation)
...@@ -6261,12 +6265,8 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6261,12 +6265,8 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
document.addEventListener('mousedown',handleDocumentMousedown); document.addEventListener('mousedown',handleDocumentMousedown);
document.addEventListener('keyup',handleDocumentKeyup); document.addEventListener('keyup',handleDocumentKeyup);
   
var contentWrapper = document.getElementById('content-wrapper'); document.addEventListener('touchstart', handleDocumentTouchstart);
contentWrapper.addEventListener('touchstart',handeContentTouchstart); document.addEventListener('touchend', handleDocumentTouchend);
contentWrapper.addEventListener('touchmove',handeContentTouchmove);
contentWrapper.addEventListener('touchend',handeContentTouchend);
contentWrapper.addEventListener('touchcancel',handeContentTouchcancel);
(0,_utils.disableUserSelect)();
}/** }/**
* Disable rect behavior * Disable rect behavior
*/function disableRect(){ */function disableRect(){
...@@ -6283,12 +6283,8 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6283,12 +6283,8 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
document.removeEventListener('mousedown',handleDocumentMousedown); document.removeEventListener('mousedown',handleDocumentMousedown);
document.removeEventListener('keyup',handleDocumentKeyup); document.removeEventListener('keyup',handleDocumentKeyup);
   
var contentWrapper = document.getElementById('content-wrapper'); document.removeEventListener('touchstart', handleDocumentTouchstart);
contentWrapper.removeEventListener('touchstart',handeContentTouchstart); document.removeEventListener('touchend', handleDocumentTouchend);
contentWrapper.removeEventListener('touchmove',handeContentTouchmove);
contentWrapper.removeEventListener('touchend',handeContentTouchend);
contentWrapper.removeEventListener('touchcancel',handeContentTouchcancel);
(0,_utils.disableUserSelect)();
} }
/***/}, /***/},
/* 33 */ /* 33 */
......
...@@ -25,6 +25,6 @@ ...@@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$plugin->component = 'mod_pdfannotator'; // Full name of the plugin (used for diagnostics). $plugin->component = 'mod_pdfannotator'; // Full name of the plugin (used for diagnostics).
$plugin->version = 2021020200; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2021020201; // The current module version (Date: YYYYMMDDXX).
$plugin->release = 'PDF Annotator v1.4 release 5'; $plugin->release = 'PDF Annotator v1.4 release 5';
$plugin->requires = 2016112900; // Requires this Moodle version. $plugin->requires = 2016112900; // Requires this Moodle version.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment