diff --git a/shared/index.js b/shared/index.js old mode 100644 new mode 100755 index 8512f9c88bc5cef532e21f2888424371303574e6..6ccdeac5ea0b07ff652a62e692fbf23e1bc8e227 --- a/shared/index.js +++ b/shared/index.js @@ -5478,7 +5478,8 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting * Handle document.mousemove event * * @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 * * @param {Event} e The DOM event to be handled @@ -5507,18 +5508,22 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting function handeContentTouchstart(e) { document.documentElement.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; lines=[]; - savePoint(e.pageX,e.pageY); + savePoint(e.touches[0].pageX,e.touches[0].pageY); } function handeContentTouchmove(e) { - savePoint(e.pageX,e.pageY); + savePoint(e.touches[0].pageX,e.touches[0].pageY); } function handeContentTouchend(e) { document.documentElement.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; - 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 documentId=_getMetadata.documentId; var pageNumber=_getMetadata.pageNumber; @@ -5539,9 +5544,37 @@ 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'; + document.body.classList.remove("lock-screen"); lines=null; 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. * @@ -5913,6 +5946,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){ //delete Overlay @@ -6036,7 +6139,7 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting var documentId=_getMetadata.documentId; var pageNumber=_getMetadata.pageNumber; var content=textarea.value.trim(); - if(content.length > 1){ + if(textarea.value.trim().length > 1){ (0,_commentWrapper.closeComment)(documentId,pageNumber,handleSubmitClick,handleCancelClick,null,true); @@ -6096,21 +6199,28 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting /** * Enable rect behavior */function enableRect(type){ - _type=type; - if(_enabled){return;} - - if(_type === 'area'){ - document.getElementById('content-wrapper').classList.add('cursor-area'); - }else if(_type === 'highlight'){ - document.getElementById('content-wrapper').classList.add('cursor-highlight'); - }else if(_type === 'strikeout'){ - document.getElementById('content-wrapper').classList.add('cursor-strikeout'); - } - - _enabled=true; - document.addEventListener('mouseup',handleDocumentMouseup); - document.addEventListener('mousedown',handleDocumentMousedown); - document.addEventListener('keyup',handleDocumentKeyup); + _type=type; + if(_enabled){return;} + + if(_type === 'area'){ + document.getElementById('content-wrapper').classList.add('cursor-area'); + }else if(_type === 'highlight'){ + document.getElementById('content-wrapper').classList.add('cursor-highlight'); + }else if(_type === 'strikeout'){ + document.getElementById('content-wrapper').classList.add('cursor-strikeout'); + } + + _enabled=true; + document.addEventListener('mouseup',handleDocumentMouseup); + document.addEventListener('mousedown',handleDocumentMousedown); + 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 */function disableRect(){ @@ -6123,7 +6233,17 @@ function startIndex(Y,_cm,_documentObject,_userid,_capabilities, _toolbarSetting }else if(_type === '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 */ /***/function(module,exports,__webpack_require__){ diff --git a/styles.css b/styles.css index e87c3663078d8ad7e0b4b1aa13f8a6f5a4a938f5..2313bfd82b7afbe652f83dccc42cddf3c51c65a2 100644 --- a/styles.css +++ b/styles.css @@ -861,3 +861,11 @@ header, section, footer, aside, nav, main, article, figure { .path-mod-pdfannotator .pdfannotator-statistic #chart-container { min-height: 500px; } + +.lock-screen { + height: 100%; + overflow: hidden; + width: 100%; + position: fixed; +} + diff --git a/version.php b/version.php index 180567a5a3e5f28e8a0326e9e9ac605dbfed4654..dad7e8a25737cb5c35ac325d8003aa7fdfe7c8dc 100644 --- a/version.php +++ b/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); $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->requires = 2016112900; // Requires this Moodle version.