[BUGFIX] Access correct event variable in ContextMenu.ts 52/59852/2
authorFrank Naegler <frank.naegler@typo3.org>
Mon, 4 Mar 2019 20:49:40 +0000 (21:49 +0100)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 8 Mar 2019 22:05:02 +0000 (23:05 +0100)
Resolves: #87839
Releases: master, 9.5
Change-Id: I9097c4e53c44b3a08eaf82ddc332514d196e1722
Reviewed-on: https://review.typo3.org/c/59852
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Björn Jacob <bjoern.jacob@tritum.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Resources/Private/TypeScript/ContextMenu.ts
typo3/sysext/backend/Resources/Public/JavaScript/ContextMenu.js

index afd5c6d..d397e00 100644 (file)
@@ -100,7 +100,7 @@ class ContextMenu {
       const $me = $(e.currentTarget);
       // if there is an other "inline" onclick setting, context menu is not triggered
       // usually this is the case for the foldertree
-      if ($(e.currentTarget).prop('onclick') && event.type === 'click') {
+      if ($me.prop('onclick') && e.type === 'click') {
         return;
       }
 
index f4ae419..7b03b69 100644 (file)
@@ -10,4 +10,4 @@
  *
  * The TYPO3 project - inspiring people to share!
  */
-define(["require","exports","jquery","./ContextMenuActions"],function(t,e,n,i){"use strict";return new(function(){function e(){var t=this;this.mousePos={X:null,Y:null},this.delayContextMenuHide=!1,this.record={uid:null,table:null},this.storeMousePositionEvent=function(e){t.mousePos={X:e.pageX,Y:e.pageY},t.mouseOutFromMenu("#contentMenu0"),t.mouseOutFromMenu("#contentMenu1")},this.initializeEvents()}return e.drawActionItem=function(t){var e=t.additionalAttributes||{},n="";for(var i in e)e.hasOwnProperty(i)&&(n+=" "+i+'="'+e[i]+'"');return'<a class="list-group-item" data-callback-action="'+t.callbackAction+'"'+n+'><span class="list-group-item-icon">'+t.icon+"</span> "+t.label+"</a>"},e.within=function(t,e,n){var i=t.offset();return n>=i.top&&n<i.top+t.height()&&e>=i.left&&e<i.left+t.width()},e.initializeContextMenuContainer=function(){if(0===n("#contentMenu0").length){n("body").append('<div id="contentMenu0" class="context-menu"></div><div id="contentMenu1" class="context-menu" style="display: block;"></div>')}},e.prototype.initializeEvents=function(){var t=this;n(document).on("click contextmenu",".t3js-contextmenutrigger",function(e){var i=n(e.currentTarget);n(e.currentTarget).prop("onclick")&&"click"===event.type||(e.preventDefault(),t.show(i.data("table"),i.data("uid"),i.data("context"),i.data("iteminfo"),i.data("parameters")))}),n(document).on("mousemove",this.storeMousePositionEvent)},e.prototype.show=function(t,e,n,i,o){this.record={table:t,uid:e};var s="";void 0!==t&&(s+="table="+encodeURIComponent(t)),void 0!==e&&(s+=(s.length>0?"&":"")+"uid="+e),void 0!==n&&(s+=(s.length>0?"&":"")+"context="+n),void 0!==i&&(s+=(s.length>0?"&":"")+"enDisItems="+i),void 0!==o&&(s+=(s.length>0?"&":"")+"addParams="+o),this.fetch(s)},e.prototype.fetch=function(t){var e=this,i=TYPO3.settings.ajaxUrls.contextmenu;t&&(i+=(-1===i.indexOf("?")?"?":"&")+t),n.ajax(i).done(function(t){void 0!==t&&Object.keys(t).length>0&&e.populateData(t,0)})},e.prototype.populateData=function(o,s){var a=this;e.initializeContextMenuContainer();var u=n("#contentMenu"+s);if(u.length&&(0===s||n("#contentMenu"+(s-1)).is(":visible"))){var r=this.drawMenu(o,s);u.html('<div class="list-group">'+r+"</div>"),n("a.list-group-item",u).click(function(e){e.preventDefault();var o=n(e.currentTarget);if(o.hasClass("list-group-item-submenu"))a.openSubmenu(s,o);else{var u=o.data("callback-action"),r=o.data("callback-module");o.data("callback-module")?t([r],function(t){t[u].bind(o)(a.record.table,a.record.uid)}):i&&"function"==typeof i[u]?i[u].bind(o)(a.record.table,a.record.uid):console.log("action: "+u+" not found"),a.hideAll()}}),u.css(this.getPosition(u)).show()}},e.prototype.openSubmenu=function(t,e){var i=n("#contentMenu"+(t+1)).html("");e.next().find(".list-group").clone(!0).appendTo(i),i.css(this.getPosition(i)).show()},e.prototype.getPosition=function(t){var e=this.mousePos.X,i=this.mousePos.Y,o=n(window).width()-20,s=n(window).height(),a=t.width(),u=t.height(),r=this.mousePos.X-n(document).scrollLeft(),c=this.mousePos.Y-n(document).scrollTop();return s-u<c&&(c>u?i-=u-10:i+=s-u-c),o-a<r&&(r>a?e-=a-10:o-a-r<n(document).scrollLeft()?e=n(document).scrollLeft():e+=o-a-r),{left:e+"px",top:i+"px"}},e.prototype.drawMenu=function(t,n){var i="";for(var o in t)if(t.hasOwnProperty(o)){var s=t[o];if("item"===s.type)i+=e.drawActionItem(s);else if("divider"===s.type)i+='<a class="list-group-item list-group-item-divider"></a>';else if("submenu"===s.type||s.childItems){i+='<a class="list-group-item list-group-item-submenu"><span class="list-group-item-icon">'+s.icon+"</span> "+s.label+'&nbsp;&nbsp;<span class="fa fa-caret-right"></span></a>',i+='<div class="context-menu contentMenu'+(n+1)+'" style="display:none;"><div class="list-group">'+this.drawMenu(s.childItems,1)+"</div></div>"}}return i},e.prototype.mouseOutFromMenu=function(t){var i=n(t);i.length>0&&i.is(":visible")&&!e.within(i,this.mousePos.X,this.mousePos.Y)?this.hide(t):i.length>0&&i.is(":visible")&&(this.delayContextMenuHide=!0)},e.prototype.hide=function(t){var e=this;this.delayContextMenuHide=!1,window.setTimeout(function(){e.delayContextMenuHide||n(t).hide()},500)},e.prototype.hideAll=function(){this.hide("#contentMenu0"),this.hide("#contentMenu1")},e}())});
\ No newline at end of file
+define(["require","exports","jquery","./ContextMenuActions"],function(t,e,n,i){"use strict";return new(function(){function e(){var t=this;this.mousePos={X:null,Y:null},this.delayContextMenuHide=!1,this.record={uid:null,table:null},this.storeMousePositionEvent=function(e){t.mousePos={X:e.pageX,Y:e.pageY},t.mouseOutFromMenu("#contentMenu0"),t.mouseOutFromMenu("#contentMenu1")},this.initializeEvents()}return e.drawActionItem=function(t){var e=t.additionalAttributes||{},n="";for(var i in e)e.hasOwnProperty(i)&&(n+=" "+i+'="'+e[i]+'"');return'<a class="list-group-item" data-callback-action="'+t.callbackAction+'"'+n+'><span class="list-group-item-icon">'+t.icon+"</span> "+t.label+"</a>"},e.within=function(t,e,n){var i=t.offset();return n>=i.top&&n<i.top+t.height()&&e>=i.left&&e<i.left+t.width()},e.initializeContextMenuContainer=function(){if(0===n("#contentMenu0").length){n("body").append('<div id="contentMenu0" class="context-menu"></div><div id="contentMenu1" class="context-menu" style="display: block;"></div>')}},e.prototype.initializeEvents=function(){var t=this;n(document).on("click contextmenu",".t3js-contextmenutrigger",function(e){var i=n(e.currentTarget);i.prop("onclick")&&"click"===e.type||(e.preventDefault(),t.show(i.data("table"),i.data("uid"),i.data("context"),i.data("iteminfo"),i.data("parameters")))}),n(document).on("mousemove",this.storeMousePositionEvent)},e.prototype.show=function(t,e,n,i,o){this.record={table:t,uid:e};var s="";void 0!==t&&(s+="table="+encodeURIComponent(t)),void 0!==e&&(s+=(s.length>0?"&":"")+"uid="+e),void 0!==n&&(s+=(s.length>0?"&":"")+"context="+n),void 0!==i&&(s+=(s.length>0?"&":"")+"enDisItems="+i),void 0!==o&&(s+=(s.length>0?"&":"")+"addParams="+o),this.fetch(s)},e.prototype.fetch=function(t){var e=this,i=TYPO3.settings.ajaxUrls.contextmenu;t&&(i+=(-1===i.indexOf("?")?"?":"&")+t),n.ajax(i).done(function(t){void 0!==t&&Object.keys(t).length>0&&e.populateData(t,0)})},e.prototype.populateData=function(o,s){var a=this;e.initializeContextMenuContainer();var u=n("#contentMenu"+s);if(u.length&&(0===s||n("#contentMenu"+(s-1)).is(":visible"))){var l=this.drawMenu(o,s);u.html('<div class="list-group">'+l+"</div>"),n("a.list-group-item",u).click(function(e){e.preventDefault();var o=n(e.currentTarget);if(o.hasClass("list-group-item-submenu"))a.openSubmenu(s,o);else{var u=o.data("callback-action"),l=o.data("callback-module");o.data("callback-module")?t([l],function(t){t[u].bind(o)(a.record.table,a.record.uid)}):i&&"function"==typeof i[u]?i[u].bind(o)(a.record.table,a.record.uid):console.log("action: "+u+" not found"),a.hideAll()}}),u.css(this.getPosition(u)).show()}},e.prototype.openSubmenu=function(t,e){var i=n("#contentMenu"+(t+1)).html("");e.next().find(".list-group").clone(!0).appendTo(i),i.css(this.getPosition(i)).show()},e.prototype.getPosition=function(t){var e=this.mousePos.X,i=this.mousePos.Y,o=n(window).width()-20,s=n(window).height(),a=t.width(),u=t.height(),l=this.mousePos.X-n(document).scrollLeft(),c=this.mousePos.Y-n(document).scrollTop();return s-u<c&&(c>u?i-=u-10:i+=s-u-c),o-a<l&&(l>a?e-=a-10:o-a-l<n(document).scrollLeft()?e=n(document).scrollLeft():e+=o-a-l),{left:e+"px",top:i+"px"}},e.prototype.drawMenu=function(t,n){var i="";for(var o in t)if(t.hasOwnProperty(o)){var s=t[o];if("item"===s.type)i+=e.drawActionItem(s);else if("divider"===s.type)i+='<a class="list-group-item list-group-item-divider"></a>';else if("submenu"===s.type||s.childItems){i+='<a class="list-group-item list-group-item-submenu"><span class="list-group-item-icon">'+s.icon+"</span> "+s.label+'&nbsp;&nbsp;<span class="fa fa-caret-right"></span></a>',i+='<div class="context-menu contentMenu'+(n+1)+'" style="display:none;"><div class="list-group">'+this.drawMenu(s.childItems,1)+"</div></div>"}}return i},e.prototype.mouseOutFromMenu=function(t){var i=n(t);i.length>0&&i.is(":visible")&&!e.within(i,this.mousePos.X,this.mousePos.Y)?this.hide(t):i.length>0&&i.is(":visible")&&(this.delayContextMenuHide=!0)},e.prototype.hide=function(t){var e=this;this.delayContextMenuHide=!1,window.setTimeout(function(){e.delayContextMenuHide||n(t).hide()},500)},e.prototype.hideAll=function(){this.hide("#contentMenu0"),this.hide("#contentMenu1")},e}())});
\ No newline at end of file