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 {
margin: 2px 2px 0 2px;
margin: 1px 5px 0 5px;
}
.ico-func {
background-position: -122px -21px;
background-position: -123px -21px;
}
.ico-interface {

View File

@ -56,8 +56,7 @@
text-shadow: #292a2b 0px 1px 0px;
}
.menu > ul > li > span:hover,
.menu > ul > li > span.selected {
.menu > ul > li.selected {
background-color: #494949;
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;

View File

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

View File

@ -465,7 +465,9 @@ var hotkeys = {
editors.tabs.setCurrent(nextId);
wide.curNode = tree.fileTree.getNodeByTId(nextId);
tree.fileTree.selectNode(wide.curNode);
wide.refreshOutline();
var cursor = wide.curEditor.getCursor();
$(".footer .cursor").text('| ' + (cursor.line + 1) + ':' + (cursor.ch + 1) + ' |');
wide.curEditor.focus();
}

View File

@ -22,12 +22,11 @@ var menu = {
this._initShare();
// 点击子菜单后消失
$(".frame li").click(function () {
$(this).closest(".frame").hide();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected");
$(".menu .frame li").click(function () {
$(".frame").hide();
$(".menu > ul > li").unbind().removeClass("selected");
menu.subMenu();
});
},
_initShare: function () {
$(".menu .ico-share").hover(function () {
@ -96,18 +95,24 @@ var menu = {
},
// 焦点不在菜单上时需点击展开子菜单,否则为鼠标移动展开
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);
$it.next().show();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected");
$it.find('.frame').show();
$(".menu > ul > li").removeClass("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();
$(this).next().show();
$(".menu > ul > li > a, .menu > ul> li > span").removeClass("selected");
$(this).find('.frame').show();
$(".menu > ul > li").removeClass("selected");
$(this).addClass("selected");
});
});

View File

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

View File

@ -19,7 +19,8 @@ var wide = {
curEditor: undefined,
curProcessId: undefined, // curent running process id (pid)
refreshOutline: function () {
if (wide.curEditor.doc.getMode().name !== "go") {
if (!wide.curEditor ||
(wide.curEditor && wide.curEditor.doc.getMode().name !== "go")) {
$("#outline").html('');
return false;
}
@ -38,18 +39,26 @@ var wide = {
}
var outlineHTML = '<ul class="list">',
decls = ['funcDecls', 'interfaceDecls', 'structDecls',
'constDecls', 'varDecls'];
decls = ['constDecls', 'varDecls', 'funcDecls',
'structDecls', 'interfaceDecls', 'typeDecls'];
for (var i = 0, max = decls.length; i < max; i++) {
var key = decls[i];
for (var j = 0, maxj = data[key].length; j < maxj; j++) {
var name = data[key][j].Name;
outlineHTML += '<li><span class="ico ico-'
+ key.replace('Decls', '') + '"></span> ' + name + '</li>';
var obj = data[key][j];
outlineHTML += '<li data-ch="' + obj.Ch + '" data-line="'
+ obj.Line + '"><span class="ico ico-'
+ key.replace('Decls', '') + '"></span> ' + obj.Name + '</li>';
}
}
$("#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();
});
}
});
},
@ -479,7 +488,7 @@ var wide = {
if (!($(event.target).closest(".frame").length > 0 || event.target.className === "frame")) {
$(".frame").hide();
$(".menu > ul > li > a, .menu > ul> li > span").unbind("mouseover").removeClass("selected");
$(".menu > ul > li").unbind().removeClass("selected");
menu.subMenu();
}
});
@ -568,7 +577,7 @@ var wide = {
});
// refresh outline
wide.randerOutline();
wide.refreshOutline();
return;
}