This commit is contained in:
Van 2014-11-14 17:06:13 +08:00
parent da10a8e395
commit 5ab014d8c0
8 changed files with 119 additions and 54 deletions

View File

@ -60,3 +60,22 @@ button {
display: none; display: none;
} }
/* end reset & function */ /* end reset & function */
/* start common */
.list li {
cursor: pointer;
line-height: 20px;
padding: 0 3px;
word-wrap: normal;
word-break: normal;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.list li.selected,
.list li:hover{
background-color: #3875d7;
color: #FFF;
}
/* end common */

View File

@ -99,16 +99,10 @@
} }
#dialogGoFilePrompt > ul { #dialogGoFilePrompt > ul {
position: relative;
height: 260px; height: 260px;
overflow: auto; overflow: auto;
margin-top: 5px; margin-top: 5px;
} background-color: #FFF;
border: 1px solid #9B9B9B;
#dialogGoFilePrompt li {
}
#dialogGoFilePrompt li.selected,
#dialogGoFilePrompt li:hover {
} }

View File

@ -336,28 +336,13 @@
padding: 0 5px; padding: 0 5px;
} }
.bottom-window-group .search li {
cursor: pointer;
line-height: 20px;
padding: 0 3px;
word-wrap: normal;
word-break: normal;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.bottom-window-group .search li.selected {
background-color: #3875d7;
color: #FFF;
}
.bottom-window-group .search .path { .bottom-window-group .search .path {
color: #999; color: #999;
font-size: 12px; font-size: 12px;
} }
.bottom-window-group .search li.selected .path { .bottom-window-group .search li.selected .path,
.bottom-window-group .search li:hover .path {
color: #FFF; color: #FFF;
} }
/* end bottom-window-group */ /* end bottom-window-group */

View File

@ -486,7 +486,7 @@ var editors = {
}; };
}, },
appendSearch: function (data, type, key) { appendSearch: function (data, type, key) {
var searcHTML = '<ul>'; var searcHTML = '<ul class="list">';
for (var i = 0, ii = data.length; i < ii; i++) { for (var i = 0, ii = data.length; i < ii; i++) {
var contents = data[i].contents[0], var contents = data[i].contents[0],

View File

@ -94,6 +94,55 @@ var hotkeys = {
which: 117 which: 117
} }
}, },
bindList: function ($source, $list, enterFun) {
$list.data("index", 0);
$source.keydown(function (event) {
var index = $list.data("index"),
count = $list.find("li").length;
if (count === 0) {
return true;
}
if (event.which === 38) { // up
index--;
if (index < 0) {
index = count - 1;
}
}
if (event.which === 40) { // down
index++;
if (index > count - 1) {
index = 0;
}
}
var $selected = $list.find("li:eq(" + index + ")");
if (event.which === 13) { // enter
enterFun($selected);
}
$list.find("li").removeClass("selected");
$list.data("index", index);
$selected.addClass("selected");
if (index === 0) {
$list.scrollTop(0);
} else {
if ($selected[0].offsetTop + $list.scrollTop() > $list.height()) {
if (event.which === 40) {
$list.scrollTop($list.scrollTop() + $selected.height());
} else {
$list.scrollTop($selected[0].offsetTop);
}
} else {
$list.scrollTop(0);
}
}
});
},
_bindOutput: function () { _bindOutput: function () {
$(".bottom-window-group .output").keydown(function (event) { $(".bottom-window-group .output").keydown(function (event) {
event.preventDefault(); event.preventDefault();

View File

@ -288,11 +288,14 @@ var wide = {
"title": config.label.goto_file, "title": config.label.goto_file,
"okText": config.label.go, "okText": config.label.go,
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function () { "afterInit": function () {
$("#dialogGoFilePrompt > input").val('').focus(); hotkeys.bindList($("#dialogGoFilePrompt > input"), $("#dialogGoFilePrompt > .list"), function ($selected) {
$("#dialogGoFilePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true); var tId = tree.getTIdByPath($selected.text());
}, tree.openFile(tree.fileTree.getNodeByTId(tId));
"ok": function () { $("#dialogGoFilePrompt").dialog("close");
});
$("#dialogGoFilePrompt > input").keydown(function () {
var name = $("#dialogGoFilePrompt > input").val(); var name = $("#dialogGoFilePrompt > input").val();
var request = newWideRequest(); var request = newWideRequest();
@ -311,12 +314,27 @@ var wide = {
var goFileHTML = ''; var goFileHTML = '';
for (var i = 0, max = data.founds.length; i < max; i++) { for (var i = 0, max = data.founds.length; i < max; i++) {
if (i === 0) {
goFileHTML += '<li class="selected">' + data.founds[i].path + '</li>';
} else {
goFileHTML += '<li>' + data.founds[i].path + '</li>'; goFileHTML += '<li>' + data.founds[i].path + '</li>';
} }
}
$("#dialogGoFilePrompt > ul").html(goFileHTML); $("#dialogGoFilePrompt > ul").html(goFileHTML);
} }
}); });
});
},
"afterOpen": function () {
$("#dialogGoFilePrompt > input").val('').focus();
$("#dialogGoFilePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true);
$("#dialogGoFilePrompt .list").html('').data("index", 0);
},
"ok": function () {
var tId = tree.getTIdByPath($("#dialogGoFilePrompt .selected").text());
tree.openFile(tree.fileTree.getNodeByTId(tId));
$("#dialogGoFilePrompt").dialog("close");
} }
}); });

View File

@ -9,6 +9,6 @@ button {
.CodeMirror, .CodeMirror,
.CodeMirror-hints { .CodeMirror-hints {
font-family: Consolas, 'Courier New', monospace; font-family: Consolas, 'Courier New', monospace;
font-size: 13px; font-size: inherit;
line-height: 17px; line-height: ;
} }

View File

@ -246,7 +246,7 @@
</div> </div>
<div id="dialogGoFilePrompt" class="dialog-prompt fn-none"> <div id="dialogGoFilePrompt" class="dialog-prompt fn-none">
<input/> <input/>
<ul></ul> <ul class="list" tabindex="-1"></ul>
</div> </div>
<div id="dialogSearchForm" class="dialog-form fn-none"> <div id="dialogSearchForm" class="dialog-form fn-none">
<input placeholder="{{.i18n.keyword}}" /> <input placeholder="{{.i18n.keyword}}" />