loleaflet/js/jquery.mCustomScrollbar.js | 85 ++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 25 deletions(-)
New commits: commit 42a36a5da36b661ee0b0b6e998ddc622df3f3c2c Author: gokaysatir <gokaysa...@collabora.com> AuthorDate: Tue Jun 2 12:09:02 2020 +0300 Commit: Henry Castro <hcas...@collabora.com> CommitDate: Tue Jun 2 14:54:06 2020 +0200 leaflet: update mcustomscrollbar.js file. Change-Id: I8adf3a8370b307c532ab64ad439f75ebfe318ebe Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95301 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Jenkins Reviewed-by: Henry Castro <hcas...@collabora.com> diff --git a/loleaflet/js/jquery.mCustomScrollbar.js b/loleaflet/js/jquery.mCustomScrollbar.js index 42876a14e..79bf0521f 100644 --- a/loleaflet/js/jquery.mCustomScrollbar.js +++ b/loleaflet/js/jquery.mCustomScrollbar.js @@ -1,7 +1,7 @@ /* -*- js-indent-level: 8; indent-tabs-mode: t; fill-column: 120 -*- */ /* == malihu jquery custom scrollbar plugin == -Version: 3.1.3 +Version: 3.1.5 Plugin URI: http://manos.malihu.gr/jquery-custom-content-scroller Author: malihu Author URI: http://manos.malihu.gr @@ -38,7 +38,9 @@ and dependencies (minified). */ (function(factory){ - if(typeof module!=="undefined" && module.exports){ + if(typeof define==="function" && define.amd){ + define(["jquery"],factory); + }else if(typeof module!=="undefined" && module.exports){ module.exports=factory; }else{ factory(jQuery,window,document); @@ -1178,8 +1180,8 @@ and dependencies (minified). /* returns input coordinates of pointer, touch and mouse events (relative to document) */ _coordinates=function(e){ - var t=e.type,o=e.target.ownerDocument!==document ? [$(frameElement).offset().top,$(frameElement).offset().left] : null, - io=_canAccessIFrame() && e.target.ownerDocument!==top.document ? [$(e.view.frameElement).offset().top,$(e.view.frameElement).offset().left] : [0,0]; + var t=e.type,o=e.target.ownerDocument!==document && frameElement!==null ? [$(frameElement).offset().top,$(frameElement).offset().left] : null, + io=_canAccessIFrame() && e.target.ownerDocument!==top.document && frameElement!==null ? [$(e.view.frameElement).offset().top,$(e.view.frameElement).offset().left] : [0,0]; switch(t){ case "pointerdown": case "MSPointerDown": case "pointermove": case "MSPointerMove": case "pointerup": case "MSPointerUp": return o ? [e.originalEvent.pageY-o[0]+io[0],e.originalEvent.pageX-o[1]+io[1],false] : [e.originalEvent.pageY,e.originalEvent.pageX,false]; @@ -1209,13 +1211,15 @@ and dependencies (minified). draggable,dragY,dragX, rds=o.advanced.releaseDraggableSelectors ? mCSB_dragger.add($(o.advanced.releaseDraggableSelectors)) : mCSB_dragger, eds=o.advanced.extraDraggableSelectors ? $(!_canAccessIFrame() || top.document).add($(o.advanced.extraDraggableSelectors)) : $(!_canAccessIFrame() || top.document); - mCSB_dragger.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){ + mCSB_dragger.bind("contextmenu."+namespace,function(e){ + e.preventDefault(); //prevent right click + }).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace,function(e){ e.stopImmediatePropagation(); e.preventDefault(); if(!_mouseBtnLeft(e)){return;} /* left mouse button only */ touchActive=true; if(oldIE){document.onselectstart=function(){return false;}} /* disable text selection for IE < 9 */ - _iframe(false); /* enable scrollbar dragging over iframes by disabling their events */ + _iframe.call(mCSB_container,false); /* enable scrollbar dragging over iframes by disabling their events */ _stop($this); draggable=$(this); var coordinates = _coordinates(e); @@ -1247,14 +1251,8 @@ and dependencies (minified). } touchActive=false; if(oldIE){document.onselectstart=null;} /* enable text selection for IE < 9 */ - _iframe(true); /* enable iframes events */ + _iframe.call(mCSB_container,true); /* enable iframes events */ }); - function _iframe(evt){ - var el=mCSB_container.find("iframe"); - if(!el.length){return;} /* check if content contains iframes */ - var val=!evt ? "none" : "auto"; - el.css("pointer-events",val); /* for IE11, iframe's display property should not be "block" */ - } function _drag(dragY,dragX,y,x){ mCSB_container[0].idleTimer=o.scrollInertia<233 ? 250 : 0; if(draggable.attr("id")===draggerId[1]){ @@ -1300,7 +1298,7 @@ and dependencies (minified). durA=0,durB,overwrite=o.axis==="yx" ? "none" : "all",touchIntent=[],touchDrag,docDrag, iframe=mCSB_container.find("iframe"), events=_getTouchEvents(namespace), - touchAction=document.body.style.touchAction!==undefined; + touchAction=document.body.style.touchAction!==undefined && document.body.style.touchAction!==""; mCSB_container.bind(events[0],function(e){ _onTouchstart(e); }).bind(events[1],function(e){ @@ -1313,7 +1311,7 @@ and dependencies (minified). }); if(iframe.length){ iframe.each(function(){ - $(this).load(function(){ + $(this).bind("load",function(){ /* bind events on accessible iframes */ if(_canAccessIFrame(this)){ $(this.contentDocument || this.contentWindow.document).bind(events[0],function(e){ @@ -1501,7 +1499,7 @@ and dependencies (minified). iframe=$("#mCSB_"+d.idx+"_container").find("iframe"); if(iframe.length){ iframe.each(function(){ - $(this).load(function(){ + $(this).bind("load",function(){ /* bind events on accessible iframes */ if(_canAccessIFrame(this)){ $(this.contentDocument || this.contentWindow.document).bind("mousewheel."+namespace,function(e,delta){ @@ -1526,7 +1524,7 @@ and dependencies (minified). contentPos=Math.abs($("#mCSB_"+d.idx+"_container")[0].offsetLeft), draggerPos=mCSB_dragger[1][0].offsetLeft, limit=mCSB_dragger[1].parent().width()-mCSB_dragger[1].width(), - dlt=e.deltaX || e.deltaY || delta; + dlt=o.mouseWheel.axis==="y" ? (e.deltaY || delta) : e.deltaX; }else{ var dir="y", px=[Math.round(deltaFactor*d.scrollRatio.y),parseInt(o.mouseWheel.scrollAmount)], @@ -1543,7 +1541,7 @@ and dependencies (minified). e.stopImmediatePropagation(); e.preventDefault(); } - if(e.deltaFactor<2 && !o.mouseWheel.normalizeDelta){ + if(e.deltaFactor<5 && !o.mouseWheel.normalizeDelta){ //very low deltaFactor values mean some kind of delta acceleration (e.g. osx trackpad), so adjusting scrolling accordingly amount=e.deltaFactor; dur=17; } @@ -1554,17 +1552,42 @@ and dependencies (minified). /* checks if iframe can be accessed */ + _canAccessIFrameCache=new Object(), _canAccessIFrame=function(iframe){ - var html=null; + var result=false,cacheKey=false,html=null; + if(iframe===undefined){ + cacheKey="#empty"; + }else if($(iframe).attr("id")!==undefined){ + cacheKey=$(iframe).attr("id"); + } + if(cacheKey!==false && _canAccessIFrameCache[cacheKey]!==undefined){ + return _canAccessIFrameCache[cacheKey]; + } if(!iframe){ - return(html!==null); + try{ + var doc=top.document; + html=doc.body.innerHTML; + }catch(err){/* do nothing */} + result=(html!==null); }else{ try{ var doc=iframe.contentDocument || iframe.contentWindow.document; html=doc.body.innerHTML; }catch(err){/* do nothing */} - return(html!==null); + result=(html!==null); } + if(cacheKey!==false){_canAccessIFrameCache[cacheKey]=result;} + return result; + }, + /* -------------------- */ + + + /* switches iframe's pointer-events property (drag, mousewheel etc. over cross-domain iframes) */ + _iframe=function(evt){ + var el=this.find("iframe"); + if(!el.length){return;} /* check if content contains iframes */ + var val=!evt ? "none" : "auto"; + el.css("pointer-events",val); /* for IE11, iframe's display property should not be "block" */ }, /* -------------------- */ @@ -1680,7 +1703,7 @@ and dependencies (minified). namespace=pluginPfx+"_"+d.idx, sel=".mCSB_"+d.idx+"_scrollbar", btn=$(sel+">a"); - btn.bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){ + btn.bind("contextmenu."+namespace,function(e){e.preventDefault();}).bind("mousedown."+namespace+" touchstart."+namespace+" pointerdown."+namespace+" MSPointerDown."+namespace+" mouseup."+namespace+" touchend."+namespace+" pointerup."+namespace+" MSPointerUp."+namespace+" mouseout."+namespace+" pointerout."+namespace+" MSPointerOut."+namespace+" click."+namespace,function(e){ e.preventDefault(); if(!_mouseBtnLeft(e)){return;} /* left mouse button only */ var btnClass=$(this).attr("class"); @@ -1728,7 +1751,7 @@ and dependencies (minified). events=["blur."+namespace+" keydown."+namespace+" keyup."+namespace]; if(iframe.length){ iframe.each(function(){ - $(this).load(function(){ + $(this).bind("load",function(){ /* bind events on accessible iframes */ if(_canAccessIFrame(this)){ $(this.contentDocument || this.contentWindow.document).bind(events[0],function(e){ @@ -1891,7 +1914,7 @@ and dependencies (minified). wrapper=mCSB_container.parent(), t=typeof val; if(!dir){dir=o.axis==="x" ? "x" : "y";} - var contentLength=dir==="x" ? mCSB_container.outerWidth(false) : mCSB_container.outerHeight(false), + var contentLength=dir==="x" ? mCSB_container.outerWidth(false)-wrapper.width() : mCSB_container.outerHeight(false)-wrapper.height(), contentPos=dir==="x" ? mCSB_container[0].offsetLeft : mCSB_container[0].offsetTop, cssProp=dir==="x" ? "left" : "top"; switch(t){ @@ -2445,7 +2468,7 @@ and dependencies (minified). */ window[pluginNS]=true; - $(window).load(function(){ + $(window).bind("load",function(){ $(defaultSelector)[pluginNS](); /* add scrollbars automatically on default selector */ @@ -2460,6 +2483,18 @@ and dependencies (minified). return cPos[0]+_childPos($el)[0]>=0 && cPos[0]+_childPos($el)[0]<wrapper.height()-$el.outerHeight(false) && cPos[1]+_childPos($el)[1]>=0 && cPos[1]+_childPos($el)[1]<wrapper.width()-$el.outerWidth(false); }, + /* checks if element or part of element is in view of scrollable viewport */ + mcsInSight:$.expr[":"].mcsInSight || function(el,i,m){ + var $el=$(el),elD,content=$el.parents(".mCSB_container"),wrapperView,pos,wrapperViewPct, + pctVals=m[3]==="exact" ? [[1,0],[1,0]] : [[0.9,0.1],[0.6,0.4]]; + if(!content.length){return;} + elD=[$el.outerHeight(false),$el.outerWidth(false)]; + pos=[content[0].offsetTop+_childPos($el)[0],content[0].offsetLeft+_childPos($el)[1]]; + wrapperView=[content.parent()[0].offsetHeight,content.parent()[0].offsetWidth]; + wrapperViewPct=[elD[0]<wrapperView[0] ? pctVals[0] : pctVals[1],elD[1]<wrapperView[1] ? pctVals[0] : pctVals[1]]; + return pos[0]-(wrapperView[0]*wrapperViewPct[0][0])<0 && pos[0]+elD[0]-(wrapperView[0]*wrapperViewPct[0][1])>=0 && + pos[1]-(wrapperView[1]*wrapperViewPct[1][0])<0 && pos[1]+elD[1]-(wrapperView[1]*wrapperViewPct[1][1])>=0; + }, /* checks if element is overflowed having visible scrollbar(s) */ mcsOverflow:$.expr[":"].mcsOverflow || function(el){ var d=$(el).data(pluginPfx); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits