快捷键关闭当前编辑器 bug 修复 & 关闭编辑器后焦点设置

This commit is contained in:
Van 2014-12-04 15:00:04 +08:00
parent c9443a8851
commit 78accaa82e
3 changed files with 16 additions and 10 deletions

View File

@ -45,9 +45,12 @@ var editors = {
$("#dialogCloseEditor").data("removeData", removeData); $("#dialogCloseEditor").data("removeData", removeData);
$(".edit-panel .tabs > div[data-index=" + removeIndex + "] .ico-close").click(); $(".edit-panel .tabs > div[data-index=" + removeIndex + "] .ico-close").click();
} }
if (wide.curEditor) {
wide.curEditor.focus();
}
}, },
_initClose: function () { _initClose: function () {
new ZeroClipboard($("#copyFilePath")); new ZeroClipboard($("#copyFilePath"));
// 关闭、关闭其他、关闭所有 // 关闭、关闭其他、关闭所有
$(".edit-panel").on("mousedown", '.tabs > div', function (event) { $(".edit-panel").on("mousedown", '.tabs > div', function (event) {
@ -90,7 +93,6 @@ var editors = {
wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor); wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
editors.tabs.del(editors.data[i].id); editors.tabs.del(editors.data[i].id);
$("#dialogCloseEditor").dialog("close"); $("#dialogCloseEditor").dialog("close");
editors._removeAllMarker(); editors._removeAllMarker();
}); });
@ -98,13 +100,11 @@ var editors = {
var i = $("#dialogCloseEditor").data("index"); var i = $("#dialogCloseEditor").data("index");
editors.tabs.del(editors.data[i].id); editors.tabs.del(editors.data[i].id);
$("#dialogCloseEditor").dialog("close"); $("#dialogCloseEditor").dialog("close");
editors._removeAllMarker(); editors._removeAllMarker();
}); });
$("#dialogCloseEditor button.cancel").click(function () { $("#dialogCloseEditor button.cancel").click(function (event) {
$("#dialogCloseEditor").dialog("close"); $("#dialogCloseEditor").dialog("close");
editors._removeAllMarker(); editors._removeAllMarker();
}); });
} }
@ -112,6 +112,11 @@ var editors = {
editors.tabs = new Tabs({ editors.tabs = new Tabs({
id: ".edit-panel", id: ".edit-panel",
setAfter: function () {
if (wide.curEditor) {
wide.curEditor.focus();
}
},
clickAfter: function (id) { clickAfter: function (id) {
if (id === 'startPage') { if (id === 'startPage') {
$(".footer .cursor").text(''); $(".footer .cursor").text('');

View File

@ -373,10 +373,7 @@ var hotkeys = {
if (event.ctrlKey === hotKeys.closeCurEditor.ctrlKey if (event.ctrlKey === hotKeys.closeCurEditor.ctrlKey
&& event.which === hotKeys.closeCurEditor.which) { // Ctrl+Q 关闭当前编辑器 && event.which === hotKeys.closeCurEditor.which) { // Ctrl+Q 关闭当前编辑器
var currentId = editors.getCurrentId(); $(".edit-panel .tabs > div.current").find(".ico-close").click();
if (currentId) {
editors.tabs.del(currentId);
}
event.preventDefault(); event.preventDefault();
return; return;

View File

@ -139,5 +139,9 @@ $.extend(Tabs.prototype, {
$tabs.children("div[data-index='" + id + "']").addClass("current"); $tabs.children("div[data-index='" + id + "']").addClass("current");
$tabsPanel.children("div[data-index='" + id + "']").show(); $tabsPanel.children("div[data-index='" + id + "']").show();
if (typeof this.obj.setAfter === 'function') {
this.obj.setAfter();
}
} }
}); });