From 489c4fb4ef10f7ac4f85f095b9ed44341d021ff2 Mon Sep 17 00:00:00 2001 From: Van Date: Mon, 17 Nov 2014 17:35:35 +0800 Subject: [PATCH] =?UTF-8?q?go=20file=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/base.css | 10 ++++ static/css/wide.css | 13 +----- static/js/editors.js | 2 +- static/js/hotkeys.js | 5 ++ static/js/wide.js | 109 +++++++++++++++++++++++++++---------------- 5 files changed, 86 insertions(+), 53 deletions(-) diff --git a/static/css/base.css b/static/css/base.css index 0dc9b7c..500fd3d 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -62,6 +62,11 @@ button { /* end reset & function */ /* start common */ +.ft-small { + color: #999; + font-size: 12px; +} + .list li { cursor: pointer; line-height: 20px; @@ -78,4 +83,9 @@ button { background-color: #3875d7; color: #FFF; } + +.list li.selected .ft-small, +.list li:hover .ft-small { + color: #FFF; +} /* end common */ \ No newline at end of file diff --git a/static/css/wide.css b/static/css/wide.css index 354be75..5f5e6d6 100644 --- a/static/css/wide.css +++ b/static/css/wide.css @@ -209,7 +209,8 @@ top: 1px; } -.edit-panel .tabs .ico { +.edit-panel .tabs .ico, +#dialogGoFilePrompt .ico { background-image: url("../images/ico-file.png"); float: left; height: 16px; @@ -335,16 +336,6 @@ width: 50px; padding: 0 5px; } - -.bottom-window-group .search .path { - color: #999; - font-size: 12px; -} - -.bottom-window-group .search li.selected .path, -.bottom-window-group .search li:hover .path { - color: #FFF; -} /* end bottom-window-group */ /* start footer */ diff --git a/static/js/editors.js b/static/js/editors.js index 5f57f0d..9105aa1 100644 --- a/static/js/editors.js +++ b/static/js/editors.js @@ -496,7 +496,7 @@ var editors = { + contents.substring(index + key.length); searcHTML += '
  • ' - + contents + "    " + data[i].path + + contents + "    " + data[i].path + ' (' + data[i].line + ':' + data[i].ch + ')
  • '; diff --git a/static/js/hotkeys.js b/static/js/hotkeys.js index 9f03413..642a960 100644 --- a/static/js/hotkeys.js +++ b/static/js/hotkeys.js @@ -141,6 +141,11 @@ var hotkeys = { $list.scrollTop(0); } } + + // 阻止上下键改变光标位置 + if (event.which === 38 || event.which === 40 || event.which === 13) { + return false; + } }); }, _bindOutput: function () { diff --git a/static/js/wide.js b/static/js/wide.js index 9b7d5cc..915545c 100644 --- a/static/js/wide.js +++ b/static/js/wide.js @@ -187,40 +187,7 @@ var wide = { } $("#dialogNewFilePrompt").dialog("close"); - var suffix = name.split(".")[1], - iconSkin = "ico-ztree-other "; - switch (suffix) { - case "html", "htm": - iconSkin = "ico-ztree-html "; - break; - case "go": - iconSkin = "ico-ztree-go "; - break; - case "css": - iconSkin = "ico-ztree-css "; - break; - case "txt": - iconSkin = "ico-ztree-text "; - break; - case "sql": - iconSkin = "ico-ztree-sql "; - break; - case "properties": - iconSkin = "ico-ztree-pro "; - break; - case "md": - iconSkin = "ico-ztree-md "; - break; - case "js", "json": - iconSkin = "ico-ztree-js "; - break; - case "xml": - iconSkin = "ico-ztree-xml "; - break; - case "jpg", "jpeg", "bmp", "gif", "png", "svg", "ico": - iconSkin = "ico-ztree-img "; - break; - } + var iconSkin = wide.getClassBySuffix(name.split(".")[1]); tree.fileTree.addNodes(wide.curNode, [{ "name": name, @@ -289,13 +256,26 @@ var wide = { "okText": config.label.go, "cancelText": config.label.cancel, "afterInit": function () { - hotkeys.bindList($("#dialogGoFilePrompt > input"), $("#dialogGoFilePrompt > .list"), function ($selected) { - var tId = tree.getTIdByPath($selected.text()); + $("#dialogGoFilePrompt").on("dblclick", "li", function () { + var tId = tree.getTIdByPath($(this).find(".ft-small").text()); tree.openFile(tree.fileTree.getNodeByTId(tId)); $("#dialogGoFilePrompt").dialog("close"); }); - $("#dialogGoFilePrompt > input").keydown(function () { + $("#dialogGoFilePrompt").on("click", "li", function () { + var $list = $("#dialogGoFilePrompt > .list") + $list.find("li").removeClass("selected"); + $list.data("index", $(this).data("index")); + $(this).addClass("selected"); + }); + + hotkeys.bindList($("#dialogGoFilePrompt > input"), $("#dialogGoFilePrompt > .list"), function ($selected) { + var tId = tree.getTIdByPath($selected.find(".ft-small").text()); + tree.openFile(tree.fileTree.getNodeByTId(tId)); + $("#dialogGoFilePrompt").dialog("close"); + }); + + $("#dialogGoFilePrompt > input").bind("input", function () { var name = $("#dialogGoFilePrompt > input").val(); var request = newWideRequest(); @@ -317,10 +297,20 @@ var wide = { var goFileHTML = ''; for (var i = 0, max = data.founds.length; i < max; i++) { + var path = data.founds[i].path, + name = path.substr(path.lastIndexOf(config.pathSeparator) + 1), + icoSkin = wide.getClassBySuffix(name.split(".")[1]); if (i === 0) { - goFileHTML += '
  • ' + data.founds[i].path + '
  • '; + goFileHTML += '
  • ' + + name + '    ' + + path + '
  • '; } else { - goFileHTML += '
  • ' + data.founds[i].path + '
  • '; + goFileHTML += '
  • ' + + name + '    ' + + path + '
  • '; } } @@ -335,7 +325,7 @@ var wide = { $("#dialogGoFilePrompt .list").html('').data("index", 0); }, "ok": function () { - var tId = tree.getTIdByPath($("#dialogGoFilePrompt .selected").text()); + var tId = tree.getTIdByPath($("#dialogGoFilePrompt .selected .ft-small").text()); tree.openFile(tree.fileTree.getNodeByTId(tId)); $("#dialogGoFilePrompt").dialog("close"); } @@ -517,7 +507,7 @@ var wide = { if (!data.succ) { return false; } - + $fontFamily.data("value", $fontFamily.val()); $fontSize.data("value", $fontSize.val()); $editorFontFamily.data("value", $editorFontFamily.val()); @@ -1031,6 +1021,43 @@ var wide = { }, openAbout: function () { $("#dialogAbout").dialog("open"); + }, + getClassBySuffix: function (suffix) { + var iconSkin = "ico-ztree-other "; + switch (suffix) { + case "html", "htm": + iconSkin = "ico-ztree-html "; + break; + case "go": + iconSkin = "ico-ztree-go "; + break; + case "css": + iconSkin = "ico-ztree-css "; + break; + case "txt": + iconSkin = "ico-ztree-text "; + break; + case "sql": + iconSkin = "ico-ztree-sql "; + break; + case "properties": + iconSkin = "ico-ztree-pro "; + break; + case "md": + iconSkin = "ico-ztree-md "; + break; + case "js", "json": + iconSkin = "ico-ztree-js "; + break; + case "xml": + iconSkin = "ico-ztree-xml "; + break; + case "jpg", "jpeg", "bmp", "gif", "png", "svg", "ico": + iconSkin = "ico-ztree-img "; + break; + } + + return iconSkin; } };