右键菜单修改。bug修改
This commit is contained in:
parent
4cb56230b0
commit
a5725f5c71
|
@ -130,7 +130,7 @@ var editors = {
|
|||
var cur = wide.curEditor.getCursor();
|
||||
|
||||
var request = {
|
||||
file: wide.curNode.path,
|
||||
file: $tabs.children(".current").data("index"),
|
||||
code: wide.curEditor.getValue(),
|
||||
cursorLine: cur.line,
|
||||
cursorCh: cur.ch
|
||||
|
|
|
@ -53,10 +53,10 @@ $.extend(Tabs.prototype, {
|
|||
prevId = currentId;
|
||||
} else {
|
||||
prevId = this.obj._prevId;
|
||||
this.setCurrent(prevId);
|
||||
}
|
||||
|
||||
|
||||
this.obj.removeAfter(id, prevId);
|
||||
this.setCurrent(prevId);
|
||||
},
|
||||
getCurrentId: function() {
|
||||
var $tabs = this.obj._$tabs;
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
var tree = {
|
||||
fileTree: undefined,
|
||||
_isParents: function(tId, parentTId) {
|
||||
var node = tree.fileTree.getNodeByTId(tId);
|
||||
if (!node || !node.parentTId) {
|
||||
return false;
|
||||
} else {
|
||||
if (node.parentTId === parentTId) {
|
||||
return true;
|
||||
} else {
|
||||
return tree._isParents(node.parentTId, parentTId);
|
||||
}
|
||||
}
|
||||
},
|
||||
newFile: function() {
|
||||
$("#dirRMenu ul").hide();
|
||||
$("#dirRMenu").hide();
|
||||
var name = prompt("Name", "");
|
||||
if (!name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var request = {
|
||||
path: wide.curNode.path + '/' + name,
|
||||
path: wide.curNode.path + '\\' + name,
|
||||
fileType: "f"
|
||||
};
|
||||
$.ajax({
|
||||
|
@ -20,21 +32,62 @@ var tree = {
|
|||
if (!data.succ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var suffix = name.split(".")[1],
|
||||
iconSkin = "ico-ztree-other ";
|
||||
switch (suffix) {
|
||||
case "html", "htm":
|
||||
iconSkin = "ico-ztree-html ";
|
||||
break;
|
||||
case "go":
|
||||
iconSkin = "ico-ztree-go ";
|
||||
break;
|
||||
case "css":
|
||||
iconSkin = "ico-ztree-css ";
|
||||
break;
|
||||
case "txt":
|
||||
iconSkin = "ico-ztree-text ";
|
||||
break;
|
||||
case "sql":
|
||||
iconSkin = "ico-ztree-sql ";
|
||||
break;
|
||||
case "properties":
|
||||
iconSkin = "ico-ztree-pro ";
|
||||
break;
|
||||
case "md":
|
||||
iconSkin = "ico-ztree-md ";
|
||||
break;
|
||||
case "md":
|
||||
iconSkin = "ico-ztree-md ";
|
||||
break;
|
||||
case "js", "json":
|
||||
iconSkin = "ico-ztree-js ";
|
||||
break;
|
||||
case "xml":
|
||||
iconSkin = "ico-ztree-xml ";
|
||||
break;
|
||||
case "jpg", "jpeg", "bmp", "gif", "png", "svg", "ico":
|
||||
iconSkin = "ico-ztree-img ";
|
||||
break;
|
||||
}
|
||||
|
||||
tree.fileTree.addNodes(wide.curNode, [{
|
||||
"name": name
|
||||
"name": name,
|
||||
"iconSkin": iconSkin,
|
||||
"path": request.path
|
||||
}]);
|
||||
}
|
||||
});
|
||||
},
|
||||
newDir: function() {
|
||||
$("#dirRMenu ul").hide();
|
||||
$("#dirRMenu").hide();
|
||||
var name = prompt("Name", "");
|
||||
if (!name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var request = {
|
||||
path: wide.curNode.path + '/' + name,
|
||||
path: wide.curNode.path + '\\' + name,
|
||||
fileType: "d"
|
||||
};
|
||||
$.ajax({
|
||||
|
@ -47,14 +100,16 @@ var tree = {
|
|||
return false;
|
||||
}
|
||||
tree.fileTree.addNodes(wide.curNode, [{
|
||||
"name": name
|
||||
"name": name,
|
||||
"iconSkin": "ico-ztree-dir ",
|
||||
"path": request.path
|
||||
}]);
|
||||
}
|
||||
});
|
||||
},
|
||||
removeIt: function() {
|
||||
$("#dirRMenu ul").hide();
|
||||
$("#fileRMenu ul").hide();
|
||||
$("#dirRMenu").hide();
|
||||
$("#fileRMenu").hide();
|
||||
|
||||
if (!confirm("Remove it?")) {
|
||||
return;
|
||||
|
@ -71,6 +126,25 @@ var tree = {
|
|||
if (!data.succ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("ico-ztree-dir " !== wide.curNode.iconSkin) {
|
||||
// 是文件的话,查看 editor 中是否被打开,如打开则移除
|
||||
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
||||
if (editors.data[i].id === wide.curNode.tId) {
|
||||
$(".edit-header .tabs > div[data-index=" + wide.curNode.tId + "]").find(".ico-close").click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var i = 0, ii = editors.data.length; i < ii; i++) {
|
||||
if (tree._isParents(editors.data[i].id, wide.curNode.tId)) {
|
||||
$(".edit-header .tabs > div[data-index=" + editors.data[i].id + "]").find(".ico-close").click();
|
||||
i--;
|
||||
ii--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tree.fileTree.removeNode(wide.curNode);
|
||||
}
|
||||
});
|
||||
|
@ -92,7 +166,7 @@ var tree = {
|
|||
onRightClick: function(event, treeId, treeNode) {
|
||||
if (treeNode) {
|
||||
wide.curNode = treeNode;
|
||||
if ("f" === treeNode.type) { // 如果右击了文件
|
||||
if ("ico-ztree-dir " !== treeNode.iconSkin) { // 如果右击了文件
|
||||
$("#fileRMenu ul").show();
|
||||
fileRMenu.css({
|
||||
"top": event.clientY - 10 + "px",
|
||||
|
@ -102,8 +176,8 @@ var tree = {
|
|||
} else { // 右击了目录
|
||||
$("#dirRMenu ul").show();
|
||||
dirRMenu.css({
|
||||
"top": event.clientY - 10 + "px",
|
||||
"left": event.clientX + "px",
|
||||
"top": event.clientY - 10 + "px",
|
||||
"left": event.clientX + "px",
|
||||
"display": "block"
|
||||
});
|
||||
}
|
||||
|
@ -141,7 +215,7 @@ var tree = {
|
|||
|
||||
wide.curNode = treeNode;
|
||||
|
||||
if ("f" === treeNode.type) { // 如果单击了文件
|
||||
if ("ico-ztree-dir " !== treeNode.iconSkin) { // 如果单击了文件
|
||||
var request = {
|
||||
path: treeNode.path
|
||||
};
|
||||
|
|
|
@ -91,7 +91,7 @@ var wide = {
|
|||
},
|
||||
saveFile: function() {
|
||||
var request = {
|
||||
file: wide.curNode.path,
|
||||
file: $(".edit-header .current span:eq(0)").attr("title"),
|
||||
code: wide.curEditor.getValue()
|
||||
};
|
||||
$.ajax({
|
||||
|
@ -117,7 +117,7 @@ var wide = {
|
|||
},
|
||||
run: function() {
|
||||
var request = {
|
||||
file: wide.curNode.path,
|
||||
file: $(".edit-header .current span:eq(0)").attr("title"),
|
||||
code: wide.curEditor.getValue()
|
||||
};
|
||||
|
||||
|
@ -135,7 +135,7 @@ var wide = {
|
|||
},
|
||||
goget: function() {
|
||||
var request = {
|
||||
file: wide.curNode.path
|
||||
file: $(".edit-header .current span:eq(0)").attr("title")
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
|
@ -152,7 +152,7 @@ var wide = {
|
|||
},
|
||||
goinstall: function() {
|
||||
var request = {
|
||||
file: wide.curNode.path,
|
||||
file: $(".edit-header .current span:eq(0)").attr("title"),
|
||||
code: wide.curEditor.getValue()
|
||||
};
|
||||
|
||||
|
@ -169,7 +169,7 @@ var wide = {
|
|||
});
|
||||
},
|
||||
fmt: function() {
|
||||
var path = wide.curNode.path;
|
||||
var path = $(".edit-header .current span:eq(0)").attr("title");
|
||||
var mode = wide.curNode.mode;
|
||||
|
||||
var request = {
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
|
||||
<div class="toolbars fn-right">
|
||||
<span onclick="wide.run()" class="font-ico icon-buildrun" title="{{.i18n.build_n_run}}"></span>
|
||||
<span onclick="wide.save()" title="{{.i18n.save}}" class="font-ico ico-save"></span>
|
||||
<span onclick="wide.saveFile()" title="{{.i18n.save}}" class="font-ico ico-save"></span>
|
||||
<span onclick="wide.fmt()" class="ico-format font-ico" title="{{.i18n.format}}"></span>
|
||||
<span class="fn-none font-ico ico-fullscreen" onclick="editors.fullscreen()" title="{{.i18n.full_screen}}"></span>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue