From 058f400dc5344ae12a1558be454befaf70e30cb6 Mon Sep 17 00:00:00 2001 From: Van Date: Mon, 13 Oct 2014 17:01:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/wide.css | 9 +++++++++ static/js/editors.js | 6 +++++- static/js/menu.js | 20 +++++++++++++++----- static/js/wide.js | 22 +++++++++++++++++++++- view/index.html | 10 +++++----- 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/static/css/wide.css b/static/css/wide.css index 23ed7a5..2a67e8b 100644 --- a/static/css/wide.css +++ b/static/css/wide.css @@ -80,11 +80,20 @@ cursor: pointer; } +.frame li.disabled { + color: #999; +} + .frame li:hover { background-color: #3875D7; color: #FFF; } +.frame li.disabled:hover { + background-color: #F8F8F8; + color: #999; +} + .frame a { color: #000; text-decoration: none; diff --git a/static/js/editors.js b/static/js/editors.js index 0a15856..e725e1e 100644 --- a/static/js/editors.js +++ b/static/js/editors.js @@ -23,8 +23,8 @@ var editors = { removeAfter: function (id, nextId) { for (var i = 0, ii = editors.data.length; i < ii; i++) { if (editors.data[i].id === id) { - editors.data.splice(i, 1); wide.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor); + editors.data.splice(i, 1); break; } } @@ -36,6 +36,8 @@ var editors = { wide.curNode = undefined; wide.curEditor = undefined; + + menu.disabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']); $(".toolbars").hide(); return false; } @@ -359,6 +361,8 @@ var editors = { + wide.curNode.iconSkin + 'ico">' + wide.curNode.name + '', content: '' }); + + menu.undisabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']); var rulers = []; rulers.push({color: "#ccc", column: 120, lineStyle: "dashed"}); diff --git a/static/js/menu.js b/static/js/menu.js index d043bd8..8a626d4 100644 --- a/static/js/menu.js +++ b/static/js/menu.js @@ -1,21 +1,31 @@ var menu = { - init: function() { + init: function () { this.subMenu(); // 点击子菜单后消失 - $(".frame li").click(function() { + $(".frame li").click(function () { $(this).closest(".frame").hide(); }); }, + disabled: function (list) { + for (var i = 0, max = list.length; i < max; i++) { + $(".menu li." + list[i]).addClass("disabled"); + } + }, + undisabled: function (list) { + for (var i = 0, max = list.length; i < max; i++) { + $(".menu li." + list[i]).removeClass("disabled"); + } + }, // 焦点不在菜单上时需点击展开子菜单,否则为鼠标移动展开 - subMenu: function() { - $(".menu > ul > li > a, .menu > ul> li > span").click(function() { + subMenu: function () { + $(".menu > ul > li > a, .menu > ul> li > span").click(function () { var $it = $(this); $it.next().show(); $(".menu > ul > li > a, .menu > ul> li > span").unbind(); - $(".menu > ul > li > a, .menu > ul> li > span").mouseover(function() { + $(".menu > ul > li > a, .menu > ul> li > span").mouseover(function () { $(".frame").hide(); var $it = $(this); $it.next().show(); diff --git a/static/js/wide.js b/static/js/wide.js index 5436913..9fdf688 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -402,6 +402,10 @@ var wide = { }, saveAllFiles: function () { // TODO: 需要全部保存的接口 + if ($(".menu li.save-all").hasClass("disabled")) { + return false; + } + 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); } @@ -410,14 +414,18 @@ var wide = { // TODO: close file }, closeAllFiles: function () { + 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']); }, exit: function () { // TODO: exit @@ -447,6 +455,10 @@ var wide = { }, // 构建 & 运行. run: function () { + if ($(".menu li.run").hasClass("disabled")) { + return false; + } + if ($(".toolbars .ico-stop").length === 1) { wide.stop(); return false; @@ -471,6 +483,10 @@ var wide = { }); }, goget: function () { + if ($(".menu li.go-get").hasClass("disabled")) { + return false; + } + var request = newWideRequest(); request.file = editors.getCurrentPath(); @@ -487,6 +503,10 @@ var wide = { }); }, goinstall: function () { + if ($(".menu li.go-install").hasClass("disabled")) { + return false; + } + var request = newWideRequest(); request.file = editors.getCurrentPath(); request.code = wide.curEditor.getValue(); diff --git a/view/index.html b/view/index.html index 435df8b..17423d3 100644 --- a/view/index.html +++ b/view/index.html @@ -26,10 +26,10 @@ {{.i18n.file}}