This commit is contained in:
Liang Ding 2014-10-12 13:40:07 +08:00
parent 90227fbe98
commit 3b421b5d0b
4 changed files with 93 additions and 33 deletions

View File

@ -259,8 +259,7 @@ var editors = {
return; return;
} }
var $usages = $('.bottom-window-group .search'), var usagesHTML = '<ul>';
usagesHTML = '<ul>';
for (var i = 0, ii = data.usages.length; i < ii; i++) { for (var i = 0, ii = data.usages.length; i < ii; i++) {
usagesHTML += '<li>' + data.usages[i].path usagesHTML += '<li>' + data.usages[i].path
@ -268,34 +267,38 @@ var editors = {
} }
usagesHTML += '</ul>'; usagesHTML += '</ul>';
if ($usages.find("ul").length === 0) { editors.appendSearch(usagesHTML);
wide.usagesTab = new Tabs({
id: ".bottom-window-group .search",
removeAfter: function (id, prevId) {
if ($usages.find("ul").length === 1) {
$usages.find(".tabs").hide();
}
}
});
$usages.find(".tabs-panel > div").append(usagesHTML);
} else if ($usages.find("ul").length === 1) {
$usages.find(".tabs").show();
wide.usagesTab.add({
id: "b",
"title": 'Usages of ',
"content": usagesHTML + 1
});
}
// focus
wide.bottomWindowTab.setCurrent("search");
windows.flowBottom();
$(".bottom-window-group .search").focus();
} }
}); });
}; };
}, },
appendSearch: function (html) {
var $usages = $('.bottom-window-group .search');
if ($usages.find("ul").length === 0) {
wide.usagesTab = new Tabs({
id: ".bottom-window-group .search",
removeAfter: function (id, prevId) {
if ($usages.find("ul").length === 1) {
$usages.find(".tabs").hide();
}
}
});
$usages.find(".tabs-panel > div").append(html);
} else if ($usages.find("ul").length === 1) {
$usages.find(".tabs").show();
wide.usagesTab.add({
id: "b",
"title": 'Usages of ',
"content": html + 1
});
}
// focus
wide.bottomWindowTab.setCurrent("search");
windows.flowBottom();
$(".bottom-window-group .search").focus();
},
// 新建一个编辑器 Tab如果已经存在 Tab 则切换到该 Tab. // 新建一个编辑器 Tab如果已经存在 Tab 则切换到该 Tab.
newEditor: function (data) { newEditor: function (data) {
$(".toolbars").show(); $(".toolbars").show();

View File

@ -35,13 +35,6 @@ var hotkeys = {
shiftKey: false, shiftKey: false,
which: 54 which: 54
}, },
// Ctrl+Q 关闭当前编辑器
closeCurEditor: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 81
},
// Ctrl+D 窗口组切换 // Ctrl+D 窗口组切换
changeEditor: { changeEditor: {
ctrlKey: true, ctrlKey: true,
@ -49,6 +42,20 @@ var hotkeys = {
shiftKey: false, shiftKey: false,
which: 68 which: 68
}, },
// Ctrl+F 搜索
search: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 70
},
// Ctrl+Q 关闭当前编辑器
closeCurEditor: {
ctrlKey: true,
altKey: false,
shiftKey: false,
which: 81
},
// F6 构建并运行 // F6 构建并运行
buildRun: { buildRun: {
ctrlKey: false, ctrlKey: false,
@ -61,6 +68,13 @@ var hotkeys = {
$("#files").keydown(function (event) { $("#files").keydown(function (event) {
event.preventDefault(); event.preventDefault();
var hotKeys = hotkeys.defaultKeyMap;
if (event.ctrlKey === hotKeys.search.ctrlKey
&& event.which === hotKeys.search.which) { // Ctrl+F 搜索
$("#dialogSearchForm").dialog("open");
return;
}
switch (event.which) { switch (event.which) {
case 46: // 删除 case 46: // 删除
tree.removeIt(); tree.removeIt();

View File

@ -209,6 +209,45 @@ var wide = {
wide.curEditor.focus(); wide.curEditor.focus();
} }
}); });
$("#dialogSearchForm").dialog({
"height": 52,
"width": 260,
"title": config.label.create_dir,
"okText": config.label.create,
"cancelText": config.label.cancel,
"afterOpen": function () {
$("#dialogSearchForm > input:eq(0)").val('').focus();
},
"ok": function () {
var request = newWideRequest();
request.dir = wide.curNode.path;
request.text = $("#dialogSearchForm > input:eq(0)").val();
request.extension = $("#dialogSearchForm > input:eq(1)").val();
$.ajax({
type: 'POST',
url: '/file/search/text',
data: JSON.stringify(request),
dataType: "json",
success: function (data) {
if (!data.succ) {
return;
}
var searcHTML = '<ul>';
for (var i = 0, ii = data.founds.length; i < ii; i++) {
searcHTML += '<li>' + data.founds[i].path
+ '</li>';
}
searcHTML += '</ul>';
editors.appendSearch(searcHTML);
}
});
}
});
}, },
_initLayout: function () { _initLayout: function () {
var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 1, var mainH = $(window).height() - $(".menu").height() - $(".footer").height() - 1,

View File

@ -195,6 +195,10 @@
<div id="dialogGoLinePrompt" class="dialog-prompt fn-none"> <div id="dialogGoLinePrompt" class="dialog-prompt fn-none">
<input/><span class="tip"></span> <input/><span class="tip"></span>
</div> </div>
<div id="dialogSearchForm" class="dialog-prompt fn-none">
<input/>
<input/>
</div>
<script> <script>
var config = { var config = {
"latestSessionContent": {{.latestSessionContent}}, "latestSessionContent": {{.latestSessionContent}},