prompt 输入框绑定回车事件,不能为空判断

This commit is contained in:
Van 2014-09-22 18:09:16 +08:00
parent 6e1b800f92
commit 711f1943c9
5 changed files with 38 additions and 18 deletions

View File

@ -33,5 +33,6 @@
"notification_2": "没有检查到 gocode这将会导致 [自动完成] 失效",
"notification_3": "没有检查到 ide_stub这将会导致 [跳转到声明]、[查找使用] 失效",
"goto_line": "跳转到行",
"goto": "跳转"
"goto": "跳转",
"input_no_empty": "输入不能为空"
}

View File

@ -71,14 +71,11 @@
}
#dialogRemoveConfirm,
#dialogNewFilePrompt,
#dialogNewDirPrompt,
#dialogGoLinePrompt {
.dialog-prompt {
padding: 10px 20px 0;
overflow: hidden;
}
#dialogNewFilePrompt > input,
#dialogNewDirPrompt > input,
#dialogGoLinePrompt > input {
.dialog-prompt > input {
width: 100%;
}

View File

@ -115,8 +115,17 @@ var wide = {
}
});
$(".dialog-prompt > input").keydown(function(event) {
$(".dialog-prompt > .tip").text('');
if (event.which === 13) {
$(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)").click();
}
});
$("#dialogNewFilePrompt").dialog({
"height": 32,
"height": 52,
"width": 260,
"title": config.label.create_file,
"okText": config.label.create,
@ -126,7 +135,12 @@ var wide = {
},
"ok": function() {
var request = newWideRequest(),
name = $("#dialogNewFilePrompt > input").val()
name = $("#dialogNewFilePrompt > input").val();
if ($.trim(name) === "") {
$("#dialogNewFilePrompt > .tip").text(config.label.input_no_empty);
return false;
}
request.path = wide.curNode.path + '\\' + name;
request.fileType = "f";
@ -187,7 +201,7 @@ var wide = {
});
$("#dialogNewDirPrompt").dialog({
"height": 32,
"height": 52,
"width": 260,
"title": config.label.create_dir,
"okText": config.label.create,
@ -198,6 +212,10 @@ var wide = {
"ok": function() {
var name = $("#dialogNewDirPrompt > input").val(),
request = newWideRequest();
if ($.trim(name) === "") {
$("#dialogNewDirPrompt > .tip").text(config.label.input_no_empty);
return false;
}
request.path = wide.curNode.path + '\\' + name;
request.fileType = "d";
@ -224,7 +242,7 @@ var wide = {
});
$("#dialogGoLinePrompt").dialog({
"height": 32,
"height": 52,
"width": 260,
"title": config.label.goto_line,
"okText": config.label.goto,
@ -234,7 +252,10 @@ var wide = {
},
"ok": function() {
var line = parseInt($("#dialogGoLinePrompt > input").val());
if ($.trim(line) === "") {
$("#dialogGoLinePrompt > .tip").text(config.label.input_no_empty);
return false;
}
$("#dialogGoLinePrompt").dialog("close");
wide.curEditor.setCursor(CodeMirror.Pos(line - 1, 0));
wide.curEditor.focus();

View File

@ -170,20 +170,21 @@
<div id="dialogRemoveConfirm">
{{.i18n.isDelete}} <b></b>?
</div>
<div id="dialogNewFilePrompt">
<input/>
<div id="dialogNewFilePrompt" class="dialog-prompt">
<input/><span class="tip"></span>
</div>
<div id="dialogNewDirPrompt">
<input/>
<div id="dialogNewDirPrompt" class="dialog-prompt">
<input/><span class="tip"></span>
</div>
<div id="dialogGoLinePrompt">
<input/>
<div id="dialogGoLinePrompt" class="dialog-prompt">
<input/><span class="tip"></span>
</div>
<script>
var config = {
"label": {
"delete": "{{.i18n.delete}}",
"cancel": "{{.i18n.cancel}}",
"input_no_empty": "{{.i18n.input_no_empty}}",
"goto_line": "{{.i18n.goto_line}}",
"goto": "{{.i18n.goto}}",
"create": "{{.i18n.create}}",