关闭所有

This commit is contained in:
Van 2014-11-01 21:28:18 +08:00
parent a6cecc0f5d
commit b496871322
4 changed files with 36 additions and 14 deletions

View File

@ -1,6 +1,14 @@
var editors = {
data: [],
tabs: {},
_removeAllMarker: function () {
var removeData = $("#dialogCloseEditor").data("removeData");
if (removeData && removeData.length > 0) {
removeData.splice(0, 1);
$("#dialogCloseEditor").data("removeData", removeData);
$(".edit-panel .tabs .ico-close:eq(0)").click();
}
},
init: function () {
$("#dialogCloseEditor").dialog({
"modal": true,
@ -19,16 +27,22 @@ var editors = {
wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
editors.tabs.del(editors.data[i].id);
$("#dialogCloseEditor").dialog("close");
editors._removeAllMarker();
});
$("#dialogCloseEditor button.discard").click(function () {
$("#dialogCloseEditor").dialog("close");
editors._removeAllMarker();
});
$("#dialogCloseEditor button.cancel").click(function () {
var i = $("#dialogCloseEditor").data("index");
editors.tabs.del(editors.data[i].id);
$("#dialogCloseEditor").dialog("close");
editors._removeAllMarker();
});
}
});
@ -56,7 +70,7 @@ var editors = {
},
removeBefore: function (id) {
if (id === 'startPage') { // 当前关闭的 tab 是起始页
return false;
return true;
}
// 移除编辑器
@ -76,6 +90,13 @@ var editors = {
}
},
removeAfter: function (id, nextId) {
editors._removeAllMarker();
if ($(".edit-panel .tabs > div").length === 0) {
// 全部 tab 都关闭时才 disables 菜单中“全部关闭”的按钮
menu.disabled(['close-all']);
}
if (id === 'startPage') { // 当前关闭的 tab 是起始页
return false;
}
@ -89,7 +110,7 @@ var editors = {
}
if (editors.data.length === 0) { // 起始页可能存在,所以用编辑器数据判断
menu.disabled(['save-all', 'close-all', 'build', 'run', 'go-test', 'go-get', 'go-install']);
menu.disabled(['save-all', 'build', 'run', 'go-test', 'go-get', 'go-install']);
$(".toolbars").hide();
}
@ -98,7 +119,6 @@ var editors = {
// remove selected tree node
tree.fileTree.cancelSelectedNode();
wide.curNode = undefined;
wide.curEditor = undefined;
return false;
}

View File

@ -478,15 +478,17 @@ var wide = {
if ($(".menu li.close-all").hasClass("disabled")) {
return false;
}
this.saveAllFiles();
editors.data = [];
tree.fileTree.cancelSelectedNode();
wide.curNode = undefined;
wide.curEditor = undefined;
$(".toolbars").hide();
$(".edit-panel .tabs, .edit-panel .tabs-panel").html('');
menu.disabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']);
// 设置全部关闭标识
var removeData = [];
$(".edit-panel .tabs > div").each(function (i) {
if (i !== 0) {
removeData.push($(this).data("index"));
}
});
$("#dialogCloseEditor").data("removeData", removeData);
// 开始关闭
$(".edit-panel .tabs .ico-close:eq(0)").click();
},
exit: function () {
var request = newWideRequest();

View File

@ -8,5 +8,5 @@ button {
}
.edit-exprinfo, .CodeMirror, .CodeMirror-hints {
font-size: 9;
font-size: ;
}

View File

@ -33,7 +33,7 @@
<li class="save-all disabled" onclick="wide.saveAllFiles()">
<span>{{.i18n.save_all_files}}</span>
</li>
<li class="close-all disabled" onclick="wide.closeAllFiles()">
<li class="close-all" onclick="wide.closeAllFiles()">
<span>{{.i18n.close_all_files}}</span>
</li>
<li class="hr"></li>