菜单栏
This commit is contained in:
parent
3e720d8179
commit
058f400dc5
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
@ -360,6 +362,8 @@ var editors = {
|
|||
content: '<textarea id="editor' + id + '"></textarea>'
|
||||
});
|
||||
|
||||
menu.undisabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']);
|
||||
|
||||
var rulers = [];
|
||||
rulers.push({color: "#ccc", column: 120, lineStyle: "dashed"});
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,6 +414,9 @@ var wide = {
|
|||
// TODO: close file
|
||||
},
|
||||
closeAllFiles: function () {
|
||||
if ($(".menu li.close-all").hasClass("disabled")) {
|
||||
return false;
|
||||
}
|
||||
this.saveAllFiles();
|
||||
editors.data = [];
|
||||
tree.fileTree.cancelSelectedNode();
|
||||
|
@ -418,6 +425,7 @@ var wide = {
|
|||
$(".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();
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
<span>{{.i18n.file}}</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li onclick="wide.saveAllFiles()">
|
||||
<li class="save-all disabled" onclick="wide.saveAllFiles()">
|
||||
<span>{{.i18n.save_all_files}}</span>
|
||||
</li>
|
||||
<li onclick="wide.closeAllFiles()">
|
||||
<li class="close-all disabled" onclick="wide.closeAllFiles()">
|
||||
<span>{{.i18n.close_all_files}}</span>
|
||||
</li>
|
||||
<li class="hr"></li>
|
||||
|
@ -43,14 +43,14 @@
|
|||
<span>{{.i18n.run}}</span>
|
||||
<div class="frame">
|
||||
<ul>
|
||||
<li onclick="wide.run()">
|
||||
<li class="run disabled" onclick="wide.run()">
|
||||
<span>{{.i18n.build_n_run}}</span>
|
||||
</li>
|
||||
<li class="hr"></li>
|
||||
<li onclick="wide.goget()">
|
||||
<li class="go-get disabled" onclick="wide.goget()">
|
||||
<span>{{.i18n.goget}}</span>
|
||||
</li>
|
||||
<li onclick="wide.goinstall()">
|
||||
<li class="go-install disabled" onclick="wide.goinstall()">
|
||||
<span>{{.i18n.goinstall}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue