From e001df500e28c625e214cf644b9be02525980f88 Mon Sep 17 00:00:00 2001 From: Van Date: Mon, 8 Dec 2014 15:18:28 +0800 Subject: [PATCH] =?UTF-8?q?preference=20=E6=A0=A1=E9=AA=8C=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E5=8F=8A=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/en_US.json | 3 +- static/css/base.css | 4 +++ static/css/dialog.css | 12 ++++---- static/css/themes/black.css | 2 +- static/css/themes/default.css | 2 +- static/js/menu.js | 57 ++++++++++++++++------------------- views/index.html | 3 +- views/preference.html | 26 +++++----------- 8 files changed, 50 insertions(+), 59 deletions(-) diff --git a/i18n/en_US.json b/i18n/en_US.json index 2a69661..a2326f4 100644 --- a/i18n/en_US.json +++ b/i18n/en_US.json @@ -156,5 +156,6 @@ "source": "Source", "toggle_comment": "Toggle Comment", "find_in_files": "Find in Files", - "email": "Email" + "email": "Email", + "no_empty": "Can not Empty!" } \ No newline at end of file diff --git a/static/css/base.css b/static/css/base.css index d3ce8ac..9351459 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -91,6 +91,10 @@ button { font-size: 12px; } +.ft-red { + color: #9d0000; +} + .list li { cursor: pointer; line-height: 20px; diff --git a/static/css/dialog.css b/static/css/dialog.css index f6ffc4d..21ce501 100644 --- a/static/css/dialog.css +++ b/static/css/dialog.css @@ -85,7 +85,8 @@ overflow: hidden; } -.dialog-main input { +.dialog-main input, +.dialog-main select { width: 100%; margin: 2px auto; } @@ -103,11 +104,10 @@ margin: 10px; } -#dialogPreference .select { - width: 100%; - margin: 2px auto; -} - #dialogPreference .tabs-panel { padding: 10px; +} + +#dialogPreference .preference { + margin-bottom: 10px; } \ No newline at end of file diff --git a/static/css/themes/black.css b/static/css/themes/black.css index 3a4b97a..ca0c2e0 100644 --- a/static/css/themes/black.css +++ b/static/css/themes/black.css @@ -146,6 +146,6 @@ color: #ebebeb; } -#dialogPreference { +#dialogPreference .preference { border: 1px solid #000; } \ No newline at end of file diff --git a/static/css/themes/default.css b/static/css/themes/default.css index 8c48fc6..2cda064 100644 --- a/static/css/themes/default.css +++ b/static/css/themes/default.css @@ -123,6 +123,6 @@ border-top: 1px solid #919191; } -#dialogPreference { +#dialogPreference .preference { border: 1px solid #A4A4A4; } \ No newline at end of file diff --git a/static/js/menu.js b/static/js/menu.js index b2df2d7..f7f3708 100644 --- a/static/js/menu.js +++ b/static/js/menu.js @@ -285,40 +285,20 @@ var menu = { }, _initPreference: function () { $("#dialogPreference").load('/preference', function () { - $("#localeSelect").on('change', function () { - var $dialogPreference = $("#dialogPreference"), - $input = $dialogPreference.find("input[name=locale]") - - $input.val(this.value); - }); - - $("#themeSelect").on('change', function () { - var $dialogPreference = $("#dialogPreference"), - $input = $dialogPreference.find("input[name=theme]") - - $input.val(this.value); - }); - - $("#editorThemeSelect").on('change', function () { - var $dialogPreference = $("#dialogPreference"), - $input = $dialogPreference.find("input[name=editorTheme]") - - $input.val(this.value); - }); - - $("#goFmtSelect").on('change', function () { - var $dialogPreference = $("#dialogPreference"), - $input = $dialogPreference.find("input[name=goFmt]") - - $input.val(this.value); - }); - $("#dialogPreference input").keyup(function () { - var isChange = false; + var isChange = false, + emptys = [], + emptysTip = ''; $("#dialogPreference input").each(function () { - if ($(this).val() !== $(this).data("value")) { + var $it = $(this); + // data-value 如为数字,则不会和 value 一样转换为 String,再次不使用全等 + if ($it.val() != $it.data("value")) { isChange = true; } + + if ($.trim($it.val()) === '') { + emptys.push($it); + } }); var $okBtn = $("#dialogPreference").closest(".dialog-main").find(".dialog-footer > button:eq(0)"); @@ -327,11 +307,21 @@ var menu = { } else { $okBtn.prop("disabled", true); } + + if (emptys.length === 0) { + $("#dialogPreference").find(".tip").html(""); + } else { + for (var i = 0, max = emptys.length; i < max; i++) { + emptysTip += emptys[i].closest('div').data("index") + ' -> ' + emptys[i].attr("name") + + ' ' + config.label.no_empty + "
"; + } + $("#dialogPreference").find(".tip").html(emptysTip); + } }); $("#dialogPreference select").on("change", function () { var isChange = false; - $("#dialogPreference input").each(function () { + $("#dialogPreference select").each(function () { if ($(this).val() !== $(this).data("value")) { isChange = true; } @@ -373,6 +363,11 @@ var menu = { $editorTheme = $dialogPreference.find("input[name=editorTheme]"), $editorTabSize = $dialogPreference.find("input[name=editorTabSize]"); + if ($.trim($email.val()) === "") { + $dialogPreference.find(".tip").html("user -> email " + config.label.no_empty); + return false; + } + $.extend(request, { "fontFamily": $fontFamily.val(), "fontSize": $fontSize.val(), diff --git a/views/index.html b/views/index.html index 8bceb13..5ed67cf 100644 --- a/views/index.html +++ b/views/index.html @@ -468,7 +468,8 @@ "file": "{{.i18n.file}}", "uptodate": "{{.i18n.uptodate}}", "perference": "{{.i18n.perference}}", - "apply": "{{.i18n.apply}}" + "apply": "{{.i18n.apply}}", + "no_empty": "{{.i18n.no_empty}}" }, "channel": { "editor": '{{.conf.EditorChannel}}', diff --git a/views/preference.html b/views/preference.html index 29c5127..5007ea8 100644 --- a/views/preference.html +++ b/views/preference.html @@ -25,15 +25,12 @@ -
-
-
- \ No newline at end of file + +
\ No newline at end of file