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;
}
/* 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 {
position: relative;
height: 260px;
overflow: auto;
margin-top: 5px;
}
#dialogGoFilePrompt li {
}
#dialogGoFilePrompt li.selected,
#dialogGoFilePrompt li:hover {
background-color: #FFF;
border: 1px solid #9B9B9B;
}

View File

@ -336,28 +336,13 @@
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 {
color: #999;
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;
}
/* end bottom-window-group */

View File

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

View File

@ -94,6 +94,55 @@ var hotkeys = {
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 () {
$(".bottom-window-group .output").keydown(function (event) {
event.preventDefault();

View File

@ -288,35 +288,53 @@ var wide = {
"title": config.label.goto_file,
"okText": config.label.go,
"cancelText": config.label.cancel,
"afterInit": function () {
hotkeys.bindList($("#dialogGoFilePrompt > input"), $("#dialogGoFilePrompt > .list"), function ($selected) {
var tId = tree.getTIdByPath($selected.text());
tree.openFile(tree.fileTree.getNodeByTId(tId));
$("#dialogGoFilePrompt").dialog("close");
});
$("#dialogGoFilePrompt > input").keydown(function () {
var name = $("#dialogGoFilePrompt > input").val();
var request = newWideRequest();
request.path = wide.curNode.path;
request.name = '*' + name + '*';
$.ajax({
type: 'POST',
url: '/file/find/name',
data: JSON.stringify(request),
dataType: "json",
success: function (data) {
if (!data.succ) {
return;
}
var goFileHTML = '';
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>';
}
}
$("#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 name = $("#dialogGoFilePrompt > input").val();
var request = newWideRequest();
request.path = wide.curNode.path;
request.name = '*' + name + '*';
$.ajax({
type: 'POST',
url: '/file/find/name',
data: JSON.stringify(request),
dataType: "json",
success: function (data) {
if (!data.succ) {
return;
}
var goFileHTML = '';
for (var i = 0, max = data.founds.length; i < max; i++) {
goFileHTML += '<li>' + data.founds[i].path + '</li>';
}
$("#dialogGoFilePrompt > ul").html(goFileHTML);
}
});
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-hints {
font-family: Consolas, 'Courier New', monospace;
font-size: 13px;
line-height: 17px;
font-size: inherit;
line-height: ;
}

View File

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