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_2": "没有检查到 gocode这将会导致 [自动完成] 失效",
"notification_3": "没有检查到 ide_stub这将会导致 [跳转到声明]、[查找使用] 失效", "notification_3": "没有检查到 ide_stub这将会导致 [跳转到声明]、[查找使用] 失效",
"goto_line": "跳转到行", "goto_line": "跳转到行",
"goto": "跳转" "goto": "跳转",
"input_no_empty": "输入不能为空"
} }

View File

@ -71,14 +71,11 @@
} }
#dialogRemoveConfirm, #dialogRemoveConfirm,
#dialogNewFilePrompt, .dialog-prompt {
#dialogNewDirPrompt,
#dialogGoLinePrompt {
padding: 10px 20px 0; padding: 10px 20px 0;
overflow: hidden;
} }
#dialogNewFilePrompt > input, .dialog-prompt > input {
#dialogNewDirPrompt > input,
#dialogGoLinePrompt > input {
width: 100%; 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({ $("#dialogNewFilePrompt").dialog({
"height": 32, "height": 52,
"width": 260, "width": 260,
"title": config.label.create_file, "title": config.label.create_file,
"okText": config.label.create, "okText": config.label.create,
@ -126,7 +135,12 @@ var wide = {
}, },
"ok": function() { "ok": function() {
var request = newWideRequest(), 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.path = wide.curNode.path + '\\' + name;
request.fileType = "f"; request.fileType = "f";
@ -187,7 +201,7 @@ var wide = {
}); });
$("#dialogNewDirPrompt").dialog({ $("#dialogNewDirPrompt").dialog({
"height": 32, "height": 52,
"width": 260, "width": 260,
"title": config.label.create_dir, "title": config.label.create_dir,
"okText": config.label.create, "okText": config.label.create,
@ -198,6 +212,10 @@ var wide = {
"ok": function() { "ok": function() {
var name = $("#dialogNewDirPrompt > input").val(), var name = $("#dialogNewDirPrompt > input").val(),
request = newWideRequest(); request = newWideRequest();
if ($.trim(name) === "") {
$("#dialogNewDirPrompt > .tip").text(config.label.input_no_empty);
return false;
}
request.path = wide.curNode.path + '\\' + name; request.path = wide.curNode.path + '\\' + name;
request.fileType = "d"; request.fileType = "d";
@ -224,7 +242,7 @@ var wide = {
}); });
$("#dialogGoLinePrompt").dialog({ $("#dialogGoLinePrompt").dialog({
"height": 32, "height": 52,
"width": 260, "width": 260,
"title": config.label.goto_line, "title": config.label.goto_line,
"okText": config.label.goto, "okText": config.label.goto,
@ -234,7 +252,10 @@ var wide = {
}, },
"ok": function() { "ok": function() {
var line = parseInt($("#dialogGoLinePrompt > input").val()); var line = parseInt($("#dialogGoLinePrompt > input").val());
if ($.trim(line) === "") {
$("#dialogGoLinePrompt > .tip").text(config.label.input_no_empty);
return false;
}
$("#dialogGoLinePrompt").dialog("close"); $("#dialogGoLinePrompt").dialog("close");
wide.curEditor.setCursor(CodeMirror.Pos(line - 1, 0)); wide.curEditor.setCursor(CodeMirror.Pos(line - 1, 0));
wide.curEditor.focus(); wide.curEditor.focus();

View File

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