From 7cb70347bfdca0ef4e1932856cea409778b99b6d Mon Sep 17 00:00:00 2001 From: Van Date: Fri, 31 Oct 2014 17:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=9C=AA=E4=BF=AE=E6=94=B9=E7=9A=84=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=86=8D=E6=AC=A1=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/editors.js | 5 +++++ static/js/wide.js | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/static/js/editors.js b/static/js/editors.js index 090e483..d03d54e 100644 --- a/static/js/editors.js +++ b/static/js/editors.js @@ -28,13 +28,16 @@ var editors = { return false; } + // 移除编辑器 for (var i = 0, ii = editors.data.length; i < ii; i++) { if (editors.data[i].id === id) { + wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor); editors.data.splice(i, 1); break; } } + if (editors.data.length === 0) { // 起始页可能存在,所以用编辑器数据判断 menu.disabled(['save-all', 'close-all', 'build', 'run', 'go-test', 'go-get', 'go-install']); $(".toolbars").hide(); @@ -51,6 +54,7 @@ var editors = { } if (nextId === editors.tabs.getCurrentId()) { + // 关闭的不是当前编辑器 return false; } @@ -219,6 +223,7 @@ var editors = { } } + // 清除未保存状态 editor.doc.markClean(); $(".edit-panel .tabs > div.current > span").removeClass("changed"); } diff --git a/static/js/wide.js b/static/js/wide.js index 78ad607..9665e4d 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -470,9 +470,6 @@ var wide = { if ($(".menu li.save-all").hasClass("disabled")) { return false; } - - // TODO: 只保存未保存过的文件 - for (var i = 0, ii = editors.data.length; i < ii; i++) { this.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor); } @@ -695,6 +692,10 @@ var wide = { }); }, fmt: function (path, curEditor) { + if (curEditor.doc.isClean()) { // 没有修改过,不需要保存 + return false; + } + var mode = curEditor.getOption("mode"); var cursor = curEditor.getCursor(); @@ -749,8 +750,14 @@ var wide = { wide._save(); } + // 清除未保存状态 curEditor.doc.markClean(); - $(".edit-panel .tabs > div.current > span").removeClass("changed"); + $(".edit-panel .tabs > div").each(function () { + var $span = $(this).find("span:eq(0)"); + if ($span.attr("title") === path) { + $span.removeClass("changed"); + } + }); }, openAbout: function () { $("#dialogAbout").dialog("open");