outline & menu bug

This commit is contained in:
Van 2015-01-03 16:01:24 +08:00
parent ef32199984
commit 3bdba1a2fa
9 changed files with 57 additions and 37 deletions

View File

@ -52,11 +52,11 @@
} }
#outline .ico { #outline .ico {
margin: 2px 2px 0 2px; margin: 1px 5px 0 5px;
} }
.ico-func { .ico-func {
background-position: -122px -21px; background-position: -123px -21px;
} }
.ico-interface { .ico-interface {

View File

@ -56,8 +56,7 @@
text-shadow: #292a2b 0px 1px 0px; text-shadow: #292a2b 0px 1px 0px;
} }
.menu > ul > li > span:hover, .menu > ul > li.selected {
.menu > ul > li > span.selected {
background-color: #494949; background-color: #494949;
color: #d4d4d4; color: #d4d4d4;
box-shadow: 1px 0 0 0 #000000 inset, 1px 0 0 0 #000000, 0 1px 0 0 rgba(255, 255, 255, 0.15) inset; box-shadow: 1px 0 0 0 #000000 inset, 1px 0 0 0 #000000, 0 1px 0 0 rgba(255, 255, 255, 0.15) inset;

View File

@ -54,8 +54,7 @@
text-shadow: 0px 1px 0px #efefef; text-shadow: 0px 1px 0px #efefef;
} }
.menu > ul > li > span:hover, .menu > ul > li.selected {
.menu > ul > li > span.selected {
background-color: #cfcfcf; background-color: #cfcfcf;
box-shadow: 1px 0 0 0 #b6b6b6 inset, 1px 0 0 0 #b6b6b6, 0 1px 0 0 rgba(255, 255, 255, 0.15) inset; box-shadow: 1px 0 0 0 #b6b6b6 inset, 1px 0 0 0 #b6b6b6, 0 1px 0 0 rgba(255, 255, 255, 0.15) inset;
color: #393939; color: #393939;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

@ -126,7 +126,9 @@ var editors = {
}, },
clickAfter: function (id) { clickAfter: function (id) {
if (id === 'startPage') { if (id === 'startPage') {
wide.curEditor = undefined;
$(".footer .cursor").text(''); $(".footer .cursor").text('');
wide.refreshOutline();
return false; return false;
} }
@ -145,6 +147,7 @@ var editors = {
var cursor = wide.curEditor.getCursor(); var cursor = wide.curEditor.getCursor();
wide.curEditor.setCursor(cursor); wide.curEditor.setCursor(cursor);
wide.curEditor.focus(); wide.curEditor.focus();
wide.refreshOutline();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |'); $(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
}, },
@ -176,10 +179,6 @@ var editors = {
menu.disabled(['close-all']); menu.disabled(['close-all']);
} }
if (id === 'startPage') { // 当前关闭的 tab 是起始页
return false;
}
// 移除编辑器 // 移除编辑器
for (var i = 0, ii = editors.data.length; i < ii; i++) { for (var i = 0, ii = editors.data.length; i < ii; i++) {
if (editors.data[i].id === id) { if (editors.data[i].id === id) {
@ -201,6 +200,7 @@ var editors = {
tree.fileTree.cancelSelectedNode(); tree.fileTree.cancelSelectedNode();
wide.curNode = undefined; wide.curNode = undefined;
wide.curEditor = undefined; wide.curEditor = undefined;
wide.refreshOutline();
$(".footer .cursor").text(''); $(".footer .cursor").text('');
return false; return false;
} }
@ -222,6 +222,7 @@ var editors = {
} }
} }
wide.refreshOutline();
var cursor = wide.curEditor.getCursor(); var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |'); $(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
} }
@ -240,6 +241,10 @@ var editors = {
this._initClose(); this._initClose();
}, },
openStartPage: function () { openStartPage: function () {
wide.curEditor = undefined;
wide.refreshOutline();
$(".footer .cursor").text('');
var dateFormat = function (time, fmt) { var dateFormat = function (time, fmt) {
var date = new Date(time); var date = new Date(time);
var dateObj = { var dateObj = {

View File

@ -377,7 +377,7 @@ var hotkeys = {
return; return;
} }
if (event.ctrlKey === hotKeys.goOutline.ctrlKey if (event.ctrlKey === hotKeys.goOutline.ctrlKey
&& event.which === hotKeys.goOutline.which) { // Ctrl-2 焦点切换到大纲 && event.which === hotKeys.goOutline.which) { // Ctrl-2 焦点切换到大纲
hotKeys.goOutline.fun(); hotKeys.goOutline.fun();
@ -465,7 +465,9 @@ var hotkeys = {
editors.tabs.setCurrent(nextId); editors.tabs.setCurrent(nextId);
wide.curNode = tree.fileTree.getNodeByTId(nextId); wide.curNode = tree.fileTree.getNodeByTId(nextId);
tree.fileTree.selectNode(wide.curNode); tree.fileTree.selectNode(wide.curNode);
wide.refreshOutline();
var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
wide.curEditor.focus(); wide.curEditor.focus();
} }

View File

@ -22,12 +22,11 @@ var menu = {
this._initShare(); this._initShare();
// 点击子菜单后消失 // 点击子菜单后消失
$(".frame li").click(function () { $(".menu .frame li").click(function () {
$(this).closest(".frame").hide(); $(".frame").hide();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected"); $(".menu > ul > li").unbind().removeClass("selected");
menu.subMenu();
}); });
}, },
_initShare: function () { _initShare: function () {
$(".menu .ico-share").hover(function () { $(".menu .ico-share").hover(function () {
@ -52,7 +51,7 @@ var menu = {
urls.weibo = "http://v.t.sina.com.cn/share/share.php?title=" + title + "&url=" + url + "&pic=" + pic; urls.weibo = "http://v.t.sina.com.cn/share/share.php?title=" + title + "&url=" + url + "&pic=" + pic;
urls.tencent = "http://share.v.t.qq.com/index.php?c=share&a=index&title=" + title + urls.tencent = "http://share.v.t.qq.com/index.php?c=share&a=index&title=" + title +
"&url=" + url + "&pic=" + pic; "&url=" + url + "&pic=" + pic;
window.open(urls[key], "_blank", "top=100,left=200,width=648,height=618"); window.open(urls[key], "_blank", "top=100,left=200,width=648,height=618");
}); });
}, },
@ -96,18 +95,24 @@ var menu = {
}, },
// 焦点不在菜单上时需点击展开子菜单,否则为鼠标移动展开 // 焦点不在菜单上时需点击展开子菜单,否则为鼠标移动展开
subMenu: function () { subMenu: function () {
$(".menu > ul > li > a, .menu > ul> li > span").click(function () { $(".menu > ul > li").click(function (event) {
if ($(event.target).closest(".frame").length === 1) {
return;
}
var $it = $(this); var $it = $(this);
$it.next().show(); $it.find('.frame').show();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected"); $(".menu > ul > li").removeClass("selected");
$(this).addClass("selected"); $(this).addClass("selected");
$(".menu > ul > li > a, .menu > ul> li > span").unbind(); $(".menu > ul > li").unbind();
$(".menu > ul > li > a, .menu > ul> li > span").mouseover(function () { $(".menu > ul > li").mouseover(function () {
if ($(event.target).closest(".frame").length === 1) {
return;
}
$(".frame").hide(); $(".frame").hide();
$(this).next().show(); $(this).find('.frame').show();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected"); $(".menu > ul > li").removeClass("selected");
$(this).addClass("selected"); $(this).addClass("selected");
}); });
}); });

View File

@ -110,6 +110,7 @@ $.extend(Tabs.prototype, {
for (var i = 0; i < stack.length; i++) { for (var i = 0; i < stack.length; i++) {
if (id === stack[i]) { if (id === stack[i]) {
stack.splice(i, 1); stack.splice(i, 1);
i--;
} }
} }

View File

@ -19,11 +19,12 @@ var wide = {
curEditor: undefined, curEditor: undefined,
curProcessId: undefined, // curent running process id (pid) curProcessId: undefined, // curent running process id (pid)
refreshOutline: function () { refreshOutline: function () {
if (wide.curEditor.doc.getMode().name !== "go") { if (!wide.curEditor ||
(wide.curEditor && wide.curEditor.doc.getMode().name !== "go")) {
$("#outline").html(''); $("#outline").html('');
return false; return false;
} }
var request = newWideRequest(); var request = newWideRequest();
request.code = wide.curEditor.getValue(); request.code = wide.curEditor.getValue();
@ -36,20 +37,28 @@ var wide = {
if (!data.succ) { if (!data.succ) {
return; return;
} }
var outlineHTML = '<ul class="list">', var outlineHTML = '<ul class="list">',
decls = ['funcDecls', 'interfaceDecls', 'structDecls', decls = ['constDecls', 'varDecls', 'funcDecls',
'constDecls', 'varDecls']; 'structDecls', 'interfaceDecls', 'typeDecls'];
for (var i = 0, max = decls.length; i < max; i++) { for (var i = 0, max = decls.length; i < max; i++) {
var key = decls[i]; var key = decls[i];
for (var j = 0, maxj = data[key].length; j < maxj; j++) { for (var j = 0, maxj = data[key].length; j < maxj; j++) {
var name = data[key][j].Name; var obj = data[key][j];
outlineHTML += '<li><span class="ico ico-' outlineHTML += '<li data-ch="' + obj.Ch + '" data-line="'
+ key.replace('Decls', '') + '"></span> ' + name + '</li>'; + obj.Line + '"><span class="ico ico-'
+ key.replace('Decls', '') + '"></span> ' + obj.Name + '</li>';
} }
} }
$("#outline").html(outlineHTML + '</ul>'); $("#outline").html(outlineHTML + '</ul>');
$("#outline li").dblclick(function () {
var $it = $(this),
cursor = CodeMirror.Pos($it.data('line'), $it.data("ch"));
wide.curEditor.setCursor(cursor);
wide.curEditor.focus();
});
} }
}); });
}, },
@ -356,7 +365,7 @@ var wide = {
} else { } else {
$(".bottom-window-group > .tabs-panel > div > div").height(bottomH - $bottomGroup.children(".tabs").height()); $(".bottom-window-group > .tabs-panel > div > div").height(bottomH - $bottomGroup.children(".tabs").height());
} }
if ($(".side-right").hasClass("side-right-max")) { if ($(".side-right").hasClass("side-right-max")) {
$(".side-right > .tabs-panel > div").height(mainH - $bottomGroup.children(".tabs").height()); $(".side-right > .tabs-panel > div").height(mainH - $bottomGroup.children(".tabs").height());
} else { } else {
@ -479,7 +488,7 @@ var wide = {
if (!($(event.target).closest(".frame").length > 0 || event.target.className === "frame")) { if (!($(event.target).closest(".frame").length > 0 || event.target.className === "frame")) {
$(".frame").hide(); $(".frame").hide();
$(".menu > ul > li > a, .menu > ul> li > span").unbind("mouseover").removeClass("selected"); $(".menu > ul > li").unbind().removeClass("selected");
menu.subMenu(); menu.subMenu();
} }
}); });
@ -568,7 +577,7 @@ var wide = {
}); });
// refresh outline // refresh outline
wide.randerOutline(); wide.refreshOutline();
return; return;
} }