From b496871322be46d9d6b9577f5277cef8b1b53af5 Mon Sep 17 00:00:00 2001 From: Van Date: Sat, 1 Nov 2014 21:28:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=97=AD=E6=89=80=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/editors.js | 28 ++++++++++++++++++++++++---- static/js/wide.js | 18 ++++++++++-------- static/user/admin/style.css | 2 +- views/index.html | 2 +- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/static/js/editors.js b/static/js/editors.js index 3b5b7d3..cc0c11a 100644 --- a/static/js/editors.js +++ b/static/js/editors.js @@ -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, @@ -9,7 +17,7 @@ var editors = { "title": config.label.tip, "hideFooter": true, "afterOpen": function (fileName) { - $("#dialogCloseEditor > div:eq(0)").html(config.label.file + $("#dialogCloseEditor > div:eq(0)").html(config.label.file + ' ' + fileName + '. ' + config.label.confirm_save + '?'); $("#dialogCloseEditor button:eq(0)").focus(); }, @@ -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; } diff --git a/static/js/wide.js b/static/js/wide.js index 3bd32db..2f4fe78 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -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(); diff --git a/static/user/admin/style.css b/static/user/admin/style.css index 2f2f376..ad31a3a 100644 --- a/static/user/admin/style.css +++ b/static/user/admin/style.css @@ -8,5 +8,5 @@ button { } .edit-exprinfo, .CodeMirror, .CodeMirror-hints { - font-size: 9; + font-size: ; } \ No newline at end of file diff --git a/views/index.html b/views/index.html index 4ef4def..9a3c43d 100644 --- a/views/index.html +++ b/views/index.html @@ -33,7 +33,7 @@
  • {{.i18n.save_all_files}}
  • -
  • +
  • {{.i18n.close_all_files}}