mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
refactor(edit) show conextmenu: addOnce -> add
This commit is contained in:
parent
8d97640fee
commit
c5c159c789
1 changed files with 40 additions and 33 deletions
|
|
@ -69,10 +69,10 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
|
|||
|
||||
initAce();
|
||||
|
||||
Events.addOnce('contextmenu', Element, setMenu)
|
||||
.add(Element, {
|
||||
drop : onDrop,
|
||||
dragover : DOM.preventDefault
|
||||
Events.add(Element, {
|
||||
contextmenu : setMenu,
|
||||
drop : onDrop,
|
||||
dragover : Events.preventDefault
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
|
|||
isAllowed = DOM.Storage.isAllowed();
|
||||
|
||||
if (error) {
|
||||
DOM.Dialog.alert(error);
|
||||
Dialog.alert(error);
|
||||
} else {
|
||||
if (!Diff)
|
||||
Diff = new DiffProto(diff_match_patch);
|
||||
|
|
@ -374,35 +374,42 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
|
|||
}
|
||||
|
||||
function setMenu() {
|
||||
DOM.loadMenu(function() {
|
||||
var position = CloudCmd.MousePosition,
|
||||
options = {
|
||||
beforeShow: function(params) {
|
||||
params.x -= 18;
|
||||
params.y -= 27;
|
||||
if (!Menu) {
|
||||
DOM.loadMenu(function(error) {
|
||||
var position = CloudCmd.MousePosition,
|
||||
options = {
|
||||
beforeShow: function(params) {
|
||||
params.x -= 18;
|
||||
params.y -= 27;
|
||||
},
|
||||
afterClick: function() {
|
||||
Ace.focus();
|
||||
}
|
||||
},
|
||||
menuData = {
|
||||
'Save Ctrl+S' : save,
|
||||
'Go To Line Ctrl+G' : function() {
|
||||
Edit.goToLine();
|
||||
},
|
||||
afterClick: function() {
|
||||
Ace.focus();
|
||||
}
|
||||
},
|
||||
menuData = {
|
||||
'Save Ctrl+S' : save,
|
||||
'Go To Line Ctrl+G' : function() {
|
||||
Edit.goToLine();
|
||||
},
|
||||
'Select All Ctrl+A' : function() {
|
||||
Ace.selectAll();
|
||||
},
|
||||
'Delete Del' : function() {
|
||||
Ace.remove('right');
|
||||
},
|
||||
'Close Esc' : Edit.hide
|
||||
};
|
||||
|
||||
Menu = new MenuIO(Element, options, menuData);
|
||||
|
||||
Menu.show(position.x, position.y);
|
||||
});
|
||||
'Select All Ctrl+A' : function() {
|
||||
Ace.selectAll();
|
||||
},
|
||||
'Delete Del' : function() {
|
||||
Ace.remove('right');
|
||||
},
|
||||
'Close Esc' : Edit.hide
|
||||
};
|
||||
|
||||
if (error) {
|
||||
Dialog.alert(error);
|
||||
} else if (!Menu) {
|
||||
Menu = new MenuIO(Element, options, menuData);
|
||||
Menu.show(position.x, position.y);
|
||||
|
||||
Events.remove('contextMenu', Element, setMenu);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function load(callback) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue