mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-22 07:34:16 +00:00
feature(edit) load menu on first request
This commit is contained in:
parent
f9a9059dc5
commit
3980819674
1 changed files with 36 additions and 30 deletions
|
|
@ -35,13 +35,15 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
|
|||
|
||||
this.show = function(value) {
|
||||
var mode, htmlMode, jsMode, isHTML, isJS, modesByName,
|
||||
onMenu,
|
||||
isStr = Util.isString(value),
|
||||
name = Info.name,
|
||||
isDir = Info.isDir,
|
||||
focus = Util.bind(callFocus, function() {
|
||||
focus = function() {
|
||||
Ace.clearSelection();
|
||||
Ace.moveCursorTo(0, 0);
|
||||
});
|
||||
Ace.focus();
|
||||
};
|
||||
|
||||
if (!Loading) {
|
||||
Images.showLoad();
|
||||
|
|
@ -56,17 +58,19 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
|
|||
'position : absolute;',
|
||||
not_append : true
|
||||
});
|
||||
|
||||
onMenu = Util.bind(setMenu, Element);
|
||||
|
||||
initAce();
|
||||
|
||||
Events.add({
|
||||
drop : onDrop,
|
||||
dragover : function(event) {
|
||||
event.preventDefault();
|
||||
},
|
||||
drop : onDrop,
|
||||
dragover : function(event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}, Element);
|
||||
|
||||
setMenu(Element);
|
||||
Events.addOnce('contextmenu', onMenu, Element);
|
||||
}
|
||||
|
||||
modesByName = Modelist.modesByName;
|
||||
|
|
@ -129,11 +133,6 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
|
|||
Ace.gotoLine(number);
|
||||
};
|
||||
|
||||
function callFocus(callback) {
|
||||
Util.exec(callback);
|
||||
Ace.focus();
|
||||
}
|
||||
|
||||
function isChanged() {
|
||||
var is,
|
||||
value = Ace.getValue(),
|
||||
|
|
@ -376,26 +375,33 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch, Zip, MenuI
|
|||
|
||||
function setMenu(element) {
|
||||
DOM.menuLoad(function() {
|
||||
var options = {
|
||||
beforeShow: function(params) {
|
||||
params.x -= 18;
|
||||
params.y -= 27;
|
||||
}
|
||||
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();
|
||||
},
|
||||
'Select All Ctrl+A' : function() {
|
||||
Ace.selectAll();
|
||||
},
|
||||
'Delete Del' : function() {
|
||||
Ace.remove('right');
|
||||
},
|
||||
'Close Esc' : Edit.hide
|
||||
};
|
||||
|
||||
Menu = new MenuIO(element, options, {
|
||||
'Save Ctrl+S' : save,
|
||||
'Go To Line Ctrl+G' : Util.bind(callFocus, function() {
|
||||
Edit.goToLine();
|
||||
}),
|
||||
'Select All Ctrl+A' : Util.bind(callFocus, function() {
|
||||
Ace.selectAll();
|
||||
}),
|
||||
'Delete Del' : Util.bind(callFocus, function() {
|
||||
Ace.remove('right');
|
||||
}),
|
||||
'Close Esc' : Edit.hide
|
||||
});
|
||||
Menu = new MenuIO(element, options, menuData);
|
||||
|
||||
Menu.show(position.x, position.y);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue