弹窗按钮改为不给非空提示了,没有内容,确认按钮直接 disabled

This commit is contained in:
Van 2014-10-13 11:43:22 +08:00
parent cc173af277
commit 68eb5a1bc3
4 changed files with 54 additions and 32 deletions

View File

@ -35,7 +35,6 @@
"notification_3": "没有检查到 ide_stub这将会导致 [跳转到声明]、[查找使用] 失效", "notification_3": "没有检查到 ide_stub这将会导致 [跳转到声明]、[查找使用] 失效",
"goto_line": "跳转到行", "goto_line": "跳转到行",
"goto": "跳转", "goto": "跳转",
"input_no_empty": "输入不能为空",
"tip": "提示", "tip": "提示",
"confirm": "确定", "confirm": "确定",
"stop": "停止", "stop": "停止",
@ -46,5 +45,7 @@
"restore_side": "左侧窗口还原", "restore_side": "左侧窗口还原",
"usages": "查找使用", "usages": "查找使用",
"search_text": "查找文本", "search_text": "查找文本",
"restore_bottom": "底部窗口还原" "restore_bottom": "底部窗口还原",
"file_format": "文件后缀",
"keyword": "关键字"
} }

View File

@ -65,11 +65,13 @@
#dialogRemoveConfirm, #dialogRemoveConfirm,
.dialog-prompt, .dialog-prompt,
.dialog-form,
#dialogAlert { #dialogAlert {
padding: 10px 20px 0; padding: 10px 20px 0;
overflow: hidden; overflow: hidden;
} }
.dialog-prompt > input { .dialog-main input {
width: 100%; width: 100%;
margin: 2px auto;
} }

View File

@ -5,6 +5,20 @@ var wide = {
bottomWindowTab: undefined, bottomWindowTab: undefined,
searchTab: undefined, searchTab: undefined,
_initDialog: function () { _initDialog: function () {
$(".dialog-prompt > input").keyup(function (event) {
var $okBtn = $(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");
if (event.which === 13 && !$okBtn.prop("disabled")) {
$okBtn.click();
}
if ($.trim($(this).val()) === "") {
$okBtn.prop("disabled", true);
} else {
$okBtn.prop("disabled", false);
}
});
$("#dialogAlert").dialog({ $("#dialogAlert").dialog({
"height": 26, "height": 26,
"width": 260, "width": 260,
@ -64,14 +78,6 @@ 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": 52, "height": 52,
"width": 260, "width": 260,
@ -80,14 +86,11 @@ var wide = {
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function () { "afterOpen": function () {
$("#dialogNewFilePrompt > input").val('').focus(); $("#dialogNewFilePrompt > input").val('').focus();
$("#dialogNewFilePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true);
}, },
"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";
@ -156,14 +159,12 @@ var wide = {
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function () { "afterOpen": function () {
$("#dialogNewDirPrompt > input").val('').focus(); $("#dialogNewDirPrompt > input").val('').focus();
$("#dialogNewDirPrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true);
}, },
"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";
@ -197,27 +198,46 @@ var wide = {
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function () { "afterOpen": function () {
$("#dialogGoLinePrompt > input").val('').focus(); $("#dialogGoLinePrompt > input").val('').focus();
$("#dialogGoLinePrompt").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true);
}, },
"ok": function () { "ok": function () {
var line = parseInt($("#dialogGoLinePrompt > input").val()); var line = parseInt($("#dialogGoLinePrompt > input").val());
if ($.trim($("#dialogGoLinePrompt > input").val()) === "") {
$("#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();
} }
}); });
$("#dialogSearchForm > input:eq(0)").keyup(function (event) {
var $okBtn = $(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");
if (event.which === 13 && !$okBtn.prop("disabled")) {
$okBtn.click();
}
if ($.trim($(this).val()) === "") {
$okBtn.prop("disabled", true);
} else {
$okBtn.prop("disabled", false);
}
});
$("#dialogSearchForm > input:eq(1)").keyup(function (event) {
var $okBtn = $(this).closest(".dialog-main").find(".dialog-footer > button:eq(0)");
if (event.which === 13 && !$okBtn.prop("disabled")) {
$okBtn.click();
}
});
$("#dialogSearchForm").dialog({ $("#dialogSearchForm").dialog({
"height": 52, "height": 62,
"width": 260, "width": 260,
"title": config.label.search, "title": config.label.search,
"okText": config.label.search, "okText": config.label.search,
"cancelText": config.label.cancel, "cancelText": config.label.cancel,
"afterOpen": function () { "afterOpen": function () {
$("#dialogSearchForm > input:eq(0)").val('').focus(); $("#dialogSearchForm > input:eq(0)").val('').focus();
$("#dialogSearchForm > input:eq(1)").val('');
$("#dialogSearchForm").closest(".dialog-main").find(".dialog-footer > button:eq(0)").prop("disabled", true);
}, },
"ok": function () { "ok": function () {
var request = newWideRequest(); var request = newWideRequest();
@ -234,7 +254,7 @@ var wide = {
if (!data.succ) { if (!data.succ) {
return; return;
} }
$("#dialogSearchForm").dialog("close"); $("#dialogSearchForm").dialog("close");
editors.appendSearch(data.founds, 'founds', request.text); editors.appendSearch(data.founds, 'founds', request.text);
} }

View File

@ -189,17 +189,17 @@
</div> </div>
<div id="dialogAlert" class="fn-none"></div> <div id="dialogAlert" class="fn-none"></div>
<div id="dialogNewFilePrompt" class="dialog-prompt fn-none"> <div id="dialogNewFilePrompt" class="dialog-prompt fn-none">
<input/><span class="tip"></span> <input/>
</div> </div>
<div id="dialogNewDirPrompt" class="dialog-prompt fn-none"> <div id="dialogNewDirPrompt" class="dialog-prompt fn-none">
<input/><span class="tip"></span> <input/>
</div> </div>
<div id="dialogGoLinePrompt" class="dialog-prompt fn-none"> <div id="dialogGoLinePrompt" class="dialog-prompt fn-none">
<input/><span class="tip"></span> <input/>
</div> </div>
<div id="dialogSearchForm" class="dialog-prompt fn-none"> <div id="dialogSearchForm" class="dialog-form fn-none">
<input/> <input placeholder="{{.i18n.keyword}}" />
<input/> <input placeholder="{{.i18n.file_format}}" />
</div> </div>
<script> <script>
var config = { var config = {
@ -209,7 +209,6 @@
"max_editor": "{{.i18n.max_editor}}", "max_editor": "{{.i18n.max_editor}}",
"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}}",