44
55const exec = require ( 'execon' ) ;
66const wrap = require ( 'wraptile' ) ;
7- const supermenu = require ( 'supermenu' ) ;
87const createElement = require ( '@cloudcmd/create-element' ) ;
98
10- const { FS } = require ( '../../common/cloudfunc' ) ;
11- const { getIdBySrc} = require ( '../dom/load' ) ;
12- const RESTful = require ( '../dom/rest' ) ;
9+ const { FS } = require ( '../../../ common/cloudfunc' ) ;
10+ const { getIdBySrc} = require ( '../../ dom/load' ) ;
11+ const RESTful = require ( '../../ dom/rest' ) ;
1312
1413const { config, Key} = CloudCmd ;
1514
@@ -32,7 +31,7 @@ module.exports.ENABLED = false;
3231
3332CloudCmd . Menu = exports ;
3433
35- module . exports . init = ( ) => {
34+ module . exports . init = async ( ) => {
3635 const { isAuth, menuDataFile} = getFileMenuData ( ) ;
3736
3837 const fm = DOM . getFM ( ) ;
@@ -46,8 +45,9 @@ module.exports.init = () => {
4645 type : 'file' ,
4746 } ) ;
4847
49- MenuContext = supermenu ( fm , options , menuData ) ;
50- MenuContextFile = supermenu ( fm , optionsFile , menuDataFile ) ;
48+ const { createCloudMenu} = await import ( './cloudmenu.mjs' ) ;
49+ MenuContext = await createCloudMenu ( fm , options , menuData ) ;
50+ MenuContextFile = await createCloudMenu ( fm , optionsFile , menuDataFile ) ;
5151
5252 MenuContext . addContextMenuListener ( ) ;
5353 MenuContextFile . addContextMenuListener ( ) ;
@@ -107,6 +107,7 @@ function getOptions({type}) {
107107 const options = {
108108 icon : true ,
109109 beforeClose : Key . setBind ,
110+ beforeHide : Key . setBind ,
110111 beforeShow : exec . with ( beforeShow , func ) ,
111112 beforeClick,
112113 name,
@@ -198,16 +199,17 @@ function isPath(x, y) {
198199 const el = document . elementFromPoint ( x , y ) ;
199200 const elements = panel . querySelectorAll ( '[data-name="js-path"] *' ) ;
200201
201- return ~ [ ] . indexOf . call ( elements , el ) ;
202+ return ! ~ [ ] . indexOf . call ( elements , el ) ;
202203}
203204
204205function beforeShow ( callback , params ) {
205206 Key . unsetBind ( ) ;
206207
207- const { name} = params ;
208+ const { name, position = { x : params . x , y : params . y } } = params ;
209+ const { x, y} = position ;
208210 const el = DOM . getCurrentByPosition ( {
209- x : params . x ,
210- y : params . y ,
211+ x,
212+ y,
211213 } ) ;
212214
213215 const menuName = getMenuNameByEl ( el ) ;
@@ -223,7 +225,7 @@ function beforeShow(callback, params) {
223225 exec ( callback ) ;
224226
225227 if ( isShow )
226- isShow = isPath ( params . x , params . y ) ;
228+ isShow = isPath ( x , y ) ;
227229
228230 return isShow ;
229231}
@@ -341,3 +343,4 @@ function listener(event) {
341343 event . preventDefault ( ) ;
342344 }
343345}
346+
0 commit comments