Skip to content
Snippets Groups Projects
Commit e4bee75a authored by Hendrik Donath's avatar Hendrik Donath Committed by Friederike Schwager
Browse files

Fixes for use on mobile devices

parent f8e606b8
Branches
Tags
No related merge requests found
shared/index.js 100644 → 100755
...@@ -5478,7 +5478,8 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -5478,7 +5478,8 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
* Handle document.mousemove event * Handle document.mousemove event
* *
* @param {Event} e The DOM event to be handled * @param {Event} e The DOM event to be handled
*/function handleDocumentMousemove(e){savePoint(e.clientX,e.clientY);}/** */function handleDocumentMousemove(e){
savePoint(e.clientX,e.clientY);}/**
* Handle document.keyup event * Handle document.keyup event
* *
* @param {Event} e The DOM event to be handled * @param {Event} e The DOM event to be handled
...@@ -5507,18 +5508,22 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -5507,18 +5508,22 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
function handeContentTouchstart(e) { function handeContentTouchstart(e) {
document.documentElement.style.overflow = 'hidden'; document.documentElement.style.overflow = 'hidden';
document.getElementById('content-wrapper').style.overflow = 'hidden'; document.getElementById('content-wrapper').style.overflow = 'hidden';
document.getElementById('body-wrapper').style.overflow = 'hidden';
document.body.classList.add("lock-screen");
path=null; path=null;
lines=[]; lines=[];
savePoint(e.pageX,e.pageY); savePoint(e.touches[0].pageX,e.touches[0].pageY);
} }
function handeContentTouchmove(e) { function handeContentTouchmove(e) {
savePoint(e.pageX,e.pageY); savePoint(e.touches[0].pageX,e.touches[0].pageY);
} }
function handeContentTouchend(e) { 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.getElementById('body-wrapper').style.overflow = 'auto';
document.body.classList.remove("lock-screen");
var svg=void 0; var svg=void 0;
if (lines.length > 1 && (svg = (0,_utils.findSVGAtPoint)(e.pageX,e.pageY))){ if (lines.length > 1 && (svg = (0,findSVGAtTouchPoint(lines[lines.length-1][0],lines[lines.length-1][1])))){
var _getMetadata=(0,_utils.getMetadata)(svg); var _getMetadata=(0,_utils.getMetadata)(svg);
var documentId=_getMetadata.documentId; var documentId=_getMetadata.documentId;
var pageNumber=_getMetadata.pageNumber; var pageNumber=_getMetadata.pageNumber;
...@@ -5539,9 +5544,37 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -5539,9 +5544,37 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
function handeContentTouchcancel(e) { function handeContentTouchcancel(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.classList.remove("lock-screen");
lines=null; lines=null;
path.parentNode.removeChild(path); path.parentNode.removeChild(path);
} }
/**
* Determine if a point intersects a rect
*
* @param {Number} x The x coordinate of the point
* @param {Number} y The y coordinate of the point
* @param {Object} rect The points of a rect (likely from getBoundingClientRect)
* @return {Boolean} True if a collision occurs, otherwise false
*/function pointIntersectsRect(x,y,rect){return y>=rect.top&&y<=rect.bottom;}/**
/* Find an SVGElement container at a given touchpoint
*
* @param {Number} x The x coordinate of the point
* @param {Number} y The y coordinate of the point
* @return {SVGElement} The container SVG or null if one can't be found.
*/function findSVGAtTouchPoint(x,y){
var elements=document.querySelectorAll('svg[data-pdf-annotate-container="true"]');
for(var i=0,l=elements.length;i<l;i++){
var el=elements[i];
var rect=el.getBoundingClientRect();
if(rect.top > 0 && rect.bottom > 0){
return el;
}
}
return null;
}
/** /**
* Set the attributes of the pen. * Set the attributes of the pen.
* *
...@@ -5914,6 +5947,76 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -5914,6 +5947,76 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
} }
   
   
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.getElementById('content-wrapper').style.overflow = 'auto';
document.body.style.overflow = 'auto';
if((typeof e.target.getAttribute('className')!='string') && e.target.className.indexOf('cursor') === -1){
disableRect();
if(_type==='area'&&overlay){
if(isOverlayTooSmall(overlay)){
overlay.parentNode.removeChild(overlay);
overlay=null;
enableRect(_type);
return;
}
var _svg=overlay.parentNode.querySelector('svg.annotationLayer');
var rect=_svg.getBoundingClientRect();
renderRect(_type,[{top:parseInt(overlay.style.top,10)+rect.top,left:parseInt(overlay.style.left,10)+rect.left,width:parseInt(overlay.style.width,10),height:parseInt(overlay.style.height,10)}],null);
[textarea,data] = (0,_commentWrapper.openComment)(e,handleCancelClick,handleSubmitClick,handleToolbarClick,handleSubmitBlur,_type);
}else if((rectsSelection=getSelectionRects()) && _type!=='area'){
renderRect(_type,[].concat(_toConsumableArray(rectsSelection)).map(function(r){return{top:r.top,left:r.left,width:r.width,height:r.height};}),null);
[textarea,data] = (0,_commentWrapper.openComment)(e,handleCancelClick,handleSubmitClick,handleToolbarClick,handleSubmitBlur,_type);
}else{
enableRect(_type);
//Do nothing!
}
}
}
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){
...@@ -6036,7 +6139,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6036,7 +6139,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
var documentId=_getMetadata.documentId; var documentId=_getMetadata.documentId;
var pageNumber=_getMetadata.pageNumber; var pageNumber=_getMetadata.pageNumber;
var content=textarea.value.trim(); var content=textarea.value.trim();
if(content.length > 1){ if(textarea.value.trim().length > 1){
(0,_commentWrapper.closeComment)(documentId,pageNumber,handleSubmitClick,handleCancelClick,null,true); (0,_commentWrapper.closeComment)(documentId,pageNumber,handleSubmitClick,handleCancelClick,null,true);
...@@ -6111,6 +6214,13 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6111,6 +6214,13 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
document.addEventListener('mouseup',handleDocumentMouseup); document.addEventListener('mouseup',handleDocumentMouseup);
document.addEventListener('mousedown',handleDocumentMousedown); document.addEventListener('mousedown',handleDocumentMousedown);
document.addEventListener('keyup',handleDocumentKeyup); document.addEventListener('keyup',handleDocumentKeyup);
var contentWrapper = document.getElementById('content-wrapper');
contentWrapper.addEventListener('touchstart',handeContentTouchstart);
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(){
...@@ -6123,7 +6233,17 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting ...@@ -6123,7 +6233,17 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting
}else if(_type === 'strikeout'){ }else if(_type === 'strikeout'){
document.getElementById('content-wrapper').classList.remove('cursor-strikeout'); document.getElementById('content-wrapper').classList.remove('cursor-strikeout');
} }
document.removeEventListener('mouseup',handleDocumentMouseup);document.removeEventListener('mousedown',handleDocumentMousedown);document.removeEventListener('keyup',handleDocumentKeyup);} document.removeEventListener('mouseup',handleDocumentMouseup);
document.removeEventListener('mousedown',handleDocumentMousedown);
document.removeEventListener('keyup',handleDocumentKeyup);
var contentWrapper = document.getElementById('content-wrapper');
contentWrapper.removeEventListener('touchstart',handeContentTouchstart);
contentWrapper.removeEventListener('touchmove',handeContentTouchmove);
contentWrapper.removeEventListener('touchend',handeContentTouchend);
contentWrapper.removeEventListener('touchcancel',handeContentTouchcancel);
(0,_utils.disableUserSelect)();
}
/***/}, /***/},
/* 33 */ /* 33 */
/***/function(module,exports,__webpack_require__){ /***/function(module,exports,__webpack_require__){
......
...@@ -861,3 +861,11 @@ header, section, footer, aside, nav, main, article, figure { ...@@ -861,3 +861,11 @@ header, section, footer, aside, nav, main, article, figure {
.path-mod-pdfannotator .pdfannotator-statistic #chart-container { .path-mod-pdfannotator .pdfannotator-statistic #chart-container {
min-height: 500px; min-height: 500px;
} }
.lock-screen {
height: 100%;
overflow: hidden;
width: 100%;
position: fixed;
}
...@@ -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 = 2020102301; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2020112600; // The current module version (Date: YYYYMMDDXX).
$plugin->release = 'PDF Annotator v1.4 release 4'; $plugin->release = 'PDF Annotator v1.4 release 4';
$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